Note: SGX (hardware-accelerated OpenGL) is supported only in Kernel 3.2
Get source (using TI DevKit)
repo init -u git://gitorious.org/rowboat/manifest.git -m TI-Android-JB-4.2.2-DevKit-4.1.1.xml
Build U-Boot and X-Loader
make CROSS_COMPILE=arm-eabi- distclean
make CROSS_COMPILE=arm-eabi- am335x_evm_config
Build Android and Kernel with SGX On
make TARGET_PRODUCT=beagleboneblack OMAPES=4.x
make TARGET_PRODUCT=beagleboneblack fs_tarball
Creating the SD Card
cp ti-android-bbb/kernel/arch/arm/boot/uImage ~/android-bbb-image
cp ti-android-bbb/u-boot/MLO ~/android-bbb-image
cp ti-android-bbb/u-boot/u-boot.img ~/android-bbb-image
cp ti-android-bbb/external/ti_android_utilities/am335x/u-boot-env/uEnv_beagleboneblack.txt ~/android-bbb-image
cp ti-android-bbb/out/target/product/beagleboneblack/rootfs.tar.bz2 ~/android-bbb-image
cp ti-android-bbb/external/ti_android_utilities/am335x/mk-mmc/mkmmc-android.sh ~/android-bbb-image
sudo./mkmmc-android.sh /dev/sdX MLO u-boot.img uImage uEnv_beagleboneblack.txt rootfs.tar.bz2
Replace Rowboat default Kernel with Kernel 3.8
Note 1: SGX is not yet supported on Kernel 3.8 so there is no hardware-accelerated OpenGL on this release./pre>
Note 2: Consider Rowboat for BeagleBone Black was cloned at ~/rowboat-android-bbb and Kernel 3.8 is at ~/linux-dev
mv kernel kernel.bkp
ln -s ~/linux-dev/KERNEL kernel
Let's modify some Makefiles in order to use 'arm-linux-gnueabihf-' instead of 'arm-eabi' for compiling.
chmod 644 ~/rowboat-android-bbb/Makefile
And add a # (comment) in front of
export PATH :=$(PATH):$(ANDROID_INSTALL_DIR)/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin.
Below that (new) comment add the following two lines and save
export PATH :=~/linux-dev/dl/gcc-linaro-arm-linux-gnueabihf-4.7-2013.04-20130415_linux/bin:$(PATH)
export CC_PREFIX := arm-linux-gnueabihf-
Search the Makefile for references to
arm-eabi- and replace them with
$(CC_PREFIX). Once all the changes are saved, go on building Android with SGX support.
$ make TARGET_PRODUCT=beagleboneblack OMAPES=4.x droid -j4 (It takes more or less 2 hours on a Intel i5 with 8GB of RAM.)
Getting U-Boot and patching
Note: Use this guide only if you are building Android with Kernel 3.8
git clone git://git.denx.de/u-boot.git
git checkout v2013.04 -b tmp
patch -p1 < 0001-am335x_evm-uEnv.txt-bootz-n-fixes.patch
We will compile U-Boot using the same toolchain used for compiling the Kernel, and not the one present in Rowboat-Android
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- distclean
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- am335x_evm_config
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
The output files are
u-boot.img. Copy these two files into a new folder in your home directory (i.e.: ~/bbb-android-image)
Next: Compiling Android with Kernel 3.8
Building Kernel 3.8 (with Device Tree)
git clone git://github.com/RobertCNelson/linux-dev.git
git checkout origin/am33x-v3.8 -b tmp
./build_kernel.sh fails with ‘undefined references’ to some functions in files like ‘menubox.c’ try running:
sudo apt-get install libncurses5 libncurses5-dev libelf-dev libncurses5 libncursesw5-dev and then retry with ./build_kernel.sh.
Setting up Kernel 3.8.x for Android
Once in the Kernel Configuration Utility (kConfig) scroll down, and enter, ‘Device Drivers’.
Make sure the ‘Staging drivers’ are enabled, or enable them (an asterisk will appear between brackets)
Then, enter ‘Staging drivers’ -> ‘Android’. Enable all Android drivers. I recommend you to include them into the kernel, and not build them as module.
Exit ‘kConfig’ and the Kernel will begin building.
When it is done you will see something like
Next: U-Boot for BeagleBone Black
Under /frameworks/base/core/jni/ there is a file called AndroidRuntime.cpp where the Dalvik VM parameters are set. You can do a search over the file for “dalvik.vm.heapsize” and you will find out something like this:
* The default starting and maximum size of the heap. Larger
* values should be specified in a product property override.
property_get("dalvik.vm.heapstartsize", heapstartsizeOptsBuf+4, "4m");
opt.optionString = heapstartsizeOptsBuf;
property_get("dalvik.vm.heapsize", heapsizeOptsBuf+4, "16m");
opt.optionString = heapsizeOptsBuf;
change “16m” for any other value, taking into account, the available memory in your device. For example, setting the heap size to 48m it is a good choice in a Beagleboard xM or Beaglebone Black, both with nearly 512Megabytes of RAM.
BusyBox provides several stripped-down Unix tools in a single executable file. It runs in a variety of POSIX environments such as Linux, and Android. Some of these tools are
Why is busybox necessary on a BeagleBoard running Android?
The default Android build does not have many useful tools like stty, so there it is where this swiss army knife comes to rescue.
- Download ‘busybox’ from http://benno.id.au/android/busybox
- Connect to the board using ADB.
- Create a busybox directory inside data.
- Exit ADB.
- Push the downloaded file to the board.
./adb push busybox /data/busybox/busybox
- Enter Shell again.
- And change permission in order to let any app execute busybox.
chmod 777 /data/busybox/busybox
Adding the driver to the Kernel
make ARCH=arm CROSS_COMPILE=arm-eabi- distclean
make ARCH=arm CROSS_COMPILE=arm-eabi- omap3_beagle_android_defconfig
Up to this point everything goes as normal. Now let’s add the FTDI support as a driver (NOT as a module). FTDI published a very detailed tutorial that can be found at http://www.ftdichip.com/Support/Documents/TechnicalNotes/TN_132_Adding_FTDI_Devices_VCP_Driver_Support_to_Android.pdf.
make ARCH=arm CROSS_COMPILE=arm-eabi- menuconfig
If ‘menuconfig’ is not present in the host (Ubuntu), install it using the following code:
sudo aptitude install lib32ncurses5-dev
As the documentation presented by FTDI says, it is necessary to enable a few things:
- “Device Drivers” -> “USB Support” -> pres ‘y’ over “Support for Host-side USB”
- “Device Drivers” -> “USB Support” -> “USB Serial Converter support” -> press ‘y’ over “FTDI Single Port Serial Driver”
Now save this configuration and build the Kernel using
make ARCH=arm CROSS_COMPILE=arm-eabi- -j4
When connecting a FTDI device to the BB xM with this modified Kernel, you will see a ttyUSBx directory inside /dev.
Connecting the FTDI device to the Beagleboard
First of all it will be very useful to connect the Beagleboard Serial port to the host machine and establish a connection using Minicom (or something like that). Once you got there it will be very easy to see if the driver was properly included, and the device is recognized.
See the following screenshot. It shows the device console before the FTDI converter was connected and after that. The device was recognized perfectly, and ttyUSB0 was created under /dev.
A simple test from shell
If you have busybox on Android you can make a simple test in order to see if the driver is well configured (In case you don’t have busybox, you can follow my post on how to install busybox on BeagleBoard).
- Connect RX and TX on the FTDI IC
- Connect to board using ADB.
- Setup ttyUSB0.
/data/busybox/busybox stty -F /dev/ttyUSB0 115200
- Open microcom (similar to minicom)
/data/busybox/busybox microcom -s 115200 /dev/ttyUSB0
- Write something and it will be echoed. If you disconnect the RX and TX, what you send it will not be echoed.
Writing to ttyUSB from C
Init the ttyUSB interface
system("/data/busybox/busybox stty -F /dev/ttyUSB0 115200");
The ttyUSB interface can also be initiated from /init.rc file at the end of “on boot” section.
Getting a File Descriptor
FILE * usbdev = fopen("/dev/ttyUSB0", "rw+");
Read and Write from the File Descriptor
char message; /* buffer of data to send */
char rMessage; /* receive buffer */
fwrite(message, sizeof(char), 8, usbdev);
fread(rMessage, sizeof(char), 8, usbdev);
Closing the File Descriptor
Writing to ttyUSB from Java
Connecting to ttyUSB from Java requires a little bit of extra work. By default, a device under “dev” has permissions only for root. And if your Java app it is not running with root (or your base board is not rooted) you have to change permissions to ttyUSB0 in order to let other apps to write and read from the file (using JNI, of course).
This can be done using several methods, for example:
chmod 777 /dev/ttyUSB0
Setting up device
First of all we need to ensure that we have an Ethernet connection up and running. Connect your PC to the Beagleboard using a USB to Serial converter. USB side on your host and Serial on the RS232 debug port of the Beagleboard.
Then connect using minicom (or any other term program) at 115200bps 8N1. This will let you access a simple linux shell. At the prompt type:
root@android:/ # netcfg
You should see something like
lo UP 127.0.0.1/0
usb0 UP 192.168.1.118/24
if not, try running
netcfg eth0 dhcp or
netcfg usb0 dhcp in order to obtain a connection.
Once the connection is established, we will change the ADB TCPIP port and then restart ADB Daemon (adbd)
root@android:/ # setprop service.adb.tcp.port 5555
root@android:/ # stop adbd
root@android:/ # start adbd
Setting up host
Back on your host machine, start ADB in TCPIP mode and then connect to your device like this
$ sudo ./adb tcpio 5555
$ sudo ./adb connect 192.168.1.118
Once you are connected you can check that everything is working running an adb command like:
$ sudo ./adb devices
List of devices attached
$ sudo ./adb logcat
This Image can be loaded into an SD Card (4GBytes min). It can run entirely from the SD Card, or the Android OS can run from a USB Flash, and U-Boot, X-Loader and the Kernel on the SD Card.
For running entirely from the SD Card
Setup U-BOOT for Android and Kernel on SD Card
For running Android OS from a USB Drive
Setup U-BOOT for Android on USB and Kernel on SD Card
copy rootfs.tar.bz2 to USB Drive and untar (all these commands should be executed as Administrator)
Note: Script not yet optimized for configuration with USB Drive (it is not necessary to copy rootfs to SD Card when booting from USB)
sudo ./mkmmc.sh /dev/sdb MLO u-boot uImage boot.scr rootfs.tar.bz2
Files: Android Image for BeagleBoard xM