[U-Boot] JFFS2 scanning bug

mpfj-list at mimc.co.uk mpfj-list at mimc.co.uk
Fri Mar 6 21:06:38 CET 2009


> Hi Mark,
>
> Don't you have JTAG debugger so you could find where exactly it hangs?
> Or you can try adding debugging printf's to the source... I can't
> reproduce your problem myself so that info would be useful.

Okay, I think I've found the problem.

When *not* using JFFS2_CMDLINE mode, U-Boot tries to work out the MTD
table automatically (for me using NOR flash, it's in the function
get_part_sector_size_nor() in cmd_jffs2.c).

Without specifying CONFIG_JFFS2_PART_SIZE, part->size defaults to
0xffffffff (use whole device).

However, the scanning code contains the line ...

end_phys = start_phys + flash->size;

... which, in this case, simply sets end_phys to (start_phys - 1).

Then the code has the lines ...

if (flash->start[i] >= end_phys)
	break;

... which results in an instant break, finally leaving the calculated
sector size as 0 !!

The attached patch seems to work for me, but probably needs double-checking
on some other platforms.

Regards
Mark
---
This patch fixes the JFFS2 scanning code when not using
CONFIG_JFFS2_CMDLINE.

Signed-off-by: Mark Jackson <mpfj at mimc.co.uk>
---
 common/cmd_jffs2.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/common/cmd_jffs2.c b/common/cmd_jffs2.c
index d0a7cea..2f3b3a9 100644
--- a/common/cmd_jffs2.c
+++ b/common/cmd_jffs2.c
@@ -1814,7 +1814,12 @@ static inline u32 get_part_sector_size_nor(struct
mtdids *id, struct part_info *
 	flash = &flash_info[id->num];

 	start_phys = flash->start[0] + part->offset;
-	end_phys = start_phys + part->size;
+
+	if (part->size == SIZE_REMAINING) {
+		end_phys = start_phys + flash->size;
+	} else {
+		end_phys = start_phys + part->size;
+	}

 	for (i = 0; i < flash->sector_count; i++) {
 		if (flash->start[i] >= end_phys)


More information about the U-Boot mailing list