Enabling the UART / SPI / I2C on the Beagle Bone Black for Android

How can I enable the UART / SPI / I2C on the Beagle Bone Black for Android…please help me

Well, I can’t speak for the official TI releases, but I can provide you with instructions for my Android build based off of the 3.8 kernel.

Configuring the pin muxing, as well as associating kernel drivers to particular muxed pins, are performed by device tree overlays in the 3.8 kernel. This means that you can use the kernel command-line options for capemgr.enable_partno to load overlays that are part of the kernel proper. For example, you can add the following kernel command line option to the uEnv.txt to enable SPI0:

capemgr.enable_partno=BB-SPI0

… or enable UART1:

capemgr.enable_partno=BB-UART1

… or enable I2C1:

capemgr.enable_partno=BB-I2C1

… or the alternate pinmux for I2C1:

capemgr.enable_partno=BB-I2C1A1

… and so on and so forth. To enable multiple cape overlays, just separate them with a comma:

capemgr.enable_partno=BB-SPI0,BB-UART1

If you want to enable an overlay that conflicts with the HDMI, you’ll have to disable either the audio portion of the HDMI cape (HDMIN) or the entire cape using capemgr.disable_partno:

capemgr.disable_partno=BB-BONELT-HDMI,BB-BONELT-HDMIN (disable both)
capemgr.disable_partno=BB-BONELT-HDMIN (disable audio)

If you have a custom overlay that is not one that you have built into your kernel (capes in the firmware/capes directory of your Linux kernel source tree), you’ll have to install it in the /system/vendor/firmware directory in the root of your Android filesystem. I believe that /system/vendor is there, but you’ll have to create the “firmware” directory in it. This is analogous to copying your custom overlay into /lib/firmware on a Linux system. Just compile your overlay into a .dtbo file with dtc and then copy it into that directory. Loading the overlay is done by echo’ing the name of the overlay into the slot manager (just like on Linux):

echo MY_CAPE_NAME > /sys/devices/bone_capemgr.8/slots

You can do this over the FTDI cable via the root shell, or you can add the command to the bottom of your init.rc to do it automatically upon system start. The number for your capemgr might be different (bone_capemgr.9, for example). On Linux I echo into cone_capemgr.*, but I believe that is a bash-specific thing and you’ll have to list the explicit file when you do it via the Android system shell.

I’ve had students that I’ve worked with turn on several UARTs for communications, turn on SPI, etc. for their projects. Of course, unless you have a HAL set up to provide access to the device drivers exposed via the /dev filesystem, you’ll need to use native code to talk to the exposed devices in /dev and then act as the interface to your Java apps via JNI.

Andrew

capemgr.enable_partno=BB-SPI1,BB-UART1,BB-UART2,BB-UART4
I have added above line in uEnv.txt but nothing seems to happen.
One more thing Where can i put init script ( For echoing in capmanager slots) . Because i don’t find any init.d directory under /system. Can i create new init.d and then put myscript in it?

capemgr.enable_partno=BB-SPI1,BB-UART1,BB-UART2,BB-UART4
I tried above line . Putted it in uEnv.txt but it sees to do nothing. For using script to enable devices using init script but i can’t find init.d folder. How can i execute an init script on Android ( On your build)