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.

PROCESSOR-SDK-AM62X: SK AM62X EVK - Configuring eMMC as if it was erased (factory fresh). Some questions about mmc hwpartion, mmc partconf, gpt and related commands

Part Number: PROCESSOR-SDK-AM62X
Other Parts Discussed in Thread: AM623

Goal: partition eMMC flash to support RAW boot (tiboot3, etc), then the backup RAW boot at 0x40 0000

First cut of flash division. sectors are 512bytes

+-------------- @0x0 0000 0000 - primary eMMC location
+ tiboot3.bin, tispl.bin, u-boot.img etc...          size=0x40 0000 (sectors=8192)
+-------------- @0x0040 0000 - backup eMMC location
+ tiboot3.bin, tispl.bin, u-boot.img etc...          size=0x40 0000 (sectors=8192)
+-------------- @0x0 0080 0000 - begining rootfs (PING)
+ rootfs etc..                                                      (sectors=15539695)
+-------------- @0x1 DABB DE00 - begining rootfs (PONG)
+ rootfs etc..                                                      (sectors=15539695)
+-------------- @0x3 B4F7 BBFF - end rootfs (PONG)

I believe I can create 4 partitions. If I offset the partitions to account for RAW
At the beginning.
The rootfs could be broken out to 4 partitions starting with PING: (PONG NOT shown
+-------------- @0x0080 0000 - begining Image (PING)
+ Image, dtb..                                               (sectors=15539695/2-1)
+-------------- @0xsensible  - begining RFS (PING)
+ rootfs etc..                                               (sectors=15539695/2-1)
+-------------- @0xsensible  - end RFS (PING)

What is difference between hwpartion, and gpt partitions?

Is the first RAW partition an actual partition?

For eMMC, are the next two partitions be rootfs only partitions ext4?

That is a53/u-boot.bin is loaded to 

In working to test this I cleared the eMMC via:

mmc erase 0 31080414            -- This should set eMMC flash to all. Count was based on creating a single partition and looking at the last LBA sector.

=> mmcinfo
Device: mmc@fa10000
Manufacturer ID: 13
OEM: 4e
Name: S0J56X
Bus Speed: 200000000
Mode: HS200 (200MHz)
Rd Block Len: 512
MMC version 5.1
High Capacity: Yes
Capacity: 14.8 GiB
Bus Width: 8-bit
Erase Group Size: 512 KiB
HC WP Group Size: 8 MiB
User Capacity: 14.8 GiB WRREL
Boot Capacity: 31.5 MiB ENH
RPMB Capacity: 4 MiB ENH
Boot area 0 is not write protected
Boot area 1 is not write protected

uEnv.txt mods

cmd_0=mmc dev 0
# Erase the device, prep for future writes.

cmd_1a=mmc erase 0 31080414

cmd_1b=setenv uuid_gpt_disk e1402411-be20-4dc6-a229-915e6bd66f33
cmd_1c=setenv uuid_gpt_rootfs e7dbd504-c47a-493d-a1d4-aa34686b4b5b
cmd_1d=setenv partitions "uuid_disk=${uuid_gpt_disk};name=rootfs,start=16384,size=15539695,uuid=${uuid_gpt_rootfs}"
cmd_1e=gpt write mmc 0 $partitions
cmd_1f=emmc part
# See what we have
cmd_1g=setenv uuid_gpt_rootfs 93e4c649-cb27-4c27-ab7f-eb65a9ec348c
cmd_1h=setenv partitions "uuid_disk=${uuid_gpt_disk};name=rootfs,start=15540719,size=15539695,uuid=${uuid_gpt_rootfs}"
cmd_1i=gpt write mmc 0 $partitions
cmd_1j=emmc part
# See what we have

However after erasing flash I attempted the above commands:

=> setenv uuid_gpt_disk e1402411-be20-4dc6-a229-915e6bd66f33
=> setenv uuid_gpt_rootfs e7dbd504-c47a-493d-a1d4-aa34686b4b5b
=> setenv partitions "uuid_disk=${uuid_gpt_disk};name=rootfs,start=16384,size=15539695,uuid=${uuid_gpt_rootfs}"

=> gpt write mmc 0 $partitions
Writing GPT: error!

=> mmc part
## Unknown partition table type 0


=> mmc info
Device: mmc@fa10000
Manufacturer ID: 13
OEM: 4e
Name: S0J56X
Bus Speed: 200000000
Mode: HS200 (200MHz)
Rd Block Len: 512
MMC version 5.1
High Capacity: Yes
Capacity: 14.8 GiB
Bus Width: 8-bit
Erase Group Size: 512 KiB
HC WP Group Size: 8 MiB
User Capacity: 14.8 GiB WRREL
Boot Capacity: 31.5 MiB ENH
RPMB Capacity: 4 MiB ENH
Boot area 0 is not write protected
Boot area 1 is not write protected

=> gpt repair mmc 0
Repairing GPT: sdhci_transfer_data: Transfer data timeout
error!
=>

I'm not sure how to recover from this.

Is there a good explanation of how to recover from this state?  

  1. mmc hwpartion commands - examples of
    1. mmc hwpartition <USER> <GP> <MODE> - does hardware partitioning
      arguments (sizes in 512-byte blocks):
      USER - <user> <enh> <start> <cnt> <wrrel> <{on|off}>
      : sets user data area attributes
      GP - <{gp1|gp2|gp3|gp4}> <cnt> <enh> <wrrel> <{on|off}>
      : general purpose partition
      MODE - <{check|set|complete}>
      : mode, complete set partitioning completed
  2. gpt and related commands

What is the easiest recovery mechanism?

The goal here is for factory programming of the initially blank eMMC, or in the case of RMAs to erase the flash to a fresh state before creating partitions and downloading images.

Thanks

  • Hi Robert,

    I am routing your query to our U-Boot expert for comments.

  • Thanks Bin!

  • Let's use Linux boot from eMMC as an example, where eMMC boot and UDA partition will be like:
    - boot partition (RAW): u-boot (tiboot3.bin/tispl.bin/u-boot.img)
    - UDA (FS): Linux kernel and RootFS..., where GPT table etc... are placed @top of UDA partition.
    This makes practical restriction - ROM redundant boot support from eMMC UDA (RAW only with 0x0 and 0x400000) is not applicable to GPT formatted UDA.

    You may refer to SDK user guide on eMMC boot
    software-dl.ti.com/.../UG-Memory.html

    Please note "gpt..." is maintained by community, not TI.
    en.wikipedia.org/.../GUID_Partition_Table
    github.com/.../README.gpt

    Some customization would be needed for creating multiple partitions within eMMC UDA via "gpt...". Here're some pointers for your reference
    rockchip.wikidot.com/partitions
    www.pengutronix.de/.../2020-10-15-anpassen-einer-emmc.html

    Best,
    -Hong

  • I can create a partition table using fdisk from linux (booting from SD card). Which won't be available on the custom board.

    And I think if I load ram with kernel images,rfs,dtb I can use bootm, then perhaps use Linux to correct the partition.

    But the basic rfs image with the SDK is  629145600 bytes. And that pushes it to conflict with the running images. So that puts pain to that idea.

    => gpt repair mmc 0
    Repairing GPT: error!

    => gpt repair mmc 0 1
    Repairing GPT: error!
    => gpt repair mmc 0 2
    Repairing GPT: error!
    => echo $partitions
    uuid_disk=e1402411-be20-4dc6-a229-915e6bd66f33;name=rootfs,start=16384,size=15539695,uuid=e7dbd504-c47a-493d-a1d4-aa34686b4b5b
    => gpt write mmc 0 $partitions
    Writing GPT: error!
    =>

    I'm not sure if your able to help at this point I reviewed the JDEC spec, I'll continue to review these and other documents. 

    Regards,

    Robert

  • Note, I have tested 0x400000 boot 2 backup to boot 1. I had seen another thread indicating ROM code did not support detection and jump to 0x400000 raw tiboot3.bin.

    I think from version 7 of the SDK. So it is good news it is supported with the SoC I have now.

  • Let's use Linux boot from eMMC as an example, where eMMC boot and UDA partition will be like:
    - boot partition (RAW): u-boot (tiboot3.bin/tispl.bin/u-boot.img)
    - UDA (FS): Linux kernel and RootFS..., where GPT table etc... are placed @top of UDA partition.

    The redundant boot (0x0 & 0x400000) is supported by ROM on eMMC UDA (RAW ONLY).
    This makes practical restriction on using ROM redundant boot on UDA (RAW ONLY) once eMMC UDA is used for Linux/RootFS (FS formatted via GPT).

    I'd recommend exploring online resource on using "GPT..." to customize eMMC UDA partitions for your system.
    Best,
    -Hong

  • Hi Hong,

    Yes, I tested RAW boot backup on boot 1 by erasing a few bytes from raw boot 0 - this works. 

    I wonder how others are partitioning flash if all they have is ethernet backup mode to program their flash (outside of JTAG).

    I would think u-boot => GPT calls easily

    If uncommented this section of uEnv.txt (should) erase the SK_AM623B flash, then create two partitions past the RAW section (starting at 0x800000), realize I reused the rootfs name, but just creating the first partition results in an GPT error.

    Walking through these commands fails at the gpt write mmc 0 $partitions step. 

    ## Erase the device, prep for future writes.
    #cmd_1a=mmc erase 0 31080414
    #cmd_1b=setenv uuid_gpt_disk e1402411-be20-4dc6-a229-915e6bd66f33
    #cmd_1c=setenv uuid_gpt_rootfs e7dbd504-c47a-493d-a1d4-aa34686b4b5b
    #cmd_1d=setenv partitions "uuid_disk=${uuid_gpt_disk};name=rootfs,start=16384,size=15539695,uuid=${uuid_gpt_rootfs}"
    #cmd_1e=gpt write mmc 0 $partitions
    #cmd_1f=emmc part
    ## See what we have

    #cmd_1g=setenv uuid_gpt_rootfs 93e4c649-cb27-4c27-ab7f-eb65a9ec348c
    #cmd_1h=setenv partitions "uuid_disk=${uuid_gpt_disk};name=rootfs,start=15540719,size=15539695,uuid=${uuid_gpt_rootfs}"
    #cmd_1i=gpt write mmc 0 $partitions
    #cmd_1j=emmc part
    ## See what we have

    Have you used gpt to perform these tasks?, I wonder if I'm missing some part of flash - the bdinfo, and last sector from prior (linux based partitioning vi SD card boot) showed that as the correct last partition.

    But I'll take another look.

    Robert

  • The eMMC UDA configuration via "GPT..." in SDK
    software-dl.ti.com/.../UG-Memory.html
    I'd recommend exploring online resource on using "GPT..." to customize eMMC UDA partitions for your system.
    Best,
    -Hong

  • I've looked at this one - it looks like you create a binary file using dd, then partition it using gdisk, then from the image extract the first 64 records with the partition table.

    But then this needs to be written where? It's not clear, and it seems the end of flash part makes the most sense.

    To determine where at the end of flash to put it, I looked at the flash (extracted to RAM) and looked through the dump to find some non zero bytes. Then attempted to pull the 'custom' partition table extracted from the gdisk creation and place it in the same location the other flash partition table had been (I had erased it)

    Steps:

    Calculating partition size as:
    0x404000 - end of flash 0x1da4000 BLKs (I beleive I don't include the boot0, boot1 space)
    Total: 19a0000 Blks or ~13.7GB
    
     Virtual Disk being partitioned Just needs to be bigger than that..
     @bs=x10000 (65K) thats 19a blk count (410) to get to bytes x512
    
    $ dd if=/dev/zero of=disk2.img bs=65K count=209920
    209920+0 records in
    209920+0 records out
    13972275200 bytes (14 GB, 13 GiB) copied, 5.80583 s, 2.4 GB/s
    
    $ gdisk disk2.img
    GPT fdisk (gdisk) version 1.0.8
    
    Partition table scan:
      MBR: not present
      BSD: not present
      APM: not present
      GPT: not present
    
    Creating new GPT entries in memory.
    
    Command (? for help): n
    Partition number (1-128, default 1):
    First sector (34-27289566, default = 2048) or {+-}size{KMGTP}:
    Last sector (2048-27289566, default = 27289566) or {+-}size{KMGTP}:
    Current type is 8300 (Linux filesystem)
    Hex code or GUID (L to show codes, Enter = 8300):
    Changed type of partition to 'Linux filesystem'
    
    Command (? for help): w
    
    Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
    PARTITIONS!!
    
    Do you want to proceed? (Y/N): y
    OK; writing new GUID partition table (GPT) to disk2.img.
    Warning: The kernel is still using the old partition table.
    The new table will be used at the next reboot or after you
    run partprobe(8) or kpartx(8)
    The operation has completed successfull
    
    Then extract the GPT table for copy to the target flash:
    
    $ dd if=disk2.img of=gpt2.img count=64
    64+0 records in
    64+0 records out
    32768 bytes (33 kB, 32 KiB) copied, 0.00063716 s, 51.4 MB/s
    
    This is where I run into problems on placement.
    It looks like flash ends at 0x1da4000, so I should move back 64x512 from this point
    (or 40 blocks) thus: 1DA3FC0 blocks from begining of flash. 
    .. Place GPT table here?
    
    The next step if I get this to work would be:
    
    => help ext4write
    ext4write - create a file in the root directory
    
    Usage:
    ext4write <interface> <dev[:part]> <addr> <absolute filename path>
        [sizebytes] [file offset]
        - create a file in / directory
        
    I'm also hitting a stumbling block with RFS file size when 
    dhcp rootfs.ext4.emmc (the eMMC image I want on the target) - it's too big.
    .. Looking to compress this again instead of following SDK instructions for USB-DFU.
    
    Thoughts? Is this the correct path?

    But then circled back to the original post, and did additional comparisons and see that

    #cmd_1d=setenv partitions "uuid_disk=${uuid_gpt_disk};name=rootfs,start=16384,size=15539695,uuid=${uuid_gpt_rootfs}"

    if I use K, and MiB and other units it works, so there is a problem with the start/size - these should be in blocks, but they fail.

    ie.: 

    fails:

    "uuid_disk=e1402411-be20-4dc6-a229-915e6bd66f33;name=rootfs,start=16384,size=15539695,uuid=e7dbd504-c47a-493d-a1d4-aa34686b4b5b"

    works:

    "uuid_disk=e1402411-be20-4dc6-a229-915e6bd66f33;name=rootfs,start=500K,size=12MiB,uuid=e7dbd504-c47a-493d-a1d4-aa34686b4b5b"

    This is good and all, but when working with RAW eMMC boot modes this overwrites my boot0 location with partition table information.

    Perhaps I do the partitions first, the write the boot0,boot1 over the first partition table - this assumes this instruction creates the backup gpt data at top of flash as well. If that's true then I may be done. As long as later when running Linux or some other process doesn't break the partition table.

    And a point here is - partition tables are redundant for a reason, loose both and I'm not sure u-boot can find the images. If that's true I wonder why boot0/boot1 in raw are using the same space the partition tables are using. Or, am i misunderstanding something here?

    => setenv uuid_gpt_disk 9fd6884f-729a-48fe-a935-a343a6ebde86
    => setenv uuid_gpt_boot 3e59e9d0-f97f-4282-af18-4a70c4c9ab59
    => setenv uuid_gpt_rootfs 2906b911-83bd-4503-8d68-1a68d78067fe
    => setenv partitions "uuid_disk=${uuid_gpt_disk};name=boot,start=2MiB,size=128MiB,uuid=${uuid_gpt_boot};name=rootfs,start=130MiB,size=-,uuid=${uuid_gpt_rootfs}"
    => gpt write mmc 0 ${partitions}
    Writing GPT: success!
    => reset
    resetting ...

  • eMMC is consists of
    - Boot partition (boot0/boot1)
    - RPMB
    - UDA partition

    => eMMC boot partition and UDA are different HW partitions
    You'll find online resources on eMMC, i.e. JESD84-xxxx standard.

    eMMC layout in TI Linux SDK
    software-dl.ti.com/.../UG-Memory.html
    - Boot partition (boot0/boot1) in RAW format for u-boot binaries (tiboot3.bin/tispl.bin/u-boot.img...)
    - UDA: GPT partioned EXT4 format for kernel/root_fs...

    I'd recommend exploring online resource on using "GPT..." to customize eMMC UDA partitions for your system.

    Best,
    -Hong

  • Hi Hong,

    Perhaps, explaining eMMC HW partitions like this would be helpful.

    NOTE: no GP1,2,3,4 Hardware Repartitioning has been done. 

    For the SK AM623 EVK

    Details available in ./board-support/ti-u-boot/doc/usage/partitions.rst

    NOTE: looking at : https://pengutronix.de/en/blog/2020-10-15-anpassen-einer-emmc.html can be deceptive in that they show boot0 the furthest to the left, leading to the false assumption that it is the 0th partition.


    eMMC

    HW PARTITION  => mmc dev selection

    UDA : mmc dev 0 0        (This is the USER DATA AREA or USER PARTITION)

    • NOTE: Erase size is 0x400 aligned, so if you have partitioned it before placing the RFS file in this space at say offset 0x22 you will overwrite the partition information.
    • Proper proceedure:
      • Erase the UDA area you need for your RFS and other partitions.
      • Create GPT partitions NEXT
      • Load your RFS to RAM then program to FLASH at offset 0x22
    • Failures can occur in this command because values are not decimal but hex values (used in error)
      • setenv partitions "uuid_disk=${uuid_gpt_disk};name=rootfs,start=16384,size=15539695,uuid=${uuid_gpt_rootfs}
        • This used a size of 1539695(hex) Blocks => 183193381376 Bytes (170 GiB) More than the system memory. 
        • Think hex values are OK, but need to reflect blocks (512) and perhaps better to proceed with 0x (Not tested)
      • Corrected:
      • setenv partitions (Using M for mega bytes) "uuid_disk=${uuid_gpt_disk};name=primary,size=2032M,uuid=${uuid_gpt_rootfs_1};name=secondary,size=2032M,uuid=${uuid_gpt_rootfs_2}"

    boot 0 : mmc dev 0 1

    • If you place tiboot3.bin (r5), tispl.bin (a53), uboot.img(a53) in this HW partition
    • Notify ROM code that boot0 is where SPL code base is via: mmc partconf 0 1 1 1

    boot 1 : mmc dev 0 2

    • If you place tiboot3.bin (r5), tispl.bin (a53), uboot.img(a53) in this HW partition
    • Notify ROM code that boot0 is where SPL code base is via: mmc partconf 0 1 2 1

    RPM : mmc dev 0 1

    • eMMC HW partition that supplies secure access (keyed) 
    • Not worked with yet ;)

    Notes on U-boot commands values passed to erase/write are in hex values, in many cases these hex values are numbers of blocks not bytes. 

    root@am62xx-evm:~# ls -al /dev/mmc*
    brw-rw---- 1 root disk 179, 0 Apr 28 17:57 /dev/mmcblk0       (mmc dev 0 0)
    brw-rw---- 1 root disk 179, 32 Apr 28 17:57 /dev/mmcblk0boot0 (mmc dev 0 1) 
    brw-rw---- 1 root disk 179, 64 Apr 28 17:57 /dev/mmcblk0boot1 (mmc dev 0 2)
    brw-rw---- 1 root disk 179, 1 Apr 28 17:57 /dev/mmcblk0p1 (gpt partition 1 on dev 0 0)
    brw-rw---- 1 root disk 179, 2 Apr 28 17:57 /dev/mmcblk0p2 (gpt partition 2 on dev 0 0)
    crw------- 1 root root 240, 0 Apr 28 17:57 /dev/mmcblk0rpmb   (mmc dev 0 3)