This guide will show you how to mount, read from, and write to the phyCORE-AM57x onboard eMMC

This guide assumes you are booting from an SD Card. If you are booting from eMMC you will first have to Create a Bootable SD Card and Change Boot Configurations.

Viewing available eMMC partition information

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.

  • The eMMC corresponds to /dev/mmcblk1 in Linux. You can verify the eMMC partitions by using the following command:

    Target (Linux)

    fdisk -l
    CODE
  • An example of the output of the above command is included below. Note that listing all disk partitions will also include the SD Card (/dev/mmcblk0). We can see that in this example the eMMC only has a single partition spanning the entirety of the drive. 

    Expected Output

    root@am57xx-phycore-kit:~# fdisk -l
    Disk /dev/mmcblk0: 7.4 GiB, 7948206080 bytes, 15523840 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: 0xaa79219e
    
    Device         Boot  Start      End  Sectors  Size Id Type
    /dev/mmcblk0p1 *      2048   145407   143360   70M  c W95 FAT32 (LBA)
    /dev/mmcblk0p2      145408 15491071 15345664  7.3G 83 Linux
    
    
    Disk /dev/mmcblk1: 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: 0xf33c7c01
    
    Device         Boot Start      End  Sectors  Size Id Type
    /dev/mmcblk1p1       2048 14876671 14874624  7.1G 83 Linux
    
    
    Disk /dev/mmcblk1boot1: 16 MiB, 16777216 bytes, 32768 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/mmcblk1boot0: 16 MiB, 16777216 bytes, 32768 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
    CODE

    If your eMMC was pre-flashed it will be normal to see 2 partitions listed for this device. You should proceed through the following steps by using the partition that is Type "Linux".

     Don't see a /dev/mmcblk1p# partition?

    If your eMMC doesn't have a partition (as signified by the "p#" at the end of the device name) then it will be necessary to create one. Use the following command to start an interactive fdisk session:

    Target (Linux)

    fdisk /dev/mmcblk1
    CODE

    Once you arrive at the fdisk prompt, you can enter "m" to get a list of available commands. Use the following commands in order to create a new partition spanning the entire drive (do not enter any of the comments as signified by "#"):

    n               #add a new partition
    p               #primary partition type
    1               #partition number
    <Enter>         #use the default start sector
    <Enter>         #use default end sector
    w               #write the changes
    CODE

    The following command, when run again, should now show a new partition within the /dev/mmcblk1 eMMC device. 

    Target (Linux)

    fdisk -l
    CODE

Mounting the eMMC

  • 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):

    mkdir temp
    mount /dev/mmcblk1p1 temp/
    CODE
  • 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!

    Expected Output (with pre-flashed eMMC)

    root@am57xx-phycore-kit:~# mount /dev/mmcblk1p2 temp/
    root@am57xx-phycore-kit:~# ls temp/
    bin         dev         home        lib         media       opt         run         srv         tmp         var
    boot        etc         include     lost+found  mnt         proc        sbin        sys         usr
    CODE
     Having Problems Mounting?

    If you get an error message when attempting to mount the eMMC partition, such as the one below: 

    Example Output

    root@am57xx-phycore-kit:~# mount /dev/mmcblk1p1 temp
    [ 5588.447437] EXT4-fs (mmcblk1p1): bad geometry: block count 524032 exceeds size of device (261888 blocks)
    mount: wrong fs type, bad option, bad superblock on /dev/mmcblk1p1,
           missing codepage or helper program, or other error
    
           In some cases useful info is found in syslog - try
           dmesg | tail or so.
    CODE

    A possible explanation would be that there is no file system on the partition. In order to create a EXT4 file system on the partition, run the following command: 

    Target (Linux)

    mkfs.ext4 /dev/mmcblk1p1
    CODE

Writing to the eMMC

  • You can write to the eMMC by using the copy or move commands just like in Linux.

    Target (Linux)

    echo "Hello World" > test.txt
    cp test.txt temp/
    CODE
  • An example of what the contents look like following the copy is provided below:

    Expected Output (without pre-flashed eMMC)

    root@am57xx-phycore-kit:~# ls temp/
    test.txt
    CODE

    Expected Output (with pre-flashed eMMC)

    root@am57xx-phycore-kit:~# mount /dev/mmcblk1p2 temp/
    root@am57xx-phycore-kit:~# ls temp/
    bin         dev         home        lib         media       opt         run         srv         test.txt	tmp
    var			boot        etc         include     lost+found  mnt         proc        sbin        sys         usr
    CODE