Difference between revisions of "Loading Images onto eMMC Devices"

From wiki.emacinc.com
Jump to: navigation, search
m (Marked buggy. Added notes.)
Line 1: Line 1:
{{todo|Review|Michael Welling|project=oe 4,oe 5,mw,Review,md}}
+
{{todo|Buggy (12.31.13-13:15->MD-)|Michael Welling|project=oe 4,oe 5,mw,Buggy,md}}
  
 
== Background ==
 
== Background ==
 
Newer EMAC products have started using 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.  
 
Newer EMAC products have started using 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 has to be boot into Linux using an auxiliary method. Once U-Boot has been loaded into RAM, it can be used to load the target kernel using TFTP and boot into a file system stored in NFS. Once the board has boot into Linux the eMMC can be partitioned, 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 the programming the SoM-3517M, SoM-9X25 and IPAC-9X25.
+
U-Boot does not support writing to file systems in eMMC. To overcome this issue, the embedded target has to boot into Linux using an auxiliary method. Once U-Boot has been loaded into RAM, it can be used to load the target kernel using TFTP and boot into a file system stored in NFS. 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 and IPAC-9X25.
  
  
Line 17: Line 17:
  
 
== Creating partitions and formatting eMMC ==
 
== Creating partitions and formatting eMMC ==
 +
 +
'''*******************The first two lines belong together.  The description is rather abrupt. ********************'''
  
 
Once the Linux command prompt is reached the Linux utilities can be used to create and format partitions on the eMMC.
 
Once the Linux command prompt is reached the Linux utilities can be used to create and format partitions on the eMMC.
Line 56: Line 58:
 
  [  566.062896]  mmcblk0: p1
 
  [  566.062896]  mmcblk0: p1
  
For more information about <code>fdisk</code>
+
For more information about <code>fdisk</code>, see:
 
http://tldp.org/HOWTO/Partition/fdisk_partitioning.html
 
http://tldp.org/HOWTO/Partition/fdisk_partitioning.html
  
After creating the partitions they can formatted with the various <code>mkfs</code> utilities.
+
After creating the partitions, they can formatted with the various <code>mkfs</code> utilities.
 +
 
 +
'''***************** Why might they want one FS over another? *************************'''
  
 
Formatting a partition with EXT3:
 
Formatting a partition with EXT3:
Line 93: Line 97:
 
== Extracting filesystems to eMMC ==
 
== Extracting filesystems to eMMC ==
 
After formatting a partition correctly, the partition can be mounted and files can be loaded to the eMMC.
 
After formatting a partition correctly, the partition can be mounted and files can be loaded to the eMMC.
 +
 +
'''*************** What does this sequence of commands boil down to?  A plain-English explanation that: "The filesystem can be extracted from a tarball into the mounted, newly formatted partition.  Permissions are preserved... blah blah  Virtual filesystems... blah blah  The fstab file... blah"  can really help the reader understand the process. *********************'''
  
 
For example, here is the procedure for writing a root filesystem to the first partition of an eMMC card:
 
For example, here is the procedure for writing a root filesystem to the first partition of an eMMC card:
Line 108: Line 114:
  
 
The partitioning steps are as follows:
 
The partitioning steps are as follows:
 +
 +
'''*********** Strictly speaking, the p's in these steps aren't necessary, since they just print the table.  An explanation that the first partition will be 64MB, and choosing defaults for the second means it will fill the remaining available space, will help the reader. ******************'''
  
 
# Create 1st partition (n,p,1,default,+64M)
 
# Create 1st partition (n,p,1,default,+64M)
Line 116: Line 124:
  
 
==== Formatting the eMMC ====
 
==== Formatting the eMMC ====
 +
 +
''' ***************** Maybe a note that there are many options that can be selectively enabled/disabled for the ext3 filesystem, and that they can find more info about that in the manpage? ****************'''
  
 
  root@emac-oe:~# mkfs.ext3 /dev/mmcblk0p2
 
  root@emac-oe:~# mkfs.ext3 /dev/mmcblk0p2
Line 121: Line 131:
  
 
==== Adding Kernel and Bootloader ====
 
==== Adding Kernel and Bootloader ====
 +
 +
'''********** What is this uImage thing?  MLO?  Why do they go directly into the root of the filesystem?  Does the p1 mean partition 1, while p2 means partition 2?  So, is p1 a special boot partition instead of the root partition?  The poor reader is now lost... *****************'''
 +
 
  root@emac-oe:~# mkdir -p /mnt/card
 
  root@emac-oe:~# mkdir -p /mnt/card
 
  root@emac-oe:~# mount /dev/mmcblk0p1 /mnt/card
 
  root@emac-oe:~# mount /dev/mmcblk0p1 /mnt/card
