r900 - trunk/src/target/u-boot/patches

werner at sita.openmoko.org werner at sita.openmoko.org
Thu Feb 8 00:31:17 CET 2007


Author: werner
Date: 2007-02-08 00:31:14 +0100 (Thu, 08 Feb 2007)
New Revision: 900

Added:
   trunk/src/target/u-boot/patches/bbt-create-optional.patch
   trunk/src/target/u-boot/patches/nand-createbbt.patch
Log:
bbt-create-optional.patch: make creation of the BBT optional for the s3c24x0
  platform
nand-createbbt.patch: add user-requested BBT creation and clean up yes/no
  questions in cmd_nand.c



Added: trunk/src/target/u-boot/patches/bbt-create-optional.patch
===================================================================
--- trunk/src/target/u-boot/patches/bbt-create-optional.patch	2007-02-07 23:08:28 UTC (rev 899)
+++ trunk/src/target/u-boot/patches/bbt-create-optional.patch	2007-02-07 23:31:14 UTC (rev 900)
@@ -0,0 +1,52 @@
+This patch makes creation of the BBT optional for the s3c24x0 platform.
+It adds:
+
+- a new platform-independent NAND-wide flag NAND_DONT_CREATE_BBT
+- one user of this flag, namely s3c24x0
+
+Experimental.
+
+- Werner Almesberger <werner at openmoko.org>
+
+
+Index: u-boot.git/cpu/arm920t/s3c24x0/nand.c
+===================================================================
+--- u-boot.git.orig/cpu/arm920t/s3c24x0/nand.c
++++ u-boot.git/cpu/arm920t/s3c24x0/nand.c
+@@ -190,7 +190,7 @@ void board_nand_init(struct nand_chip *n
+ 
+ 	nand->eccmode = NAND_ECC_SOFT;
+ #ifdef CONFIG_S3C2410_NAND_BBT
+-	nand->options = NAND_USE_FLASH_BBT;
++	nand->options = NAND_USE_FLASH_BBT | NAND_DONT_CREATE_BBT;
+ #else
+ 	nand->options = 0;
+ #endif
+Index: u-boot.git/drivers/nand/nand_bbt.c
+===================================================================
+--- u-boot.git.orig/drivers/nand/nand_bbt.c
++++ u-boot.git/drivers/nand/nand_bbt.c
+@@ -680,7 +680,8 @@ static int check_create (struct mtd_info
+ 		}
+ create:
+ 		/* Create the bad block table by scanning the device ? */
+-		if (!(td->options & NAND_BBT_CREATE))
++		if (!(td->options & NAND_BBT_CREATE) ||
++		  (this->options & NAND_DONT_CREATE_BBT))
+ 			continue;
+ 
+ 		/* Create the table in memory by scanning the chip(s) */
+Index: u-boot.git/include/linux/mtd/nand.h
+===================================================================
+--- u-boot.git.orig/include/linux/mtd/nand.h
++++ u-boot.git/include/linux/mtd/nand.h
+@@ -187,7 +187,8 @@ extern int nand_read_raw (struct mtd_inf
+  * This can only work if we have the ecc bytes directly behind the
+  * data bytes. Applies for DOC and AG-AND Renesas HW Reed Solomon generators */
+ #define NAND_HWECC_SYNDROME	0x00020000
+-
++/* Do not create an BBT if none is found. Overrides NAND_BBT_CREATE. */
++#define NAND_DONT_CREATE_BBT	0x00040000
+ 
+ /* Options set by nand scan */
+ /* Nand scan has allocated oob_buf */

Added: trunk/src/target/u-boot/patches/nand-createbbt.patch
===================================================================
--- trunk/src/target/u-boot/patches/nand-createbbt.patch	2007-02-07 23:08:28 UTC (rev 899)
+++ trunk/src/target/u-boot/patches/nand-createbbt.patch	2007-02-07 23:31:14 UTC (rev 900)
@@ -0,0 +1,126 @@
+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
+
+Experimental.
+
+- Werner Almesberger <werner at openmoko.org>
+
+
+Index: u-boot.git/common/cmd_nand.c
+===================================================================
+--- u-boot.git.orig/common/cmd_nand.c
++++ u-boot.git/common/cmd_nand.c
+@@ -163,6 +163,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;
+@@ -228,7 +239,8 @@ int do_nand(cmd_tbl_t * cmdtp, int flag,
+ 	    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 */
+@@ -283,13 +295,23 @@ int do_nand(cmd_tbl_t * cmdtp, int flag,
+ 			     "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");
+ 
+@@ -458,6 +480,33 @@ int do_nand(cmd_tbl_t * cmdtp, int flag,
+ 		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;
++		}
++		nand_chip->options &= ~NAND_DONT_CREATE_BBT;
++		puts("Creating BBT. Please wait ...");
++		if (nand_default_bbt(nand)) {
++			puts("\nFailed\n");
++			return 1;
++		}
++		else {
++			puts("\n");
++			return 0;
++		}
++	}
++
+ usage:
+ 	printf("Usage:\n%s\n", cmdtp->usage);
+ 	return 1;
+@@ -478,7 +527,8 @@ U_BOOT_CMD(nand, 5, 1, do_nand,
+ 	"nand markbad off - mark bad block at offset (UNSAFE)\n"
+ 	"nand biterr off - make a bit error at offset (UNSAFE)\n"
+ 	"nand lock [tight] [status] - bring nand to lock state or display locked pages\n"
+-	"nand unlock [offset] [size] - unlock section\n");
++	"nand unlock [offset] [size] - unlock section\n"
++        "nand createbbt - create bad block table\n");
+ 
+ static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand,
+ 			   ulong offset, ulong addr, char *cmd)
+Index: u-boot.git/drivers/nand/nand_bbt.c
+===================================================================
+--- u-boot.git.orig/drivers/nand/nand_bbt.c
++++ u-boot.git/drivers/nand/nand_bbt.c
+@@ -797,7 +797,8 @@ int nand_scan_bbt (struct mtd_info *mtd,
+ 
+ 	len = mtd->size >> (this->bbt_erase_shift + 2);
+ 	/* Allocate memory (2bit per block) */
+-	this->bbt = kmalloc (len, GFP_KERNEL);
++	if (!this->bbt)
++		this->bbt = kmalloc (len, GFP_KERNEL);
+ 	if (!this->bbt) {
+ 		printk (KERN_ERR "nand_scan_bbt: Out of memory\n");
+ 		return -ENOMEM;





More information about the commitlog mailing list