Edit your ~/.bashrc and add these 2 lines
export ARCH=arm
export CROSS_COMPILE=/opt/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-
To build and debug android you will need to install some packages and services in the host machine,this how-to assumes that you are using Ubuntu 9.04 or greater.
sudo apt-get install nfs-kernel-server patch g++ rpm zlib1g-dev m4 bison libncurses5-dev gettext build-essential tcl intltool libxml2-dev minicom tftpd xinetd
For a complete list, depending on system type, refer to Installing required packages
Download the SDK from our internal repository
cd /opt
wget http://android.maxtrack.com.br/imx-android-r6.tar.gz
tar xvfz imx-android-r6.tar.gz
cd imx-android-r6/code
tar xzvf R6.tar.gz
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 donut
* If you are behind a firewall or proxy try this one:./repo init -u http://android.git.kernel.org/platform/manifest.git -b donut
cp /opt/imx-android-r6/code/R6/default.xml .repo/manifests/default.xml
./repo sync
cd /opt/imx-android-r6/tool
tar xzvf gcc-4.1.2-glibc-2.5-nptl-3.tar.gz -C /opt
export ARCH=arm
export CROSS_COMPILE=/opt/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-
git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-2.6.28.y.git kernel_imx
cd bootable/bootloader
git clone git://git.denx.de/u-boot.git uboot-imx
Previously we decompressed the SDK at "/opt/imx-android-r6/code/R6" there we can find all the patches needed to iMX51
cd ~/myandroid
. /opt/imx-android-r6/code/R6/and_patch.sh
c_patch /opt/imx-android-r6/code/R6 imx_R6
cd ~/myandroid/bootable/bootloader/uboot-imx
make mx51_bbg_android_config
make
cd ~/myandroid
make PRODUCT-imx51_BBG-eng 2>&1 | tee build_imx51_BBG_android.log
For i.MX51 BBG build, it will generate the compiled environment under myandroid/out/target/product/imx51_BBG. These 4 folders can be used to create your Android file system for NFS mounting, i.e., "root/" -> "/", "system/" -> "/system", "data/" -> "/data"
root/ : root file system (including init, init.rc, etc). Will be mounted at "/"
system/: Android system binary/libraries. Will be mounted at "/system"
data/: Android data area. Will be mounted at "/data"
recovery/: root file system when booting in "recovery" mode. Not directly used.
Image files to use with SD cards
ramdisk.img: Ramdisk image generated from "root/". Not directly used.
system.img: EXT3 image generated from "system/". Can be programmed to "SYSTEM" partition on SD card with "dd"
userdata.img: EXT3 image generated from "data/".
recovery.img: EXT3 image generated from "recovery/". Can be programmed to "RECOVERY" partition on SD card with "dd"
Assuming that 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
If you want to run Android via NFS or from SD, you can build kernel with default configuration now:
cd ~/myandroid/kernel_imx
make imx51_android_defconfig
make uImage
After compiling the image can be found at ~/myandroid/kernel_imx/arch/arm/boot/uImage.
Since we are using Uboot we will need to do this step:
cd myandroid/kernel_imx/arch/arm/boot
~/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
Insert your SD card/cardreader to the Linux PC (you need root privileges for programming SD), you can use dmesg to check the SD device, in our how-to we will consider that the sdcard is detected as /dev/sdb, so be careful to not mess up your own file system. To boot the entire FS from SDcard you must follow this partition schema:
To achieve this, we are going to use fdisk to create the partition table:
# sudo fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x1787490d.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Listing the partition talbe (in our example the SDcard does not have a partition schema):
Command (m for help): p
Disk /dev/sdb: 3965 MB, 3965190144 bytes
122 heads, 62 sectors/track, 1023 cylinders
Units = cylinders of 7564 * 512 = 3872768 bytesDisk identifier: 0x1787490d
Device Boot Start End Blocks Id System
If you have any previous partition, please delete it using the "d" command. Pay attention that each sdcard block has 3872768 bytes (this size usually changes for each type of sdcard) so the first step is to jump at least 8 MB to store uboot, kernel and ramdisk ( as shown in the partition schema )
With that advice in mind, create a 10 MB primary partition that will store the media (/sdcards):
Command (m for help): nCommand action
e extended
p primary partition (1-4)
pPartition number (1-4): 1First cylinder (1-1023, default 1): +8MLast cylinder, +cylinders or +size{K,M,G} (2-1023, default 1023): +10M
List the partition table to check if the partition was correctly created:
Command (m for help): p
Disk /dev/sdb: 3965 MB, 3965190144 bytes
122 heads, 62 sectors/track, 1023 cylinders
Units = cylinders of 7564 * 512 = 3872768 bytes
Disk identifier: 0x1787490d
Device Boot Start End Blocks Id System
/dev/sdb1 2 5 15128 83 Linux
Note that the first partition does not start in the first cylinder; the first cylinder and the second one will store uboot, kernel and ramdisk. Now we need to change the partition label to vfat:
Command (m for help): tSelected partition 1
Hex code (type L to list codes): bChanged system type of partition 1 to b (W95 FAT32)
Command (m for help): p
Disk /dev/sdb: 3965 MB, 3965190144 bytes
122 heads, 62 sectors/track, 1023 cylinders
Units = cylinders of 7564 * 512 = 3872768 bytes
Disk identifier: 0x1787490d
Device Boot Start End Blocks Id System
/dev/sdb1 2 5 15128 b W95 FAT32
Create another 80 MB primary partition with 80 MB storage capacity; this partition will store the system's files. This partition must start in the cylinder that follows the last cylinder of the former partition.
Command (m for help): nCommand action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2First cylinder (1-1023, default 1): 6Last cylinder, +cylinders or +size{K,M,G} (6-1023, default 1023): +80M
Command (m for help): p
Disk /dev/sdb: 3965 MB, 3965190144 bytes
122 heads, 62 sectors/track, 1023 cylinders
Units = cylinders of 7564 * 512 = 3872768 bytes
Disk identifier: 0x1787490d
Device Boot Start End Blocks Id System
/dev/sdb1 2 5 15128 b W95 FAT32
/dev/sdb2 6 28 86986 83 Linux
Now you must create an extended partition big enough to store other 2 logic partitions ( DATA partition with 20 MegaBytes and CACHE partition with 10 MB):
Command (m for help): nCommand action
e extended
p primary partition (1-4)
ePartition number (1-4): 3First cylinder (1-1023, default 1): 29Last cylinder, +cylinders or +size{K,M,G} (29-1023, default 1023): +30M
Command (m for help): p
Disk /dev/sdb: 3965 MB, 3965190144 bytes
122 heads, 62 sectors/track, 1023 cylinders
Units = cylinders of 7564 * 512 = 3872768 bytes
Disk identifier: 0x1787490d
Device Boot Start End Blocks Id System
/dev/sdb1 2 5 15128 b W95 FAT32
/dev/sdb2 6 28 86986 83 Linux
/dev/sdb3 29 37 34038 5 Extended
Now create the logic partitions:
Command (m for help): nCommand action
l logical (5 or over)
p primary partition (1-4)
lFirst cylinder (29-37, default 29):
Using default value 29
Last cylinder, +cylinders or +size{K,M,G} (29-37, default 37): +20M
Command (m for help): p
Disk /dev/sdb: 3965 MB, 3965190144 bytes
122 heads, 62 sectors/track, 1023 cylinders
Units = cylinders of 7564 * 512 = 3872768 bytes
Disk identifier: 0x1787490d
Device Boot Start End Blocks Id System
/dev/sdb1 2 5 15128 b W95 FAT32
/dev/sdb2 6 28 86986 83 Linux
/dev/sdb3 29 37 34038 5 Extended
/dev/sdb5 29 34 22661 83 Linux
Command (m for help): nCommand action
l logical (5 or over)
p primary partition (1-4)
lFirst cylinder (35-37, default 35):
Using default value 35
Last cylinder, +cylinders or +size{K,M,G} (35-37, default 37):
Using default value 37
At last, you must create a primary partition to store the /recovery:
Command (m for help): nCommand action
l logical (5 or over)
p primary partition (1-4)
pSelected partition 4
First cylinder (1-1023, default 1): 38
Last cylinder, +cylinders or +size{K,M,G} (38-1023, default 1023): +10M
Command (m for help): p
Disk /dev/sdb: 3965 MB, 3965190144 bytes
122 heads, 62 sectors/track, 1023 cylinders
Units = cylinders of 7564 * 512 = 3872768 bytes
Disk identifier: 0x1787490d
Device Boot Start End Blocks Id System
/dev/sdb1 2 5 15128 b W95 FAT32
/dev/sdb2 6 28 86986 83 Linux
/dev/sdb3 29 37 34038 5 Extended
/dev/sdb4 38 41 15128 83 Linux
/dev/sdb5 29 34 22661 83 Linux
/dev/sdb6 35 37 11315 83 Linux
Saving the partition table:
Command (m for help): wThe partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
WARNING: If you have created or modified any DOS 6.x
partitions, please see the fdisk manual page for additional
information.
Syncing disks.
Now you are ready to start flashing the SDcard:
cd ~/myandroid/bootable/bootloader/uboot-imx
sudo dd if=your_bootloader_binfile of=/dev/sdb bs=1K seek=1
Usually we use this no-padding uboot image in SD card, i.e. program this no-padding uboot image into 1KB offset of SD card so that we will NOT overwrite the MBR (including partition table) within 1st 512B on SD card.
Do not copy and paste the commands; wait for the complete output.
sudo mkfs.vfat /dev/sdb1
sudo mkfs.ext3 /dev/sdb2
sudo mkfs.ext3 /dev/sdb4
sudo mkfs.ext3 /dev/sdb5
sudo mkfs.ext3 /dev/sdb6
cd ~/myandroid/kernel_imx/arch/arm/boot
sudo dd if=uImage of=/dev/sdb bs=1M seek=1
cd ~/myandroid/out/target/product/imx51_BBG
sudo dd if=uramdisk.img of=/dev/sdb bs=4M seek=1
sudo dd if=system.img of=/dev/sdb2 (Program system.img into SYSTEM partition which will be mounted as "/system")
sudo dd if=recovery.img of=/dev/sdb4 (Program recovery.img into RECOVERY partition which will mounted as "/" in recovery mode)
After inserting the SD card in the board (the slot is located at the inferior portion of the board), plugging in the serial cable and start a configured minicom session, you should turn on the iMX51 board and see in your console something like this:
U-Boot 2009.08-00046-gf91e287 (Jan 18 2010 - 12:32:32)
CPU: Freescale i.MX51 family 2.5V at 400 MHz
mx51 pll1: 800MHz
mx51 pll2: 665MHz
mx51 pll3: 216MHz
ipg clock : 66500000Hz
ipg per clock : 665000000Hz
uart clock : 66500000Hz
cspi clock : 54000000Hz
Board: MX51 BABBAGE 3.0 [POR]
Boot Device: MMC
DRAM: 512 MB
MMC: FSL_ESDHC: 0
In: serial
Out: serial
Err: serial
Press home + power to enter recovery mode ...
Net: FEC0 [PRIME]
Hit any key to stop autoboot: 0
BBG U-Boot >
Copy and paste these configurations, line by line:
setenv bootcmd 'run bootcmd_SD1 bootcmd_SD2'
setenv bootcmd_SD1 'run bootargs_base bootargs_android bootargs_SD'
setenv bootcmd_SD2 'mmc read 0 ${loadaddr} 0x800 0x1280;mmc read 0 ${rd_loadaddr} 0x2000 0x258;bootm ${loadaddr} ${rd_loadaddr}'
setenv bootargs_base 'setenv bootargs console=ttymxc0,115200'
setenv bootargs_SD 'setenv bootargs ${bootargs}'
setenv bootargs_android 'setenv bootargs ${bootargs} init=/init androidboot.console=ttymxc0 wvga calibration'
setenv loadaddr 0x90800000
setenv rd_loadaddr 0x90B00000
saveenv
Reboot the board:
reset
All Board Android Without Ramdisk
All Boards Debugging Android
[Android] Fatal exception happens when preview size does not match video snapshot size
Android Data Partition Encryption on i.MX6
Android Graphic UI with GPU hardware acceleration
Android Memory Usage Tool: Procrank
Build Android 4.0 ICS under Ubuntu 11.10
Build Linphone Android for i.MX6
How to find the crash point: Android Native crash
How to debug memory leakage in media server in Android
How to Enable LDO Bypass Based on i.MX6 Android ICS
How to Enable PCIe WiFi into i.MX6 Android Release?
How to Install Android on SD Card
How to play a file with 2 audio tracks: DTS & AC3 on i.MX6/Android
How to play a media file/stream from console in Android
How to port new audio codec into Android.docx
How to Print Function Caller Stack in Android Log File
How to Support New WiFi Card in Android
How to Use Proxy to Access Network in Android
i.MX6 Android 13.4.1.03 Patch Release
i.MX6 Android R13.4.1.04 patch release
i.MX6 D/Q and i.MX6 DL/S Android JB4.2.2_1.0.0-GA release
iMX6QD How to Add 24-bit LVDS Support in Android
i.MX6 Android R13.4-GA.03 patch release
IoT Solutions: Cloud Connector for Android
Memory Management on i.MX6 Android
New Android SD Card Demo Image for the i.MX6Q SABRE Board for Smart Devices
New Android SD Card Demo Image for the i.MX6Q SABRE Platform for Smart Devices
Video - Bye-Bye Standby Power - Ubiquitous QuickBoot with Android on NetWalker
Video - Efika MX Smartbook Android Flash