This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

U-BOOT manually writing to NAND Timeout for initramfs in NAND approach

Other Parts Discussed in Thread: UNIFLASH

Hi,

My SD with worked fine in the customised AM335x board running as initramfs but I am having trouble when trying to manually write image files from SD to NAND in u-boot.  

The default NAND partitions I could see when booting up from SD is as follow


[    5.087055] Creating 10 MTD partitions on "omap2-nand.0":
[    5.091645] 0x000000000000-0x000000020000 : "NAND.SPL"                                --->128 K
[    5.097802] 0x000000020000-0x000000040000 : "NAND.SPL.backup1"                --->128 K
[    5.104451] 0x000000040000-0x000000060000 : "NAND.SPL.backup2"                --->128 K
[    5.111122] 0x000000060000-0x000000080000 : "NAND.SPL.backup3"                 --->128 K
[    5.117535] 0x000000080000-0x0000000c0000 : "NAND.u-boot-spl-os"                --->256 K
[    5.124502] 0x0000000c0000-0x0000001c0000 : "NAND.u-boot"                             --->1 M
[    5.131953] 0x0000001c0000-0x0000001e0000 : "NAND.u-boot-env"                     --->128 K
[    5.138298] 0x0000001e0000-0x000000200000 : "NAND.u-boot-env.backup1"    --->128 K
[    5.145541] 0x000000200000-0x000000a00000 : "NAND.kernel"                            --->8 M
[    5.163324] 0x000000a00000-0x000010000000 : "NAND.file-system"                    --->246 M

And when under the U-BOOT prompt I could:

(1) flash my 'MLO' to 'NAND.SPL'-


U-Boot# fatload mmc 0 0x82000000 MLO
U-Boot# nand write 0x82000000 0x0 0x20000

NAND write 131072 bytes OK

(2) flash my 'u-boot.img' to 'NAND.u-boot'-


U-Boot# fatload mmc 0 0x82000000 u-boot.img
U-Boot# nand write 0x82000000 0xc0000 0x100000

NAND write 437852 bytes OK

(3) flash my 'am335x-evm.dtb' to 'NAND.u-boot-spl-os'


U-Boot# ext4load mmc 0:2 0x82000000 boot/am335x-evm.dtb
U-Boot# nand write 0x82000000 0x80000 0x40000

NAND write 33850 bytes OK

And then I got stuck as my image is 'zImage' for initramfs and is about 50 M.  I could load it but I don't know where to write to as 'NAND.kernel' only has 8M.

I then changed the 'NAND.kernel' size to 100 M, which I am not sure if it's correct thing to do but just for a try to see if I can write zImage to the NAND.   I then got stuck when trying to write the zImage to 'NAND.kernel'. 


U-Boot# ext4load mmc 0:2 0x82000000 boot/zImage
52010112 bytes read in 5487 ms (9 MiB/s)
Timeout!NAND write to offset 200000 failed -5
 0 bytes written: ERROR

How to write my zImage to the NAND? is it because the size is too large?

 

I am guessing It probably isn't correct anyway, as refer to my SD card which has boot and rootfs partitions as:

boot/MLO

boot/u-boot.img

rootfs/boot/zImage

rootfs/boot/am335x-evm.dtb

and I am guessing I should write my whole rootfs into 'NAND.file-system' instead?  hence my second (real) question is; how to write and boot from NAND (as initramfs) given the four files I have.

Thanks for your help.

