jffs2: fix sector_size calculation in case of NOR flash

Ilya Yanok yanok at emcraft.com
Wed Oct 15 16:22:35 CEST 2008


Need to take all sectors into account then calculating sector_size
for NOR flashes.

Signed-off-by: Ilya Yanok <yanok at emcraft.com>
---
 common/cmd_jffs2.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/common/cmd_jffs2.c b/common/cmd_jffs2.c
index e7f07bf..2fc0b7d 100644
--- a/common/cmd_jffs2.c
+++ b/common/cmd_jffs2.c
@@ -344,7 +344,9 @@ static int part_validate_nor(struct mtdids *id,
struct part_info *part)
 
     flash = &flash_info[id->num];
 
-    part->sector_size = 0;
+    /* size of last sector */
+    part->sector_size = flash->size -
+        (flash->start[flash->sector_count-1] - flash->start[0]);
 
     offset_aligned = 0;
     for (i = 0; i < flash->sector_count; i++) {
@@ -360,6 +362,7 @@ static int part_validate_nor(struct mtdids *id,
struct part_info *part)
     }
 
     end_offset = part->offset + part->size;
+    offset_aligned = 0;
     for (i = 0; i < flash->sector_count; i++) {
         if (i) {
             sector_size = flash->start[i] - flash->start[i-1];
@@ -367,10 +370,10 @@ static int part_validate_nor(struct mtdids *id,
struct part_info *part)
                 part->sector_size = sector_size;
         }
         if ((flash->start[i] - flash->start[0]) == end_offset)
-            return 0;
+            offset_aligned = 1;
     }
 
-    if (flash->size == end_offset)
+    if (offset_aligned || flash->size == end_offset)
         return 0;
 
     printf("%s%d: partition (%s) size alignment incorrect\n",
-- 
1.5.6.1

You can try it. But I think the only affected case is summary enabled FS
which is rather rare.

Regards, Ilya.



More information about the U-Boot mailing list