VAR-SOM-AM33 Android JB GS

From Variscite Wiki
VAR-SOM-AM33 Android JB 4.2.2 DevKit 4.1.1 DevelopersGuide

1 Overview

The objective of this document is to guide Android developers to get access to Android JB 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.

1.1 Hardware Requirements

VAR-SOM-AM33 evaluation kit.

1.2 Host (PC) setup requirements

The host development environment for Android is based on Ubuntu, please install Ubuntu version 10.04 or later

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

This DevKit Release does not support 32-bit build host. Only 64-bit hosts are supported
The host installation would need few more Android specific dependencies, these can be installed dynamically over network using below commands.

For 64-bit Ubuntu 10.04
The following command installs the required packages for setting up the android build host:

$ sudo apt-get install git-core gnupg flex bison gperf build-essential \
  zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs \
  x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev \
  libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown \
  libxml2-utils xsltproc minicom tftpd uboot-mkimage expect

For 64-bit Ubuntu 12.04
The following command installs the required packages for setting up the android build host:

$ sudo apt-get install git-core gnupg flex bison gperf build-essential \
  zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \
  libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \
  libgl1-mesa-dev g++-multilib mingw32 openjdk-6-jdk tofrodos \
  python-markdown libxml2-utils xsltproc zlib1g-dev:i386 \
  minicom tftpd uboot-mkimage expect

$ sudo ln -s /usr/lib/i386-linux-gnu/mesa/ /usr/lib/i386-linux-gnu/

Install Oracle JDK 6

  1. Download the latest JDK 6 installer from Oracle
  2. Accept the license agreement and click on the Linux x64 bin installer. The downloaded file will be named jdk-6uXX-linux-x64.bin where XX is the JDK 6 update version.
  3. Follow the following steps to install JDK 6
$ chmod a+x jdk-6uXX-linux-x64.bin
$ ./jdk-6uXX-linux-x64.bin
$ sudo mkdir -p /usr/lib/jvm
$ sudo mv jdk1.6.0_XX /usr/lib/jvm/
$ sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.6.0_XX/bin/java" 1
$ sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.6.0_XX/bin/javac" 1
$ sudo update-alternatives --config java
$ sudo update-alternatives --config javac
Android Jelly Bean (4.2.2) needs Oracle JDK 6.
The Hard Disk should have at least 30 GigaBytes of free space to complete the building of sources.
Please refer to the AOSP documentation for latest information and instructions for setting up other Ubuntu versions

2 Getting Source

TI provides Android sources for all it's supported devices in multiple locations. Developers can download the sources from the rowboat repository.
To support VAR-SOM-AM33, Variscite provides patches to apply on top of TI source code.

2.1 Obtain source code 

A tool called Repo helps to fetch the android sources from 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 > ~/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:// -m TI-Android-JB-4.2.2-DevKit-4.1.1.xml
$ repo sync

2.2 Updating the TI WIFI+BT firmware images

Please download the following file from Variscite FTP to $HOME/rowboat-android/:

$ VAR-SOM-AM33/Software/Android/JB4.2.2.VAR15/Source/ti-wifi-firmware.tar.gz


$ mkdir $HOME/ti-firmware
$ cd $HOME/ti-firmware

Extract it as follows:

$ tar xvf ti-wifi-firmware.tar.gz -C $HOME/ti-firmware

Replace the files in the Android build directory:

