i.MX Android R10 User Guide

Last Update: Jan.29th, 2011

1. Setup
    1.1 PC Setup
    1.2 Unpack i.MX Android Release Package
    1.3 Run Android with Prebuilt Image

2. Build Android for i.MX
    2.1 Get Android Source Code
    2.2 Patch Code for i.MX
    2.3 Build Uboot Image
    2.4 Build Kernel Image
    2.5 Build Android Image

3. Download Images and Bootup
    3.1 Board Dip Switch Setting
        3.1.1 USB serial download settings
        3.1.2 Boot up settings
    3.2 System on MMC/SD and eMMC
        3.2.1 Storage Partitions
        3.2.2 Download with MFG Tool
        3.2.3 Download with dd utility 
        3.2.4 Download with fastboot
        3.2.6 Boot from MMC/SD and eMMC
    3.3 System on NFS
        3.3.1 Setup the NFS root
        3.3.2 Boot from TFTP and NFS
    3.4 Boot up configurations

4. Run
    4.1 Multimedia
        4.1.1 Music Play
        4.1.2 Video Play
        4.1.3 Streaming Play
        4.1.4 Camera
        4.1.5 Sound Recording
        4.1.6 Camcorder
        4.1.7 Usb Video Camera
    4.2 Storage
        4.2.1 Usb Mass Storage
        4.2.2 Multi-Storage
    4.3 Connection
        4.3.1 Wifi
        4.3.2 3G Modem
        4.3.3 Enable AR6003/AR6102 Wifi Card
    4.4 Display
        4.4.1 TVout with Video Only
        4.4.2 TVout with Video and UI
        4.4.3 Dual-Display
        4.4.4 Support 24bpp Pixel Format
    4.5 Applications & Development
        4.5.1 Key Maps
        4.5.2 Volume
        4.5.3 Brightness
        4.5.4 Screen Timeout
        4.5.5 ADB
        4.5.6 App to SD
        4.5.7 Recovery
        4.5.8 3D Demo
        4.5.9 Fastboot
        4.5.10 2G/2G

5. FAQ
    5.1 Why did the code fail to download from Google when repo init?
    5.2 Why I can't access the internet with browser using ethernet?
    5.3 Can I access Android shell using ethernet instead of a serial port?
    5.4 How do I change Android boot logo?
    5.5 How to use wake_lock to control specific devices? 

1. Setup

1.1 PC Setup

To build the Android source files, you will need to use Linux PC. It's suggested that you use the most recent version of Ubuntu which is the mostly tested OS for an Android build.
After installing Linux PC, you need check whether you have all necessary packages installed for an Android build. Refer to "Setting up your machine" on the Android web site http://source.android.com/source/download.html

1.2 Unpack i.MX Android Release Package

After you setup a Linux PC, unpack the FSL i.MX Android Release Package using the following commands: 
    $ cd /opt (or any other directory you like)
    $ tar xzvf imx-android-r10.tar.gz
    $ cd imx-android-r10/code
    $ tar xzvf r10.tar.gz

1.3 Run Android with Prebuilt Image

To try Android before building any code, use the prebuilt images under image/ and directly go to "Download Images and Bootup"。

The prebuilt image is under each platform directory that uncompressed from the release package:

i.MX51 BBG board (i.MX53 SMD  board have the same directory structure)

System images for MMC/SD and eMMC

System images for TFTP/NFS


2. Build Android for i.MX

2.1 Get Android Source Code (Android/Kernel/uboot)

the Android source code is maintained as more than 100 gits in an Android repository (Visit GitWeb from browser).
To get the Android source code from Google repo, follow the steps: 

    Assume you had unzipped i.MX Android release package to /opt/imx-android-r10/.
    $ cd ~
    $ mkdir myandroid
    $ cd myandroid
    $ curl http://android.git.kernel.org/repo > ./repo
    $ chmod a+x ./repo
    $ ./repo init -u git://android.git.kernel.org/platform/manifest.git -b gingerbread
    $ cp /opt/imx-android-r10/code/r10/default.xml .repo/manifests/default.xml 
      (To avoid loading unnecessary gits from Google repo, meanwhile load some gits from Google repo which is not included in default manifest)
    $ ./repo sync
Get a clean kernel source code from kernel.org, and checkout the tag of 2.6.35.3

    $ cd myandroid
    $ git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-2.6.35.y.git kernel_imx
    $ cd kernel_imx
    $ git checkout v2.6.35.3

If you use uboot as your bootloader, then you need get a clean source code base from the original git:

    $ cd myandroid/bootable/bootloader
    $ git clone git://git.denx.de/u-boot.git uboot-imx
      

2.2 Patch Code for i.MX 

Apply all i.MX Android patches using following steps:

    Assume you had unzipped i.MX Android release package to /opt/imx-android-r10/.
    $ cd ~/myandroid
    $ . /opt/imx-android-r10/code/r10/and_patch.sh
    $ help
    Now you should see "c_patch" function is available for you
 
    $ c_patch /opt/imx-android-r10/code/r10 imx_r10
 
    Here "/opt/imx-android-r10/code/r10" is the location of the patches (i.e. directory created when you unzip release package)
    "imx_r10" is the branch which will be created automatically for you to hold all patches (only in those existing Google gits). 
    You can choose any branch name you like instead of "imx_r10".
    
    If everything is OK, "c_patch" will generate the following output to indicate successful patch:
    **************************************************************
    Success: Now you can build android code for FSL i.MX platform
    **************************************************************
