
Android Hardware Interfacing with the BeagleBone Black
Description
Alles über E-Books | Antworten auf Fragen rund um E-Books, Kopierschutz und Dateiformate finden Sie in unserem Info- & Hilfebereich.
Book DescriptionIf you are an Android app developer who wants to experiment with the hardware capabilities of the BeagleBone Black platform, then this book is ideal for you. You are expected to have basic knowledge of developing Android apps but no prior hardware experience is required.What you will learn
Install Android on your BeagleBone Black Explore the three primary hardware interfaces of the BeagleBone Black-GPIO, SPI, and I2C Construct circuits that interface the BeagleBone Black with high-speed sensors, external memory chips, and more Discover the advantages and disadvantages of using GPIO, I2C, and SPI components in your interfacing projects Modify Android to recognize and interface with your own custom and prototype hardware Develop multithreaded apps that communicate directly with custom circuitry
Who this book is for
All prices
More details
Other editions
Additional editions

Persons
Content
Introducing Android and BeagleBone Black
Interfacing with Android
Handling inputs and outputs with GPIOs
Storing and retrieving data with I2C
Interfacing with high-speed sensors using SPI
Creating a complete interfacing solution
Where to go from here
Installing PacktHAL
All of the various pieces of PacktHAL are located in the PacktHAL.tgz file, which is available for download from Packt's website (http://www.packtpub.com/support). This is a compressed tar file that contains all of the source code and configuration files required to modify BBBAndroid to use PacktHAL and include PacktHAL support in your apps.
Preparing PacktHAL under Linux
Once you have downloaded the PacktHAL.tgz file, you must decompress and untar it. We will assume that you have copied PacktHAL.tgz to your home directory after downloading it and will decompress it from there. We will refer to your home directory as $HOME.
Use the Linux tar command to decompress and untar the file:
A directory named PacktHAL now exists in your $HOME directory. All of the PacktHAL files are located in this directory.
Preparing PacktHAL under Windows
Once you have downloaded the PacktHAL.tgz file, decompress and untar it. We will assume that you have copied PacktHAL.tgz to the root directory of the C: drive after downloading it and will use WinRAR to decompress it from there.
Tip
Where should I unpack PacktHAL.tgz?
You can decompress and untar PacktHAL.tgz on the desktop or wherever else you wish, but you will be performing some command-line commands to copy files around later. It is much simpler to perform these operations if PacktHAL.tgz is decompressed and untarred in the root directory of the C: drive, so we will assume that you are performing these operations from there.
Perform the following steps to extract the PacktHAL.tgz file:
- Open a file explorer window and navigate to the root of the
C:drive. - Right-click on the
PacktHAL.tgzfile in file explorer and select Extract Here.
A directory named C:\PacktHAL now exists. All of the PacktHAL files are located in this directory.
The PacktHAL directory structure
The PacktHAL directory has the following structure:
The cape subdirectory contains the source code and build script for building a Device Tree overlay that enables all of the hardware features that PacktHAL needs. You will learn more about Device Tree overlays later in this chapter. The jni subdirectory contains the source code files that implement PacktHAL. These source files will be added to your projects in later chapters to build PacktHAL support into your apps. The prebuilt directory contains a few premade files that must be added to your BBBAndroid image and Android NDK to build and use PacktHAL. You will install the files in the prebuilt directory to their required locations in the next few sections.
Preparing Android for PacktHAL
Before using PacktHAL with any apps, you have to prepare your BBBAndroid installation. By default, Android is very restrictive on the permissions that it assigns to hardware devices. To use PacktHAL, you must lessen the permission restrictions and configure Android for the hardware that you will interface with. These actions require copying some prebuilt files into your Android system to make a few configuration changes that relax various Android permissions and configure the hardware properly for PacktHAL's use.
You will use the ADB tool to push (push) the necessary files over to your running BBB system. Prior to pushing the files, boot Android on the BBB and connect the BBB to your PC using the USB cable that came with your BBB. Once you have reached this point, continue with the instructions.
Pushing PacktHAL files under Linux
The following steps are used in order to publish PacktHAL files under Linux:
- Before you get started, make sure that ADB can see your BBB by using the
adb devicescommand. The BBB will report as having a serial number ofBBBAndroid. Execute the following command: $ adb devices List of devices attached BBBAndroid device - If you are missing the
adbcommand, install theandroid-tools-adbpackage viaapt-get: $ sudo apt-get install android-tools-adbTip
Why can't Linux find my BBB?
If
adbis installed on your system and you are unable to see the BBB, you might need to add audevrule to your system and perform some additional troubleshooting. Google provides directions for adding this rule and some troubleshooting steps if you run into any difficulty, and this can be found at http://developer.android.com/tools/device.html.BBBAndroid reports the USB device ID of its ADB interface as
18D1:4E23, which is the device ID of a Google Nexus S, so the USB vendor ID for the BBB is 18D1 (the device ID for Google devices). - Once you have verified that
adbcan see the BBB, change into thePacktHALdirectory, shell into Android viaadb, and remount the read-onlyrootfsfilesystem as read-write: $ cd $HOME/PacktHAL/prebuilt $ adb shell root@beagleboneblack:/ # mount rootfs rootfs / rw root@beagleboneblack:/ # exit - Now, push the necessary files into Android's
rootfsfilesystem: $ adb push BB-PACKTPUB-00A0.dtbo /system/vendor/firmware $ adb push init.genericam33xx\(flatteneddevicetr.rc / $ adb chmod 750 /init.genericam33xx\(flatteneddevicetr.rc - Finally, shell into Android's
rootfsfilesystem to sync it and remount it as read-only: $ adb shell root@beagleboneblack:/ # sync root@beagleboneblack:/ # mount rootfs rootfs / ro remount root@beagleboneblack:/ # exit - You have now prepared your BBBAndroid image for PacktHAL under Linux. Remove the power supply cable and USB cable from your BBB to shut it down.
- Then, power up the BBB to verify that Android boots properly with the modifications that you have just made.
Pushing PacktHAL files under Windows
You must locate where your adb.exe file is located. It is part of the platform tools in the Android SDK. In the following instructions, we are assuming that you installed the Eclipse ADT in the c:\adt-bundle directory, making the full path to adb to be c:\adt-bundle\sdk\platform-tools\adb.exe.
The following steps are used in order to publish PacktHAL files under Windows:
- Before you get started, make sure that
adbcan see your BBB by using theadb devicescommand. The BBB will report as having a serial number ofBBBAndroid: $ adb devices List of devices attached BBBAndroid deviceTip
Why can't Windows find my BBB?
It can be notoriously difficult to get
adbto see Android devices under Windows. This is because each hardware manufacturer that creates an Android device provides its own Windows ADB device driver that Windows uses to talk to that device. BBBAndroid reports the USB device ID of its ADB interface as18D1:4E23, which is the device ID of a Google Nexus S. This device is one of the (many) USB devices that are supported by Koushik Dutta's excellent Universal ADB driver for Windows. Ifadbcan't find your BBB, install the Universal ADB driver and then try again. You can download the driver from http://www.koushikdutta.com/post/universal-adb-driver. - Once you have verified this,
adbcan see the BBB, shell into Android viaadb, and remount the read-onlyrootfsfilesystem as read-write: $ adb shell root@beagleboneblack:/ # mount rootfs rootfs / rw root@beagleboneblack:/ #...
System requirements
File format: ePUB
Copy protection: Adobe-DRM (Digital Rights Management)
System requirements:
- Computer (Windows; MacOS X; Linux): Install the free reader Adobe Digital Editions prior to download (see eBook Help).
- Tablet/smartphone (Android; iOS): Install the free app Adobe Digital Editions or the app PocketBook before downloading (see eBook Help).
- E-reader: Bookeen, Kobo, Pocketbook, Sony, Tolino and many more (not Kindle).
The file format ePub works well for novels and non-fiction books – i.e., „flowing” text without complex layout. On an e-reader or smartphone, line and page breaks automatically adjust to fit the small displays.
This eBook uses Adobe-DRM, a „hard” copy protection. If the necessary requirements are not met, unfortunately you will not be able to open the eBook. You will therefore need to prepare your reading hardware before downloading.
Please note: We strongly recommend that you authorise using your personal Adobe ID after installation of any reading software.
For more information, see our ebook Help page.
File format: PDF
Copy-Protection: Adobe-DRM (Digital Rights Management)
System requirements:
- Computer (Windows; MacOS X; Linux): Install the free reader Adobe Digital Editions prior to download (see eBook Help).
- Tablet/smartphone (Android; iOS): Install the free app Adobe Digital Editions or the app PocketBook before downloading (see eBook Help).
- E-reader: Bookeen, Kobo, Pocketbook, Sony, Tolino and many more (only limited: Kindle).
The file format PDF always displays a book page identically on any hardware. This makes PDF suitable for complex layouts such as those used in textbooks and reference books (images, tables, columns, footnotes). Unfortunately, on the small screens of e-readers or smartphones, PDFs are rather annoying, requiring too much scrolling.
This eBook uses Adobe-DRM, a „hard” copy protection. If the necessary requirements are not met, unfortunately you will not be able to open the eBook. You will therefore need to prepare your reading hardware before downloading.
Please note: We strongly recommend that you authorise using your personal Adobe ID after installation of any reading software.
For more information, see our eBook Help page.