KitKat 4.4 AOSP for BeagleBone Black with accelerated graphics

Update: This page is out of date. I have put together all of the information on running Android on BeagelBone on the Android4Beagle page

After a little bit of tweaking I have got my port of Android KitKat up and running on the BeagleBone Black. For some background on why I am doing this, read my previous post about Android on the BeagleBone Black

Screenshot of BeagleBone running KK 4.4

I tested it with AOSP 4.4.4_r1 on a BeagelBone Black rev A6 with these display options:

  • LCD4
  • LCD7
  • HDMI
  • VNC server

Just to set people's expectations here, I should mention that the BeagleBone Black is in many ways not an ideal target for running Android. It is slow, has no hardware assisted media codecs (so video does not play back very well), does not implement the vsync/hwcomposer backend (so animations are jittery) and has an old kernel. But it is a very good target for prototyping and learning skills that can be used on real projects because it is cheap, has a serial console (handy for debugging), USB OTG, Ethernet and lots of capes for more exotic hardware configurations.

You can try this out in one of three ways:

  1. Copy pre-built images to a micro SD card – easy, little prior knowledge required
  2. Build SD card images from scratch – advanced, you need to set up a fast build machine and be familiar with Linux command line tools
  3. Build images for fastboot and internal flash – advanced, in addition to (2) you need a serial to USB connector fitted to the BeagleBone

Problems encountered along the way

There were two problems doing the port, both associated with the old SGX-530 graphics driver binaries which were compiled against JB 4.1.

Change to the libutils ABI

There is a class called CallStack that is used to keep track of and print the call stack for debugging purposes. In JB 4.3 the signature for the update function was

void update(int32_t ignoreDepth=1, int32_t maxDepth=MAX_DEPTH);

In KK 4.4 a third optional argument, tid, was added

void update(int32_t ignoreDepth=1, int32_t maxDepth=MAX_DEPTH, pid_t tid=CURRENT_THREAD);

Since the argument is optional it is backwards compatible with source code but the binary linkage changes, hence it failed when dynamically linked from gralloc.omap3.so.

The only way to solve this is to patch the AOSP code. I reverted the signature for update to that prior to 4.4:

void update(int32_t ignoreDepth=1, int32_t maxDepth=MAX_DEPTH);

And added an overloaded update that takes 3 non-optional parameters

void update(int32_t ignoreDepth, int32_t maxDepth, pid_t tid);

Now everyone is happy.

EGL init

The handling of attributes in eglCreateWindowSurface (frameworks/native/opengl/libs/EGL/eglApi.cpp) changed in KK 4.4. However, a fallback was implemented specifically for the omap4/3 SoCs. You enable it by adding this to BoardConfig.mk:

COMMON_GLOBAL_CFLAGS += -DWORKAROUND_BUG_10194508=1

[Thanks to XDA developer quarx2k for pointing this out]

Problem like these will continue to exist as log as we have binary-only components with no open source alternatives. While there has been progress in this area, notably the fact that Boardcom released the source to the VideoCore IV graphics core, there is very little coming out of Imagination Technologies. There is an open source community initiative (http://powervr.gnu.org.ve/) but it is a little stalled.

Copy pre-built images to a micro SD card

You will need a microSD card of at least 4 GiB

Get the pre-built image

Plug the SD card into your card reader: it will show up as something like /dev/mmcblk0 or /dev/sdc. Make absolutely sure that you know which it is before continuing because hard drives also show up as /dev/sd* and writing this image to your hard drive will make your computer unbootable!. Assuming that the card reader is mmcblk0, write the image using a command like this:

$ sudo sh -c "unzip -p BBB-aosp-4.4.4_r1-sd-img.zip | dd of=/dev/mmcblk0 bs=4M"

Now put the SD card in your BeagleBone. Depending on what is in your on-board eMMC flash, you may need to hold down the boot button while powering on to get it to load U-Boot from the SD card. All being well, you should see the "Android" boot animation after about 30 seconds and the launcher screen after 90 to 120 seconds. The second time the boot should be faster, I find it to be about 30 seconds.

Build SD card images from scratch

Follow the instructions in README.md at https://github.com/csimmonds/bbb-android-device-files/tree/kk4.4-sdcard

Build images for fastboot and internal flash

Follow the instructions in README.md at https://github.com/csimmonds/bbb-android-device-files/tree/kk4.4-fastboot