NOTICE: The Processors Wiki will End-of-Life in December of 2020. It is recommended to download any files or other content you may need that are hosted on The site is now set to read only.

AM335x Android eMMC booting

From Texas Instruments Wiki
Jump to: navigation, search

Content is no longer maintained and is being kept for reference only!


Content is no longer maintained and is being kept for reference only!

  • AM335xEVM has on board NAND and MMC interface. Either interface can be used for booting a system.
    • NAND boot is raw boot, as it reads raw data and manipulates it.
    • MMC boot is FAT boot, as it reads file from MMC sector and manipulates it.
  • MMC and NAND boot is already supported by android devkit releases available at
  • This wiki highlights on:
    • Using the available MMC interface on the AM335xEVM to simulate the eMMC functionality.
    • Adding eMMC support for fastboot.
    • Updating images to eMMC over fastboot.
    • Boot android from eMMC using RAW boot technique.
  • Wiki will also act as porting guide to port eMMC support on other platforms.

NoteNote: All patches described in this documents are validated on Texas Instruments' AM335xEVM board.

What is eMMC?

eMMC describes an architecture consisting of an embedded storage solution with MMC interface, flash memory and controller. In one line it is a flash/NAND over MMC interface.

The OMAP processor follows a 2 stage boot process. Details on the boot procedure can be found at the boot sequence page.

What is fastboot?

  • Fastboot is the method that android uses to flash the android built onto the target.
  • Fastboot protocol specification is found here.
  • Fastboot speeds up your development NOT the time it takes to boot.
  • Also, fastboot is used to update x-loader, bootloader, kernel, systemfs, userdata etc. by oem.

eMMC layout

In the discussion that follows, “sector” refers to a 512-byte disk sector, addressed by its Logical Block Address (LBA). Although the UEFI specs allow for disk sectors of other sizes, in practice 512 bytes is the norm.

Protective master boot record

The master boot record is the first sector on the hard drive (LBA 0). As mentioned above, legacy BIOSes will boot from this sector. To protect the GUID partitions on the drive from legacy OSes, the MBR partition table normally contains a single partition entry of type 0xEE, filling the entire drive.

GUID Partition Table (GPT)

The second sector (LBA 1) contains the primary GPT header, followed immediately by 16K (32 sectors) of the primary GUID Partition Entry Array. In conformance with the EFI spec, another copy of these data should be located at the end of the disk as well, with the secondary GPT header in the last accessible sector and the secondary GUID Partition Entry Array immediately preceding it. In current implementation secondary GPT is not included.

eMMC partition layout

  • GPT allows a large number of partitions on a drive. Choosing a partition scheme may vary across OEM vendor. Partition scheme described here is most chosen by OEM for mobile/hand-held device for a 1GB eMMC.
Partition Name Size Start LBA-End LBR Description
0 MBR & GPT 128KB 0x00000000-0x000000FF Master Boot Record and GUID Partition Table.
1 spl(MLO) 128KB 0x00000100-0x000001FF First stage bootloader.
2 bootloader(u-boot.bin) 512KB 0x00000200-0x000005FF Second stage bootloader.
3 misc 128KB 0x00000600-0x000006FF Reserved. This partition can be used for internal purpose.
4 - 128KB 0x00000700-0x000007FF Reserved.
5 recovery (zImage + recovery-ramdisk.img) 8MB 0x00000800-0x000047FF Recovery partition.
6 boot (boot.img = zImage + ramdisk.img) 8MB 0x00004800-0x000087FF Partition contains kernel + ramdisk images.
7 system (system.img) 256MB 0x00008800-0x000887FF Android file system.
8 cache (cache.img) 256MB 0x00088800-0x001087FF Partition will be used to store application cache.
9 userdata (userdata.img) 256MB 0x00108700-0x001887FF Partition contains userdata supplied by oem vendor like configuration files,utilities etc..
10 media Remaining 0x00188800-0x001FFFFF Partition contains media files, supplied by oem vendor.

Fastboot flowchart

Fastboot flowchart.png

Support for eMMC fastboot update and raw boot on AM335xEVM

Prepare the u-boot source code

  • Download source (if it is not downloaded).
