Building Jelly Bean 4.3 AOSP for Beaglebone Black v2.0 - with fastboot

A little while ago I wrote Building Jelly Bean 4.3 AOSP for Beaglebone Black which describes how to install Android on a micro SD card and boot the BeagleBone from it. Then I did some research on integrating fastboot into U-Boot and wrote Android fastboot for BeagleBone Black. Now I am bringing the two together.

I did think about editing the first article, but I think it is cleaner to have a new tutoruial that works for the new use case.

To recap: I wanted to create an Android install for the BeagelBone Black for my Android training classes. I looked at the Rowboat project (http://arowboat.org) but found that some things were not done "in the Android way" for no good reason. So I re-packaged Rowboat to:

  1. Use the Android Makefile unchanged. Rowboat modifies it to build the kernel, U-Boot and GPU drivers as well
  2. Build the extras (kernel, etc.) separately by hand, as a consequence of (1)
  3. Use a “normal” set of Android images and file system partitions (ramdisk.img, system.img, userdata.img and cache.img). Rowboat combines the contents together into a single partition which is mounted through a “root=/dev/mmcblk0p2” kernel command line
  4. Use fastboot to flash those images
  5. Use a later version of Android: Jelly Bean 4.3

Overall, the steps are

  1. Get AOSP source from Google
  2. Get my device files for the BeagleBone Black
  3. Get the Rowboat kernel
  4. Get the Rowboat SGX 530 GPU drivers
  5. Build everything
  6. Install U-Boot with fastboot on the BeagleBone following the instructions here
  7. Flash the Android images onto the BeagleBone

Before you begin, make sure that you have a system capable to building AOSP in a reasonable amount of time as described here http://source.android.com/source/building.html. Then follow these steps to set it up http://source.android.com/source/initializing.html. For reference, I tested on two machines: one a laptop with dual core i7 and 4 GiB RAM running Ubuntu 12.04 64 bit (AOSP build takes more than 2 hours), and the other an octo core AMD FX-8150 with 16 GiB RAM running Ubuntu 10.04 64 bit (takes 35 minutes).

Get AOSP version 4.3_r2.1

Note: in the following I am installing and building everything in the home directory (“~”). You may use whichever directory you wish but you will have to modify the paths used below accordingly.

Begin by getting the repo tool and using it to download the AOSP:

$ curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo 
$ chmod a+x ~/bin/repo
$ mkdir ~/aosp-4.3_r2.1
$ cd aosp-4.3_r2.1
$ repo init -u https://android.googlesource.com/platform/manifest -b android-4.3_r2.1
$ repo sync

This takes several hours because there is 17 GiB to download. When complete you will have all the Android source in ~/aosp-4.3_r2.1.

Get device files for BeagleBone Black

Get my device files for the Beaglebone Black into device/ti/beagleboneblack

$ cd ~/aosp-4.3_r2.1/device/ti
$ git clone https://github.com/csimmonds/bbb-android-device-files.git beagleboneblack
$ cd beagleboneblack
$ git checkout jb4.3-fastboot
$ cd ~/aosp-4.3_r2.1
$ . build/envsetup.sh
$ lunch beagleboneblack-eng

Get and build the kernel

The kernel comes from the Rowboat project. It is version 3.2, without device tree support, but it works well enough for me.

$ cd ~/aosp-4.3_r2.1
$ git clone git://gitorious.org/rowboat/kernel.git
$ cd kernel
$ git checkout rowboat-am335x-kernel-3.2

You can use the Android ARM cross compiler, arm-eabi-gcc, to build. Assuming that you have already sourced build/envsetup.sh and run lunch then you can:

$ cd ~/aosp-4.3_r2.1/kernel
$ make ARCH=arm CROSS_COMPILE=arm-eabi- am335x_evm_android_defconfig
$ make ARCH=arm CROSS_COMPILE=arm-eabi- -j4 zImage
$ croot
$ cp kernel/arch/arm/boot/zImage device/ti/beagleboneblack/kernel

Build AOSP for BeagleBone

Now you are ready to run the first AOSP build. Note: the -j option to "make" determines the number of parallel jobs to run. My rule of thumb is to use the number of CPU cores plus 2

$ cd ~/aosp-4.3_r2.1
$ make -j10

This takes an hour or so. When complete you will find the compiled Android system in ~/aosp-4.3_r2.1/out/target/product/beagleboneblack/

Get the SGX drivers

Once again I am getting these from Rowboat. This is messy because they are not very well integrated with the AOSP code. One issue is that the makefile has some paths hard coded which is why it has to be put into hardware/ti/sgx, and also why the kernel has to be in directory kernel/.

$ cd ~/aosp-4.3_r2.1/hardware/ti
$ git clone git://git.gitorious.org/rowboat/hardware-ti-sgx.git sgx
$ cd sgx
$ git checkout ti_sgx_sdk-ddk_1.10-jb-4.3

With Rowboat, the binaries are copied into out/target/product/beagleboneblack/system after the AOSP build is complete and then post-processed into the install tar ball. I want to have them built as part of the AOSP build, so I edit one of the makefiles to put the binaries into my device directory. Then they get sucked into the final images by the rules in my device.mk. So, edit Rules.make: line 23 and change

TARGETFS_INSTALL_DIR=$(ANDROID_ROOT_DIR)/out/target/product/$(TARGET_PRODUCT)/

to

TARGETFS_INSTALL_DIR=$(ANDROID_ROOT_DIR)/device/ti/beagleboneblack/sgx

Build SGX

This next bit has to be run in a completely new shell. I'm sorry, but for some reason it won't build in a shell that has been set up for an AOSP build (i.e. has ". build/emvsetup.sh").

Note: W=1 is needed to avoid turning warnings into errors...

$ cd ~/aosp-4.3_r2.1/hardware/ti/sgx
$ PATH=$HOME/aosp-4.3_r2.1/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin:$PATH
$ make TARGET_PRODUCT=beagleboneblack OMAPES=4.x ANDROID_ROOT_DIR=$HOME/aosp-4.3_r2.1 W=1
$ make TARGET_PRODUCT=beagleboneblack OMAPES=4.x ANDROID_ROOT_DIR=$HOME/aosp-4.3_r2.1 W=1 install 

That will result in populating device/ti/beagleboneblack/sgx

Optional – get Android VNC server

The droid VNC server is useful if you want to test Android on your BeagleBone but don't have a screen:

$ cd  ~/aosp-4.3_r2.1/external
$ git clone git://gitorious.org/rowboat/droid-vnc-server

Final build

Now you need to regenerate the Android image files to include the SGX binaries. This should only take a few minutes.

$ cd ~/aosp-4.3_r2.1
$ . build/envsetup.sh
$ lunch beagleboneblack-eng
$ make installclean
$ make -j10

Flash the new images to the BeagleBone

If you haven't already, install U-Boot with fastboot as described in this tutorial

Then

  1. Plug in the serial-to-USB cable from the BeagleBone to the PC
  2. Start your terminal emulator (e.g if using gtkterm: gtkterm -p /dev/ttyUSB0 -s 115200)
  3. Apply 5V power to the BeagleBone
  4. At the “U-Boot#” prompt, type “fastboot”
  5. Plug in the USB cable between the mini USB port on the BeagleBone and the PC

Now you can use fastboot to flash the Android images:

$ croot
$ fastboot flash userdata
$ fastboot flash cache
$ fastboot flashall

The last command flashes boot.img, recovery.img and sytem.img and then reboots the device.

Display options

You have three options

HDMI

There is a 720p output (1280 x 720) on the HDMI port. Plug this into a suitable display, plug a mouse in to the USB and you have a usable system. This is your best bet.

LCD cape

I have tried it with the LCD7 cape (800 x 480). The display is fine but the resistive touch screen is a dead loss. OK for demos.

VNC

If all else fails...

Run "androidvncserver" on the Beagleboard. Now you can connect to it either over USB or Ethernet. For USB you need to use adb to forward the VNC port and run a VNC client such as vinagre like so:

$ adb forward tcp:5901 tcp:5901
$ vinagre localhost:5901

To use Ethernet, you need to know what the IP address of the Beagleboard:

# netcfg
lo       UP          127.0.0.1/8   0x00000049 00:00:00:00:00:00
sit0     DOWN          0.0.0.0/0   0x00000080 00:00:00:00:00:00
eth0     UP       192.168.1.19/24  0x00001043 90:59:af:5d:85:78

Then on the PC

$ vinagre 192.168.1.19:5901

There is an irritating quirk you should know about: any keys you press in vinagre will not be transmitted to the device until you click the left mouse button.

Conclusion

After this fairly lengthy set of instructions you should have JB 4.3 running on your BeagleBone, and more importantly you will have experienced the stages of putting together an AOSP build, including fastboot!

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

vncserver build

Hi,

Do I need to provide an Android.mk file in the vncserver repo ?

Or just below steps are sufficient:
$ cd ~/aosp-4.3_r2.1/external
$ git clone git://gitorious.org/rowboat/droid-vnc-server

any other makefiles to be modified so that vncserver is part of system images ?

Regards
Sedra

No, that is really all you

No, that is really all you need to do.

The reason it works is that, first, there is a makefile already in the droid-vnc-server directory: look at external/droid-vnc-server/jni/vnc/Android.mk. In there you find the name of the package:

LOCAL_MODULE:= androidvncserver

And secondly, in device/ti/beagleboneblack/device.mk the following statement will build that package if it exists (if not, it fails silently)

PRODUCT_PACKAGES += \
androidvncserver

So the next time you run a top-level make it will include this package in the images it generates.

Google Play Store

Can I bake in Google Play Store Functionality, or am I out of luck? Also, does Audio Work over HDMI?

Re: Google Play Store

You could use the unofficial Google Apps package to get Play Store and such, see http://wiki.cyanogenmod.org/w/Gapps. The only problem is that I have reduced the size of the partitions to 256M to make the flashing faster, and so there is not enough room for apps. Sorry.

Installing to SD card

What changes would be need to install to SD?

Re: Installing to SD card

Just follow the instructions on my earlier post: http://2net.co.uk/tutorial/android-4.3-beaglebone

Android won't boot

I'm getting these messages in the console when trying to boot. Any advice?

[ 7.008810] fs_mgr: Cannot mount filesystem on /dev/block/mmcblk1p6 at /system
[ 7.016400] init: fs_mgr_mount_all returned an error
[ 7.023364] init: Unable to open persistent property directory /data/property errno: 2
[ 7.034331] init: cannot find '/system/bin/servicemanager', disabling 'servicemanager'
[ 7.042938] init: cannot find '/system/bin/vold', disabling 'vold'
[ 7.049430] init: cannot find '/system/bin/sgx/rc.pvr', disabling 'pvr'
[ 7.056385] init: cannot find '/system/bin/netd', disabling 'netd'
[ 7.062869] init: cannot find '/system/bin/debuggerd', disabling 'debuggerd'
[ 7.070254] init: cannot find '/system/bin/rild', disabling 'ril-daemon'
[ 7.077275] init: cannot find '/system/bin/surfaceflinger', disabling 'surfaceflinger'
[ 7.085573] init: cannot find '/system/bin/app_process', disabling 'zygote'
[ 7.092866] init: cannot find '/system/bin/drmserver', disabling 'drm'
[ 7.099698] init: cannot find '/system/bin/mediaserver', disabling 'media'
[ 7.106901] init: cannot find '/system/bin/installd', disabling 'installd'
[ 7.114106] init: cannot find '/system/etc/install-recovery.sh', disabling 'flash_recovery'
[ 7.122854] init: cannot find '/system/bin/keystore', disabling 'keystore'
[ 7.130140] init: property 'ro.product.manufacturer' doesn't exist while expanding '${ro.product.manufacturer}'
[ 7.140708] init: cannot expand '${ro.product.manufacturer}' while writing to '/sys/class/android_usb/android0/iManufacturer'
[ 7.152546] init: property 'ro.product.model' doesn't exist while expanding '${ro.product.model}'
[ 7.161833] init: cannot expand '${ro.product.model}' while writing to '/sys/class/android_usb/android0/iProduct'
[ 7.173101] init: cannot find '/system/bin/sh', disabling 'console'

I got the same message. I

I got the same message. I found out that not all files were compiled sucessfull. It happend when you don't have inssuficent amount of RAM memory. You need at leat 4GB RAM to compile all files. I got 2 GB and I didn't see any warning or messages about compile faild, and the Android didn't boot. I increased the memory to 4GB and compiled again. Now Android boot up.

7" LCD on BeagleBoneBlack - Android 4.4.4

Hi Chris, I am interested in running Android 4.4.4 on a BeagleBoneBlack. I have followed your instructions and got the Android 4.4.4 image on an SD card and all looks 100% OK with an HDMI monitor attached. Can you confirm that this will work with the 7" LCD CAPE (as you state for your JellyBean image). In particular I don't want to spend £73.46 on http://uk.farnell.com/element14/bb-view-70/7inch-lcd-display-cape-for-be... unless I think it is going to work!
A very interesting www page - many thanks.
PS - I wonder how much work would be involved in getting device drivers for the BeagleBoneBlack GPIO pins and the serial ports?

Re 7" LCD on BeagleBoneBlack - Android 4.4.4

I have tested it with the Curcuitco LCD7 cape. Never tried the Element 14 7" cape.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Youtube and Vimeo video links are automatically converted into embedded videos.
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.