Installing a USB Bluetooth dongle on a Beagleboard xM running Android ICS

by Anton Weber

Some Android ready devices do not ship with any wireless modules on board. The easiest way to upgrade them for Bluetooth or WiFi connectivity are USB dongles.

I tried myself using a Beagleboard xM (runnign Android ICS) and a Bluetooth USB dongle with a Broadcom BCM2045 chip. Unfortunately it is not just a matter of plug and play, especially not on the kernel that ships with the rowboat Android port. 

Preparing the source

Board configuration

We need to modify the board configuration in <android_root>/device/ti/beagleboard/BoardConfig.mk and set:

BOARD_HAVE_BLUETOOTH := true

so the Android build system includes all Bluetooth components.

Kernel

We also want to add Bluetooth support and the Broadcom driver to the kernel. This is done by enabling following options in the <android_root>/kernel/.config

# BT components
CONFIG_BT=y
CONFIG_BT_L2CAP=y
CONFIG_BT_SCO=y
CONFIG_BT_RFCOMM=y
CONFIG_BT_RFCOMM_TTY=y
CONFIG_BT_BNEP=y
CONFIG_BT_BNEP_MC_FILTER=y
CONFIG_BT_BNEP_PROTO_FILTER=y
CONFIG_BT_HIDP=y
# Broadcom driver
CONFIG_BT_HCIBCM203X=y

Bluedroid workaround

Here comes the tricky part. Android uses a component named Bluedroid to power up/shut down the Bluetooth device through the rfkill interface. The problem is that Texas Instrument's kernel does not support rfkill.

A workaround is to give the Android system the impression, it is still in control, without actually using rfkill. For that we remove the affected lines and always return 1 on check_bluetooth_power().

Another problem is, that Bluedroid is starting or stopping the hciattach service on every call of bt_enable() and bt_disable(). hciattach is used to connect serial Bluetooth devices (e.g. connected through UART) to the Bluez stack. Since we are using USB instead, we don't need this service any longer. So we can get rid of these lines too.

The full patch is in the download section.

After this we can start the build and grab a few coffees while the build system does it's job.

Configuring the system

Once all files are on the SD card, there are only a few steps left.

init.rc

We need to start the Bluetooth service when booting up the system. So we add it to the init.rc:

service dbus /system/bin/dbus-daemon --system --nofork
class main
socket dbus stream 660 bluetooth bluetooth
user bluetooth
group bluetooth net_bt_admin
service bluetoothd /system/bin/bluetoothd -n
class main
socket bluetooth stream 660 bluetooth bluetooth
socket dbus_bluetooth stream 660 bluetooth bluetooth
# init.rc does not yet support applying capabilities, so run as root and
# let bluetoothd drop uid to bluetooth with the right linux capabilities
group bluetooth net_bt_admin misc
disabled

Enable Bluetooth feature

Now everything is installed and set up properly and the Bluetooth adapter is ready for use. The system just doesn't know it yet. We have to add the right <feature> tag in one of the files in /system/etc/permissions/. I created a new beagleboard_xm.xml file in that directory containing:

<permissions>
<feature name="android.hardware.bluetooth" />
</permissions>
 

And that's it!

tl_files/projects/beagleboard/bluetooth/bt_final_6am.jpg

Downloads

Bluedroid patch

References and Links

Most instructions were taken from the Texas Instruments Android DevKit Porting Guide.

Go back

Comments

Anton Weber

@Deepti
Are you trying to connect two Bluetooth dongles at the same time?

Deepti

Question : How can you connect 2 usb dongles with beaglebone? I am trying to connect 2 usb dongles with my beagleboard and I can only connect one at a time. I am unable to find a way to connect the second one.I tried through GUI and CL. I am using ubuntu box. TIA.

Chris

I forgot to mention that i already run my own version of ICS compiled from the rowboat sources so hopefully adding bluetooth should be fairly straightforward

Chris

I have just started with a home made tablet wich is built using the beaglebone and lcd3 cape and this might be just what i was looking for to add bluetooth next up is wifi

Pallab Das

@Mika31000 , how can you make it possible?

Anton Weber

@Pallab
Don't have access to the hardware anymore, so no video. But I'm sure you can find plenty of videos on how to build Android. Everything else is in the post above

Pallab Das

Can you please post a video on how to enable external BT device as stated above. That will be very helpful to follow. Thank you.

Fab

So, I have an Android media box running on Allwinner A20 so my question is where can I find proper kernel for this? It's a noname product so it doesn't have any support. Also if I built new kernel I will propably lose all of included devices like 2,4G remote control or optical audio out support. If someone knows anything about this I would be really thankful! :)

syamala

i had ported linux-3.2.8 on beagleboard-xm and i want to implement bluetooth on it. should i add bluetooth before porting itself or i can add after porting and recompile it

umair khan

I need to know that my device has WiFi but don't have Bluetooth. About thing your answer is there. But I need to know that how shall I enter in kernel of my tablet

sandesh

Here i'm using i.MX6Q sabrelite version processor and with WiFi-Bt chip(Atheros AR3012 + AR9485), with this chip, i'm able to bringup WiFi feature successfully and now try to bringup BTUSB interface.

