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.

Linux: Partitioning eMMC from u-boot

Other Parts Discussed in Thread: AM5718

Tool/software: Linux

Hi,

We have developed a custom board with AM5718 processor and we are having a on board eMMC. Presently I am booting the device from SD card, I want to store the images in onboard eMMC and want to boot from eMMC. Since it is a custom board, I have to partition this eMMC memory, for that I am trying to do it from u-boot, but it is not working:

U-Boot# mmc list
OMAP SD/MMC: 0 (SD)
OMAP SD/MMC: 1


U-Boot# mmc dev 0
mmc_init: 0, time 65
switch to partitions #0, OK
mmc0 is current device


U-Boot# mmc dev 1
mmc_init: 0, time 298
switch to partitions #0, OK
mmc1(part 0) is current device


U-Boot# mmc part
## Unknown partition table

I tried to partition eMMC using the commands listed in the below link:
http://processors.wiki.ti.com/index.php/Linux_Core_U-Boot_User's_Guide#Partitioning_eMMC_from_U-Boot


U-Boot# uuidgen
Unknown command 'uuidgen' - try 'help'

U-Boot# gpt write mmc 1 ${partitions}
Writing GPT: set_gpt_info:  lba num: 0x734000 7553024
${uuid_gpt_disk} unset.
${uuid_gpt_rootfs} unset.
error!

Please suggest how to do eMMC partition

Best Regards,