Note: The patch script (and_patch.sh) utalizes some basic utilities like awk/sed. If they are not available on your LinuxPC, install them in advance.

2.3 Build Uboot Images

    $ cd ~/myandroid/bootable/bootloader/uboot-imx
    
    $ export ARCH=arm
    $ export CROSS_COMPILE=~/myandroid/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi-

    Command to build for i.MX51 BBG3 board is:
    $ make distclean
    $ make mx51_bbg_android_config
    $ make

    Command to build for i.MX53 SMD board is:
    $ make distclean
    $ make mx53_
smd_android_config
    $ make



    "u-boot.bin" is generated if you have a successful build.

    The above u-boot.bin has 1024KB padding at the head of file,for example first executable instruction is at the offset 1KB. If you want to generate a no-padding image, you need do below dd command in host.
    $ sudo dd if=./u-boot.bin of=./u-boot-no-padding.bin bs=1024 skip=1; sync
     
    Usually this no-padding uboot image is used in the SD card, for example, program this no-padding uboot image into 1KB offset of SD card so that we do not overwrite the MBR (including partition table) within first 512B on the SD card.

    
Note: Any image which must be loaded by uboot must have an unique image head, for example, some data must be added at the head of loaded image to tell uboot about the image (for example, it's a kernel, or ramfs, etc) and how to load the image (for example, load/execute address).
    Therefor before you can load any image into RAM by uboot, you need a tool to add this information to generate a new image which can be recognized by uboot. Fortunately, this tool is delivered together with uboot. After you make uboot using the above steps, you can find the tool (mkimage) under tools/.
    Later the document will describe how to use mkimage to generate the image (for example kernel image, ramfs image) to be loaded by uboot. 

2.4 Build Kernel Image

Kernel image will be built out when building the android root file system. So you can jump to next section if you do not take care how to build kernel image.
To run Android using NFS or from SD, build the kernel with the default configuration now as follows:

      Assume you had already built uboot. mkimage was generated under myandroid/bootable/bootloader/uboot-imx/tools/ and it's in your PATH
    $ export PATH=~/myandroid/bootable/bootloader/uboot-imx/tools:$PATH
    $ cd ~/myandroid/kernel_imx

    $ echo $ARCH && echo $CROSS_COMPILE
    Make sure you have those 2 environment variables set
    If the two variables have not set, please set the as:
    $ export ARCH=arm
    $ export CROSS_COMPILE=~/myandroid/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi-

  

      $ make imx5_android_defconfig
    Generate ".config" according to default config file under arch/arm/configs.

    $ make uImage

With a successful build in either of the above case, the generated kernel image is ~/myandroid/kernel_imx/arch/arm/boot/uImage.

Generate uImage to be loaded by u-boot

To generate uImage from the built zImage, generate a uImage based on the above zImage as follows:

    $ cd ~/myandroid/kernel_imx/arch/arm/boot

For i.MX51 BBG Board:
    $ ~/myandroid/bootable/bootloader/uboot-imx/tools/mkimage -A arm -O linux -T kernel -C none -a 0x90008000 -e 0x90008000 -n "Android Linux Kernel" -d ./zImage ./uImage

For i.MX53 SMD Board:
    $ ~/myandroid/bootable/bootloader/uboot-imx/tools/mkimage -A arm -O linux -T kernel -C none -a 0x70008000 -e 0x70008000 -n "Android Linux Kernel" -d ./zImage ./uImage

    During boot, when uboot try to load above "uImage", it will know to load it (without image head added by mkimage tool) into 0x90008000 or 0x70008000 (specified by "-a"), and then jump to 0x90008000 or 0x70008000 (specified by "-e") to execute it. "-C none" means no compression when generating "uImage". This is because the original zImage is already a compressed one.


2.5 Build Android Image 

After applying all i.MX patches, build the kernel and Android image using following steps:

    $ cd ~/myandroid
    $ export CROSS_COMPILE=~/myandroid/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi- 

    Command to build for i.MX51 BBG3 board is:
    $ make PRODUCT-imx51_bbg-eng 2>&1 | tee build_imx51_bbg_android.log

    "imx51_BBG" is the product names (see ~/myandroid/device/fsl/product)

Command to build for i.MX53 smd board is:   
$ make PRODUCT-imx53_
smd-eng 2>&1 | tee build_imx53_smd_android.log

    "imx53_smd" is the product names (see ~/myandroid/device/fsl/product)

 
    After build, check build_*_android.log to make sure no build error.

For i.MX51 BBG build, the following outputs are generated as default under myandroid/out/target/product/imx51_BBG: 
or 

For i.MX53 SMD build, the following outputs are generated as default under myandroid/out/target/product/imx53_smd :

root/ : root file system (including init, init.rc, etc). Mounted at /
system/:  Android system binary/libraries. Mounted at /system

data/: Android data area. Mounted at /data
Above three folders can be used to create your Android file system for NFS mounting, i.e. root/ > /, system/ > /system, data/ > /data
recovery/: root file system when booting in "recovery" mode. Not directly used.
ramdisk.img: Ramdisk image generated from "root/". Not directly used.
system.img: EXT4 image generated from "system/". Can be programmed to "SYSTEM" partition on SD card with "dd"
userdata.img: EXT4 image generated from "data/".
recovery.img: EXT4 image generated from "recovery/". Can be programmed to "RECOVERY" partition on SD card with "dd" 

Generate uRamdisk to be loaded by uboot
The following steps generate a RAMDISK image recognized by uboot:
     Assume you had already built uboot. mkimage was generated under myandroid/bootable/bootloader/uboot-imx/tools/

    $ cd myandroid/out/target/product/imx51_bbg
    $ ~/myandroid/bootable/bootloader/uboot-imx/tools/mkimage -A arm -O linux -T ramdisk -C none -a 0x90308000 -n "Android Root Filesystem" -d ./ramdisk.img ./uramdisk.img


or
    $ cd myandroid/out/target/product/imx53_smd
    $ ~/myandroid/bootable/bootloader/uboot-imx/tools/mkimage
-A arm -O linux -T ramdisk -C none -a 0x70308000 -n "Android Root Filesystem" -d ./ramdisk.img ./uramdisk.img



3. Download images and Boot-up system

To boot up the android system, you must first download the bootloader, kernel, ramdisk and rootfs images into the main storage device (MMC/SD or eMMC) or unpack the NFS root filesystem into the NFS server root.
This section describes how to run the system on main storage device or NFS with several methods to download the images into storage device.

3.1 Board Dip Switch Setting

First of all, introduce the hardware board's Dip Switch settings. You may use these dips before download and boot system.
About the details dip switches, you can refer to "uboot_mx51.pdf", "i.MX53_EVK_Linux_BSP_UserGuide.pdf" and "Codex_CPU_Boot_Mode.xls"

3.1.1 USB serial download settings

You may use this USB serial download settings before using the MFG tool to download image.

i.mx51 BBG

Switch
S-1
S-2
S-3
S-4
S-5
S-6
S-7
S-8
S-9
S-10
S1 OFF
OFF
OFF
OFF
OFF
OFF
OFF
OFF
OFF
ON

i.mx53 SMD

Switch
D1
D2
D3
D4
D5
D6
D7
D8
SW26
OFF
OFF
OFF
OFF
OFF
OFF
OFF
OFF
SW28
OFF
OFF
ON
ON
OFF
OFF
OFF
OFF

i.mx50 RD

Switch
D1
D2
D3
D4
D5
D6
D7
D8
SW5
OFF
OFF
OFF
OFF
OFF
OFF
OFF
OFF
SW4
OFF
OFF
OFF
OFF
OFF
OFF
OFF
OFF
SW3
OFF
OFF
OFF
OFF
OFF
OFF
OFF
OFF

3.1.2 Boot up settings

i.mx51 BBG MMC/SD Slot1 Boot


Switch
S-1
S-2
S-3
S-4
S-5
S-6
S-7
S-8
S-9
S-10
S1 OFF
OFF
OFF
OFF
OFF
OFF
ON
ON
OFF
OFF

i.mx53 SMD eMMC(SD slot3) Boot


Switch
D1
D2
D3
D4
D5
D6
D7
D8
SW26
OFF
ON
OFF
OFF
ON
ON
ON
OFF
SW28
OFF
OFF
OFF
OFF
OFF
OFF
OFF
ON

i.mx53 SMD MMC/SD (slot1) Boot


Switch
D1
D2
D3
D4
D5
D6
D7
D8
SW26
OFF
OFF
OFF
OFF
OFF
OFF
ON
OFF
SW28
OFF
OFF
OFF
OFF
OFF
OFF
OFF
OFF

i.mx50 RD eSDHC1-SD-4bit; others boot mode, refer to "Codex_CPU_Boot_Mode.xls"


Switch
D1
D2
D3
D4
D5
D6
D7
D8
SW5
OFF
ON
OFF
OFF
ON
OFF
OFF
OFF
SW4
OFF
OFF
OFF
OFF
OFF
OFF
OFF
OFF
SW3
OFF
OFF
OFF
OFF
OFF
OFF
OFF
OFF

3.2 System on MMC/SD and eMMC

Android support running on the MMC/SD card, or on board eMMC device.
Currently, i.MX51 BBG and i.MX50 RD only support MMC/SD system, but i.MX53 SMD also support eMMC device.

We need images below to create an android system on MMC/SD or eMMC device:
All the images you can get from the release package, or built out by yourself as 2.5 section described.

3.2.1 Storage Partitions

The layout of the MMC/SD card or eMMC for Android system is showed in below.

The SYSTEM partition is used to put the built out android system image. The DATA is used to put application's unpacked codes/data, system configurations database, etc. In normal boot mode, the root file system is mounted from uRamdisk. In recovery mode, the root file system is mounted from the REOVERY partition.

Partition Type/Index Name Start Offset Size File System Content
N/A BOOT 0 10MB N/A bootloader/kernel/uramdisk images
Primary 1 MEDIA 11MB User Defined VFAT. Mount as /sdcards Media file storage
Primary 2 SYSTEM follow MEDIA >= 200MB EXT4. Mount as /system (with read only) Android system bin/libs (system.img)
Logic 5 (Extended 3) DATA follow SYSTEM > 200MB EXT4. Mount as /data Android data (e.g. installed app)
Logic 6 (Extended 3) CACHE follow DATA > 10MB EXT4. Mount as /cache Android cache
Primary 4 RECOVERY follow CACHE > 20MB EXT4. Mount as / in recovery mode Root file system for recovery mode (recovery.img)

To create these partitions, you can simply use MFG tool described in next section, or use fdisk utility on Linux PC.
After creating the partitions by fdisk, please format each file systems by the following commands:
    
    # mkfs.vfat /dev/sdx1
    # mkfs.ext4 /dev/sdx2 -O ^extent -L system
    # mkfs.ext4 /dev/sdx4 -O ^extent -L recovery
    # mkfs.ext4 /dev/sdx5 -O ^extent -L data
    # mkfs.ext4 /dev/sdx6 -O ^extent -L cache


NOTE: /dev/sdxN, the x is the disk index from 'a' to 'z', that may be different on each Linux PC.

3.2.2 Download Images with MFG Tool

Before using the MFG tool, please setup the board's Boot Dip switch settings to USB serial download mode.
       Using the i.MX53 SMD as a example:
       Copy "u-boot.bin" "uImage" to  Profiles/MX53 Linux Updata/OS Firmware/files, and rename u-boot.bin to u-boot-mx53-smd.bin
       Copy "system.img", "recovery.img", "uramdisk.img" to  Profiles/MX53 Linux Updata/OS Firmware/files/android
       Notes: found a new devices and install the driver  (the drivers\ directory)
                 select the profile: Option -> Configuration -> Profiles -> Options-> click the  cell (such as: MX53SMD-SD )
       Such as: “Freescale i.MX53 USB BuldIO Device”; please check the right port number and devices.
                    “Options->Configuration->USB Ports”

Notes: you can connect the serial port to check the download process.

Android profile in MFG tool uses the default mbr.bin to create partitions for the storage. This default mbr.bin is only for the images provided into the example. If the user replace with new flashed image, the user must update mbr.bin to create the right partition table. Another option is that the user modify ucl.xls to use fdisk instead of mbr.bin to create partitions. For fdisk usage, please refer to other profile to create the right fdisk-u.input.

3.2.3 Download Images with dd utility

The linux utility "dd" on Linux PC can be used to download the images into the MMC/SD card. Before download, make sure your MMC/SD card's partitions are created.
And all the partitions can be recognized by Linux PC. To download all the images into the card, please use the commands below:

    Download the uboot image:
    # sudo dd if=u-boot.bin of=/dev/sdx bs=1K skip=1 seek=1; sync
Or If you're using no padding uboot image:
    # sudo dd if=u-boot-no-padding.bin of=/dev/sdx bs=1K seek=1; sync
    Download the kernel image:
    # sudo dd if=uImage of=/dev/sdx bs=1M seek=1; sync    
    Download the initramfs image:
    # sudo dd if=uramdisk.img of=/dev/sdx bs=1M seek=6; sync
    Download the android system root image:
    # sudo dd if=system.img of=/dev/sdx2; sync
       Download the android recovery image:
    # sudo dd if=recovery.img of=/dev/sdx4; sync

3.2.4 Download Images with fastboot

The fastboot is a utility which can use to download images from Windows/Linux PC to the target storage device.
This utility is released by google in the Android SDK packages, user can download them from Android's official site.
Freescale's android release implement some of the fastboot commands in the uboot, like flash, reboot, getvar. 
It supports MMC/SD on i.MX51 BBG and MMC/SD, eMMC on i.MX53 SMD board.

NOTE: MX53 SMD eMMC fastboot can only support up to 4GB size right now.

Before using the fastboot, Android SDK must be installed on the HOST and the target board can boot up to bootloader.
So using fastboot, the uboot must be downloaded to the MMC/SD or eMMC device with all the partitions created formatted as 3.2.1. And setup the correct board dip switch to boot up the board from that device with uboot.

Target side:

    BBG U-Boot > fastboot
    fastboot is in init......USB Mini b cable Connected!
    fastboot initialized
    USB_SUSPEND
    USB_RESET
    USB_RESET

        NOTE: On HOST PC, It will prompt you that a new device found and need to install the driver. please install it.

Host side:

  • Enter the Android SDK tools directory and find the fastboot utility (it's fastboot.exe on Win, fastboot on Linux)
  • Copy all download images to the "images" folder
  • Run the following commands:
   
    > fastboot flash bootloader images\u-boot-no-padding.bin
    > fastboot flash kernel images\uImage
    fastboot flash uramdisk images\uramdisk.img
    fastboot flash system images\system.img
    fastboot flash recovery images\recovery.img
    fastboot reboot

  
After reboot, you can check the target, and setup the bootloader environments.


3.2.5 Boot from MMC/SD and eMMC

When a MMC/SD or eMMC device ready for Android system boot, then you can power on the board to setup the u-boot environment for loading kernel/ramdisk from device
On the u-boot shell:

U-Boot > setenv ethaddr 00:04:9f:00:ea:d3            [setup the MAC address]
U-Boot > setenv fec_addr 00:04:9f:00:ea:d3           [setup the MAC address]
U-Boot > setenv loadaddr <kernel load addr>          [0x90800000 for i.MX51, 0x70800000 for i.MX50/3]
U-Boot > setenv rd_loadaddr <ramdisk load addr>       [0x90C00000 for i.MX51, 0x70C00000 for i.MX50/3]       
U-Boot > setenv bootcmd 'run bootcmd_SD; bootm ${loadaddr} ${rd_loadaddr}'
U-Boot > setenv bootcmd_SD 'mmc read 0 ${loadaddr} 0x800 0x2000; mmc read 0 ${rd_loadaddr} 0x3000 0x300;'  [load kernel and ramdisk from MMC/SD or eMMC]
[About the eMMC boot, please use the "mmc read 1" replace the "mmc read 0"] 
U-Boot > setenv bootargs <SD/MMC bootargs>           [For different platforms, please refer to below table]
U-Boot > saveenv                                     [Save the environments]

Examples for bootargs:
Platform Bootargs
i.MX51 BBG with WVGA console=ttymxc0 init=/init androidboot.console=ttymxc0 di1_primary calibration ip=dhcp gpu_memory=16M
i.MX53 SMD with LVDS console=ttymxc0 init=/init androidboot.console=ttymxc0 video=mxcdi1fb:RGB666,XGA ldb di1_primary ip=dhcp gpu_memory=64M
i.MX50 RDP with E-Ink console=ttymxc0 init=/init androidboot.console=ttymxc0  ip=dhcp keypad
NOTE: each items in the bootargs will be explained in the section 3.4

After done these settings, reboot the board, let u-boot to run the bootcmd environment to load kernel and run.
For the first time boot, it causes some time to finish and finally you can got to the Android UI.

3.3 System on NFS

Android support running the system on NFS root filesystem. We can put the total android root system into NFS, but loading kernel image from TFTP server.
Therefore you must have a PC which has NFS and TFTP server, with their root directory setup correctly, e.g /opt/tftproot for TFTP root, and /opt/nfsroot for NFS root.

3.3.1 Setup the TFTP and NFS root

After you setup the TFTP/NFS server, please put the kernel image into the tftp server root directory and the Android file system files into the NFS server root directory.


For kernel image, use uImage instead of zImage 

  * If you are using a prebuilt image, make sure you pick up the correct uImage (see "Prebuilt image for using uboot")

  * If you are building your own image, make sure you generated a uImage (see "Generate uImage to be loaded by u-boot").


Copy uImage to the TFTP server root directory. For example:

    $ cp your_uImage /opt/tftproot/

Setup the Android file system:
 * If you are using a prebuilt image, unzip the android zip file (see "Prebuilt image for using uboot") to the NFS server root. For example:
     $ cd /opt/imx-android-r10/image/imx5x_BOARD/NFS
     $ tar xzvf ./android_fs.tar.gz
     $ cd android_fs
     $ rm -rf /opt/nfsroot/*
     $ cp -r * /opt/nfsroot/*

 * If you built out your own Android image, copy the generated Android files to the NFS root manually. For example:
     $ cd myandroid
     $ rm -rf /opt/nfsroot/*
     $ cp -r out/target/product/imx5x_BOARD/root/* /opt/nfsroot/
     $ cp -r out/target/product/imx5x_BOARD/system/* /opt/nfsroot/system/ 
NOTE: Since the NFS uses system and cache folder under /opt/nfsroot/, comment out the mount system and cache lines in /opt/nfsroot/init.rc.

3.3.2 Boot from TFTP and NFS

Setup the u-boot environment for loading kernel from TFTP and mounting NFS as root filesystem after we got the u-boot shell:

U-Boot > setenv ethaddr 00:04:9f:00:ea:d3            [setup the MAC address]
U-Boot > setenv fec_addr 00:04:9f:00:ea:d3           [setup the MAC address]
U-Boot > setenv loadaddr <kernel load addr>          [0x90800000 for i.MX51, 0x70800000 for i.MX50/3]       
U-Boot > setenv bootfile uImage
U-Boot > setenv serverip <your server ip>            [Your TFTP/NFS server ip]
U-Boot > setenv nfsroot <your rootfs>                [Your rootfs]
U-Boot > setenv bootcmd 'dhcp;bootm'                 [load kernel from TFTP and boot]
U-Boot > setenv bootargs <NFS bootargs>              [For different platforms, please refer to below table; do not add '']
U-Boot > saveenv                                     [Save the environments]

Examples for bootargs:
Platform Bootargs
i.MX51 BBG with WVGA console=ttymxc0 init=/init androidboot.console=ttymxc0 root=/dev/nfs nfsroot=${serverip}:${nfsroot} rw ip=dhcp di1_primary gpu_memory=16M
i.MX53 SMD with LVDS console=ttymxc0 init=/init androidboot.console=ttymxc0 root=/dev/nfs nfsroot=${serverip}:${nfsroot} rw ip=dhcp video=mxcdi1fb:RGB666,XGA ldb di1_primary gpu_memory=64M
i.MX50 RDP with E-Ink console=ttymxc0 init=/init androidboot.console=ttymxc0 root=/dev/nfs nfsroot=${serverip}:${nfsroot} rw ip=dhcp keypad

After done these settings, reboot the board, let u-boot to run the bootcmd environment to load kernel and run.
For the first time boot, it causes some time to finish and finally you can got to the Android UI.

3.4 Boot Up configurations

This section explains the common u-boot environments we used for NFS, MMC/SD boot above, and also kernel command line we may changed for different usage scenarios.

3.4.1 U-Boot environment



3.4.2 Kernel command line (bootargs)

Depend on different booting/usage scenarios, you may need different kernel boot parameters set for bootargs.

Kernel Parameter Description Typical Value Used When
console where to output kernel log by printk console=ttymxc0 All case
androidboot.console indicate Android shell where to put log androidboot.console=ttymxc0 All case for Android (with this parameter, you can use Ctrl-C in Android shell)
init tell kernel where is the init file init=/init All case for Android. "init" in Android is located in "/" instead of in "/sbin"
ip tell kernel how/whether to get IP address ip=none
or 
ip=dhcp
or 
ip=static_ip_address
"ip=dhcp" or "ip=static_ip_address" is mandatory in "boot from TFTP/NFS"
nfsroot where is NFS server/directory rootfs=ip_address:/opt/nfsroot,v3,tcp Used in "boot from tftp/NFS" together with "root=/dev/nfs"
root indicate where is the root file system root=/dev/nfs
or
root=/dev/mmcblk0p2
Used in "boot from tftp/NFS" (i.e. root=/dev/nfs);
Used in "boot from SD" (i.e. root=/dev/mmcblk0p2) if no ramdisk is used for root fs
video tell kernel/driver which resolution/depth and refresh rate should be used video=mxcdi0fb:1024x768M-16@60 Used when display on DVI (i.MX51 BBG3 board). Please check "Display Settings" table below for detail.
di1_primary tell kernel/driver using DI1 display di1_primary Used to tell kernel which display interface is the default on for UI.
calibration tell kernel/driver to do touch panel calibration when 1st boot calibration Used when touch panel is needed. i.e. when you display everything on DVI or multitouch screen, no need for this.
gpu_memory GPU shared memory used by driver gpu_memory=16M It's 16MB on MX51 BBG, but 64M on MX53 SMD
keypad (for i.mx50)
Use the keypad on E-ink panel board
keypad
Use the keypad on E-ink panel board

Display settings


MX51

MX53


Display device
Interface Format Video Mode Interface
Format
Video Mode
DVI di0 RGB24
mxcdi0fb:800x600M-16@60
di0
RGB24
mxcdi0fb:800x600M-16@60
DVI-HDMI di0
RGB24
mxcdi0fb:720P60
di0
RGB24
mxcdi0fb:720P60
LVDS
di0
LVDS666
mxcdi0fb:XGA
di0/1
RGB666
mxcdixfb:RGB666,XGA ldb
WVGA LCD
di1 RGB565
mxcdi1fb:800x480M-16@55
di0
RGB565
mxcdi0fb:800x480M-16@55
TV Encoder
di1
YUV444
mxcdi1fb:TV-NTSC                                                      mxcdi1fb:TV-PAL
mxcdi1fb:720P60
di1
YUV444
mxcdi1fb:TV-NTSC                                                      mxcdi1fb:TV-PAL
mxcdi1fb:720P60


4. Run

4.1 Multimedia

4.1.1 Music Play

Use the following steps to play music:

4.1.2 Video Play

Use the following steps to play video:

4.1.3 Streaming Play

Use the following steps to stream from http:

4.1.4 Camera (Still Image Capture)

Use the following steps to capture a still image, using the SOC Camera:

4.1.5 Sound Recording

Use the following steps for sound recording:

4.1.6 Camcorder

Use the following steps to record video, using the SOC camera:

4.1.7 USB Camera

Use the following steps to enale a USB camera (not support in default build) for Camera / Camcorder

notes: the UVC may be not enable in the default configure, so you can enable it by manual
         Device Drivers  --->
                  <*> Multimedia support  --->
                          [*]   Video capture adapters  --->
                                  [*]   V4L USB devices  --->
                                          <*>   USB Video Class (UVC)

4.2 Storage

4.2.1 USB Mass Storage

    After connecting USB cable to the board, please open the notification status bar, and click the "USB connected" bar.
    It shows a window with "Turn on USB Storage" button, click it.
    This causes vold to umount local storage and then export it to the PC
 
    With either of those methods, you should be able to access on-board storage (for example SD card) from the PC.

4.2.2 Multi-Storage Access

There are total three storages supported in i.MX51 BBG.i.MX51 BBG supports the following storages:
They are mounted to /sdcard, /extsd and /udisk in Android rootfs.

Since the Android SDK only supports the export of /sdcard as external storage, the Android Application can only access one external storage. freescale extends the Android SDK to multi-storage access from Android Application. This extension can be summarized into two categories:
  • The SDK API Environment.getExternalStorageDirectory()/getExternalStorageState() returns the external stoage directory based on the Storages present on the Board. If there is a SD card in the MMC/SD connector P1, it returns the directory of /sdcard. If there is a UDISK connected to the board through the USB port, and no SD card is in the MMC/SD connector P1, it returns the directory of /udisk. If there is a SD card in the MMC/SD connector P2, and no SD card in the MMC/SD connector P1, no UDISK connected to the board through the USB port, it will return the directory of /extsd. It dynamically determines which directory to return based on whether the valid device connected to the board based on the sequence /sdcard, /udisk and /extsd. Without the modification, the Android application can access one external storage at a time. And the media file linked with the URL content://media/external also follow the logical.
  • The APIs are added into the Android SDK API to support access the external storages as request:
Environment.getExternalSDStorageDirectory()
Environment.getExternalUDiskStorageDirectory()
Environment.getExternalExtSDStorageDirectory()
Environment.getExternalSDStorageState()
Environment.getExternalUDiskStorageState()
Environment.getExternalExtSDStorageState()
And to access media through MediaProvider, the Android application should use the URL content://media/external_sd, content://media/external_udisk, and content://media/external_extsd for the specific media files in /sdcard, /udisk, and /exts". Refer to the code change in the Camera Application for the use of the API extension.

Mountservice broadcasts a intent for each external storages state change. This intent had the URL file://sdcard, file://udisk, or file://extsd in extra data of this intent, to indicate which storage changed. Upon receiving those intent, Android Application should check the extra data of this intent, or count on the SDK API Environment.getExternalStorageDirectory()/getExternalStorageState() or FSL extended storage API to fetch its interested external storage state and directory.

4.3 Connection

4.3.1 Enable WiFi

Use the following steps to enable WiFi:

4.3.2 Browse Internet using 3G Modem Connection

Use the following steps to browse the internet:

4.3.3 Enable the AR6002 WIFI card

    Notes: the default enabled is AR6003; the AR6102 also can use the same module with AR6002
  • Rebuild android project again.


4.4 Display

4.4.1 TVout (Video Only)

Use the following steps for video only TV out:

4.4.2 TVout (Video and UI)

Use the following steps for video and UI TV out:

4.4.3 Dual-Display

Two display outputs can be supported simultaneously in i.MX51 BBG3 board and i.MX53 SMD board. 
In i.MX51 BBG, the primary display output is WVGA LCD, the second display output is DVI output. To enable this feature, there are two valid UBOOT settings needed as below, one for setting the secondary DVI output to 1024x768 resolution, and the other for setting the secondary DVI output to 1280*720 resolution:
In i.MX53 SMD, the primary display output is LVDS panel, and the other display output is HDMI output. To enable this feature, there is one valid UBOOT setting needed as below:

Dual-Display feature can be enabled dynamically with below steps:
setprop rw.SECOND_DISPLAY_CONNECTED 1
setprop sys.SECOND_DISPLAY_ENABLED 1
Also this feature can be disabled dynamically by setting the below properties in Android's console:
setprop rw.SECOND_DISPLAY_CONNECTED 0
setprop sys.SECOND_DISPLAY_ENABLED 0
Notes:

4.4.4 24bpp pixel format support for UI

24bpp pixel format for UI and Display can be supported by the below valid UBOOT setting:

4.5 Application & Development

4.5.1 Key Map

The key mapping for a Dell USB keyboard used with the BBG3 board (defined in /system/usr/keylayout/Dell_Dell_USB_Keyboard.kl) is as follows:

Key Act as
ESC BACK
F1 MENU
F2 SOFT_RIGHT
F3 CALL
F4 ENDCALL
F5 ENDCALL
F8 HOME
F9 DPAD_CENTER
UP DPAD_UP
DOWN DPAD_DOWN
BACK DEL
ENTER ENTER

The key map of the keypad on the BBG3 add-on peripheral board (defined in /system/usr/keylayout/mxckpd.kl) is as follows:

POWER N/A CALL VOLUME_UP
DPAD_LEFT
MENU




DPAD_DOWN DPAD_CENTER DPAD_UP HOME
CAMERA N/A ENDCALL VOLUME_DOWN
DPAD_RIGHT
BACK

The key map of the keypad on the i.MX508 (defined in /system/usr/keylayout/mxckpd.kl) is as follows:
Key Act as
PREV(SW2) BACK
F1(SW5) MENU
F9(SW15) ENTER
9(SW24) DPAD_LEFT
0(SW25) DPAD_RIGHT
O(SW34) DPAD_UP
P(SW35) DPAD_DOWN
POWER(SW70) POWER
RESET(SW71) RESET
NXT1(SW3)/NXT2(SW4) DPAD_CENTER

For imx53_EVK/imx50_PD, the "power key" on board support the suspend/resume operation.

4.5.2 Adjust Media Volume for Music and Video

Use the following menu to adjust the volume:
Main Menu > Settings > Sound > Volume

4.5.3 Adjust Brightness of LCD Backlight

Use the following menu to adjust the brightness (the i.mx51 BBG need hardware rework):
Main Menu > Settings > Display > Brightness

4.5.4 longer Screen Timeout

Use the following menu to disable the screen timeout:
Main Menu > Settings > Display > Screen timeout > 30 minutes

4.5.5 ADB over USB

A PC with ADB installed is required. A Windows PC installed with Android SDK package (adb is default under YOUR_SDK_ROOT_DIR/tools/) or a Linux PC on which you had build the Android from source (adb is generated at YOUR_ANDROID_REPO_DIR/out/host/linux-x86/bin).
     
Connect the board to the PC using USB. Connect the USB cable to the OTG port instead of Host port.
On the PC, run adb devices to see a list of the attached device (the board). If yes, you can now use any adb command.
If using a Windows PC, you can see a ADB Interface in Hardware list.

In linux environment, the "idVendor" must be set.  Now, the "idVendor" is "0x0bb4".


# Log in as root and create this file: /etc/udev/rules.d/51-android.rules.

SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", MODE="0666"

# Now execute:

chmod a+r /etc/udev/rules.d/51-android.rules

4.5.6 App to SD

Now, the App could be installed in the internal device or the external SD card. But not all applications support this feature.
       click the application and selection "Move to SD card"

4.5.7 Software Update and Wipe Partition using Recovery Mode

It is possible to format the /data and /cache partitions or update software based on a update script using recovery mode as follows:
       for imx51_BBG board:
       setenv bootargs_android_recovery 'setenv bootargs ${bootargs} init=/init root=/dev/mmcblk0p4 rootfs=ext4 di1_primary'
       setenv bootcmd_android_recovery 'run bootargs_base bootargs_android_recovery;mmc read 0 ${loadaddr} 0x800 0x1800;bootm'
       run bootcmd_android_recovery

       For imx53_EVK board:
       setenv bootargs_android_recovery 'setenv bootargs ${bootargs} init=/init root=/dev/mmcblk0p4 rootfs=ext4'
       setenv bootcmd_android_recovery 'run bootargs_base bootargs_android_recovery;mmc read 0 ${loadaddr} 0x800 0x1800;bootm'

       run bootcmd_android_recovery
        

4.5.8 3D Demo

   Android has an API demo application that includes a test function for OpenGL/ES. However by default it's not built. You can build it as follows:
   $ cd myandroid
   $ make ApiDemos

   The generated API demo application will be out/target/product/YOUR_PRODUCT/system/app/ApiDemos.apk. Copy it into your Android file system (/system/app/) and then reboot the board.

   Main menu > ApiDemo > Graphic > OpenGLES > ...

 
  
  Note: 

  $ setprop debug.sf.enable_hgl 0

  $ setprop debug.egl.hw 0

  $ setprop debug.sf.showfps 1

4.5.9 Fastboot

The fastboot mode support download images from Windows
        Notes; It will prompt you that a new device found and need to install the driver. please install it.
fastboot.exe reboot

4.5.10 2G/2G enable

Follow below steps to enable the 2G/2G feature:
TARGET_KERNEL_2G := true
Notes: 

5. FAQ

5.1 Why did the code fail to download from Google when repo init?

        Perhaps because you are behind the firewall. If you have http proxy and your firewall support socks, then take the following steps:
 
   * Install Dante - a socks client   
    $ sudo apt-get install dante-client
    * Configure Dante by adding below lines into /etc/dante.conf      
    route {        
        from: 0.0.0.0/0 to: .  via: DNS_OR_IP_OF_YOUR_SOCKS_SERVER port = PORT_OF_YOUR_SOCKS_SERVER        
        proxyprotocol: socks_v5      
              }       resolveprotocol: fake  
    * Set environment variable for http proxy and socks  
    $ export http_proxy=...   
    $ export SOCKS_USER=...   
    $ export SOCKS_PASSWD=...  
    * Download Android code from google   
    $ curl http://android.git.kernel.org/repo > ./repo    
    $ chmod a+x ./repo    
    $ socksify ./repo init -u git://android.git.kernel.org/platform/manifest.git -b froyo
    $ cp /opt/imx-android-r10/code/r10/default.xml .repo/manifests/default.xml    
    $ socksify ./repo sync


5.2 Why I can't access the internet with browser using ethernet?

        It always reports "Web page not available" even if I have directly internet access (not behind a proxy/firewall. Note: Android browser seems not support proxy setup)?

DNS setup. For ethernet, the Android does not setup DNS automatically. So DNS must be manually setup. This is not an issue for WiFi since dhcpcd is explicitly called after WiFi access is available.

How to solve/workaround this issue:
In console, input setprop net.dns1 IP_OF_YOUR_PRIMARY_DNS_SERVER. Ping any host with DNS name. If successful, you should be able to use Browser to access any web site now.

5.3 Can I access Android shell using ethernet instead of a serial port?

        Yes. On the Linux PC (assume you had built Android code or install Android SDK), complete the following actions:
    $ ping IP_OF_YOUR_BOARD (run "netcfg" on board to get IP address)
    $ export ADBHOST=IP_OF_YOUR_BOARD
    "adb" is a host tool created during Android build.It's under out/host/linux-x86/bin/. Make sure you set path properly.
    $ adb kill-server (not sure why need this step. Just re-start adb daemon on board)
    $ adb shell
    # NOW YOU ARE IN ANDROID SHELL ON BOARD

5.4 How do I change Android boot logo?

        If there is a file called initlogo.rle under the root folder, Android displays it while booting. Complete following steps to create a rle compressed picture from a png file.

             1. Find an image you like
             2. Edit it with your favorite editing suite and scale it to 480x640
             3. After scaling it, convert the colorspace to 256 colors (8-bit)
             4. Save it as a PNG without alpha channel/transparency.
             5. Use the convert tool from the ImageMagick toolkit: convert -depth 8 splash.png rgb:splash.raw
             6. Compile the Android tool in mydroid/build/tools/rgb2565(gcc -O2 -Wall -Wno-unused-parameter -o rgb2565 to565.c)
             7. Run the conversion command: rgb2565 < splash.raw > splash.raw565
             8. Copy splash.raw565 to mydroid/out/target/product/imx51_BBG/root/initlogo.rle. make it to zImage ramdisk for nand boot

5.5 How to use wake_lock to control specific devices?

        If an application hold a wake_lock, the system will not enter suspend mode. Except turn off LCD, you may want to do more things to control device during the time of holding a wake_lock. For instance, if mp3 player holds the wake_lock called “audioplay”, device drivers can also call register_lock_handle() with the same lock name as parameter, to register one or more device handles dealing with power related operation during early suspend.This is an extension to refine devices control during early suspend.