How to program eMMC

From liteSOM Wiki
Jump to: navigation, search

Preconditions

To program liteSOM eMMC memory you need:

  1. uSD card to boot liteSOM,
  2. USB flash where you can store firmware for eMMC.

In addition on uSD please install MMC_UTILS package. You can install this package via Buildroot menu

-> Target packages
  -> Filesystem and flash utilities
    -> mmc-utils

To the USB flash please copy following - generated by the Buildroot - files (all of them you can find output/images directory):

  • SPL,
  • u-boot.img,
  • boot.vfat,
  • rootfs.ext2.

Program procedure

1. Please boot liteboard from uSD card,

2. insert and mount USB flash, for example

# mkdir /tmp/fw
# mount /dev/sda1 /tmp/fw/

3. enable write access to the eMMC boot partition

# echo 0 > /sys/block/mmcblk1boot0/force_ro

4. install bootloader software

# dd if=/tmp/fw/SPL of=/dev/mmcblk1boot0 bs=512 seek=2
62+0 records in
62+0 records out
# dd if=/tmp/fw/u-boot.img of=/dev/mmcblk1boot0 bs=512 seek=138
487+1 records in
487+1 records out

5. disable write access to the eMMC boot partition

# echo 1 > /sys/block/mmcblk1boot0/force_ro

6. configure partitions on eMMC memory like presented below

# fdisk /dev/mmcblk1

The number of cylinders for this disk is set to 58624.
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): p

Disk /dev/mmcblk1: 1920 MB, 1920991232 bytes
4 heads, 16 sectors/track, 58624 cylinders
Units = cylinders of 64 * 512 = 32768 bytes

        Device Boot      Start         End      Blocks  Id System
/dev/mmcblk1p1               1         611       19544   c Win95 FAT32 (LBA)
/dev/mmcblk1p2             612        8425      250048  83 Linux

To create partitions like above you can use fdisk and proceed following steps:

  1. add a new partition
    1. type of partition: primary partition
    2. partition number: 1
    3. first cylinder: 1
    4. last cylinder: +20M (partition size 20MB)
  2. add a new partition
    1. type of partition: primary partition
    2. partition number: 2
    3. first cylinder: 612 (default value)
    4. last cylinder: +256M (partition size 256MB)
  3. change a partition's system id
    1. partition number: 2
    2. hex code: c (Win95 FAT32 (LBA))
  4. write table to disk and exit

7. install Linux and device tree

# dd if=/tmp/fw/boot.vfat  of=/dev/mmcblk1p1
32768+0 records in
32768+0 records out

8. install rootfs

# dd if=/tmp/fw/rootfs.ext2  of=/dev/mmcblk1p2
33120+0 records in
33120+0 records out

9. enable boot partition

# mmc bootpart enable 1 1 /dev/mmcblk1

10. synchronize (flush) all internal caches

# sync

11. configure BOOT configuration to boot from eMMC and reboot liteboard.