/* download u-boot source, if not available */
$git clone git://
$cd u-boot

/* checkout mentioned commit id, branch:am335x-master-android-ics */
$git checkout 429a3860feea2711d3f1561ac1a431b849f45729

Selection of eMMC boot or NAND boot in u-boot

With the u-boot with the eMMC RAW boot patches integrated, has support for RAW booting from eMMC and flashing the images to eMMC through Fastboot for AM335x.

  • The code is enabled for SD/MMC boot by default. Also it can be used for NAND boot by loading the images to NAND using Fastboot.
  • For enabling eMMC booting with Fastboot, do the following modifications in "include/configs/am335x_evm.h":
   Enable "#define CONFIG_STORAGE_EMMC"
  • And for NAND boot with Fastboot, do the following modifications in "include/configs/am335x_evm.h":
   Disable "#define CONFIG_STORAGE_EMMC"

NoteNote: When eMMC boot mode is enabled, the normal SD/MMC FAT boot will not work. For getting the SD?MMC FAT boot user has to enable the configuration for NAND boot.

Selection of MMC0 or MMC1 as boot device for eMMC Raw boot on AM335xEVM

  • The AM335x General Purpose EVM has two SD/MMC connectors.
    • The SD/MMC0 connector is placed on the Base board and is available for all the 7 Profile modes.
    • The SD/MMC1 connector is placed on the General purpose Daughterboard and is available only on Profile 2.
  • The code adds two Macros to the board config file (include/configs/am335x_evm.h), named:
    • CONFIG_USE_MMC0: To enable the SD/MMC0 as the boot device.
    • CONFIG_USE_MMC1: To enable the SD/MMC1 as the boot device.
  • By default when the CONFIG_STORAGE_EMMC boot option is enabled the MMC0 device gets selected as the boot medium.
  • For eMMC booting support for SD/MMC0 or SD/MMC1 the boot mode switch should be set as:
 SW3 (8:1): 11100011 (ON | ON | ON | OFF | OFF | OFF | ON | ON)
 This will change the SYSBOOT[4:0] to 11100
  • Also configure the AM335xEVM to Profile 2 mode, in order to enable both the MMC slots.
  • All the binaries can be flashed to the device, with the eMMC card interfaced to the respective slot, as per the enabled Macro in the board config file, using fastboot.
  • After flashing those binaries, on reboot the device boots Android through the raw read from the eMMC.

u-boot build

  • Build u-boot (both MLO and u-boot.img)
$make CROSS_COMPILE=arm-eabi- distclean
$make CROSS_COMPILE=arm-eabi- am335x_evm_config
$make CROSS_COMPILE=arm-eabi-

The above commands will generate MLO and u-boot.img files.

  • Append eMMC raw header to MLO
    • Download eMMC raw header here (right click and "save link as").
$dd if=<eMMC_raw_header> of=./
$dd if=<MLO-Path>/MLO of=./ conv=notrunc oflag=append

Prepare the kernel source code

  • Download source (if it is not downloaded).
/* download kernel source, if not available */
$git clone git://
$cd kernel

/* checkout mentioned commit id, branch:rowboat-am335x-kernel-3.2 */
$git checkout 27694c7773a621dd8616dbbc741b5e978e36034a

kernel build

  • Build kernel
$make ARCH=arm CROSS_COMPILE=arm-eabi- distclean
$make ARCH=arm CROSS_COMPILE=arm-eabi- am335x_evm_android_defconfig
$make ARCH=arm CROSS_COMPILE=arm-eabi- uImage

Build android file system

  • Follow build steps mentioned here.

Prepare Images


$mkdir <YOUR_PATH>/images
$cd <YOUR_PATH>/images
$cp <ANDROID_SOURCE>/kernel/arch/arm/boot/zImage .
  • Update init.rc file and rebuild images
  • Add following lines to <ANDROID_SOURCE>/out/target/product/am335x3evm/root/init.rc
on fs
    mount ext4 /dev/block/mmcblk0p6 /system wait ro
    mount ext4 /dev/block/mmcblk0p8 /data wait noatime nosuid nodev
    mount ext4 /dev/block/mmcblk0p7 /cache wait noatime nosuid nodev
  • Rebuild images
