eMMC

An embedded Multi-Media Card (eMMC) flash device is populated on the phyCORE-AM62x SOM as a programmable nonvolatile storage. The eMMC flash is connected to the MMC0 8-bit interface of the phyCORE-AM62x, which supports the JEDEC eMMC electrical standard v5.1. This guide will show how to view partition information, read from, and write to the eMMC featured on the phyCORE-AM62x SOM. To learn more information about the phyCORE-AM62x eMMC flash memory, please see section 6.1.3 in the Hardware Manual.

Note

In order to follow this guide your phyCORE-AM62x development kit must be booting from SD Card.

Viewing eMMC Partition Information

  • You can verify the eMMC partitions by using the following command to list the partition information of known MMC devices:

    Target (Linux)
     fdisk -l
    
    Expected Output
    Disk /dev/mmcblk1: 15 GB, 15931539456 bytes, 31116288 sectors
    243096 cylinders, 4 heads, 32 sectors/track
    Units: sectors of 1 * 512 = 512 bytes
    
    Device       Boot StartCHS    EndCHS        StartLBA     EndLBA    Sectors  Size Id Type
    /dev/mmcblk1p1 *  16,0,1      1023,3,32         2048     264191     262144  128M  c Win95 FAT32 (LBA)
    /dev/mmcblk1p2    1023,3,32   1023,3,32       264192    2330587    2066396 1008M 83 Linux
    Disk /dev/mmcblk0: 30 GB, 31826378752 bytes, 62160896 sectors
    485632 cylinders, 4 heads, 32 sectors/track
    Units: sectors of 1 * 512 = 512 bytes
    
    Device       Boot StartCHS    EndCHS        StartLBA     EndLBA    Sectors  Size Id Type
    /dev/mmcblk0p1 *  16,0,1      1023,3,32         2048     273063     271016  132M  c Win95 FAT32 (LBA)
    /dev/mmcblk0p2    1023,3,32   1023,3,32       274432    5799513    5525082 2697M 83 Linux
    Disk /dev/mmcblk0boot0: 31 MB, 33030144 bytes, 64512 sectors
    1008 cylinders, 4 heads, 16 sectors/track
    Units: sectors of 1 * 512 = 512 bytes
    
    Disk /dev/mmcblk0boot0 doesn't contain a valid partition table
    Disk /dev/mmcblk0boot1: 31 MB, 33030144 bytes, 64512 sectors
    1008 cylinders, 4 heads, 16 sectors/track
    Units: sectors of 1 * 512 = 512 bytes
    
    Disk /dev/mmcblk0boot1 doesn't contain a valid partition table
    
  • As can be seen in the above Example Output, this eMMC has already been formatted with a data partition, /dev/mmcblk0p1. To follow the rest of this guide, one data partition will be required.

  • If you did not see a /dev/mmcblk0p* partition refer to the following commands in order to create one:

    Warning

    Be careful using the “fdisk” command. If you aren’t careful, it can easily delete a partition of a flash device you didn’t intend to, and this could be your root filesystem! Just be sure to specify /dev/mmcblk0, not the SD card you are booting from.

Target (Linux)
    fdisk /dev/mmcblk0

    # Enter into fdisk interactive session:
    # Use the following commands in order to create a Linux partition.

    n                         # create new partition
    p                         # partition type
    1                         # partition number
    2048                      # first sector
    30777310                  # last sector
    t                         # change partition type
    83                        # linux filesystem
    w                         # write changes
  • Now reboot the system and you should see the eMMC device mounted automatically in the following steps.

    Target (Linux)
    reboot
    

Setup a Root Filesystem on the eMMC

In order to interact with the eMMC, the eMMC has to be partitioned and a rootfilesystem needs to be setup.

  • Create a ext4 type root filesystem

    Target (Linux)
    mkfs.ext4 /dev/mmcblk0p1
    
    Expected Output
    root@phyboard-lyra-am62xx-3:~# mkfs.ext4 /dev/mmcblk0p1
    mke2fs 1.45.7 (28-Jan-2021)
    /dev/mmcblk0p1 contains a vfat file system labelled 'boot'
    Proceed anyway? (y,N) y
    Discarding device blocks: done
    Creating filesystem with 135508 1k blocks and 34000 inodes
    Filesystem UUID: 2cb4ccd0-ea94-4c61-a547-bdd264c6d600
    Superblock backups stored on blocks:
         8193, 24577, 40961, 57345, 73729
    
    Allocating group tables: done
    Writing inode tables: done
    Creating journal (4096 blocks): done
    Writing superblocks and filesystem accounting information: done
    

Mounting the eMMC

  • Mount the eMMC to a volatile tmp folder

    Target (Linux)
     mkdir /tmp/emmc
     mount /dev/mmcblk0p1 /tmp/emmc
    
    Expected Output
     root@phyboard-lyra-am62xx-3:~# mount /dev/mmcblk0p1 /tmp/emmc
     [ 6120.746333] EXT4-fs (mmcblk0p1): mounted filesystem with ordered data mode. Opts: (null)
    

Writing to eMMC

  • Create a test file.

    Target (Linux)
     echo "Hello World" > ~/test.txt
    
  • Now you can use copy (cp) command to put this file on the eMMC.

    Target (Linux)
    cp test.txt /tmp/emmc
    
  • Verify that the file was written to the eMMC.

    Target (Linux)
     ls /tmp/emmc
    
    Expected Output
    root@phyboard-lyra-am62xx-3:~# ls /tmp/emmc
    lost+found/ test.txt
    
  • Make sure the file was not corrupted during the transfer using md5sum.

    Target (Linux)
    md5sum test.txt /tmp/emmc/test.txt
    
    Expected Output
    root@phyboard-lyra-am62xx-3:~# md5sum test.txt /tmp/emmc/test.txt
    e59ff97941044f85df5297e1c302d260  test.txt
    e59ff97941044f85df5297e1c302d260  /tmp/emmc/test.txt
    

Reading from the eMMC

  • Use the copy (cp) or move (mv) command to put this file back onto your SD card.

    Target (Linux)
    cp /tmp/emmc/test.txt ~/test-READ.txt
    
  • Make sure the file was not corrupted during the transfer using md5sum.

    Target (Linux)
    md5sum /tmp/emmc/test.txt test-READ.txt
    
    Expected Output
    root@phyboard-lyra-am62xx-3:~# md5sum /tmp/emmc/test.txt test-READ.txt
    e59ff97941044f85df5297e1c302d260  /tmp/emmc/test.txt
    e59ff97941044f85df5297e1c302d260  test-READ.txt