George

 

  • Hi,

    Which SDK version is this?
  • Hi Biser,

    I am using 'ti-processor-sdk-linux-am335x-evm-01.00.00.03' (so 'u-boot-2014.07+gitAUTOINC+fb6ab76dad-gfb6ab76')

    I have actually seen your other post in here

    e2e.ti.com/.../1584867

    which seems relevant for the 'timeout' issue? I will try bch16 to see whether I could write large size anyway.

    Meanwhile my other question is about how/where to write the zImage to and boot from NAND as initramfs; given the four files I have. Is it 'NAND.kernel'? and how about 'NAND.file-system'?

    Many Thanks

    George
  • Hi, maybe not.... I just modified to 'BCH16_HW' by following up

    processors.wiki.ti.com/.../Linux_Core_NAND_User's_Guide

    And my NAND is gone...

    NAND: nand: error: insufficient OOB: require=106

    George
  • Hi,

    NAND write to NAND.kernel with my zImage file larger than 50M is now working (i.e. no more time out), I think because I forgot to change device tree from bch8 to bch16 according to

    processors.wiki.ti.com/.../Linux_Core_NAND_User's_Guide

    I could see the device is trying to fetch the linux image.

    'The Expected Linux image was not found. Please check your NAND configuration.'

    I will check those env parameters hopefully to see some hint.

    Thanks

    George
  • Hi George,

    I've answered on your other thread.

    Please have a look at it. It should provide the information you need.

    Best Regards,
    Yordan
  • Thanks Yordan,

    I did come across the link and I was under impression it was for eMMC not NAND but yes it did say for other type like NAND as well. Thanks for pointing out I will study it.

    My other thread is about how to use uniflash to flash initramfs to NAND; and this thread basically I was trying to flash the NAND manually under U-BOOT.

    Could you help please- I have managed to write the MLO to 'NAND.SPL', the 'u-boot.img' to 'NAND.u-boot', the device tree to 'NAND.u-boot-spl-os' as well as the zImage to 'NAND.kernel', only partition I miss is the 'NAND.file-system'

    I then execute 'run nandboot' and I have 'echo Booting from nand ..' followed by many many

    'nand: bit-flip corrected @oob=0'

    and then

    'Kernel image @ 0x82000000 [ 0x000000 - 0x3199c80 ]
    ERROR: Did not find a cmdline Flattened Device Tree
    Could not find a valid device tree'

    My 'nandboot' is the default

    "nandargs=setenv bootargs console=${console} " \
    "${optargs} " \
    "root=${nandroot} " \
    "rootfstype=${nandrootfstype}\0" \
    "nandroot=ubi0:rootfs rw ubi.mtd=NAND.file-system,2048\0" \
    "nandrootfstype=ubifs rootwait=1\0" \

    "nandboot=echo Booting from nand ...; " \
    "run nandargs; " \
    "nand read ${fdtaddr} NAND.u-boot-spl-os; " \
    "nand read ${loadaddr} NAND.kernel; " \
    "bootz ${loadaddr} - ${fdtaddr}\0"


    So I am guessing the problem is that I also need to write something to 'NAND.file-system', perhaps a tar ball of my rootfs, which contains 'rootfs/boot/zImage' and 'rootfs/boot/am335x-evm.dtb'?

    Thanks again

    George
  • Hi,

    I have managed to manually flash from SD to NAND and boot up from NAND with some extra things below, note it is just for my case.

    (1) 'common/spl/spl.c'; change from
    #define CONFIG_SYS_MONITOR_LEN (200 * 1024)
    to
    #define CONFIG_SYS_MONITOR_LEN (512 * 1024)

    As although by default 'mtdparts' has defined enough space (i.e. 1M) and my 'u-boot.bin' is less than 1M (i.e. 428K); without changing it would result in kernel image not found when booting from NAND.

    (2) change on 'drivers/mtd/nand/nand_base.c' to suppress 'nand: bit-flip corrected @oob=0'

    static void nand_command_lp(struct mtd_info *mtd, unsigned int command,
    ctrl &= ~NAND_CTRL_CHANGE;
    chip->cmd_ctrl(mtd, column >> 8, ctrl);
    }
    - if (page_addr != -1) {
    + if (page_addr != -11 && command != NAND_CMD_RNDOUT) {

    As my kernel is from WindRiver.

    (3) I had to extract the 'rootfs.cpio.gz' from my 'zImage-initramfs.bin' image, make a 'ubi.img' of the 'rootfs' and then flash the 'ubi.img' to the 'NAND.file-systems'.

    This is a troublesome for me and I need some help please. Not just because my initramfs is directly embeded in the kernel image; but also at the moment if I make some change to the 'NAND.file-systems' the change will be made permanently. I want a new install each time the target board is power cycled. I have managed this in the SD booting and would like to be the same when booting up by NAND. How do I do it? Is there any material for me to follow up?

    Many Thanks

    George

  • Hi there,

    I have further progress.

    I could now boot from NAND via the U-BOOT after flashing my 70M initramfs zImage to 'NAND.kernel' ; i.e.

    U-Boot# run nandboot
    Booting from nand ...

    NAND read: device 0 offset 0x80000, size 0x40000
    262144 bytes read: OK

    NAND read: device 0 offset 0x200000, size 0x800000
    8388608 bytes read: OK
    Kernel image @ 0x82000000 [ 0x000000 - 0x31ea7e8 ]
    ## Flattened Device Tree blob at 88000000
    Booting using the fdt blob at 0x88000000
    Loading Device Tree to 8fff4000, end 8ffff439 ... OK

    Starting kernel ...

    Booting Linux on physical CPU 0x0
    Initializing cgroup subsys cpuset
    Initializing cgroup subsys cpu
    Initializing cgroup subsys cpuacct
    Linux version 3.10.62-ltsi-WR6.0.0.26_standard (ssl@windrivervm) (gcc version 4.8.1 (Wind River Linux Sourcery CodeBench 4.8-47) ) #2 SMP PREEMPT Fri Jan 29 18:58:17 GMT 2016
    ...

    However; if I restart the processor to let it auto boot from NAND; it hangs...

    ...
    Booting from nand ...

    NAND read: device 0 offset 0x80000, size 0x40000
    262144 bytes read: OK

    NAND read: device 0 offset 0x200000, size 0x800000
    8388608 bytes read: OK
    Kernel image @ 0x82000000 [ 0x000000 - 0x31ea7e8 ]
    ## Flattened Device Tree blob at 88000000
    Booting using the fdt blob at 0x88000000
    Loading Device Tree to 8fff4000, end 8ffff439 ... OK

    Starting kernel ...

    and then it hangs

    What could be the cause?

    Many thanks

    George
  • Hi there,

    I have further progress.

    I could now boot from NAND via the U-BOOT after flashing my 70M initramfs zImage to 'NAND.kernel' ; i.e.

    U-Boot# run nandboot
    Booting from nand ...

    NAND read: device 0 offset 0x80000, size 0x40000
    262144 bytes read: OK

    NAND read: device 0 offset 0x200000, size 0x800000
    8388608 bytes read: OK
    Kernel image @ 0x82000000 [ 0x000000 - 0x31ea7e8 ]
    ## Flattened Device Tree blob at 88000000
    Booting using the fdt blob at 0x88000000
    Loading Device Tree to 8fff4000, end 8ffff439 ... OK

    Starting kernel ...

    Booting Linux on physical CPU 0x0
    Initializing cgroup subsys cpuset
    Initializing cgroup subsys cpu
    Initializing cgroup subsys cpuacct
    Linux version 3.10.62-ltsi-WR6.0.0.26_standard (ssl@windrivervm) (gcc version 4.8.1 (Wind River Linux Sourcery CodeBench 4.8-47) ) #2 SMP PREEMPT Fri Jan 29 18:58:17 GMT 2016
    ...

    However; if I restart the processor to let it auto boot from NAND; it hangs...

    ...
    Booting from nand ...

    NAND read: device 0 offset 0x80000, size 0x40000
    262144 bytes read: OK

    NAND read: device 0 offset 0x200000, size 0x800000
    8388608 bytes read: OK
    Kernel image @ 0x82000000 [ 0x000000 - 0x31ea7e8 ]
    ## Flattened Device Tree blob at 88000000
    Booting using the fdt blob at 0x88000000
    Loading Device Tree to 8fff4000, end 8ffff439 ... OK

    Starting kernel ...

    and then it hangs

    What could be the cause?

    Many thanks

    George
  • Hi,

    I have managed to manually flash my large initramfs zImage which has the fs embedded (so the size is around 70M) to NAND from SD card; and then it now auto boots from NAND, resulting in loading the same large initramfs zImage from NAND before installing a new kernel and fs into RAM at each power cycle (i.e. fs is not in persistent storage)

    Below is the extra bit I had to do on top of what's been discussed in the post; note it's just in my case.

    Assuming 'mtdparts' has been changed accordingly in the device tree (e.g. increase NAND.kernel size), for consistency, change u-boot as well

    - change bootm size from 8M to, in my case is 100M
    - by default in my case fdtaddr is 0x88000000 and loadaddr is 0x82000000, if execute nandboot, which is booz ${loadaddr} - ${fdtaddr}, as the NAND.kernel in my case is 100M (more than 0x6000000) loading image to the loadaddr would override the fdtfile in memory. This can be taken care by either changing the default fdtaddr, or reduce the kernel partition to less than 0x6000000.

    Thanks

    George