Difference between revisions of "Loading Images onto eMMC Devices"
Line 19: | Line 19: | ||
* Installation of an NFS Server with Linux: [[Setting up an NFS File Server]] | * Installation of an NFS Server with Linux: [[Setting up an NFS File Server]] | ||
* Instruction for booting into NFS with U-Boot: [[Booting with an NFS Root Filesystem]] | * Instruction for booting into NFS with U-Boot: [[Booting with an NFS Root Filesystem]] | ||
+ | * Instruction for booting into a filesystem on a USB drive: [[Booting with a USB Root Filesystem]] | ||
* More information about MMC: http://en.wikipedia.org/wiki/MultiMediaCard | * More information about MMC: http://en.wikipedia.org/wiki/MultiMediaCard | ||
Latest revision as of 12:13, 15 April 2021
Contents
Background
Some EMAC products use eMMC in place of NAND flash. eMMC is an embedded MMC compliant memory that takes the form of an integrated circuit instead of a media card.
U-Boot does not support writing to file systems in eMMC. To overcome this issue, the embedded target needs to boot into an alternate media such as a network file system or USB flash drive. Once the board has booted into Linux, the eMMC can be partitioned and formatted, and the root file system can be extracted. The SoM-3517M requires a special FAT formatted partition that contains the bootloader and Linux kernel images. This article explains the general process of writing the eMMC from Linux as well as some specifics related to programming the SoM-3517M, SoM-9X25, SoM-A5D35/6, SoM-3354, SoM-iMX6M, SoM-iMX6UL and IPAC-9X25.
NOTE |
The procedures below require that you have a TFTP and NFS server setup on a host computer or a USB thumb drive created using Booting with a USB Root Filesystem. |
- Instructions on setting up a TFTP server: Installing TFTP server
- Installation of an NFS Server with Linux: Setting up an NFS File Server
- Instruction for booting into NFS with U-Boot: Booting with an NFS Root Filesystem
- Instruction for booting into a filesystem on a USB drive: Booting with a USB Root Filesystem
- More information about MMC: http://en.wikipedia.org/wiki/MultiMediaCard
Creating partitions and formatting eMMC
Once the Linux command prompt is reached, Linux utilities can be used to create and format partitions on the eMMC. By partitioning the eMMC, the partitions can be accessed individually and formatted differently as required. The fdisk
utility can be used to create these partitions on the eMMC.
For example here is the procedure for creating a 128 MB primary partition:
root
@
emac-oe
:
~
#
fdisk /dev/mmcblk0
root
@
emac-oe
:
~
#
For more information about fdisk
, see:
http://tldp.org/HOWTO/Partition/fdisk_partitioning.html
After creating the partitions, they can formatted with the various mkfs
utilities. The formatting used is dependent on how the partition is to be accessed. For eMMC root filesystems EMAC currently uses EXT4 (http://en.wikipedia.org/wiki/Ext3). Other formatting options are available (EXT2, EXT3, etc) and can be used. It should be noted that the kernel must be configured to support the chosen filesystem and the bootargs need to specify the correct type.
NOTE |
For additional information on configuring and compiling the Linux kernel see the following page: Building the Linux Kernel |
As described above, the bootargs
is used for signalling to the Linux kernel the location of the root filesystem partition, and its formatting. The root
parameter is used to specify the partition to use while the rootfstype
parameter is used to specify the formatting of the partition.
NOTE |
For more information about the bootargs variable see this page: U-Boot Overview |
Partitions accessed by processor boot ROM or U-Boot typically need to be formatted with FAT32 formatting. The SoM-3517M, for instance, requires a FAT32 formatted partition for the bootloader and kernel in order to boot properly from eMMC. For more specifics about the SoM-3517M, see the quick reference section below.
Formatting a partition with EXT4
root
@
emac-oe
:
~
#
mkfs.ext4 /dev/mmcblk0p1
root
@
emac-oe
:
~
#
Formatting a partition with FAT32
root
@
emac-oe
:
~
#
mkdosfs -F 32 /dev/mmcblk0p1
mkdosfs 2.11 (12 Mar 2005)
root
@
emac-oe
:
~
#
Extracting filesystems to eMMC
After formatting a partition correctly, the partition can be mounted and files can be loaded to the eMMC.
For example, here is the procedure for writing a root filesystem to the first partition of an eMMC card:
root
@
emac-oe
:
~
#
mkdir -p /mnt/card
root
@
emac-oe
:
~
#
mount /dev/mmcblk0p1 /mnt/card
root
@
emac-oe
:
~
#
cd /mnt/card
root
@
emac-oe
:
~
#
tar xzvf /images/emac-image.rootfs.tar.gz
⋮
In the above example the /mnt/card
directory is called the mount point. The mkdir -p
command creates the directory if it does not already exist. The mount
command attaches the specified partition to the directory. Any files written to the mounted directory will go to the partition on the eMMC. After the mount is complete, files can be extracted as shown using the tar
command.
It should be noted that the /etc/fstab
file can be used to specify mount points for partitions upon boot. See http://en.wikipedia.org/wiki/Fstab for additional information.
Quick Reference (by Target Type)
This section is used to provide specifics for programming eMMC on various targets.
For the partitioning sections, the information in the parenthesis denotes a keyboard input sequence. The (n,p,1,default,+64M) creates a new primary partition. Each input is followed a carriage return and the default is selected by pressing carriage return with no entry. See the expanded example in the above Creating partitions and formatting eMMC section for an idea of how the interface looks when commands are executed correctly.
SoM-3517M
Partitioning the eMMC
root
@
emac-oe
:
~
#
fdisk -H 255 -S 63 /dev/mmcblk0
The partitioning steps are as follows:
- Create 1st partition (n,p,1,default,+64M)
- Create 2nd partition (n,p,2,default,default)
- Change 1st partition type to FAT32 (t,1,c)
- Make 1st partition ACTIVE (a,1)
- Write (w)
Formatting the eMMC
root
@
emac-oe
:
~
#
mkfs.ext3 /dev/mmcblk0p2
root
@
emac-oe
:
~
#
mkdosfs -F 32 /dev/mmcblk0p1
The first command formats the second partition as ext3. The mkfs.ext3
command can take further configuration parameters. See the mkfs.ext3
man page for more information.
The second command formats the first partition as FAT32 for use with the AM3517's boot ROM. This is a requirement to boot from the eMMC.
Adding Kernel and Bootloader
root
@
emac-oe
:
~
#
mkdir -p /mnt/card
root
@
emac-oe
:
~
#
mount /dev/mmcblk0p1 /mnt/card
root
@
emac-oe
:
~
#
cd /images
root
@
emac-oe
:
images
#
cp MLO uImage u-boot.bin /mnt/card/
root
@
emac-oe
:
images
#
sync
root
@
emac-oe
:
images
#
umount /dev/mmcblk0p1
NOTE |
The first partition must be formatted FAT32 and the MLO binary must be in the first sector for the eMMC boot sequence to work properly. |
Extracting Root Filesystem
root
@
emac-oe
:
images
#
mount /dev/mmcblk0p2 /mnt/card
root
@
emac-oe
:
images
#
cd /mnt/card
root
@
emac-oe
:
/mnt/card
#
tar xzvf /emac-image.rootfs.tar.gz
root
@
emac-oe
:
/mnt/card
#
cd ..
root
@
emac-oe
:
/mnt
#
sync
root
@
emac-oe
:
/mnt
#
umount /dev/mmcblk0p2
SoM-9X25M / IPAC-9X25 / SoM-A5D35/6 / SoM-3354 / SoM-iMX6M / SoM-iMX6UL
Unlike the SoM-3517, these SoMs store U-Boot and the Linux kernel in a separate serial flash instead of the eMMC. Typically, two partitions are created. The first partition contains the complete filesystem and is mounted read-only while the second partition contains the /home directory and is mounted read-write.
Unmount partitions
root
@
emac-oe
:
~
#
umount /dev/mmcblk0p1
root
@
emac-oe
:
~
#
umount /dev/mmcblk0p2
Partitioning the eMMC
root
@
emac-oe
:
~
#
fdisk /dev/mmcblk0
NOTE |
For the SoM-9x25M revisions 7 and above, the eMMC block device is /dev/sdb |
The partitioning steps are as follows:
- Create 1st partition (n,p,1,default,+1G)
- Create 2nd partition (n,p,2,default,default)
- Write (w)
Formatting the eMMC
root
@
emac-oe
:
~
#
mkfs.ext4 /dev/mmcblk0p1
root
@
emac-oe
:
~
#
mkfs.ext4 /dev/mmcblk0p2
Extracting Root Filesystem
root
@
emac-oe
:
~
#
mkdir -p /mnt/card
root
@
emac-oe
:
~
#
mount /dev/mmcblk0p1 /mnt/card
root
@
emac-oe
:
~
#
cd /mnt/card
root
@
emac-oe
:
/mnt/card
#
tar xzvf /emac-image.rootfs.tar.gz
root
@
emac-oe
:
/mnt/card
#
cd ..
root
@
emac-oe
:
/mnt
#
sync
root
@
emac-oe
:
/mnt
#
umount /dev/mmcblk0p1