[U-Boot] JFFS2 scanning bug

Ilya Yanok yanok at emcraft.com
Sat Mar 14 01:59:22 CET 2009


Hi Mark,

mpfj-list at mimc.co.uk wrote:
>> 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.
>>     
>
>   

Thanks for clearing this out.

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

This is wrong actually as sector_size is not an attribute of a partition
but is an attribute of a whole mtd device and we don't want to get
smaller sector size (this would make generic scanning slower and can
break summary support). So just need to remove this break.

I'll prepare the patch and will post it in some days. (We can just drop
the above two lines and it should work but the most clean way would be
to calculate sector_size after flash_init() and then just use that value
but that means a lot of patching... Maybe someone has any ideas?)

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

I can still imagine an overflow here.

Regards, Ilya.



More information about the U-Boot mailing list