eMMC
This guide will show how to view partition information, read from, and write to the eMMC featured on the phyCORE-AM62Ax SOM. To learn more information about the phyCORE-AM62Ax eMMC flash memory, please see section 6.1.3 in the Hardware Manual.
Note
In order to follow this guide your phyCORE-AM62Ax 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
root@phyboard-lyra-am62axx-2:~# fdisk -l Disk /dev/mmcblk0: 15 GB, 15913189376 bytes, 31080448 sectors 485632 cylinders, 4 heads, 16 sectors/track Units: sectors of 1 * 512 = 512 bytes Disk /dev/mmcblk0 doesn't contain a valid partition table 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 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 2121229 1857038 906M 83 Linux
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.
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.
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-lyra-am62axx-2:~# mkfs.ext4 /dev/mmcblk0p1 mke2fs 1.46.5 (30-Dec-2021) Discarding device blocks: done Creating filesystem with 3846907 4k blocks and 962880 inodes Filesystem UUID: 43970f19-5d01-4983-8fe3-b312bf720c08 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-lyra-am62axx-2:~# mount /dev/mmcblk0p1 /tmp/emmc [ 76.395810] EXT4-fs (mmcblk0p1): mounted filesystem with ordered data mode. Quota mode: none.
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-lyra-am62axx-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-lyra-am62axx-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-lyra-am62axx-2:~# md5sum /tmp/emmc/test.txt test-READ.txt e59ff97941044f85df5297e1c302d260 /tmp/emmc/test.txt e59ff97941044f85df5297e1c302d260 test-READ.txt