eMMC
This guide will show how to view partition information, read from, and write to the eMMC featured on the phyCORE-i.MX8X SOM.
Note
In order to follow this guide your phyCORE-i.MX8X development kit must be booting from SD Card.
Viewing Available eMMC Partitions
You can verify the eMMC partitions by using the following command to list the partition information of known MMC devices. The ‘fdisk’ utility is a very powerful tool which you can use to manage the partitions on a particular flash device.
fdisk -l
Note
The eMMC corresponds to /dev/mmcblk0 and the SD Card is /dev/mmcblk1 in the output.
Disk /dev/mtdblock0: 64 MiB, 67108864 bytes, 131072 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/mmcblk0: 7.1 GiB, 7616856064 bytes, 14876672 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x539985d3 Device Boot Start End Sectors Size Id Type /dev/mmcblk0p1 * 16384 186775 170392 83.2M c W95 FAT32 (LBA) /dev/mmcblk0p2 196608 7480935 7284328 3.5G 83 Linux Disk /dev/mmcblk1: 14.86 GiB, 15931539456 bytes, 31116288 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x539985d3 Device Boot Start End Sectors Size Id Type /dev/mmcblk1p1 * 16384 186775 170392 83.2M c W95 FAT32 (LBA) /dev/mmcblk1p2 196608 7480935 7284328 3.5G 83 Linux /dev/mmcblk1p3 7481344 31115263 23633920 11.3G b W95 FAT32
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!
Mounting the eMMC
The flash devices are mounted by default and you can verify their mount points with the following command.
Note
The eMMC partitions are mounted as “mmcblk0p1” and “mmcblk0p2” respectively. The SD card partitions are mounted as “mmcblk1p*”.
mount | grep mmc/dev/mmcblk1p2 on / type ext4 (rw,relatime) /dev/mmcblk0p1 on /run/media/mmcblk0p1 type vfat (rw,relatime,gid=6,fmask=0007,dmask=0007,allow_utime=0020,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro) /dev/mmcblk0p2 on /run/media/mmcblk0p2 type ext4 (rw,relatime) /dev/mmcblk1p1 on /run/media/mmcblk1p1 type vfat (rw,relatime,gid=6,fmask=0007,dmask=0007,allow_utime=0020,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro) /dev/mmcblk1p3 on /run/media/mmcblk1p3 type vfat (rw,relatime,gid=6,fmask=0007,dmask=0007,allow_utime=0020,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
Check the contents of the eMMC’s partition by entering the following.
ls /run/media/mmcblk0p2
bin dev home lost+found mnt proc sbin tmp usr boot etc lib media opt run sys unit_tests var
Write to eMMC
Create a test file.
echo "Hello World" > ~/test.txt
Now you can use the copy (cp) or move (mv) commands to put this file on the eMMC.
cp ~/test.txt /run/media/mmcblk0p2
Verify that the file was written to the eMMC.
ls /run/media/mmcblk0p2
bin dev home lost+found mnt proc sbin test.txt unit_tests var boot etc lib media opt run sys tmp usr
Make sure the file was not corrupted during the transfer using md5sum.
md5sum ~/test.txt md5sum /run/media/mmcblk0p2/test.txt
e59ff97941044f85df5297e1c302d260 /home/root/test.txt e59ff97941044f85df5297e1c302d260 /run/media/mmcblk0p2/test.txt
Reading from eMMC
Use the copy (cp) or move (mv) command to put this file back onto your SD card.
cp /run/media/mmcblk0p2/test.txt ~/test-READ.txt
Make sure the file was not corrupted during the transfer using md5sum.
md5sum /run/media/mmcblk0p2/test.txt md5sum ~/test-READ.txt
e59ff97941044f85df5297e1c302d260 /run/media/mmcblk0p2/test.txt e59ff97941044f85df5297e1c302d260 /home/root/test-READ.txt
Booting from eMMC
To learn more about booting from eMMC, checkout the flashing eMMC guide.