- Table of contents
- Example SOM eMMC
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.
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:
root@mitysom-am62x:~# fdisk -l /dev/mmcblk0 Disk /dev/mmcblk0: 59.29 GiB, 63652757504 bytes, 124321792 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: gpt Disk identifier: F097536D-8E87-46CF-B35A-5A176F2AE3DB Device Start End Sectors Size Type /dev/mmcblk0p1 34 124321758 124321725 59.3G Microsoft basic data
In this example, there is already a partition setup on the device. If there is not, you can create a partition by following the example below:
root@mitysom-am62x:~# fdisk /dev/mmcblk0 Device contains neither a valid DOS partition table, nor Sun, SGI, OSF or GPT disklabel Building a new DOS disklabel. Changes will remain in memory only, until you decide to write them. After that the previous content won't be recoverable. The number of cylinders for this disk is set to 1942528. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Command (m for help): n Partition type p primary partition (1-4) e extended p Partition number (1-4): 1 First sector (16-124321791, default 16): 1024 Last sector or +size{,K,M,G,T} (1024-124321791, default 124321791):. Using default value 124321791 Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table
Formatting a partition¶
To format the partition with an ext3 filesystem (linux compatible with a journal), run the following command.
root@mitysom-am62x:~# mke2fs -j /dev/mmcblk0p1
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 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¶
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