This post is for ESC Boston attendees taking part in Thursday's "Embedded Android Workshop" on the BeagleBoard. I'm assuming here that you've already prepared your laptop, per my previous post, by downloading the VM image, setting it up and putting the various tarballs into the Ubuntu guest VM. If you haven't done so yet, it's very important that you do so ASAP. Remember that there's a help desk in front of room 210 to assist you with these steps.

The following explanations show you how to build a version of the AOSP for the BeagleBoard configuration used for the workshop; which includes an LCD panel. For this purpose, I assume you were able to copy the tarballs through your host -- possibly via a mapped drive -- into ~/Desktop/bridge. You'll also need this patch, which I'll also assume you've put in the same location as the tarballs.

The first step is to make sure you have the proper tools -- pay close attention to the second command and note that I'm selection "2" (i.e. the 'jar' tool that comes from the Sun JDK):

$ sudo apt-get install uboot-mkimage
$ sudo update-alternatives --config jar
There are 2 choices for the alternative jar (providing /usr/bin/jar).

  Selection    Path                             Priority   Status
------------------------------------------------------------
* 0            /usr/bin/fastjar                  100       auto mode
  1            /usr/bin/fastjar                  100       manual mode
  2            /usr/lib/jvm/java-6-sun/bin/jar   63        manual mode

Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/java-6-sun/bin/jar to provide /usr/bin/jar (jar) in manual mode.

Let's now extract the AOSP sources:

$ cd ~/android
$ tar xvzf ~/Desktop/bridge/TI_Android_GingerBread_2_3_4Sources.tar.gz
$ cd TI_Android_GingerBread_2_3_4Sources/

In this directory, there will only be a "Readme" file. To retrieve the sources from the archive, you need to use the 'repo' tool -- this should run for a few minutes:

$ ./.repo/repo/repo sync --local-only

If you look again, you'll see that the sources now contain the entire AOSP. We can now begin patching this tree for our purposes:

$ tar xvjf ~/Desktop/bridge/rootfs-glibc-110919.tar.bz2
$ patch -p5 < ~/Desktop/bridge/ulcd-esc-boston-2011-110925
patching file build/core/combo/arch/arm/armv7-a-neon.mk
patching file device/ti/beagleboard/beagleboard.mk
patching file device/ti/beagleboard/init.i2c_setup.sh
patching file device/ti/beagleboard/init.rc
patching file device/ti/beagleboard/ueventd.omap3.rc
patching file frameworks/base/Android.mk
patching file frameworks/base/api/current.xml
patching file frameworks/base/core/java/android/app/ContextImpl.java
patching file frameworks/base/core/java/android/content/Context.java
patching file frameworks/base/core/java/android/hardware/chronos/ChronosManager.java
patching file frameworks/base/core/java/android/hardware/chronos/IChronosService.aidl
patching file frameworks/base/services/java/com/android/server/ChronosService.java
patching file frameworks/base/services/java/com/android/server/SystemServer.java
patching file frameworks/base/services/jni/Android.mk
patching file frameworks/base/services/jni/com_android_server_ChronosService.cpp
patching file frameworks/base/services/jni/onload.cpp
patching file hardware/libhardware/Android.mk
patching file hardware/libhardware/include/hardware/chronos.h
patching file hardware/libhardware/modules/chronos/Android.mk
patching file hardware/libhardware/modules/chronos/chronos.c
patching file kernel/arch/arm/configs/omap3_beagle_android_defconfig
patching file kernel/arch/arm/mach-omap2/board-omap3beagle.c
patching file kernel/drivers/media/video/omap/omap_vout.c
patching file kernel/drivers/video/omap2/displays/panel-generic.c
patching file kernel/include/video/omap-panel-generic-dpi.h
patching file kernel/kbuild
patching file system/core/include/private/android_filesystem_config.h
patching file system/core/rootdir/Android.mk

We are now ready to build this AOSP. Note that you will get a warning about building on a 32 bit system. Ignore it, it's been taken care of by TI.

$ make TARGET_PRODUCT=beagleboard OMAPES=5.x -j4
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=2.3.4
TARGET_PRODUCT=beagleboard
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=GRJ22
============================================

Checking build tools versions...
build/core/main.mk:76: ************************************************************
build/core/main.mk:77: You are attempting to build on a 32-bit system.
build/core/main.mk:78: Only 64-bit build environments are supported beyond froyo/2.2.
build/core/main.mk:79: ************************************************************
...
binary launcher.apk -> /data/app/launcher.apk
binary hal_client_test -> /system/bin/hal_client_test
binary hal_server_test -> /system/bin/hal_server_test
binary framebuffer_test -> /system/bin/framebuffer_test
binary texture_benchmark -> /system/bin/texture_benchmark

Installation complete!

make[1]: Leaving directory `/home/opersys/android/TI_Android_GingerBread_2_3_4Sources/hardware/ti/sgx'

Finally, we need to do some legwork to prepare the root filesystem image before writing it to the SD card:

$ cd out/target/product/beagleboard/
$ mkdir android_rootfs
$ cp -a root/* android_rootfs/
$ cp -r system android_rootfs/
$ sudo ../../../../build/tools/mktarball.sh ../../../host/linux-x86/bin/fs_get_stats android_rootfs \
> . rootfs rootfs_beagle_xm.tar.bz2

We now have images we can use to program the SD card, which we'll do Thursday:

$ sudo cp rootfs_beagle_xm.tar.bz2 ~/Desktop/bridge/
$ cd ~/android/TI_Android_GingerBread_2_3_4Sources/
$ sudo cp kernel/arch/arm/boot/uImage ~/Desktop/bridge/

It's very important that you do these steps ASAP so that I can help you if you encounter any issues. Note also that you won't have time to build this tree during the workshop on Thursday. This is why you need to do so in advance.