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

laforge at sita.openmoko.org laforge at sita.openmoko.org
Sun Feb 25 16:50:20 CET 2007


Author: laforge
Date: 2007-02-25 16:50:19 +0100 (Sun, 25 Feb 2007)
New Revision: 1117

Modified:
   trunk/src/target/u-boot/patches/dynpart-absorb-bad.patch
   trunk/src/target/u-boot/patches/nand-dynamic_partitions.patch
Log:
* correctly handle gross/net partition sizes.  I.e., if we erase a partition,
  we want to erase all non-bad blocks in it.  but if we write to it [skipping
  blocks], then we definitely do not want to exceed the end of the partition.
  This introduces one additional argument to the arg_off_size() function.
* Fix nand_isbad_bbt() to also consider 'factory default bad-blocks' as being bad


Modified: trunk/src/target/u-boot/patches/dynpart-absorb-bad.patch
===================================================================
--- trunk/src/target/u-boot/patches/dynpart-absorb-bad.patch	2007-02-25 15:43:38 UTC (rev 1116)
+++ trunk/src/target/u-boot/patches/dynpart-absorb-bad.patch	2007-02-25 15:50:19 UTC (rev 1117)
@@ -1,10 +1,10 @@
 Index: u-boot/drivers/nand/nand_bbt.c
 ===================================================================
---- u-boot.orig/drivers/nand/nand_bbt.c	2007-02-16 23:53:57.000000000 +0100
-+++ u-boot/drivers/nand/nand_bbt.c	2007-02-16 23:54:02.000000000 +0100
-@@ -1062,6 +1062,15 @@
- static unsigned int part_size[] = { 0x30000, 0x4000, 0x200000, 0x130000, 0x3c9c000 };
- static char *part_names[] = { "u-boot", "u-boot_env", "kernel", "splash", "rootfs" };
+--- u-boot.orig/drivers/nand/nand_bbt.c	2007-02-25 14:57:29.000000000 +0100
++++ u-boot/drivers/nand/nand_bbt.c	2007-02-25 15:03:52.000000000 +0100
+@@ -1065,6 +1065,15 @@
+ static char *part_names[] = {
+     "u-boot", "u-boot_env", "kernel", "splash", "rootfs" };
  
 +
 +static int skip_offs(const struct nand_chip *this, unsigned int offs)
