[Letux-kernel] gta04 - reading nand from u-boot

Josua Mayer josua.mayer at jm0.eu
Fri Jul 20 19:57:48 CEST 2018

Hi Nikolaus,

Am 20.07.2018 um 18:04 schrieb H. Nikolaus Schaller:
> Hi,
>> Am 20.07.2018 um 17:49 schrieb Josua Mayer <josua.mayer at jm0.eu>:
>> Hi everybody,
>> my experiments have reached a point where I want to use nand, so I
>> started by setting it up from within linux, and then tried to boot.
>> And I was greeted by a ton of errors on the serial console:
>> fallback to NAND kernel
>> NAND read: device 0 offset 0x280000, size 0x5c0000
>> Error: Bad compare! failed
>> ^^ This line keeps repeating seemingly endless.
>> So I notice two things:
>> - read starts at 0x280000: this matches the start of the kernel
>> partition as declared in devicetree.
>> - trying to read 0x5c0000 bytes: This should be enoufg for my kernel
>> image which is only 3.3MB, but maybe it should be as much as the kernel
>> partition size 0x400000.
>> So what is going wrong? Nothing obvious. So I started playing with the
>> nand read command:
>> nand read 0x82000000 0x0 0x240000
>> 2359296 bytes read: OK
>> nand read 0x82000000 0x0 0x260000
>> 2490368 bytes read: OK
>> nand read 0x82000000 0x0 0x280000
>> 2621440 bytes read: OK
>> nand read 0x82000000 0x240000 0x20000
>> 131072 bytes read: OK
>> nand read 0x82000000 0x280000 0x1   
>> NAND read: device 0 offset 0x280000, size 0x1
>> Error: Bad compare! failed
>> Error: Bad compare! failed
>> Error: Bad compare! failed
>> Error: Bad compare! failed
>> NAND read from offset 280000 failed -74
>>  0 bytes read: ERROR
>> ^^ So I can't read beyond 0x27ffff
>> Has anyone seen this?
>> @Nikolaus does this work for you?
> Yes. Probably it is because you can't read single bytes
> (size 0x1). Depending on NAND type it must be 0x10000
> or 0x20000.
I also tried reading single bytes before 0x280000.
The offset needs to be aligned to some size, probably that 0x10000 you
but then it does work:
nand read 0x82000000 0x240000 0x1   
NAND read: device 0 offset 0x240000, size 0x1
 1 bytes read: OK
> The next thing to consider is ECC. AFAIR you
> can only write kernel and rootfs from Linux
> but not U-Boot and MLO. They use a different ECC
> scheme.
Very interesting!
So I did write Linux and rootfs from within linux, and I used u-boot to
write u-boot.
But I erased everything first from within linux!
However right now I am just trying to read ...
> I am not sure if the Bad compare! failed comes from
> ECC. Sometimes it helps to erase the NAND (section)
> from U-Boot console.
Maybe it does?
So you would suggest erasing the kernel section first from within u-boot?
nand erase 0x280000 0x400000 ?
Or scrub? According to the help bad blocks will be skipped, so this
command may erase beyond 0x680000?
Do I maybe want to scrub the whole nand?
> Therefore we have these "production images" with
> MLO and U-Boot and automatic reflashing if you
> have a newer "production image".
Yes, and that process did start as expected after I had erased nand from
within linux first.
> In general it is very very fragile to get a working
> setup... (and this is why I almost never touch this
> running system :).
> Hope this helps.
> BR,
> Nikolaus
> _______________________________________________
> http://projects.goldelico.com/p/gta04-kernel/
> Letux-kernel mailing list
> Letux-kernel at openphoenux.org
> http://lists.goldelico.com/mailman/listinfo.cgi/letux-kernel

More information about the Letux-kernel mailing list