Saturday, January 08, 2011

Cohabiting with Android on the Beagle Board

I recently migrated Contraption, my Android platform, from version 1 of the TI Android development kit for the Beagle Board, which was based on the Eclair Android release, to version 2 of the kit, based on the Froyo release. Both development kits run on top of the 2.6.32 Linux kernel. As before, I configured and built a custom version of the Android Linux kernel to support the additional hardware of the Zippy2 expansion board. The Zippy2 gives you a second SD card slot and an RJ45 Ethernet port.

I used the pre-built root file system, although I've also had good luck building the Android port to the Beagle Board from the Rowboat distribution sources. Note that the Rowboat distribution requires the older Java 1.5 JDK, so you might not want to delete it quite yet from your system.

I also got busybox, bash, dropbear, and strace running with Android on the Beagle Board, which simplified a lot of things. busybox is a very commonly used (one might say: indispensable) utility for embedded Linux-based systems that includes a boat load of commonly used commands and utilities all in one executable binary. It's your one stop shopping source for embedded Linux goodness. Although busybox implements a quite usable shell itself, porting bash gives me a more complete scripting capability. dropbear is a secure shell server that provides SSH and related services. strace (different from the Android strace) is a Linux system call tracing utility that makes it much easier to figure out why things aren't working.

Below you can see my set up. On the big display on the left, connected to my desktop system, you can see a small white window to the left where I have SSHed into the Beagle Board, and a small black window on the right where I am connected to the Beagle Board through its serial port and am running bash. On the smaller display on the right, connected to the Beagle Board, I am web cruising using the Android web browser. The tiny red Beagle Board sits barely visible in between.

Configuring and building tools based on Linux and GNU in a cross-compilation environment can be a little challenging. I was able to leverage a lot of prior work porting tools to the Atmel evaluation board for my Diminuto and Arroyo projects. Because Android and its C/C++ tool chain doesn't include the normal GNU libraries, I had to use the excellent CodeSourcery GCC tool chain and statically link the resulting executable binaries. (In the near future, I'll look at dropping the GNU libraries on the Beagle Board and going back to dynamic linking.) Because Android lacks all the usual Linux and GNU password and user identification infrastructure, dropbear required patches developed by Jakob Blomer at CERN. (A big Thank You to Jakob.)

I probably could have used the native Android utility adb to push binaries to the Beagle Board, but that would have been too easy. Instead, I built busybox, then dropped it into the Android root file system that I built on an SD card. Once I had Android running, I used the tftp function in busybox to copy over the other binaries. Once that was done, it was easy to get a dropbear SSH server running, and from there I had ssh and scp.

Was all this really necessary? Probably not. But I earn a good living in product development as a systems programmer, and that means I am interested with how systems work under the hood.

Most of this effort is captured in a single Makefile that can be found in the Contraption release. If you want to duplicate it, you'll also need to download a ton of other software distributions off the web, the URLs for which are in the Makefile comments.

The Froyo release on the Beagle Board seems to take a little longer to come up than Eclair. USB devices sometimes come and go. And once in a while the Java stack seems to get stuck coming up. But if it were easy, anyone could do it, and it wouldn't be any fun. Once I get over these minor hurdles, I'll be back into the Android software development kit and trying to remember how to write in Java.

Update (2011-01-24)

I've successfully built Android from the Rowboat sources, instead of using the pre-built root file system from the developer's kit. It installed and came up. There are a few elements of weirdness, but not nearly as many as I expected. I'm impressed.

Update (2011-01-31)

I've had some luck running dynamically linked executable binaries built with the standard Code Sourcery tool chain (as opposed to Android's modified version of it) under Android on the Beagle Board. It was fairly straightforward. I haven't tried it yet with the utilities I described here, but I have done so with my Diminuto library and toolkit, the porting of which to Android I have described in another article.

I had to copy all the requisite shared objects to the Beagle Board. For me, that meant /lib/,, and from the arm-none-linux-gnueabi/libc/lib directory of the Code Sourcery tool chain, plus my own For all but the first one I was able to put the shared objects in a new directory and point the LD_LIBRARY_PATH environmental variable to it from my bash session. For the first one, which had an absolute path name embedded in the resulting binary executables, I had to create a /lib directory in the Android file system and placed it there. (I'm trying not to unduly contaminate the Android file system, keeping all my own stuff under my /Contraption directory; sometimes that's not possible.) I also had to make all the shared objects executable, which is required by the dynamic loader.

No comments: