Personal tools

VAR-SOM-AM33 Android JB GS

From Variscite Wiki

Jump to: navigation, search

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


IMPORTANT
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/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so

Install Oracle JDK 6

  1. Download the latest JDK 6 installer from Oracle http://www.oracle.com/technetwork/java/javase/downloads/index.html
  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
NOTE:
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 http://source.android.com/source/initializing.html

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 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 http://commondatastorage.googleapis.com/git-repo-downloads/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-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

Then,

$ 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 wl12xx_bt_products.mk Makefile:

$ gedit hardware/ti/wpan/wl12xx-bluetooth/wl12xx_bt_products.mk

As follows:

PRODUCT_COPY_FILES += \
    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 \
    hardware/ti/wpan/wl12xx-bluetooth/firmware/TIInit_12.8.32.bts:system/etc/firmware/TIInit_7.2.31.bts\
    hardware/ti/wpan/wl12xx-bluetooth/firmware/TIInit_12.8.32.bts:system/etc/firmware/TIInit_7.6.15.bts


ifeq ($(TARGET_PRODUCT), am335xevm)
PRODUCT_COPY_FILES += \
    hardware/ti/wpan/wl12xx-bluetooth/firmware/am335xevm_TIInit_7.2.31.bts:system/etc/firmware/TIInit_7.2.31.bts
else
PRODUCT_COPY_FILES += \
    hardware/ti/wpan/wl12xx-bluetooth/firmware/omap3evm_TIInit_7.2.31.bts:system/etc/firmware/TIInit_7.2.31.bts
endif

2.3 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/JB4.2.2.VAR14/Source

$ 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:
/VAR-SOM-AM33/Software/Android/JB4.2.2.VAR14/Source

$ 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:
/VAR-SOM-AM33/Software/Android/JB4.2.2.VAR14/Source

$ 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


NOTE:
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

NOTE:

  • 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
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 $HOME/rowboat-android/external/ti_android_utilities/am335x/mk-mmc/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
$ 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.


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.

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://git.infradead.org/mtd-utils.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:
[rootfs]
mode=ubi 
image=system_ubifs.img 
vol_id=0 
vol_size=160MiB 
vol_type=dynamic 
vol_name=rootfs 

[data] 
mode=ubi 
vol_id=3 
vol_size=76MiB 
vol_type=dynamic 
vol_name=data 
vol_alignment=1 
vol_flags=autoresize
  • 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 (nand-recovery.sh) 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: "android-nand-recovery.sh -o Android". (This will install Android on the NAND)
  • Unplug the SD card and reboot


NAND recovery script usage:

usage: /sbin/nand-recovery.sh options

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

OPTIONS:
  -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 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