[Yaffs] patch: mkyaffs - detect image too large due to bad blocks

Frank Rowand frowand@mvista.com
Mon, 22 Nov 2004 15:51:40 -0800


This is a multi-part message in MIME format.
--------------030306040801060407010302
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

The attached patch updates mkyaffs to detect when it was not
able to to write the complete image to NAND due to an
excessive number of bad blocks.

-Frank
-- 
Frank Rowand <frank_rowand@mvista.com>
MontaVista Software, Inc


--------------030306040801060407010302
Content-Type: text/plain;
 name="yaffs_userland_05_mkyaffs_damaged_count.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="yaffs_userland_05_mkyaffs_damaged_count.patch"

Index: yaffs/utils/mkyaffs.c
===================================================================
--- yaffs.orig/utils/mkyaffs.c
+++ yaffs/utils/mkyaffs.c
@@ -88,11 +88,13 @@
 {
 	unsigned long addr;
 	unsigned long offset;
+	int damaged_count = 0;
 	int fd;
 	int img=-1;
 	int optcnt = 1;
 	int usemtdecc = 0;
 	int imglen = 0;
+	int img_written = 0;
 	int showHelp = 0;
 	struct mtd_oob_buf oob = {0, 16, (unsigned char *) &oobbuf};
 	mtd_info_t meminfo;
@@ -197,6 +199,7 @@
 		
 		if(countBits[oobbuf[5]] < 7)
 		{
+			damaged_count++;
 			printf("Block at 0x08%lx is damaged and is not being formatted\n",addr);
 		}
 		else
@@ -218,6 +221,7 @@
 				for(offset = 0; offset <meminfo.erasesize; offset+=512)
 				{
 					if(read(img,imgpage,528) == 528){
+						img_written += 528;
 						if (usemtdecc) {
 							imgpage[512+8] = 0xff;
 							imgpage[512+9] = 0xff;
@@ -242,6 +246,14 @@
 	}
 
 
+	printf("\n");
+	printf("Count of damaged blocks: %d\n", damaged_count);
+	if (imglen != img_written)
+	{
+		printf("Image not completely written to NAND due to large number of damaged blocks\n");
+		exit(1);
+	}
+
 
 	/* All the tests succeeded */
 	printf("OK\n");

--------------030306040801060407010302--