$ cd $HOME/rowboat-android/
$ rm -rf hardware/ti/wpan/wl12xx-bluetooth/firmware/*
$ cp $HOME/ti-firmware/firmware/* hardware/ti/wpan/wl12xx-bluetooth/firmware
$ rm -rf hardware/ti/wlan/mac80211/firmware/*
$ cp -a $HOME/ti-firmware/firmware/ti-connectivity/* hardware/ti/wlan/mac80211/firmware/

Update Makefile:

$ gedit hardware/ti/wpan/wl12xx-bluetooth/

As follows:

    hardware/ti/wpan/wl12xx-bluetooth/firmware/TIInit_10.6.15.bts:system/etc/firmware/TIInit_10.6.15.bts \
    hardware/ti/wpan/wl12xx-bluetooth/firmware/TIInit_7.6.15.bts:system/etc/firmware/TIInit_7.6.15.bts \
    hardware/ti/wpan/wl12xx-bluetooth/firmware/TIInit_12.7.27.bts:system/etc/firmware/TIInit_12.8.32.bts \

ifeq ($(TARGET_PRODUCT), am335xevm)

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

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


$ cd $HOME/rowboat-android/u-boot
$ git apply --whitespace=nowarn VAR_SOM_AM33_U_BOOT_Support.patch
$ git add .
$ git commit -a -m "Variscite initial"

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

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

$ cd $HOME/rowboat-android/kernel
$ git apply --whitespace=nowarn VAR_SOM_AM33_Kernel_Support.patch
$ git add .
$ git commit -a -m "Variscite initial"

2.5 Apply VAR-SOM-AM33 Android File-System patch

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

$ cd $HOME/rowboat-android/device/ti/am335xevm
$ git apply --whitespace=nowarn VAR_SOM_AM33_AFS_Support.patch

3 Build Procedure & toolchain setup

3.1 Toolchain setup

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

3.2 Build Bootloader

  • Change directory to u-boot
$ cd $HOME/rowboat-android/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"

3.3 Build Android Linux Kernel

  • Change directory to kernel
$ cd $HOME/rowboat-android/kernel
  • 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

Genrated uImage run on both am335xevm and beaglebone.

3.4 Build Android Filesystem

  • To Build the root filesystem for
$ cd $HOME/rowboat-android/ 
$ make -j12 TARGET_PRODUCT=am335xevm OMAPES=4.x


  • 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.

3.5 Memory Optimization (Required for systems with 256MB RAM)

Cutting down memory footprint will allow the system to run smoothly and boot faster.
Removing phone, live wallpaper and browser support can save up to 30 MBytes RAM.

Remove phone support,run the following commands:

$ rm out/target/product/am335xevm/system/app/Contacts.apk
$ rm out/target/product/am335xevm/system/app/Phone.apk
$ rm out/target/product/am335xevm/system/app/ContactsProvider.apk
$ rm out/target/product/am335xevm/system/app/TelephonyProvider.apk
$ rm out/target/product/am335xevm/system/app/UserDictionaryProvider.apk

Remove live wallpaper support, run the following commands:

$ rm out/target/product/am335xevm/system/app/LiveWallpapers.apk 
$ rm out/target/product/am335xevm/system/app/LiveWallpapersPicker.apk

Remove browser support, run the following command:

$ rm out/target/product/am335xevm/system/app/Browser.apk 

4 Boot

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

4.1 Boot From SD Card

4.1.1 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=am335xevm OMAPES=4.x 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
  • 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

Get the Media_clips folder from the Variscite's SD card creation folder.
  • Copy the SD/MMC card creation script:
$ cp $HOME/rowboat-android/external/ti_android_utilities/am335x/mk-mmc/ image_folder

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

4.1.2 Boot Android from SD card

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

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.

4.2 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.

4.2.1 Create Android UBI image

$ make TARGET_PRODUCT=am335xevm OMAPES=4.x fs_tarball
$ mkdir android_rootfs
$ sudo tar -xjvf out/target/product/am335xevm/rootfs.tar.bz2 -C android_rootfs

Use MTD tools v1.5.0 to create UBI Android file-system image as desbribed.

The MTD and UBI user-space tools are available from the the following git repository:

$ git clone git://
$ cd mtd-utils/
$ git checkout v1.5.0
$ make
  • Create UBIFS: 
$ sudo mkfs.ubifs -r android_rootfs/ -F -o system_ubifs.img -m 2048 -e 126976 -c 1960
  • Create "ubinize.cfg" file and write the bellow contents into it:

  • ubinize
$ ubinize -o rootfs-var-som-am33.ubi.img -m 2048 -p 128KiB -s 2048 -O 2048 ubinize.cfg

4.2.2 Install UBIFS image

We can Flash UBIFS image from either Linux Kernel or U-Boot.

From U-boot

Get the UBIFS image to U-Boot from tftp or MMC/SD.

Since we copy the data to NAND, Empty/Erase the required RAM. Then, g et the UBIFS image to U-Boot

u-boot# mw.b ${loadaddr} 0xFF <filesystem_image_size> <=== filesystem image size is upward aligned to NAND block size(128k).
u-boot# mmc rescan
u-boot# fatload mmc 0 ${loadaddr} rootfs-var-som-am33.ubi.img
u-boot# nand erase 0x00780000 0xF880000
u-boot# nand write.i ${loadaddr} 0x780000 0xFC0000

From Linux

$ flash_erase /dev/mtd7 0 0
$ ubiformat /dev/mtd7 -f rootfs-var-som-am33.ubi.img -s 2048 -O 2048

5 NAND Recovery

As an easy and fast way to recover the VAR-SOM-AM33 NAND flash, Variscite provides a recovery SD card image that can be used to install the pre-built Linux and Android systems.
This SD card image includes a script ( that installs all the boot images and root file-system.

Preparing rescue SD-Card

  • Plug your SD card to your Linux machine, run dmesg and see what device is added (i.e. /dev/sdX)
  • gunzip am33-som-nand-recovery-sd.v5.img.gz
  • dd if=am33-som-nand-recovery-sd.v5.img of=/dev/sdX bs=128k

Recover Nand Flash

  • Insert the SD card into the SD/MMC slot of the custom board
  • Press and hold the boot select switch while powering ON the board
  • Login as root (no password)
  • From Linux command line, type: " -o Android". (This will install Android on the NAND)
  • Unplug the SD card and reboot

NAND recovery script usage:

usage: /sbin/ options

This script install Linux/Android binaries in VAR-SOM-AM33 NAND.

  -h Show this message
  -o <Linux|Android> OS type (defualt: Linux).
  -c Install kernel with capacitive touchscreen support (defualt: no).

6 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

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:
%SingleAdbInterface% = USB_Install, USB\VID_18D1&PID_D002
%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_D002&amp&MI_01