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: Write MLO, uboot, uImage, rootfs on to eMMC/mNAND of am335x EVM(J5 Echo) based custom board

Hi All,

1. I've am335x EVM(J5 Echo) based custom board.

2. I've  MLO, uboot, uImage, rootfs on DDR3 through uboot tftp.

3. I want to know the steps/cmds to write these images on to eMMC/mNAND using U-boot.

Regards,

Gangadhar

  • Hi Gangadhar,

    Which version of the TI SDK are you using?

    I assume you are using SDK version 06.00.00.00, because you use uImage instead of zImage + device tree.

    Follow these steps:

    U-Boot# nand erase.chip
    U-Boot# tftp 0x81000000 MLO
    U-Boot# cp.b 0x81000000 0x81020000 20000
    U-Boot# cp.b 0x81000000 0x81040000 20000
    U-Boot# cp.b 0x81000000 0x81060000 20000
    U-Boot# tftp 0x81080000 u-boot.img
    U-Boot# tftp 0x81280000 uImage
    U-Boot# tftp 0x81780000 ubi.img
    U-Boot# nand write 0x81000000 0x0 0x2000000

    Best regards,
    Miroslav

  • Hi Miroslav,

                        

    1. I'm using SDK version 07.00.00.00. I'll use zImage + device tree. Please give me the offset addresses to write into mNAND/eMMC.

    2. In your reply you've used "nand erase.chip" and "nand write". Will these cmds work with mNAND/eMMC?

    Regards,

    Gangadhar

     

  • Gangadhar,

    Here are my steps to flash the AM335x GP EVM board's NAND with the binaries included in SDK v07.00.00.00. Please note that I use a SD card, but you can easily do the same using tftp.

    U-Boot# nand erase.chip

    NAND erase.chip: device 0 whole chip
    Erasing at 0xffe0000 -- 100% complete.
    OK
    U-Boot# mmc rescan
    U-Boot# fatls mmc 0
       107920   mlo
       389768   u-boot.img
           13   .ipaddr
        41564   devicetree-zimage-am335x-evm.dtb
      4117616   zimage
     32768000   arago-base-tisdk-image-am335x-evm.ubi

    6 file(s), 0 dir(s)

    U-Boot# fatload mmc 0 0x81000000 MLO
    reading MLO
    107920 bytes read in 10 ms (10.3 MiB/s)
    U-Boot# cp.b 0x81000000 0x81020000 20000; cp.b 0x81000000 0x81040000 20000; cp.b 0x81000000 0x81060000 20000
    U-Boot# fatload mmc 0 0x81080000 devicetree-zimage-am335x-evm.dtb
    reading devicetree-zimage-am335x-evm.dtb
    41564 bytes read in 8 ms (5 MiB/s)
    U-Boot# fatload mmc 0 0x810c0000 u-boot.img
    reading u-boot.img
    389768 bytes read in 28 ms (13.3 MiB/s)
    U-Boot# fatload mmc 0 0x81200000 zImage
    reading zImage
    4117616 bytes read in 258 ms (15.2 MiB/s)
    U-Boot# fatload mmc 0 0x81a00000 arago-base-tisdk-image-am335x-evm.ubi
    reading arago-base-tisdk-image-am335x-evm.ubi
    32768000 bytes read in 2039 ms (15.3 MiB/s)
    U-Boot# nand write 0x81000000 0x0 0x2950000

    NAND write: device 0 offset 0x0, size 0x2950000
     43319296 bytes written: OK

    Regarding the eMMC, the "nand" commands won't work with it. There are a set of "mmc" commands in U-Boot, but the eMMC has to be pre-formatted and I can't see how this can be achieved from U-Boot. Here are the steps I have followed to configure and flash the BeagleBoneBlack's on-board eMMC using SDK v07.00.00.00:

    1. Prepare a SD card either with the create-sdcard.sh script or:
    On the host PC with the SD card inserted:
    1.01. sudo fdisc /dev/sdd (or /dev/mmcblk0)
    1.02. o - this clears the existing partitions
    1.03. p - this lists all partition tables on the card (there should be none)
    1.04. n - create a new partition
    1.05. p - primary partition
    1.06. 1 - partition number
    1.07. 2048 - default value for the first sector
    1.08. +64M - last sector / partition size
    1.09. t - change the partition type (select partition 1)
    1.10. e - change tha partition type to "W95 FAT16 (LBA)"
    1.11. a - set the bootable flag for the selected partition (1)
    1.12. n - create a new partition
    1.13. p - primary partition
    1.14. 2 - partition number
    1.15. hit Enter to choose the default (next available) value for the first sector
    1.16. hit Enter to choose the default (last) value for the last sector
    1.17. p - this lists all partition tables on the card (there should be two)
    1.18. w - write all the above changes to disk
    1.19. sudo mkfs.vfat -F 16 /dev/mmcblk0p1 (or /dev/sdd1) - format the first partition
    1.20. sudo mkfs.ext4 /dev/mmcblk0p2 (or /dev/sdd2) - format the second partition
    1.21. copy the {MLO,u-boot.img,uEnv.txt} files to the first partition:
    # mkdir boot
    # sudo mount /dev/mmcblk0p1 boot
    # cp {MLO,u-boot.img,uEnv.txt} boot
    # sudo umount boot
    1.22. copy the root file system to the second partition:
    # mkdir root
    # sudo mount /dev/mmcblk0p2 root
    # tar -xf tisdk-rootfs-image-am335x-evm.tar.gz -C root
    # sudo umount root

    2. Run the BBB from the SD card (hold the USR button when powering the board up)

    3. ssh into the board:
    # ssh root@172.20.0.111

    4. The eMMC is /dev/mmcblk1. Format it this way:
    4.01. fdisk /dev/mmcblk1
    4.02. o - this clears the existing partitions
    4.03. p - this lists all partition tables on the card (there should be none)
    4.04. n - create a new partition
    4.05. p - primary partition
    4.06. 1 - partition number
    4.07. 2048 - default value for the first sector
    4.08. +16M - last sector / partition size
    4.09. t - change the partition type (select partition 1)
    4.10. e - change tha partition type to "W95 FAT16 (LBA)"
    4.11. a - set the bootable flag for the selected partition (1)
    4.12. n - create a new partition
    4.13. p - primary partition
    4.14. 2 - partition number
    4.15. hit Enter to choose the default (next available) value for the first sector
    4.16. hit Enter to choose the default (last) value for the last sector
    4.17. p - this lists all partition tables on the card (there should be two)
    4.18. w - write all the above changes to disk
    4.19. umount /dev/mmcblk1p1; mkfs.vfat -F 16 /dev/mmcblk1p1 - format the first partition
    4.20. umount /dev/mmcblk1p2; mkfs.ext4 /dev/mmcblk1p2 - format the second partition

    5. Copy the {MLO,u-boot.img,uEnv.txt} files to the first partition:
    # mkdir boot
    # mount /dev/mmcblk1p1 boot
    # cp {MLO,u-boot.img,uEnv.txt} boot
    # umount boot

    6. Copy the root file system to the second partition:
    # mkdir root
    # mount /dev/mmcblk1p2 root
    # tar -xf tisdk-rootfs-image-am335x-evm.tar.gz -C root
    # umount root

    7. Shutdown the BBB, remove the SD card and start it from the eMMC.

    Best regards,
    Miroslav

  • Hi Miroslav,

    1. I booted uboot over UART.

    2. Wrote MLO and uboot on NAND flash.

    U-Boot# setenv ipaddr 192.168.0.201
    U-Boot# setenv serverip 192.168.0.45
    U-Boot# setenv gatewayip 192.168.0.1
    U-Boot# setenv netmask 255.255.255.0
    U-Boot# setenv Image1_Name MLO
    U-Boot# setenv Image2_Name u-boot.img
    U-Boot# setenv Image1_NAND_Offset 0x0
    U-Boot# setenv Image2_NAND_Offset 0x80000
    U-Boot# setenv Image1_DDR_ADDR 0x80200000
    U-Boot# setenv Image2_DDR_ADDR 0x80219000  
    U-Boot# setenv Image1_Length 0x1880D
    U-Boot# setenv Image2_Length 0x58E00
    U-Boot# setenv EraseNand 'echo Erasing NAND; if nand erase.chip; then echo NAND Erased; echo; else echo NAND Erase Failure Error Exit; fi;'
    U-Boot# setenv FlashImage 'if nand write ${source_addr} ${storage_offset} ${image_length}; then echo; echo   ${ImageName} succesfully programmed;echo; else echo ${ImageName} Programming Failed... error exit; fi;'
    U-Boot# setenv GetImage 'tftpboot ${source_addr} ${serverip}:${ImageName}'
    U-Boot# run EraseNand
    Erasing NAND

    NAND erase.chip: device 0 whole chip
    Erasing at 0xffe0000 -- 100% complete.
    OK
    NAND Erased

    U-Boot# setenv source_addr ${Image1_DDR_ADDR}
    U-Boot# setenv storage_offset ${Image1_NAND_Offset}
    U-Boot# setenv image_length ${Image1_Length}
    U-Boot# setenv ImageName ${Image1_Name}
    U-Boot# run GetImage
    link up on port 0, speed 100, full duplex
    Using cpsw device
    TFTP from server 192.168.0.45; our IP address is 192.168.0.201
    Filename 'MLO'.
    Load address: 0x80200000
    Loading: ######################
         1.4 MiB/s
    done
    Bytes transferred = 107936 (1a5a0 hex)
    U-Boot# run FlashImage

    NAND write: device 0 offset 0x0, size 0x1880d
     100365 bytes written: OK

    MLO succesfully programmed

    U-Boot# setenv source_addr ${Image2_DDR_ADDR}
    U-Boot# setenv storage_offset ${Image2_NAND_Offset}
    U-Boot# setenv image_length ${Image2_Length}
    U-Boot# setenv ImageName ${Image2_Name}
    U-Boot# run GetImage
    link up on port 0, speed 100, full duplex
    Using cpsw device
    TFTP from server 192.168.0.45; our IP address is 192.168.0.201
    Filename 'u-boot.img'.
    Load address: 0x80219000
    Loading: #################################################################
         ############
         2.5 MiB/s
    done
    Bytes transferred = 389780 (5f294 hex)
    U-Boot# run FlashImage

    NAND write: device 0 offset 0x80000, size 0x58e00
     364032 bytes written: OK

    u-boot.img succesfully programmed

    3. I switched off the EVM and made these switch positions,



    4. I switched on the board, got ccccccc, what change should I make for uboot to come up on NAND Flash.

    Regards,

    Gangadhar

  • Gangadhar, it is really hard to follow your steps when you have so many variables.

    Please first try to do it with the simplest set of commands and once you get it working, you can write a command to do it.

    Please follow my steps I posted in my previous post, replacing the "fatload" commands with the corresponding "tftp" commands.

    Best regards,
    Miroslav

  • Thankyou Miroslav. It's working.

    Regards,

    Gangadhar