I'm using Android JellyBean(4.2.2 freescale release version code), Android 4.2.2 version is using Bluedroid instead of BleuZ stack, i did following changes while bringup BTUSB feature:

1. How to Enable USB Bluetooth Dongle Based on i.MX6 Android ICS, This changes are already part of jellybean code.

2. Android JNI is directly calling Bluedroid enable API's to start android(in path external/bluetooth/bluedroid, instead of /system/bluetooth/bludroid)

3. when i ON the android from Android UI, it initialize the android stack and looking for libbt-vendor.so firmware and fails.

4. If i enable BOARD_USE_AR3K_BLUETOOTH := true BoardConfig.mk file, then i'm able to build libbt-vendor.so library which is looking by bt_hw module from bluedroid.

5. With libbt-vendor.so, it's looking for URTport(ttymxc4), which is not created in /dev/ttymxc4 path and even i tried to create for rfcomm and ttyUSB devices and no success.

For BT-USB dongle on android , what changes i need to do libbt-vendor library functions or no need to use libbt-vendor.so library?

How to communicate from Bluedroid stack to lower level driver ath3k.ko + btusb.ko driver.

It will helpful if anyone share the details fo BTUSB bringup on Android JellyBean.

Unknown

Does this support hotplugging?

Anton Weber

@Braian Unfortunately this is a very device specific process and there is no easy way to provide users with a universal patch. If you'd still like to give it a try, there are many instructions on the web on how to build your own Android kernel from source and how to modify the Android platform.

Braian Schmidt

Hi, i am from Argentina, i am a begginer. would you do a Begginer tutorial??

Mika31000

Worked on android 4.1.2 (from rowboat)
Thanks a lot !!!

freddy

Thanks for the reply. I can't find "BoardConfig.mk" or any ".mk" file. My tablet is a generic Allwinner a13 ARM Cortex A8. Any suggestion? Thanks.

Anton Weber

@Aman
The steps should be very similar. You'd just have to apply the changes to Bluedroid manually

Anton Weber

@freddy
The patch only applies to Bluedroid. You need to edit the BoardConfig.mk as well. Otherwise the build won't include all the Bluetooth components.

freddy

Hello.
Do you have to manually edit BoardConfig.mk or just apply the patch? Thanks

Aman gautam

Bro this tutorial is only for ICS.Can you please add a tutorial for Android 2.2 Froyo for us.Bro really i need this!

Anton Weber

@Rodrigo
It should as long as you have access to a Linux driver for the dongle and all source files

Rodrigo Felix Robazzi

This procedure works for any (china)tablet running android 4? with any bluetooth dongle?

trizio

Thanks for the answer.
I rebuilt the all system (with a lot of manual change) and now it works!

Anton Weber

@trizio
Once you set BOARD_HAVE_BLUETOOTH := true, you'll have to rebuild the rootfs. there probably is a way to just rebuild a selection of the affected modules, but I didn't have the time to look into that

And with your first issue, did you make sure that the device drivers are up and running properly? You can use some Android unrelated debug tools to make sure

Anton Weber

@Kars just run the patch command in the correct directory. for example, see http://www.cyberciti.biz/faq/appy-patch-file-using-patch-command/

Kars

Hi!
I'm a beginner, how do I install de patch?

trizio

I have one more doubt.
I do not find the file bluetoothd in /system/bin.
Should I rebuilt the rootfs too?
Please Help
Thanks for the tutorial

trizio

hi,
Thanks for the tutorial.

I have a BBxM rev C and I have compiled the kernel and I am sure my BB is using my Rebuilt Kernel (using uname -a I can read the date and a user string added before compiling it).
I have followed your guide and I have applied the patch to the file but the init.rc already contains booth services add on, I have created the file /system/etc/permissions/beagleboard_xm.xml
but after the boot I can see the settings/bluetooth menu but I can not switch it on.
I tried two different usb bluetooth dongle but I does not now the chip producer:

sh-3.2# usb 1-2.2: new full speed USB device using ehci-omap and address 7
usb 1-2.2: New USB device found, idVendor=0a12, idProduct=0001
usb 1-2.2: New USB device strings: Mfr=0, Product=2, SerialNumber=0
usb 1-2.2: Product: Bluetooth2.1+EDR CLASS1
select 1489 (m.android.email), adj 15, size 7583, to kill
send sigkill to 1489 (m.android.email), adj 15, size 7583

sh-3.2#
sh-3.2# usb 1-2.2: USB disconnect, address 7
usb 1-2.2: new full speed USB device using ehci-omap and address 8
usb 1-2.2: New USB device found, idVendor=0a12, idProduct=0001
usb 1-2.2: New USB device strings: Mfr=0, Product=0, SerialNumber=0

sh-3.2#
sh-3.2# usb 1-2.2: USB disconnect, address 8

Can you help me with some suggestion?

Regards and Thanks for the suggestion.

Nick

Good one here! I had a lot of problems with the USB BT dongle from Jan and finally let it go because I had other stuff up on my priority.

Will try this out now!
Thanks for the tutorial :)

vipul

dlink DWA-212 wifi dongle not working in same sinerio

Add a comment