This is the Beaglebone Black

It’s a single-board computer, about the size of a credit card. It’s powered by an ARM Cortex A8 and includes the NEON floating point accelerator. Happily that matches nicely with the Android device requirements for RAD Studio and AppMethod.

When I saw that, I wondered what it would take to deploy a FireMonkey app to it. Like most things, it’s pretty easy once you know how, but it took me a few false starts to get it all figured out. Further, much of the information online assumes you’ll be doing this from Linux. Given my aim of running FireMonkey apps on the Beaglebone, I really wanted to show the steps from Windows.

So here they are.

Step 1: Get an Android image on a MicroSD card

The Beaglebone Black ships with a Linux distribution called Angstrom. So the first step is to get Android running on it instead.

If you are really keen, there are steps for building Android from the source. However, initially I just want to see if I can make it work, so I’ll use a pre-built KitKat image available here

Once you’ve you unzipped that image, you should have a file called BBB-aosp-4.4.4_r1-sd.img. Next we need to get it onto a MicroSD Card that we can use to boot the Beaglebone Black. You need a card at least 4gb in size. 8gb cards seem to be the smallest I could easily find, so that’s what I used.

To do this, you’ll need a few things:

a USB MicroSD Card Reader

Win32 Disk Imager, a free piece of software you can download here

Put the MicroSD card into your Card Reader and plug it into your PC. Run Win32 Disk Imager and click the little blue button to browse to the BBB-aosp-4.4.4_r1-sd.img we just downloaded.

Then, select the drive letter of your Card Reader in the Devices groupbox. Make sure you get this right, as whatever is on the drive you select will be deleted.

Here’s what mine looked like at this point:

Press the Write button, at which point Disk Imager will check with you once again that you got the drive letter correct. Confirm you did and it’ll start writing the disk image to the MicroSD card. This took between 15 minutes in the best case I saw, and 45 in the worst case. I think this was down to the quality of the SD card.

Step 2: Boot the Beaglebone Black into Android

Once Disk Imager is done, power off your BeagleBone Black and insert the SD Card into it (click the above image for a larger version). Hold down the Boot switch then apply power to the Beaglebone. Keep holding down the Boot switch until you see the USB Client LEDs start to flash. This tells the Beaglebone that you want to boot from the MicroSD card, not from the internal flash.

If you’re not sure where the Boot switch, the USB Client LEDs and the SD Card slot are located, click on the image above. In that image, the Boot switch is down near the corner at the bottom centre of the image, the SD Card slot is to the left of it and the USB Client LEDs are at the opposite end, to the right of the Ethernet port.

The very first time you do this, it’ll take a little longer as it needs to do some setup on the SD Card. Subsequent times it boots much more quickly.

You don’t need to have a monitor plugged in, but it’ll help with testing if you do. If you do have a monitor plugged in, shortly afterward you should see the Android home screen.

If you have a USB mouse plugged in, you’ll be able to run apps, change settings, etc. If you have an Ethernet cable plugged in, you should also be able to use the web browser.

Step 3 : Get it talking to Windows.

The first time this happened, I got very excited. “From here on in it should be easy”.

If all you want to do is run a FireMonkey app on it, it basically is. Get the APK onto it, say by downloading it from the browser, and you’re away.

However, I want to deploy from the IDE, so to do that we need to get it talking to Windows via a USB driver.

If you try plugging the Beaglebone Black into the USB port at this point, you won’t get very far. Windows will go looking for a USB driver that matches the idVendor and idProduct that the device reports, and it won’t find one for the Beaglebone.

If you bring up Device Manager, you’ll see it showing up under Other Devices with a sad little warning icon on it.

Never fear, we won’t let this stop us. Download the generic Android USB Driver and unzip it. That will give you a folder called usb_driver_r03-windows. In that you’ll find a file called android_winusb.inf. This is a text file so open it up in notepad.

If you’re on Win32, then you need to add an entry for the Beaglebone Black under the [Google.NTx86] section. If you’re on Win64, you’ll need to add it under [Google.NTamd64] . The entry you need to add is:

;Beaglebone Black %SingleAdbInterface% = USB_Install, USB\VID_18D1&PID_D002 %CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_D002&MI_01 1 2 3 ; Beaglebone Black % SingleAdbInterface % = USB_Install , USB \ VID_18D1 & PID_D002 % CompositeAdbInterface % = USB_Install , USB \ VID_18D1 & PID_D002 & MI_01

The key parts of this are the VID and PID sections. VID = Vendor ID and PID = Product ID. The Vendor ID for the Beaglebone is 18D1 and the Product ID is D002.

Adding these will mean that when windows checks to see if this driver works with this device, it’ll decide it does.

Save the file, then go back to the Device Manager. Right-click on the Beaglebone node and select Update Driver Software. Browse to the directory containing our modified USB Driver and click Next. You might get a warning about not being able to verify the publisher, don’t worry. Push on through and let it install the driver. Once done, you should see a screen like this:

If you now startup RAD Studio or AppMethod, create a new Multi Device Application, and go to the Project Manager, you should see Beaglebone Black showing up as a Target device.

Drop a TLabel on the form with some appropriate text and hit Run Without Debugging. It should build the project and then deploy it to the Beaglebone. Shortly afterward you should see your app running.

Unfortunately at this stage I haven’t managed to get Debugging working, but I think I know why. It seems to be related to this build of Android using an older kernel that doesn’t support the Secure USB Debugging that KitKat expects. I’m digging into this, but meantime I’ve used a mixture of debugging on other Android devices and also using a USB Serial Adapter to see debug messages.

Wrap-up

Hopefully that will get you up and started. Yes, we’ve ventured off the beaten track a little, but the Beaglebone Black is a board for experimenting, so that should be expected. When I get some time I want to explore accessing the GPIO ports on it to interact with external sensors and other components. I would love to hear what you end up doing with it.