@@ -18,20 +18,23 @@
  int nand_create_mtd_dynpart(struct mtd_info *mtd)
  {
  	struct nand_chip *this = mtd->priv;
-@@ -1080,11 +1089,22 @@
+@@ -1083,12 +1092,23 @@
  		unsigned int bb_delta = 0;
  		unsigned int offs = 0;
  		char mtdpart[32];
--		for (offs = cur_offs; offs < cur_offs + part_size[part] + bb_delta; offs += 0x4000) {
+-		for (offs = cur_offs; offs < cur_offs + part_size[part] + bb_delta;
+-		     offs += this->erasesize) {
 -			int block = (int) (offs >> (this->bbt_erase_shift - 1));
 -			u_int8_t bbt = (this->bbt[block >> 3] >> (block & 0x06)) & 0x03;
 -			if (bbt == 0x03)
+-				bb_delta += this->erasesize;
 +
 +		for (offs = cur_offs;
-+		    offs < cur_offs + part_size[part] + bb_delta;
-+		    offs += 0x4000)
++		     offs < cur_offs + part_size[part] + bb_delta;
++		     offs += mtd->erasesize) {
 +			if (skip_offs(this, offs))
- 				bb_delta += 0x4000;
++				bb_delta += mtd->erasesize;
++		}
 +
 +		/*
 +		 * Absorb bad blocks immediately following this partition also
@@ -40,8 +43,8 @@
 +		 * environment partition.
 +		 */
 +		while (offs < this->chipsize && skip_offs(this, offs)) {
-+			bb_delta += 0x4000;
-+			offs += 0x4000;
++			bb_delta += mtd->erasesize;
++			offs += mtd->erasesize;
  		}
  
  		if (cur_offs + part_size[part] + bb_delta > this->chipsize)

Modified: trunk/src/target/u-boot/patches/nand-dynamic_partitions.patch
===================================================================
--- trunk/src/target/u-boot/patches/nand-dynamic_partitions.patch	2007-02-25 15:43:38 UTC (rev 1116)
+++ trunk/src/target/u-boot/patches/nand-dynamic_partitions.patch	2007-02-25 15:50:19 UTC (rev 1117)
@@ -17,9 +17,15 @@
 
 Index: u-boot/drivers/nand/nand_bbt.c
 ===================================================================
---- u-boot.orig/drivers/nand/nand_bbt.c
-+++ u-boot/drivers/nand/nand_bbt.c
-@@ -1049,4 +1049,63 @@ int nand_isbad_bbt (struct mtd_info *mtd
+--- u-boot.orig/drivers/nand/nand_bbt.c	2007-02-25 15:36:10.000000000 +0100
++++ u-boot/drivers/nand/nand_bbt.c	2007-02-25 15:36:51.000000000 +0100
+@@ -1044,9 +1044,70 @@
+ 	switch ((int)res) {
+ 	case 0x00:	return 0;
+ 	case 0x01:	return 1;
++	case 0x03:	return 1;
+ 	case 0x02:	return allowbbt ? 0 : 1;
+ 	}
  	return 1;
  }
  
@@ -54,11 +60,12 @@
 +		unsigned int bb_delta = 0;
 +		unsigned int offs = 0;
 +		char mtdpart[32];
-+		for (offs = cur_offs; offs < cur_offs + part_size[part] + bb_delta; offs += 0x4000) {
++		for (offs = cur_offs; offs < cur_offs + part_size[part] + bb_delta;
++		     offs += this->erasesize) {
 +			int block = (int) (offs >> (this->bbt_erase_shift - 1));
 +			u_int8_t bbt = (this->bbt[block >> 3] >> (block & 0x06)) & 0x03;
 +			if (bbt == 0x03)
-+				bb_delta += 0x4000;
++				bb_delta += this->erasesize;
 +		}
 +
 +		if (cur_offs + part_size[part] + bb_delta > this->chipsize)
@@ -85,8 +92,8 @@
  #endif
 Index: u-boot/include/configs/neo1973.h
 ===================================================================
---- u-boot.orig/include/configs/neo1973.h
-+++ u-boot/include/configs/neo1973.h
+--- u-boot.orig/include/configs/neo1973.h	2007-02-25 15:36:18.000000000 +0100
++++ u-boot/include/configs/neo1973.h	2007-02-25 15:36:51.000000000 +0100
 @@ -99,7 +99,7 @@
  			CFG_CMD_ELF	 | \
  			CFG_CMD_MISC	 | \
@@ -123,9 +130,39 @@
  #endif	/* __CONFIG_H */
 Index: u-boot/common/cmd_jffs2.c
 ===================================================================
---- u-boot.orig/common/cmd_jffs2.c
-+++ u-boot/common/cmd_jffs2.c
-@@ -2132,6 +2132,18 @@ int do_jffs2_mtdparts(cmd_tbl_t *cmdtp, 
+--- u-boot.orig/common/cmd_jffs2.c	2007-02-25 15:36:10.000000000 +0100
++++ u-boot/common/cmd_jffs2.c	2007-02-25 15:36:18.000000000 +0100
+@@ -1841,6 +1841,29 @@
+ 	return NULL;
+ }
+ 
++/* Return the 'net size' of the partition (i.e. excluding any bad blocks) */
++unsigned int nand_net_part_size(struct part_info *part)
++{
++	struct mtd_info *mtd;
++	unsigned int offs;
++	unsigned int bb_delta = 0;
++
++	if (!part || !part->dev || !part->dev->id ||
++	    part->dev->id->num >= CFG_MAX_NAND_DEVICE)
++		return 0;
++
++ 	mtd = &nand_info[part->dev->id->num];
++
++	for (offs = part->offset; offs < part->offset + part->size;
++	     offs += mtd->erasesize) {
++		if (nand_isbad_bbt(mtd, offs, 0))
++			bb_delta += mtd->erasesize;
++	}
++
++	return part->size - bb_delta;
++}
++
++
+ /***************************************************/
+ /* U-boot commands				   */
+ /***************************************************/
+@@ -2132,6 +2155,20 @@
  	printf ("Usage:\n%s\n", cmdtp->usage);
  	return 1;
  }
@@ -140,11 +177,13 @@
 +		return -EINVAL;
 +#endif
 +	nand_create_mtd_dynpart(&nand_info[0]);
++
++	return 0;
 +}
  #endif /* #ifdef CONFIG_JFFS2_CMDLINE */
  
  /***************************************************/
-@@ -2197,6 +2209,13 @@ U_BOOT_CMD(
+@@ -2197,6 +2234,13 @@
  	"<name>     := '(' NAME ')'\n"
  	"<ro-flag>  := when set to 'ro' makes partition read-only (not used, passed to kernel)\n"
  );
@@ -158,3 +197,89 @@
  #endif /* #ifdef CONFIG_JFFS2_CMDLINE */
  
  /***************************************************/
+Index: u-boot/common/cmd_nand.c
+===================================================================
+--- u-boot.orig/common/cmd_nand.c	2007-02-25 15:36:10.000000000 +0100
++++ u-boot/common/cmd_nand.c	2007-02-25 15:36:50.000000000 +0100
+@@ -101,7 +101,7 @@
+ }
+ 
+ int
+-arg_off_size(int argc, char *argv[], nand_info_t *nand, ulong *off, ulong *size)
++arg_off_size(int argc, char *argv[], nand_info_t *nand, ulong *off, ulong *size, int net)
+ {
+ 	int idx = nand_curr_device;
+ #if (CONFIG_COMMANDS & CFG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE)
+@@ -122,10 +122,17 @@
+ 					printf("'%s' is not a number\n", argv[1]);
+ 					return -1;
+ 				}
+-				if (*size > part->size)
+-					*size = part->size;
++				if (*size > part->size) {
++					if (net)
++						*size = nand_net_part_size(part);
++					else
++						*size = part->size;
++				}
+ 			} else {
+-				*size = part->size;
++				if (net)
++					*size = nand_net_part_size(part);
++				else
++					*size = part->size;
+ 			}
+ 			idx = dev->id->num;
+ 			*nand = nand_info[idx];
+@@ -261,7 +268,7 @@
+ 
+ 		printf("\nNAND %s: ", scrub ? "scrub" : "erase");
+ 		/* skip first two or three arguments, look for offset and size */
+-		if (arg_off_size(argc - o, argv + o, nand, &off, &size) != 0)
++		if (arg_off_size(argc - o, argv + o, nand, &off, &size, 0) != 0)
+ 			return 1;
+ 
+ 		memset(&opts, 0, sizeof(opts));
+@@ -323,7 +330,7 @@
+ 
+ 		read = strncmp(cmd, "read", 4) == 0; /* 1 = read, 0 = write */
+ 		printf("\nNAND %s: ", read ? "read" : "write");
+-		if (arg_off_size(argc - 3, argv + 3, nand, &off, &size) != 0)
++		if (arg_off_size(argc - 3, argv + 3, nand, &off, &size, 1) != 0)
+ 			return 1;
+ 
+ 		s = strchr(cmd, '.');
+@@ -445,7 +452,7 @@
+ 	}
+ 
+ 	if (strcmp(cmd, "unlock") == 0) {
+-		if (arg_off_size(argc - 2, argv + 2, nand, &off, &size) < 0)
++		if (arg_off_size(argc - 2, argv + 2, nand, &off, &size, 0) < 0)
+ 			return 1;
+ 
+ 		if (!nand_unlock(nand, off, size)) {
+Index: u-boot/common/cmd_dynenv.c
+===================================================================
+--- u-boot.orig/common/cmd_dynenv.c	2007-02-25 15:37:32.000000000 +0100
++++ u-boot/common/cmd_dynenv.c	2007-02-25 15:37:39.000000000 +0100
+@@ -60,7 +60,7 @@
+ 		buf[2] = 'V';
+ 		buf[3] = '0';
+ 
+-		if (arg_off_size(argc-2, argv+2, mtd, &addr, &dummy) < 0) {
++		if (arg_off_size(argc-2, argv+2, mtd, &addr, &dummy, 1) < 0) {
+ 			printf("Offset or partition name expected\n");
+ 			goto fail;
+ 		}
+Index: u-boot/include/util.h
+===================================================================
+--- u-boot.orig/include/util.h	2007-02-25 15:37:43.000000000 +0100
++++ u-boot/include/util.h	2007-02-25 15:37:49.000000000 +0100
+@@ -28,6 +28,6 @@
+ 
+ /* common/cmd_nand.c */
+ int arg_off_size(int argc, char *argv[], nand_info_t *nand, ulong *off,
+-  ulong *size);
++  ulong *size, int net);
+ 
+ #endif /* UTIL_H */





More information about the commitlog mailing list