Line 138: Line 151:
 
=== SoM-9X25M / IPAC-9X25 ===
 
=== SoM-9X25M / IPAC-9X25 ===
 
==== Partitioning the eMMC ====
 
==== Partitioning the eMMC ====
 +
 +
'''*********** The sensible reader skipped reading about the 3517, because the reader doesn't possess one, and went straight to this section.  Now the reader asks for the same information that was provided for the 3517. ****************'''
  
 
  root@emac-oe:~# fdisk /dev/mmcblk0
 
  root@emac-oe:~# fdisk /dev/mmcblk0

Revision as of 13:14, 31 December 2013

TODO: {{#todo:Buggy (12.31.13-13:15->MD-)|Michael Welling|oe 4,oe 5,mw,Buggy,md}}

Background

Newer EMAC products have started using 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 has to boot into Linux using an auxiliary method. Once U-Boot has been loaded into RAM, it can be used to load the target kernel using TFTP and boot into a file system stored in NFS. 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 and IPAC-9X25.




Creating partitions and formatting eMMC

*******************The first two lines belong together. The description is rather abrupt. ********************

Once the Linux command prompt is reached the Linux utilities can be used to create and format partitions on the eMMC.

The fdisk utility can be used to create partitions on the eMMC.

For example here is the procedure for creating a 128 MB primary partition:

root@emac-oe:~# fdisk /dev/mmcblk0

The number of cylinders for this disk is set to 57024.
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
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-57024, default 1): Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-57024, default 57024): +128M

Command (m for help): p

Disk /dev/mmcblk0: 1868 MB, 1868562432 bytes
4 heads, 16 sectors/track, 57024 cylinders
Units = cylinders of 64 * 512 = 32768 bytes

        Device Boot      Start         End      Blocks  Id System
/dev/mmcblk0p1               1        3907      125016  83 Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table
[  566.062896]  mmcblk0: p1

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.

***************** Why might they want one FS over another? *************************

Formatting a partition with EXT3:

root@emac-oe:~# mkfs.ext3 /dev/mmcblk0p1
mke2fs 1.41.14 (22-Dec-2010)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
31360 inodes, 125016 blocks
6250 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67371008
16 block groups
8192 blocks per group, 8192 fragments per group
1960 inodes per group
Superblock backups stored on blocks: 
        8193, 24577, 40961, 57345, 73729

Writing inode tables: done      
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 39 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.


Formatting a partition with FAT32:

root@emac-oe:~# mkdosfs -F 32 /dev/mmcblk0p1
mkdosfs 2.11 (12 Mar 2005)

Extracting filesystems to eMMC

After formatting a partition correctly, the partition can be mounted and files can be loaded to the eMMC.

*************** What does this sequence of commands boil down to? A plain-English explanation that: "The filesystem can be extracted from a tarball into the mounted, newly formatted partition. Permissions are preserved... blah blah Virtual filesystems... blah blah The fstab file... blah" can really help the reader understand the process. *********************

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
    ⋮

Quick Reference (by Target Type)

SoM-3517M

Partitioning the eMMC

root@emac-oe:~# fdisk /dev/mmcblk0

The partitioning steps are as follows:

*********** Strictly speaking, the p's in these steps aren't necessary, since they just print the table. An explanation that the first partition will be 64MB, and choosing defaults for the second means it will fill the remaining available space, will help the reader. ******************

  1. Create 1st partition (n,p,1,default,+64M)
  2. Create 2nd partition (n,p,2,default,default)
  3. Change 1st partition type to FAT32 (t,1,c)
  4. Make 1st partition ACTIVE (a,1)
  5. Write (w)

Formatting the eMMC

***************** Maybe a note that there are many options that can be selectively enabled/disabled for the ext3 filesystem, and that they can find more info about that in the manpage? ****************

root@emac-oe:~# mkfs.ext3 /dev/mmcblk0p2
root@emac-oe:~# mkdosfs -F 32 /dev/mmcblk0p1

Adding Kernel and Bootloader

********** What is this uImage thing? MLO? Why do they go directly into the root of the filesystem? Does the p1 mean partition 1, while p2 means partition 2? So, is p1 a special boot partition instead of the root partition? The poor reader is now lost... *****************

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

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

Partitioning the eMMC

*********** The sensible reader skipped reading about the 3517, because the reader doesn't possess one, and went straight to this section. Now the reader asks for the same information that was provided for the 3517. ****************

root@emac-oe:~# fdisk /dev/mmcblk0

The partitioning steps are as follows:

  1. Create 1st partition (n,p,1,default,default)
  2. Write (w)

Formatting the eMMC

root@emac-oe:~# mkfs.ext3 /dev/mmcblk0p1

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