Ganesh

  • Hi Ganesh,

    please note that the command "uuidgen" must be run on the Linux PC. It will generate unique ID that look something like
    "6c873bd0-a4c6-4062-9df0-94c8e237ca5d". For example:

    On Linux PC:

    $ uuidgen
    39aad9ef-73d3-407d-8141-48e709904ae4
    $ uuidgen
    6250f2c8-005e-4664-9b34-79962e5e860f

    we generated two IDs, then on U-boot console we use them:

    U-Boot # setenv uuid_gpt_disk 39aad9ef-73d3-407d-8141-48e709904ae4
    U-Boot # setenv uuid_gpt_rootfs 6250f2c8-005e-4664-9b34-79962e5e860f
    U-Boot # gpt write mmc 1 ${partitions}

    Regards,
    Yordan
  • Hi Yordan,

    I have executed the commands and please check below, what is happening:

    U-Boot# mmc dev 1
    mmc_init: 0, time 299
    switch to partitions #0, OK
    mmc1(part 0) is current device

    U-Boot# setenv uuid_gpt_disk ddc49fea-ca2a-430d-961a-b17caeadee63
    Initial value for argc=3
    Final value for argc=3

    U-Boot# setenv uuid_gpt_rootfs 02527057-ebe1-4ec4-b321-4a35585d0770
    Initial value for argc=3
    Final value for argc=3

    U-Boot# gpt write mmc 1 ${partitions}
    Writing GPT: set_gpt_info: lba num: 0x734000 7553024
    ${uuid_gpt_disk} get from environment.
    ${uuid_gpt_rootfs} get from environment.
    gpt_fill_pte: name: rootfs offset[0]: 0x1000 size[0]: 0x0
    max lba: 734000
    GPT successfully written to block device!
    success!

    U-Boot# mmc info
    Device: OMAP SD/MMC
    Manufacturer ID: fe
    OEM: 14e
    Name: MMC04
    Tran Speed: 52000000
    Rd Block Len: 512
    MMC version 4.4.1
    High Capacity: Yes
    Capacity: 3.6 GiB
    Bus Width: 4-bit
    Erase Group Size: 512 KiB
    HC WP Group Size: 4 MiB
    User Capacity: 3.6 GiB
    Boot Capacity: 16 MiB ENH
    RPMB Capacity: 128 KiB ENH

    U-Boot# mmc part
    ## Unknown partition table

    U-Boot# mmc dev 1
    mmc_init: 0, time 55
    switch to partitions #0, OK
    mmc1(part 0) is current device

    Best Regards,
    Ganesh
  • Hi Ganesh,

    according to the wiki you need to restart the device after "gpt write mmc 1 ${partitions}" to make the partition table visible.

    Regards,
    Yordan
  • Hi Yordan,

    Thank You. I am able to see partitions in MMC1 after restart ,

    U-Boot# mmc part

    Partition Map for MMC device 0 -- Partition Type: DOS

    Part Start Sector Num Sectors UUID Type
    1 63 144522 00000000-01 0c Boot
    2 160650 7454160 00000000-02 83
    U-Boot# mmc dev 1
    mmc_init: 0, time 282
    switch to partitions #0, OK
    mmc1(part 0) is current device
    U-Boot# mmc part

    Partition Map for MMC device 1 -- Partition Type: EFI

    GPT: first_usable_lba: 22 last_usable_lba: 733FDE last lba: 734000
    alloc_read_gpt_entries: count = 128 * 128 = 16384
    print_part_efi: gpt-entry at bef3dc40
    Part Start LBA End LBA Name
    Attributes
    Type GUID
    Partition GUID
    1 0x00001000 0x00733fde "rootfs"
    attrs: 0x0000000000000000
    type: ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
    guid: 57705202-e1eb-c44e-b321-4a35585d0770
    is_pte_valid: Found an unused PTE GUID at 0xBEF3DCC0

    U-Boot# print partitions
    partitions=uuid_disk=${uuid_gpt_disk};name=rootfs,start=2MiB,size=-,uuid=${uuid_gpt_rootfs}

    1. When I issue mmcinfo commad from U-Boot I am only getting the SD card info, no information about eMMC
    U-Boot# mmc info
    Device: OMAP SD/MMC
    Manufacturer ID: fe
    OEM: 14e
    Name: MMC04
    Tran Speed: 52000000
    Rd Block Len: 512
    MMC version 4.4.1
    High Capacity: Yes
    Capacity: 3.6 GiB
    Bus Width: 4-bit
    Erase Group Size: 512 KiB
    HC WP Group Size: 4 MiB
    User Capacity: 3.6 GiB
    Boot Capacity: 16 MiB ENH
    RPMB Capacity: 128 KiB ENH

    U-Boot# print partitions
    partitions=uuid_disk=${uuid_gpt_disk};name=rootfs,start=2MiB,size=-,uuid=${uuid_gpt_rootfs}

    2. Only one partition is created as in partitions only one is mentioned, I guess two partitions boot and rootfs is necessary to boot from eMMC. Or can I copy all the images to this partition and boot from eMMC???

    Best regards,
    Ganesh.
  • Hi Ganesh,

    1. I am not sure why this happens, can you try to run "mmc rescan" before "mmc info"

    2. I think two separate partitions are needed. Also according to this:
    processors.wiki.ti.com/.../Linux_Core_U-Boot_User's_Guide
    you may need to use raw writes to write MLO and u-boot.img on emmc.

    Regards,
    Yordan
  • Hi Yordan,

    1. Tried "mmc rescan" befor "mmc info", but no change. No issue even if it is not displayed, until it's working
    2. I have done raw writes using the below commands,
    U-Boot # mmc dev 0
    U-Boot # mmc rescan
    U-Boot # mmc dev 1
    U-Boot # fatload mmc 0 ${loadaddr} MLO
    U-Boot # mmc write ${loadaddr} 0x100 0x100
    U-Boot # mmc write ${loadaddr} 0x200 0x100
    U-Boot # fatload mmc 0 ${loadaddr} u-boot.img
    U-Boot # mmc write ${loadaddr} 0x300 0x400
    and it is booting from eMMC till u-boot.

    3. These two commands syntax is not clear:
    U-Boot # fatload mmc 0 ${loadaddr} rootfs.ext4
    U-Boot # mmc write ${loadaddr} 0x1000 ...rootfs.ext4 size in bytes divided by 512, in hex...
    How should I copy the remaining images like zImage & dtb, file system and where??? I want to make eMMC as my booting device.

    4. As we have not copied the remaining images into eMMC, I am getting the below error in u-boot:
    HY status read failed
    cpsw connected to Generic PHY
    cpsw
    initcall: 808046d9 (relocated to bff5d6d9)
    Initial value for argc=3
    Final value for argc=3
    ### main_loop entered: bootdelay=1

    ### main_loop: bootcmd="if test ${dofastboot} -eq 1; then echo Boot fastboot requested, resetting dofastboot ...;setenv dofastboot 0; saveenv;"
    Hit any key to stop autoboot: 0
    : returns 1
    Command failed, result=1: returns 1
    Command failed, result=1: returns 1
    Command failed, result=1: returns 1
    Command failed, result=1: returns 1
    Command failed, result=1: returns 1
    Command failed, result=1: returns 1
    Command failed, result=1: returns 1
    Command failed, result=1: returns 1
    Command failed, result=1: returns 1
    Command failed, result=1: returns 0
    WARNING: Could not determine device tree to use
    Card did not respond to voltage select!
    mmc_init: -17, time 12
    Command failed, result=1Card did not respond to voltage select!
    mmc_init: -17, time 12
    Command failed, result=1Command failed, result=1Card did not respond to voltage select!
    mmc_init: -17, time 11
    Command failed, result=1Card did not respond to voltage select!
    mmc_init: -17, time 11
    Command failed, result=1Command failed, result=1Initial value for argc=3
    Final value for argc=3
    Initial value for argc=3
    Final value for argc=3
    Initial value for argc=4
    Final value for argc=4
    mmc_init: 0, time 54
    switch to partitions #0, OK
    mmc1(part 0) is current device
    mmc_init: 0, time 55
    SD/MMC found on device 1
    GPT: first_usable_lba: 22 last_usable_lba: 733FDE last lba: 734000
    alloc_read_gpt_entries: count = 128 * 128 = 16384
    is_pte_valid: Found an unused PTE GUID at 0xBEF4F2C0
    get_partition_info_efi: *** ERROR: Invalid partition number 2 ***
    ** Invalid partition 2 **

    Best Regards,
    Ganesh
  • Hi Ganesh,

    can you boot the board with the SD card? You can then use some of the scripts from this thread:

    e2e.ti.com/.../488408

    to format the emmc and copy necessary files from the Linux running on the board.

    Regards,
    Yordan