eMMC
An embedded Multi-Media Card (eMMC) flash device is populated on the phyCORE-AM64x SOM as a programmable nonvolatile storage. The eMMC flash is connected to the MMC0 8-bit interface of the phyCORE-AM64x 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-AM64x SOM. To learn more information about the phyCORE-AM64x eMMC flash memory, please see section 6.1.3 in the Hardware Manual.
Note
In order to follow this guide your phyCORE-AM64x 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:
fdisk -l
The eMMC corresponds to /dev/mmcblk0 and the SD Card is /dev/mmcblk1 in the output.
root@phyboard-electra-am64xx-2:~# fdisk -l
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 1110165 845974 413M 83 Linux
Disk /dev/mmcblk0: 15 GB, 15913189376 bytes, 31080448 sectors
485632 cylinders, 4 heads, 16 sectors/track
Units: sectors of 1 * 512 = 512 bytes
Device Boot StartCHS EndCHS StartLBA EndLBA Sectors Size Id Type
/dev/mmcblk0p1 0,1,1 1023,3,16 16 31080447 31080432 14.8G 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 not been formatted with a data partition, /dev/mmcblk0. 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.
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, you will see the eMMC device automatically mounted in the next steps of this guide.
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
mkfs.ext4 /dev/mmcblk0p1
root@phyboard-electra-am64xx-2:~# mkfs.ext4 /dev/mmcblk0p1 mke2fs 1.45.7 (28-Jan-2021) Discarding device blocks: done Creating filesystem with 3846907 4k blocks and 962880 inodes Filesystem UUID: cd37c3b9-854c-4f48-8643-1e58443b0870 Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208 Allocating group tables: done Writing inode tables: done Creating journal (16384 blocks): done Writing superblocks and filesystem accounting information: done
Mounting the eMMC
Mount the eMMC to a volatile tmp folder
mkdir /tmp/emmc
mount /dev/mmcblk0p1 /tmp/emmc
root@phyboard-electra-am64xx-2:~# mount /dev/mmcblk0p1 /tmp/emmc
[ 151.633498] EXT4-fs (mmcblk0p1): mounted filesystem with ordered data mode. Opts: (null)
Writing to eMMC
Create a test file.
echo "Hello World" > ~/test.txt
Now you can use copy (cp) command to put this file on the eMMC.
cp test.txt /tmp/emmc
Verify that the file was written to the eMMC.
ls /tmp/emmc
root@phyboard-electra-am64xx-2:~# ls /tmp/emmc
lost+found/ test.txt
Make sure the file was not corrupted during the transfer using md5sum.
md5sum test.txt /tmp/emmc/test.txt
root@phyboard-electra-am64xx-2:~# 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.
cp /tmp/emmc/test.txt ~/test-READ.txt
Make sure the file was not corrupted during the transfer using md5sum.
md5sum /tmp/emmc/test.txt test-READ.txt
root@phyboard-electra-am64xx-2:~# md5sum /tmp/emmc/test.txt testREAD.txt
e59ff97941044f85d5297e1c302d260 /tmp/emmc/test.txt
e59ff97941044f85df5297e1c302d260 testREAD.txt