E-Book, Englisch, 134 Seiten
Henderson / Prakash Android Hardware Interfacing with the BeagleBone Black
1. Auflage 2025
ISBN: 978-1-78439-345-8
Verlag: De Gruyter
Format: PDF
Kopierschutz: Adobe DRM (»Systemvoraussetzungen)
Design and implement Android apps that interface with your own custom hardware circuits and the BeagleBone Black
E-Book, Englisch, 134 Seiten
ISBN: 978-1-78439-345-8
Verlag: De Gruyter
Format: PDF
Kopierschutz: Adobe DRM (»Systemvoraussetzungen)
If 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.
Autoren/Hrsg.
Weitere Infos & Material
Installing PacktHAL
All of the various pieces of PacktHAL are located in the 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 file, you must decompress and untar it. We will assume that you have copied to your home directory after downloading it and will decompress it from there. We will refer to your home directory as .
Use the Linux command to decompress and untar the file:
A directory named now exists in your directory. All of the PacktHAL files are located in this directory.
Preparing PacktHAL under Windows
Once you have downloaded the file, decompress and untar it. We will assume that you have copied to the root directory of the 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 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 is decompressed and untarred in the root directory of the drive, so we will assume that you are performing these operations from there.
Perform the following steps to extract the file:
- Open a file explorer window and navigate to the root of the drive.
- Right-click on the file in file explorer and select Extract Here.
A directory named now exists. All of the PacktHAL files are located in this directory.
The PacktHAL directory structure
The directory has the following structure:
The 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 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 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 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 () 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 command. The BBB will report as having a serial number of . Execute the following command: $ adb devices List of devices attached BBBAndroid device
- If you are missing the command, install the package via : $ sudo apt-get install android-tools-adb
Tip
Why can't Linux find my BBB?
If is installed on your system and you are unable to see the BBB, you might need to add a rule 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 , 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 can see the BBB, change into the directory, shell into Android via , and remount the read-only filesystem 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 filesystem: $ 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 filesystem 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 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 directory, making the full path to to be .
The following steps are used in order to publish PacktHAL files under Windows:
- Before you get started, make sure that can see your BBB by using the command. The BBB will report as having a serial number of : $ adb devices List of devices attached BBBAndroid device
Tip
Why can't Windows find my BBB?
It can be notoriously difficult to get to 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 as , 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. If can'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, can see the BBB, shell into Android via , and remount the read-only filesystem as read-write: $ adb shell root@beagleboneblack:/ # mount rootfs rootfs / rw root@beagleboneblack:/ #...




