.. _emmc-57: eMMC ==== An embedded Multi-Media Card (eMMC) flash device is populated on the phyCORE-AM57x SOM as a programmable nonvolatile storage. This guide will show you how to mount, read from, and write to the phyCORE-AM57x onboard eMMC. To learn more information about the phyCORE-AM57x eMMC flash memory, please see section 6.2 in the `Hardware Manual `_. .. note:: In order to follow this guide your phyCORE-AM62x development kit must be booting from SD Card. Viewing Available eMMC Partition Information -------------------------------------------- .. note:: Be careful with the fdisk command. You can accidentally delete the contents of other memory devices connected to the system so it is recommended to copy and paste the following commands. * You can verify the eMMC partitions by using the following command to list the partition information of known MMC devices: .. code-block:: none :caption: Target (Linux) fdisk -l .. code-block:: none :caption: Expected Output root@phycore-am57xx-1:~# fdisk -l Disk /dev/mmcblk1: 7264 MB, 7616856064 bytes, 14876672 sectors 922 cylinders, 256 heads, 63 sectors/track Units: sectors of 1 * 512 = 512 bytes Device Boot StartCHS EndCHS StartLBA EndLBA Sectors Size Id Type /dev/mmcblk1p1 0,0,2 1023,255,63 1 14876671 14876671 7263M ee EFI GPT Partition 1 has different physical/logical end: phys=(1023,255,63) logical=(922,105,41) Disk /dev/mmcblk0: 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/mmcblk0p1 * 16,0,1 1023,3,32 2048 133119 131072 64.0M c Win95 FAT32 (LBA) /dev/mmcblk0p2 1023,3,32 1023,3,32 133120 2036277 1903158 929M 83 Linux * As can be seen in the above Example Output, this eMMC has already been formatted with a data partition, /dev/mmcblk1p1. To follow the rest of this guide, one data partition will be required. * If you did not see a /dev/mmcblk1p* partition refer to the following commands in order to create one: .. code-block:: none :caption: 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 # first sector # 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. .. code-block:: none :caption: Target (Linux) reboot * Verify the eMMC partitions. .. code-block:: none :caption: Target (Linux) fdisk -l 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 .. code-block:: none :caption: Target (Linux) mkfs.ext4 /dev/mmcblk1p1 .. code-block:: none :caption: Expected Output root@phycore-am57xx-1:~# mkfs.ext4 /dev/mmcblk1p1 mke2fs 1.45.7 (28-Jan-2021) Discarding device blocks: done Creating filesystem with 1859576 4k blocks and 465120 inodes Filesystem UUID: 87f11df6-48ec-4ac9-bbe9-174ba7d1ff7a Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632 Allocating group tables: done Writing inode tables: done Creating journal (16384 blocks): done Writing superblocks and filesystem accounting information: done Mounting the eMMC ----------------- Typically, if the filesystem is already setup then it should mount automatically during boot at */run/media/*. These steps will help you manually mount the filesystem. * In order to read and write to the eMMC you will need to create a directory and then mount the partition you want to read from to that directory. Follow the steps below to mount partition 1 ("p1") of the eMMC (you should replace this with the "Linux" type partition if your eMMC was pre-flashed): .. code-block:: none :caption: Target (Linux) mkdir temp mount /dev/mmcblk1p1 temp/ * If you mounted a newly created partition it will likely be empty. If you had a pre-flashed eMMC then you will notice that the contents of the mounted directory look like the root directory! .. code-block:: none :caption: Target (Linux) ls temp Writing to the eMMC ------------------- * You can write to the eMMC by using the copy or move commands just like in Linux. .. code-block:: none :caption: Target (Linux) echo "Hello World" > test.txt cp test.txt temp/ * An example of what the contents look like following the copy is provided below: .. code-block:: none :caption: Example Output root@am57xx-phycore-kit:~# ls temp/ test.txt * Make sure the file was not corrupted during the transfer using md5sum. .. code-block:: none :caption: Target (Linux) md5sum test.txt ~/temp/test.txt .. code-block:: none :caption: Expected Output root@phycore-am57xx-1:~# md5sum test.txt ~/temp/test.txt e59ff97941044f85df5297e1c302d260 test.txt e59ff97941044f85df5297e1c302d260 /root/temp/test.txt Reading from the eMMC ---------------------- * Use the copy (cp) or move (mv) command to put this file back onto your SD card. .. code-block:: none :caption: Target (Linux) cp ~/temp/test.txt ~/test-READ.txt * Make sure the file was not corrupted during the transfer using md5sum. .. code-block:: none :caption: Target (Linux) md5sum ~/temp/test.txt test-READ.txt .. code-block:: none :caption: Expected Output root@phycore-am57xx-1:~# md5sum ~/temp/test.txt test-READ.txt e59ff97941044f85df5297e1c302d260 /root/temp/test.txt e59ff97941044f85df5297e1c302d260 test-READ.txt