Project

General

Profile

Example SOM eMMC

Goal

The goal of this example is to demonstrate how to use the SOM eMMC storage. Note: not all SOMs include eMMC. Check the model number and datasheet to confirm that eMMC is available on your device.

This storage can be used for:

  • General purpose storage.
  • As a boot device

General Purpose Storage

Prerequisites

  • The Device needs to be divided into one or more partitions.
  • To use as a Linux file system, a file system must be created in the partition.
  • Run through Clearing_the_eMMC

Steps

Creating a partition

The eMMC device should appear as /dev/mmcblk0. In this example, we will create 1 large partition using the total available space on the eMMC and format as an ext3 journaled filesystem. From the command shell, run the following command to print the current partition table:

  • Optional: Run through Clearing_the_eMMC if you want to test flashing a clean eMMC
  • Boot to linux using a valid sd card image
  • Make the partition table
    root@mitysom-am62x:~# parted /dev/mmcblk0 mklabel gpt
    
  • Make the partiton
    root@mitysom-am62x:~# parted /dev/mmcblk0 mkpart primary ext4 0% 100%
    
  • Print the newly created partition
    root@mitysom-am62x:~# parted /dev/mmcblk0 print
    Model: MMC KC3032 (sd/mmc)
    Disk /dev/mmcblk0: 31.3GB
    Sector size (logical/physical): 512B/512B
    Partition Table: gpt
    Disk Flags:
    
    Number  Start   End     Size    File system  Name     Flags
     1      1049kB  31.3GB  31.3GB               primary
    
    

Mounting / locating the filesystem

If you just created / formatted the partition, reboot the unit. The base filesystem will auto mount a detected mmcblk0 partition on boot up.

To manually mount the partition run the following

root@mitysom-am62x:~# mkfs.ext4 /dev/mmcblk0p1
root@mitysom-am62x:~# mkdir /run/media/mmcblk0p1
root@mitysom-am62x:~# mount /dev/mmcblk0p1 /run/media/mmcblk0p1

To locate the mount point of the filesystem, run the command shown below:

root@mitysom-am62x:~# lsblk
NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
mtdblock0     31:0    0   512K  0 disk
mtdblock1     31:1    0     2M  0 disk
mtdblock2     31:2    0     4M  0 disk
mtdblock3     31:3    0   256K  0 disk
mtdblock4     31:4    0   256K  0 disk
mtdblock5     31:5    0 247.8M  0 disk
mtdblock6     31:6    0   256K  0 disk
mmcblk0      179:0    0  59.3G  0 disk
`-mmcblk0p1  179:1    0  59.3G  0 part /run/media/mmcblk0p1
mmcblk0boot0 179:32   0  31.5M  1 disk
mmcblk0boot1 179:64   0  31.5M  1 disk
mmcblk1      179:96   0  14.9G  0 disk
|-mmcblk1p1  179:97   0 132.6M  0 part /media/mmcblk1p1
`-mmcblk1p2  179:98   0   3.3G  0 part /

In the above listing, the mmcblk0p1 (first partition of mmcblk0, the eMMC device) is mounted on /run/media/mmcblk0p1.

Test Accessing the Device

To run a simple write and read test, run the following commands:

root@mitysom-am62x:~# dd if=/dev/urandom of=/run/media/mmcblk0p1/test.dat bs=1M count=100
100+0 records in
100+0 records out
104857600 bytes (105 MB, 100 MiB) copied, 1.54506 s, 67.9 MB/s
root@mitysom-am62x:~# dd if=/run/media/mmcblk0p1/test.dat of=/dev/null
204800+0 records in
204800+0 records out
104857600 bytes (105 MB, 100 MiB) copied, 0.517582 s, 203 MB/s
root@mitysom-am62x:~# rm /run/media/mmcblk0p1/test.dat

Boot Device

Boot EMMC

Conclusion

This example has demonstrated how to use the eMMC as a regular filesystem and how it could be used as a boot device.

Go to top
Add picture from clipboard (Maximum size: 1 GB)