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

Josua Mayer josua.mayer at jm0.eu
Fri Jul 20 20:25:24 CEST 2018


Am 20.07.2018 um 19:57 schrieb Josua Mayer:
> 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
> mentioned,
> 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?
reading more carefully, nand erase.spread skips bytes, but erase does not.
So this is the command I want to use, and sure enough, after first
erasing that section I can read from it from u-boot.

So next I booted into linux and wrote my uImage:
nandwrite -m -p /dev/mtd3 uImage
rebooted, and receive the same errors :/

Am I doing this part wrong?

So retry from u-boot:
load mmc 0:2 0x82000000 uImage.nand
nand erase 0x280000 0x400000
nand write 0x82000000 0x280000 0x33FDC7
3407303 bytes written: OK
nand read 0x82000000 0x280000 0x400000
NAND read: device 0 offset 0x280000, size 0x400000
4194304 bytes read: OK

So if I write from linux to nand flash, u-boot can not read it :(
linux meaning linux-image-armmp 4.16 in this context.
Next thing to try is if the same thing happens when writing to nand this
way from letux-*.
> 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.
Thanks, it does indeed help a little but I still have some way to go.
>>
>> 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
>
> _______________________________________________
> 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