VAR-SOM-AM33 Android ICS GS

From Variscite Wiki
Revision as of 12:50, 19 January 2014 by Admin (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

VAR-SOM-AM33 Android ICS 4.0.3 DevKit-3.0.1 DevelopersGuide

Overview

The objective of this document is to guide Android developers to get access to Android ICS DevKit release sources for VAR-SOM-AM33, setting up host environment for compilation and deployment.

This document contains instructions to:

  • Hardware and software requirement.
  • Setup the hardware.
  • Setup the toolchain.
  • Download & build the source.
  • Install the binaries on the VAR-SOM-AM33.

Hardware Requirements

VAR-SOM-AM33 evaluation kit.

Host (PC) setup requirements

The host development environment for Android is based on Ubuntu, please install Ubuntu version 10.04 or later http://www.ubuntu.com/desktop/get-ubuntu/download.

We recommend you to have a Linux "Ubuntu 10.04 or above" Host machine, See Ubuntu Linux installation notes

The host installation would need few more Android specific dependencies, these can be installed dynamically over network using below commands.

For Ubuntu on 32-bit machines

$ sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
$ sudo add-apt-repository "deb-src http://archive.canonical.com/ubuntu lucid partner"
$ sudo apt-get update
$ sudo apt-get install git-core gnupg sun-java6-jdk flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev minicom tftpd uboot-mkimage expect
$ sudo update-java-alternatives -s java-6-sun


NOTE:
  1. Android ICS (4.0.3) needs Java 6.
  2. The hard disk should have at least 25 GigaBytes of free space to complete the building of sources.
  3. Please refer to the AOSP for latest information http://source.android.com/source/initializing.html

Getting Source & Toolchain

TI provides Android sources for all it's supported devices in multiple locations, developers can download the sources from the rowboat repository or use the pre-packaged sources in the DevKit.
To support VAR-SOM-AM33, Variscite provide patches to be applied on top of TI source code.

Using Rowboat Gitorious

A tool called Repo helps to fetch the android sources from gitorious.org/rowboat. Repo is a tool that makes it easier to work with Git in the context of Android.
To install, initialize, and configure Repo, follow these steps:

Make sure you have a bin/ directory in your home directory, and that it is included in your path:

$ mkdir ~/bin
$ PATH=~/bin:$PATH

Download the Repo script and ensure it is executable:

$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
$ chmod a+x ~/bin/repo

The following commands help developers to clone sources from rowboat repository

$ mkdir $HOME/rowboat-android
$ cd $HOME/rowboat-android
$ repo init -u git://gitorious.org/rowboat/manifest.git -m TI-Android-ICS-4.0.3-DevKit-3.0.1.xml
$ repo sync

Using Pre-Packaged Sources

The above method is time consuming. Developers can use the pre-packaged Android sources in DevKit package.

Download the pre-packaged DevKit sources from TI-Android-ICS-4.0.3_AM335x_3.0.1.bin.

Run following commands to extract the pre-packaged source:

$ mkdir $HOME/rowboat-android
$ cd $HOME/rowboat-android
$ chmod a+x TI-Android-ICS-4.0.3_AM335x_3.0.1.bin
$ ./TI-Android-ICS-4.0.3_AM335x_3.0.1.bin
  • Accept the Licence when the installer prompts
  • This will generate following sources
    • Android File system : $HOME/rowboat-android/TI-Android-ICS-4.0.3_AM335x_3.0.1/
    • Android Linux Kernel: $HOME/rowboat-android/TI-Android-ICS-4.0.3_AM335x_3.0.1/kernel
    • Bootloader  : $HOME/rowboat-android/TI-Android-ICS-4.0.3_AM335x_3.0.1/u-boot
    • Toolchain location will be at $HOME/rowboat-android/TI-Android-ICS-4.0.3_AM335x_3.0.1/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin

Toolchain setup

  • Setup the toolchain path to point to arm-eabi- tools in prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin
  $ export PATH=$HOME/rowboat-android/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin:$PATH


Note:
We recommend to keep the add the toolchain path as shown above to avoid conflicts with any other installed toolchain

Apply VAR-SOM-AM33 U-Boot patch to U-Boot source code

Patch can be obtained from Variscite's FTP, under:

/VAR-SOM-AM33/Software/Android/Android-ICS-4.0.3_AM335x_3.0.1.VAR7/Source/U-boot-patches

$ cd <android source path>/u-boot
$ git checkout 429a3860feea2711d3f1561ac1a431b849f45729
$ git apply VAR_SOM_AM33_U_BOOT_Support.patch

Apply VAR-SOM-AM33 kernel patch to kernel source code

Patches can be obtained from Variscite's FTP, under:
/VAR-SOM-AM33/Software/Android/Android-ICS-4.0.3_AM335x_3.0.1.VAR7/Source/kernel-patches

$ cd <android source path>/kernel
$ cd kernel
$ git checkout c0d71b6f64950d5ca529c17d91a590dfd51e8208
$ git apply VAR_SOM_AM33_Kernel_Support.patch

Use VAR-SOM-AM33 Android File-System

The below modifications are required to orignal TI's built AFS.

$ cp <Variscite's AFS>/gpio-keys.kl $HOME/rowboat-android/TI-Android-ICS-4.0.3_AM335x_3.0.1/device/ti/am335xevm/gpio-keys.kl
$ cp <Variscite's AFS>/init.rc $HOME/rowboat-android/TI-Android-ICS-4.0.3_AM335x_3.0.1/device/ti/am335xevm/init.rc


NOTE: Variscite's pre-build Android file-system can be obtain from Variscite's FTP.

Build Procedure

Toolchain setup

  • Setup the toolchain path to point to arm-eabi- tools in prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin
$ export PATH=$HOME/rowboat-android/TI-Android-ICS-4.0.3_AM335x_3.0.1/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin:$PATH

Build Bootloader

  • Change directory to u-boot
$ cd $HOME/rowboat-android/TI-Android-ICS-4.0.3_AM335x_3.0.1/u-boot
  • Execute following commands:
$ make CROSS_COMPILE=arm-eabi- distclean
$ make CROSS_COMPILE=arm-eabi- var_am335x_config
$ make CROSS_COMPILE=arm-eabi- 
  • This command will generate the MLO and the u-boot Image "u-boot.img"

Build Android Linux Kernel

  • Change directory to kernel
$ cd $HOME/rowboat-android/TI-Android-ICS-4.0.3_AM335x_3.0.1kernel
  • Execute following commands
$ make ARCH=arm CROSS_COMPILE=arm-eabi- distclean
$ make ARCH=arm CROSS_COMPILE=arm-eabi- var_am335x_android_defconfig
$ make ARCH=arm CROSS_COMPILE=arm-eabi- uImage

This will generate uImage(kernel image) in kernel/arch/arm/boot folder


NOTE: Genrated uImage run on both am335xevm and beaglebone.

Build Android Filesystem

  • To Build the root filesystem for
$ make TARGET_PRODUCT=am335xevm OMAPES=4.x -j<N>


NOTE:
  • <N> should be twice the number of processors on your host machine. For example, a dual core machine would use -j4
  • The above command will build Android file-system, kernel and related modules,
  • SGX drivers and WLAN drivers will be built and installed in android rootfs.
  • Android rootfs components (root and system directories) will be located in out/target/product/am335xevm.
  • SGX drivers and libraries will get installed in Android rootfs components.

Boot

The Android can either be booted from NAND or MMC/SD device. Following sections describe various boot options possible.

Boot From SD Card

Create bootable SD card

This section describes the steps to create a bootable SD card to boot Android on the VAR-SOM-AM33.

  • Get a 4GB SD memory card.
  • Connect the 4G SD memory card using memory card reader to the Linux machine.
  • Note the name allocated for this device. Type "dmesg". The SD card name should show up near the end, usually something like "SDC" (/dev/sdc) or "SDD" (/dev/sdd).
  • Create root file-system tarball, run the following command:
make TARGET_PRODUCT=<product name> fs_tarball
  • Create a boot script file named uEnv.txt file with following content:
bootargs=console=ttyO0,115200n8 androidboot.console=ttyO0 mem=256M root=/dev/mmcblk0p2 rw rootfstype=ext4 rootwait init=/init ip=off
bootcmd=mmc rescan ; fatload mmc 0 81000000 uImage ; bootm 81000000
uenvcmd=boot
  • Copy compiled images to image folder and create a bootable SD card as follows.
$ mkdir image_folder
$ cp uEnv.txt image_folder
$ cp kernel/arch/arm/boot/uImage image_folder
$ cp u-boot/u-boot.img image_folder
$ cp u-boot/MLO image_folder
$ cp out/target/product/am335xevm/rootfs.tar.bz2 image_folder
$ cp Media_Clips image_folder


NOTE: Get the Media_clips folder from the Variscite's SD card creation folder.
  • Copy the SD/MMC card creation script:
$ cp <android-devkit>/mkmmc-android.sh image_folder


NOTE: Get the mkmmc-android.sh script from the Variscite's SD card creation folder.
  • Generate Android bootable SD card using SD/MMC card creation script.
$ cd image_folder
$ sudo ./mkmmc-android.sh /dev/sdX MLO u-boot.img uImage uEnv.txt rootfs.tar.bz2 Media_Clips

Boot Android from SD card

  • Insert the SD card you just created into the MMC/SD slot on the custom board.
  • Power on the.


NOTE:
By default the will boot from NAND, to boot from SD/MMC make sure the NAND chip is erased or press and hold the boot select switch while power on.

Boot From NAND

By default the boot from NAND. The boot images(MLO, U-Boot, Kernel) and UBIFS Android file-system should be flashed to the NAND device.

Create Android UBI image

$ cd $HOME/rowboat-android/TI-Android-ICS-4.0.3_AM335x_3.0.1/out/target/product/am335xevm
$ mkdir android_rootfs
$ cp -r root/* android_rootfs
$ cp -r system android_rootfs
$ ckmod -R 777 android_rootfs
  • Use MTD tools to create UBI Android file-system image as desbribed here.

Flash Images to NAND

  • Get FAT32 formated SD card.
  • Copy the boot images(MLO, u-boot.img, uImage) and UBIFS Android file-system image to the SD card.
  • Insert the SD card you just created into the MMC/SD slot on the custom board.
  • Install the images. From U-Boot console:
U-Boot # nand erase.chip
U-Boot # reset
<< REBOOT ... >>
U-Boot # mmc rescan
U-Boot # nandecc hw 2
 << Install MLO >>
U-Boot # fatload mmc 0:1 0x81000000 MLO
U-Boot # nand write 0x81000000 0x00000000 0x00020000
<< Install u-boot.img >>
U-Boot # fatload mmc 0 0x81000000 u-boot.img
U-Boot # nand write 0x81000000 0x00080000 0x001E0000
<< Install uImage >>
U-Boot # fatload mmc 0 0x81000000 uImage
U-Boot # nand write.i 0x81000000 0x00280000 0x00500000
<< Install ubi.img >>
U-Boot # fatload mmc 0 0x81000000 ubi.img
U-Boot # nand write.i 0x81000000 0x00780000 0x07460000

Boot Android from SD card

  • Insert the SD card you just created into the MMC/SD slot on the custom board.
  • Power on the VAR-SOM-AM33.

Android ADB Setup

Android Debug Bridge (adb) is a versatile tool that let you manage the state of the Android-powered device.

For more information about how to setup ADB adb, see TI ADB Setup page at http://processors.wiki.ti.com/index.php/Android_ADB_Setup.


NOTE:
When using adb over USB on Windows Machine, edit android_winusb.inf to match VAR-SOM-AM33 vendor and product ids, under Google.NTx86 section add:
;VAR-SOM-AM33
%SingleAdbInterface% = USB_Install, USB\VID_18D1&PID_D002
%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_D002&amp&MI_01