[U-Boot] [PATCH] add explicit bbt creation to commandline
Steven Zedeck
saz at proliphix.com
Fri Feb 12 03:49:33 CET 2010
Hi,
I know this message is about 18 months old. I am using Uboot 2008.10, which
seems to not include support for creating the Nand BBT (bad block table).
Was this patch released and if so when? Forgive me as I don't know how to
find out.
How best to add BBT support to Uboot? I need to have a BBT created such that
Linux can use it when it loads.
I hope you can help.
Thanks in advance,
Steve
P.S.: I snipped out portions of this code to save space in this reply.
Harald Welte wrote:
>
> [PATCH] add explicit bbt creation to commandline ("nand createbbt"
> command)
>
> This patch adds user-requested BBT creation. It includes the following
> changes:
>
> - common/cmd_nand.c: move yes/no decision to separate function
> - do_nand: ask for confirmation for "nand erase"
> - do_nand: add command "nand createbbt" to erase NAND and create a new BBT
>
> Signed-off-by: Werner Almesberger <werner at openmoko.org>
> Signed-off-by: Harald Welte <laforge at openmoko.org>
>
> ---
>
> diff --git a/common/cmd_nand.c b/common/cmd_nand.c
> index bb46f34..2f41157 100644
> --- a/common/cmd_nand.c
> +++ b/common/cmd_nand.c
> @@ -162,6 +162,17 @@ out:
> return 0;
> }
>
> +static int yes(void)
> +{
> + char c;
> +
> + c = getc();
> + if (c != 'y' && c != 'Y')
> + return 0;
> + c = getc();
> + return c == '\r' || c == '\n';
> +}
> +
> int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
> {
> int i, dev, ret;
> @@ -231,7 +242,8 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc,
> char *argv[])
> strncmp(cmd, "read", 4) != 0 && strncmp(cmd, "write", 5) != 0 &&
> strcmp(cmd, "scrub") != 0 && strcmp(cmd, "markbad") != 0 &&
> strcmp(cmd, "biterr") != 0 &&
> - strcmp(cmd, "lock") != 0 && strcmp(cmd, "unlock") != 0 )
> + strcmp(cmd, "lock") != 0 && strcmp(cmd, "unlock") != 0 &&
> + strcmp(cmd, "createbbt") != 0 )
> goto usage;
>
> /* the following commands operate on the current device */
> @@ -286,13 +298,23 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc,
> char *argv[])
> "are sure of what you are doing!\n"
> "\nReally scrub this NAND flash? <y/N>\n");
>
> - if (getc() == 'y' && getc() == '\r') {
> + if (yes()) {
> opts.scrub = 1;
> } else {
> puts("scrub aborted\n");
> return -1;
> }
> }
> + else {
> + if (opts.length == nand->size) {
> + puts("Really erase everything ? <y/N>\n");
> + if (!yes()) {
> + puts("erase aborted\n");
> + return -1;
> + }
> + }
> + }
> +
> ret = nand_erase_opts(nand, &opts);
> printf("%s\n", ret ? "ERROR" : "OK");
>
> @@ -461,6 +483,33 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc,
> char *argv[])
> return 0;
> }
>
> + if (strcmp(cmd, "createbbt") == 0) {
> + struct nand_chip *nand_chip = nand->priv;
> + nand_erase_options_t opts;
> +
> + puts("Create BBT and erase everything ? <y/N>\n");
> + if (!yes()) {
> + puts("createbbt aborted\n");
> + return -1;
> + }
> + memset(&opts, 0, sizeof(opts));
> + opts.length = nand->size;
> + if (nand_erase_opts(nand, &opts)) {
> + puts("Erase failed\n");
> + return 1;
> +.
> .
> .
> snip....
> .
> .
> .
>
>
>
--
View this message in context: http://old.nabble.com/-PATCH--add-explicit-bbt-creation-to-commandline-tp18299804p27558231.html
Sent from the Uboot - Users mailing list archive at Nabble.com.
More information about the U-Boot
mailing list