$find out/target/product/am335xevm -name *.img -exec rm -f {} \;
$make TARGET_PRODUCT=am335xevm OMAPES=4.x
  • Prepare boot.img
$cd <YOUR_PATH>/images
$cp <ANDROID_SOURCE>/out/target/product/am335xevm/ramdisk.img .
$cp <ANDROID_SOURCE>/out/host/linux-x86/bin/mkbootimg .
$./mkbootimg --kernel zImage --ramdisk ramdisk.img --base 0x80000000 --cmdline "console=ttyO0,115200n8 androidboot.console=ttyO0 mem=256M root=/dev/ram0 rw initramfs=0x81000000,8M init=/init ip=off omap_vout.vid1_static_vrfb_alloc=y vram="2M" omapfb.vram=0:2M" -o boot.img


$cd <YOUR_PATH>/images
/* creating 192MB, it can be configure as per need */
$dd if=/dev/zero of=./system.img bs=1M count=192
$mkfs.ext4 system.img
$mkdir mnt-point
$sudo mount -t ext4 -o loop system.img mnt-point/
$cp -rfp <ANDROID_SOURCE>/out/target/product/am335xevm/system/* mnt-point/
$sudo umount mnt-point


$cd <YOUR_PATH>/images
/* creating 192MB, it can be configure as per need */
$dd if=/dev/zero of=./userdata.img bs=1M count=192
$mkfs.ext4 userdata.img
$sudo mount -t ext4 -o loop userdata.img mnt-point/
$cp -rfp <ANDROID_SOURCE>/out/target/product/am335xevm/data/* mnt-point/
$cp -rfp <ANDROID_SOURCE>/out/target/product/am335xevm/root/data/* mnt-point/
$sudo umount mnt-point


$cd <YOUR_PATH>/images
/* creating 192MB, it can be configure as per need */
$dd if=/dev/zero of=./cache.img bs=1M count=192
$mkfs.ext4 cache.img

Using Fastboot

Creating the GPT table on eMMC and flash raw images

  • Create MMC card for FAT boot mentioned here.
On Target
  1. Connect target to host machine using USB cable. Connect USB cable to OTG port on target.
  2. Boot target and enter any key at the U-boot prompt.
  3. At the u-boot prompt enter following command:
Fastboot entered...
On Host Machine
/* locate fastboot in android filesystem */
$cd <ANDROID_SOURCE>/out/host/linux-x86/bin/

/* search for fastboot devices */
$./fastboot devices

/* create GPT table on eMMC/SD card */
$./fastboot oem format

/* flash all partitions: ./fastboot flash <name> <binary> */

/* flash SPL */
$./fastboot flash spl <YOUR_PATH>/images/

/* flash bootloader */
$./fastboot flash bootloader <YOUR_PATH>/images/u-boot.img

/* flash boot image */
$./fastboot flash boot <YOUR_PATH>/images/boot.img

/* flash file system - system image */
$./fastboot flash system <YOUR_PATH>/images/system.img

/* flash user data */
$./fastboot flash userdata <YOUR_PATH>/images/userdata.img

/* flash cache partition */
$./fastboot flash cache <YOUR_PATH>/images/cache.img

/* reboot target */
$./fastboot reboot

NoteNote: Flashing of system.img, userdata.img, cache.img, each may take around 10-12 minutes.

How to change GPT(GUID Partition Table) configuration

  • GPT configuration has been defined in "<ANDROID_PATH>/u-boot/board/ti/am335x/mmc.c" as below. Kindly change as per need
static struct partition partitions[] = {
        { "-", 128 },
        { "spl", 128 },
        { "bootloader", 512 },
        /* "misc" partition is required for recovery */
        { "misc", 128 },
        { "-", 128 },
        { "recovery", 8*1024 },
        { "boot", 8*1024 },
        { "system", 256*1024 },
        { "cache", 256*1024 },
        { "userdata", 256*1024},
        { "media", 0 },
        { 0, 0 },

Technical Support and Product Updates

For further information or to report any problems, contact

For community support join
For IRC #rowboat on