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/
patching file device/ti/beagleboard/
patching file device/ti/beagleboard/
patching file device/ti/beagleboard/init.rc
patching file device/ti/beagleboard/ueventd.omap3.rc
patching file frameworks/base/
patching file frameworks/base/api/current.xml
patching file frameworks/base/core/java/android/app/
patching file frameworks/base/core/java/android/content/
patching file frameworks/base/core/java/android/hardware/chronos/
patching file frameworks/base/core/java/android/hardware/chronos/IChronosService.aidl
patching file frameworks/base/services/java/com/android/server/
patching file frameworks/base/services/java/com/android/server/
patching file frameworks/base/services/jni/
patching file frameworks/base/services/jni/com_android_server_ChronosService.cpp
patching file frameworks/base/services/jni/onload.cpp
patching file hardware/libhardware/
patching file hardware/libhardware/include/hardware/chronos.h
patching file hardware/libhardware/modules/chronos/
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/

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

Checking build tools versions...
build/core/ ************************************************************
build/core/ You are attempting to build on a 32-bit system.
build/core/ Only 64-bit build environments are supported beyond froyo/2.2.
build/core/ ************************************************************
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/ ../../../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.