Using EMMC on OMAP4 devices

From OMAPpedia

Revision as of 07:21, 3 November 2011 by Gadiyar (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


[edit] Using eMMC on OMAP4

The eMMC partition table is as shown below

    Sector#    Size     Name
       256     128K     xloader
       512     256K     bootloader
      2048       8M     boot
     18432     512M     system
   1067008     256M     cache
   1591296     512M     userdata
   2639872    2191M     media

We use fastboot to flash all the partitions above

[edit] First time flashing on eMMC

If there is no u-boot on your board's eMMC, you will have to boot using SD card. Copy u-boot.bin and MLO files to an SD card (boot partition) and then boot the target board from this external SD card using the following SYSBOOT switch settings to boot from external SD card: 01011101

   For SDP4430 board: Switch S8-(1:8): OFF ON OFF ON ON ON OFF ON
   For Blaze board: Switch S2-(1:8): OFF ON OFF ON ON ON OFF ON

Note: S8-(6:1) corresponds to SYSBOOT[5:0] in TRM. (ON=0, OFF=1)

Once you boot the board, start fastboot server on the target (OMAP4 board).

   # fastboot

You should see a message

    Fastboot started

Now from the PC execute following commands to flash MLO and u-boot to eMMC

   ./fastboot oem format
   ./fastboot flash xloader ./MLO
   ./fastboot flash bootloader ./u-boot.bin

Now change the following SYSBOOT switch settings to boot out of EMMC: 11111101 whenever the board is restarted.

   For SDP4430 board: Switch S8-(1:8): ON ON ON ON ON ON OFF ON
   For Blaze board: Switch S2-(1:8): ON ON ON ON ON ON OFF ON

You can use the script from the repo or use the one shown below to to flash all these partitions. Note the binary names used for each partition.

   ./fastboot flash xloader ./MLO
   ./fastboot flash bootloader ./u-boot.bin
   ./fastboot reboot-bootloader
   sleep 5
   # < Note after running reboot-bootloader command you will see that the board reboots with the flashed u-boot >
   ./fastboot flash boot ./boot.img
   ./fastboot flash system ./system.img
   ./fastboot flash userdata ./data.img
   ./fastboot flash cache ./cache.img

[edit] Details on individual partitions

[edit] Boot.img details

The boot.img is generated using script (also shown below)

   ./mkbootimg --kernel zImage --ramdisk ramdisk.img --base 0x80000000 
               --cmdline "console=ttyO2,115200n8 mem=456M@0x80000000 mem=512M@0xA0000000 init=/init vram=10M omapfb.vram=0:4M androidboot.console=ttyO2" 
               --board omap4 -o boot.img

As you see in the line above, the kernel image used is zImage instead of uImage that we usually use.

TIP: If you have a uImage, you can create a zImage from it using the following command

    dd if=uImage bs=64 skip=1 of=zImage

The zImage is combined with ramdisk.img, which contains all the initial boot up programs (init, init.rc etc).

[edit] Opening and changing files in ramdisk.img for debugging

A ramdisk is basically a small filesystem containing the core files needed to initialize the system. It includes the critical init process, as well as init.rc, which is where you can set many system-wide properties. If you really want to know more about it, here is the documentation. Here's a list of files on a typical ramdisk:


Here are the steps to open, edit and create a new ramdisk.img

       # cp ramdisk.img ramdisk.img.bkup
       # mkdir tmp && cd tmp
       # gunzip -c ../ramdisk.img | cpio -i
       Modify the contents of file in tmp folder eg. init.rc
        # find . | cpio -o -H newc | gzip > ../ramdisk.img

Once the ramdisk.img is re-generated, you need to regenerate the boot.img using mkbootimg command shown above, and flash it for your init.rc changes to get reflected. Similarly, for updating the kernel you should regenerate boot.img with new zImage and flash it using fastboot command in earlier section.

TIP: If you want to just test your boot.img, without flashing you can use the command below

     ./fastboot boot ./boot.img

[edit] System.img details

System image is a sparsed ext4 loop mounted file system. To open (mount) system image use the commands below

      ./simg2img system.img system.img.raw
      mkdir tmp 
      sudo mount -t ext4 -o loop system.img.raw tmp/

After this, all your system image files are part of tmp folder.

Make any changes you need in the tmp folder. To re-create the parsed system image ( use the command below. This can be individually flashed using fastboot command

      sudo ./make_ext4fs -s -l 512M -a system tmp/
      sudo umount tmp
      rm -rf tmp

[edit] Userdata.img details

This partition contains user-installed applications and data, including customization data

Again this is a sparsed ext4 loop mounted filesystem. To extract the sparesed image, use the command below

   ./simg2img userdata.img userdata.img.raw
   ./mkdir tmp
   sudo mount -t ext4 -o loop userdata.img.raw tmp/

Now you can make any changed in the tmp folder. To re-create a new userdata.img, use the command below to generate, which can be flashed using fastboot.

   # The command below is the original one - it does not work from GB onwards. So I've commented it out
   # and added a version that does work. I'm leaving the original behind for reference.
   # sudo ./make_ext4fs -s -l 512M -a userdata tmp/
   sudo ./make_ext4fs -s -l 512M -a data tmp/
   sudo umount tmp
   rm -rf tmp

[edit] Cache.img details

This partition can be used to store temporary data. It is currently an empty ext4 image.

Commands to create this image

  mkdir tmp/
  sudo ./make_ext4fs -s -l 256M -a cache cache.img tmp/

[edit] Frequently used Commands for eMMC

To remount system partition in R/W mode for OMAP4

    adb remount                  - remounts the /system partition on the device read-write

To remount rootfs as R/W mode

   mount -o rw,remount -t auto /dev/block/mmcblk0p1 /

To add busybox run the commands below

   adb shell 'chmod 0755 /data/busybox/bin/* /data/busybox/sbin/*'
   adb shell '/data/busybox/bin/mount -oremount,rw /'
   adb shell '/data/busybox/bin/mount -oremount,rw /system'
   adb shell 'ln -s /data/busybox/bin /system/vendor/bin'
   adb shell 'ln -s /data/busybox/sbin /system/vendor/sbin'
Personal tools