{"id":1613,"date":"2014-09-25T13:41:58","date_gmt":"2014-09-25T03:41:58","guid":{"rendered":"http:\/\/www.malcolmgroves.com\/blog\/?p=1613"},"modified":"2014-09-25T13:45:57","modified_gmt":"2014-09-25T03:45:57","slug":"running-firemonkey-apps-on-the-beaglebone-black","status":"publish","type":"post","link":"https:\/\/www.malcolmgroves.com\/blog\/?p=1613","title":{"rendered":"Running FireMonkey apps on the Beaglebone Black"},"content":{"rendered":"<p>This is the <a href=\"http:\/\/beagleboard.org\/black\" target=\"_blank\">Beaglebone Black<\/a><\/p>\n<p><a href=\"http:\/\/www.malcolmgroves.com\/blog\/wp-content\/uploads\/2014\/09\/beaglebone-black.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1614\" src=\"http:\/\/www.malcolmgroves.com\/blog\/wp-content\/uploads\/2014\/09\/beaglebone-black.jpg\" alt=\"Beaglebone Black\" width=\"300\" height=\"231\" \/><\/a><\/p>\n<p>It&#8217;s a single-board computer, about the size of a credit card. It&#8217;s powered by an\u00a0ARM Cortex A8 and includes the NEON floating point accelerator.\u00a0Happily that matches nicely with the <a href=\"http:\/\/docwiki.embarcadero.com\/RADStudio\/XE7\/en\/Installation_Notes_for_XE7#Requirements_for_Developing_Android_Applications\" target=\"_blank\">Android device requirements<\/a> for RAD Studio and AppMethod.<\/p>\n<p>When I saw that, I wondered what it would take to deploy a FireMonkey app to it. Like most things, it&#8217;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&#8217;ll be doing this from Linux. Given my aim of running\u00a0FireMonkey apps on the Beaglebone, I really wanted to show the steps from Windows.<\/p>\n<p>So here they are.<\/p>\n<p><!--more--><\/p>\n<h2>Step 1: Get an\u00a0Android image on a MicroSD card<\/h2>\n<p>The Beaglebone Black ships with a Linux distribution called Angstrom. So the first step is to get Android running on it instead.<\/p>\n<p>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&#8217;ll use a pre-built KitKat image available <a href=\"http:\/\/2net.co.uk\/downloads\/bbb-android\/BBB-aosp-4.4.4_r1-sd-img.zip\" target=\"_blank\">here<\/a><\/p>\n<p>Once you&#8217;ve you unzipped that image, you should have a file called\u00a0BBB-aosp-4.4.4_r1-sd.img. Next\u00a0we 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&#8217;s what I used.<\/p>\n<p>To do this, you&#8217;ll need a few things:<\/p>\n<ul>\n<li>a USB MicroSD Card Reader<\/li>\n<li>Win32 Disk Imager, a free piece of software you can download <a href=\"http:\/\/sourceforge.net\/projects\/win32diskimager\/\" target=\"_blank\">here<\/a><\/li>\n<\/ul>\n<p>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\u00a0BBB-aosp-4.4.4_r1-sd.img we just downloaded.<\/p>\n<p>Then, select the drive letter of your Card Reader in the Devices groupbox. <strong>Make sure you get this right, as whatever is on the drive you select will be deleted.<\/strong><\/p>\n<p>Here&#8217;s what mine looked like at this point:<\/p>\n<p><a href=\"http:\/\/www.malcolmgroves.com\/blog\/wp-content\/uploads\/2014\/09\/disk-imager.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1616\" src=\"http:\/\/www.malcolmgroves.com\/blog\/wp-content\/uploads\/2014\/09\/disk-imager.png\" alt=\"Disk Imager ready to go\" width=\"420\" height=\"215\" srcset=\"https:\/\/www.malcolmgroves.com\/blog\/wp-content\/uploads\/2014\/09\/disk-imager.png 420w, https:\/\/www.malcolmgroves.com\/blog\/wp-content\/uploads\/2014\/09\/disk-imager-300x153.png 300w\" sizes=\"auto, (max-width: 420px) 100vw, 420px\" \/><\/a><\/p>\n<p>Press the Write button, at which point Disk Imager will check\u00a0with you once again that you got the drive letter correct. Confirm you did and it&#8217;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.<\/p>\n<h2>Step 2: Boot the Beaglebone Black into Android<\/h2>\n<p><a href=\"http:\/\/www.malcolmgroves.com\/blog\/wp-content\/uploads\/2014\/09\/bbb_parts.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-1615\" src=\"http:\/\/www.malcolmgroves.com\/blog\/wp-content\/uploads\/2014\/09\/bbb_parts-300x200.jpg\" alt=\"Beaglebone Black Parts\" width=\"300\" height=\"200\" srcset=\"https:\/\/www.malcolmgroves.com\/blog\/wp-content\/uploads\/2014\/09\/bbb_parts-300x200.jpg 300w, https:\/\/www.malcolmgroves.com\/blog\/wp-content\/uploads\/2014\/09\/bbb_parts-535x357.jpg 535w, https:\/\/www.malcolmgroves.com\/blog\/wp-content\/uploads\/2014\/09\/bbb_parts.jpg 575w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>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\u00a0then apply power to the Beaglebone. Keep holding down the Boot switch\u00a0until you see the USB Client LEDs\u00a0start to flash. This tells the Beaglebone that you want to boot from the MicroSD card, not from the internal flash.<\/p>\n<p>If you&#8217;re not sure where the Boot switch, the USB Client LEDs\u00a0and the SD Card slot are located, click on the image above. In that image, the Boot switch\u00a0is 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.<\/p>\n<p>The very first time you do this, it&#8217;ll take a little longer as it needs to do some setup on the SD Card. Subsequent times it boots much more quickly.<\/p>\n<p><a href=\"http:\/\/www.malcolmgroves.com\/blog\/wp-content\/uploads\/2014\/09\/android-splash-screen.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1619\" src=\"http:\/\/www.malcolmgroves.com\/blog\/wp-content\/uploads\/2014\/09\/android-splash-screen.jpg\" alt=\"Android Splash Screen\" width=\"320\" height=\"240\" srcset=\"https:\/\/www.malcolmgroves.com\/blog\/wp-content\/uploads\/2014\/09\/android-splash-screen.jpg 320w, https:\/\/www.malcolmgroves.com\/blog\/wp-content\/uploads\/2014\/09\/android-splash-screen-300x225.jpg 300w\" sizes=\"auto, (max-width: 320px) 100vw, 320px\" \/><\/a><\/p>\n<p>You don&#8217;t need to have a monitor plugged in, but it&#8217;ll help with testing if you do. If you do have\u00a0a monitor plugged in, shortly afterward you should see the Android home screen.<\/p>\n<p><a href=\"http:\/\/www.malcolmgroves.com\/blog\/wp-content\/uploads\/2014\/09\/android-settings.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1620\" src=\"http:\/\/www.malcolmgroves.com\/blog\/wp-content\/uploads\/2014\/09\/android-settings.jpg\" alt=\"Andrid Settings\" width=\"320\" height=\"206\" srcset=\"https:\/\/www.malcolmgroves.com\/blog\/wp-content\/uploads\/2014\/09\/android-settings.jpg 320w, https:\/\/www.malcolmgroves.com\/blog\/wp-content\/uploads\/2014\/09\/android-settings-300x193.jpg 300w\" sizes=\"auto, (max-width: 320px) 100vw, 320px\" \/><\/a><\/p>\n<p>If you have a USB mouse plugged in, you&#8217;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.<\/p>\n<h2>Step 3 : Get it talking to Windows.<\/h2>\n<p>The first time this happened, I got very excited. &#8220;From here on in it should be easy&#8221;.<\/p>\n<p>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&#8217;re away.<\/p>\n<p>However, I want to deploy from the IDE, so to do that we need to get it talking to Windows via a USB driver.<\/p>\n<p>If you try plugging the Beaglebone Black into the USB port at this point, you won&#8217;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&#8217;t find one for the Beaglebone.<\/p>\n<p>If you bring up Device Manager, you&#8217;ll see it showing up under Other Devices with a sad little warning icon on it.<\/p>\n<p><a href=\"http:\/\/www.malcolmgroves.com\/blog\/wp-content\/uploads\/2014\/09\/bbb-device-manager.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1623\" src=\"http:\/\/www.malcolmgroves.com\/blog\/wp-content\/uploads\/2014\/09\/bbb-device-manager.png\" alt=\"Beaglebone in the Windows Device Manager\" width=\"214\" height=\"116\" \/><\/a><\/p>\n<p>Never fear, we won&#8217;t let this stop us.\u00a0Download the <a href=\"https:\/\/dl-ssl.google.com\/android\/repository\/usb_driver_r03-windows.zip\" target=\"_blank\">generic Android USB Driver<\/a> and unzip it. \u00a0That will give you a folder called usb_driver_r03-windows. In that you&#8217;ll find a file called android_winusb.inf. This is a text file so open it up in notepad.<\/p>\n<p>If you&#8217;re on Win32, then you need to add an entry for the Beaglebone Black under the\u00a0<span style=\"color: #232323;\">[Google.NTx86]<\/span>\u00a0section. If you&#8217;re on Win64, you&#8217;ll need to add it under\u00a0<span style=\"color: #232323;\">[Google.NTamd64]<\/span>\u00a0. The entry you need to add is:<\/p>\n<pre>;Beaglebone Black\r\n %SingleAdbInterface% = USB_Install, USB\\VID_18D1&amp;PID_D002\r\n %CompositeAdbInterface% = USB_Install, USB\\VID_18D1&amp;PID_D002&amp;MI_01<\/pre>\n<p>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.<\/p>\n<p>Adding these will mean that when windows checks to see if this driver works with this device, it&#8217;ll decide it does.<\/p>\n<p>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&#8217;t worry. Push on through and let it install\u00a0the driver. Once done, you should see a screen like this:<\/p>\n<p><a href=\"http:\/\/www.malcolmgroves.com\/blog\/wp-content\/uploads\/2014\/09\/driver-installed.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1624\" src=\"http:\/\/www.malcolmgroves.com\/blog\/wp-content\/uploads\/2014\/09\/driver-installed.png\" alt=\"ADB Driver installed\" width=\"400\" height=\"298\" srcset=\"https:\/\/www.malcolmgroves.com\/blog\/wp-content\/uploads\/2014\/09\/driver-installed.png 400w, https:\/\/www.malcolmgroves.com\/blog\/wp-content\/uploads\/2014\/09\/driver-installed-300x223.png 300w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>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.<\/p>\n<p><a href=\"http:\/\/www.malcolmgroves.com\/blog\/wp-content\/uploads\/2014\/09\/project-manager.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1625\" src=\"http:\/\/www.malcolmgroves.com\/blog\/wp-content\/uploads\/2014\/09\/project-manager.png\" alt=\"Beaglebone Black in the IDE Project Manager\" width=\"306\" height=\"324\" srcset=\"https:\/\/www.malcolmgroves.com\/blog\/wp-content\/uploads\/2014\/09\/project-manager.png 306w, https:\/\/www.malcolmgroves.com\/blog\/wp-content\/uploads\/2014\/09\/project-manager-283x300.png 283w\" sizes=\"auto, (max-width: 306px) 100vw, 306px\" \/><\/a><\/p>\n<p>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.<\/p>\n<p><a href=\"http:\/\/www.malcolmgroves.com\/blog\/wp-content\/uploads\/2014\/09\/hello-beaglebone.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1631\" src=\"http:\/\/www.malcolmgroves.com\/blog\/wp-content\/uploads\/2014\/09\/hello-beaglebone.jpg\" alt=\"Hello Beaglebone Black\" width=\"400\" height=\"300\" srcset=\"https:\/\/www.malcolmgroves.com\/blog\/wp-content\/uploads\/2014\/09\/hello-beaglebone.jpg 400w, https:\/\/www.malcolmgroves.com\/blog\/wp-content\/uploads\/2014\/09\/hello-beaglebone-300x225.jpg 300w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/a><\/p>\n<p>Unfortunately at this stage I haven&#8217;t managed to get Debugging working, but I think I know why. It seems to be related to this build\u00a0of Android using an older kernel that doesn&#8217;t \u00a0support the Secure USB Debugging that KitKat expects. I&#8217;m digging into this, but meantime I&#8217;ve used a mixture of debugging on other Android devices and also using a <a href=\"http:\/\/www.freetronics.com\/products\/usb-serial-adapter\" target=\"_blank\">USB Serial Adapter<\/a> to see debug messages.<\/p>\n<h2>Wrap-up<\/h2>\n<p>Hopefully that will get you up and started. Yes, we&#8217;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\u00a0external sensors and other components. I would love to hear what you end up doing with it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is the Beaglebone Black It&#8217;s a single-board computer, about the size of a credit card. It&#8217;s powered by an\u00a0ARM Cortex A8 and includes the NEON floating point accelerator.\u00a0Happily 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 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[121,122,120,105],"tags":[93,106],"class_list":["post-1613","post","type-post","status-publish","format-standard","hentry","category-android","category-beaglebone","category-firemonkey","category-iot","tag-android","tag-beaglebone"],"_links":{"self":[{"href":"https:\/\/www.malcolmgroves.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1613","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.malcolmgroves.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.malcolmgroves.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.malcolmgroves.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.malcolmgroves.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1613"}],"version-history":[{"count":14,"href":"https:\/\/www.malcolmgroves.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1613\/revisions"}],"predecessor-version":[{"id":1636,"href":"https:\/\/www.malcolmgroves.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1613\/revisions\/1636"}],"wp:attachment":[{"href":"https:\/\/www.malcolmgroves.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1613"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.malcolmgroves.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1613"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.malcolmgroves.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1613"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}