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

Top Page
Attachments:
Message as email
+ (text/plain)
+ yaffs_userland_05_mkyaffs_damaged_count.patch (text/plain)
Delete this message
Reply to this message
Author: Frank Rowand
Date:  
To: yaffs
Subject: [Yaffs] patch: mkyaffs - detect image too large due to bad blocks
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 <>
MontaVista Software, Inc

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");