Minnowboard:Adding Bluetooth Support To Your Kernel

From eLinux.org
Jump to: navigation, search

This guide will walk you through the steps necessary to add additional kernel modules to your Angstrom build, in order to properly support a Bluetooth USB adapter on your Minnowboard


  1. You have made it to the "Customize Your Build" step on the Building Angstrom Linux for the MinnowBoard guide.
  2. A USB Bluetooth adapter. I used an LM506 Bluetooth 4.0 USB adapter, but many other devices should work

Adding kernel configs to the kernel recipe

Let's start by creating a kernel .config addition file to the linux yocto recipe by running:

vim sources/meta-minnow/recipes-kernel/linux/linux-yocto/bluetooth.cfg

This will create a new file. I added the following kernel options to make it work, but many of these are probably not required for the device I used:


Adding a reference to our config file in the kernel recipe

Modify the "linux-yocto_3.8.bb" bitbake definition file by adding a reference to the newly created "bluetooth.cfg".

  SRC_URI = "git://git.yoctoproject.org/linux-yocto-3.8.git;protocol=git;nocheckout=1;branch=${KBRANCH},${KMETA},emgd-1.16;name=machine,meta,emgd \

Now proceed with the rest of your build

Once the above changes have been made, you can proceed onto the "Compile Time" steps in the Building Angstrom Linux for the MinnowBoard guide. When your image is running, you should see that the new modules have been compiled and installed in "/lib/modules/3.8.13-yocto-standard" (and that similarly, your kernel interfaces reflect the newly configured functionality)

Configuring Bluetooth once your image is running

First install the Bluez4 package. You can do this by adding it to your build, as described in Adding Additional Packages To Your Build, by adding a reference in your "setup-scripts/conf/local.conf" file:

IMAGE_INSTALL_append=" bluez4"

Note that installing the newer bluez5 package resulted in build-errors for me, not sure why, so I reverted back to bluez4.

Alternatively, you can install Bluez it after your build on your Minnowboard by doing:

opkg install bluez4

Setting up Bluetooth

Unfortunately, if you install the bluez4 package during build-time, the Angstrom image seems to be missing the very useful script 'bluez-simple-agent', which can be used for pairing. However, you can copy this Python script from Ubuntu to your Minnowboard (if Bluez is installed on your Ubuntu system of course):

 scp -r /usr/bin/bluez-simple-agent root@<your_minnowboard_ip>:/usr/local/bin

Now plug in your bluetooth USB dongle, and let's start pairing up with some Bluetooth devices! First, we start the service:

 systemctl enable bluetooth.service 

Apparently rfkill has a soft-block on the bluetooth device hci0 be default, so I had to unblock it first:

 rfkill unblock all && rfkill list             

We use hciconfig to see what bluetooth devices we have:


We should see an hci0. If not, do a lsusb to see if the dongle is there, and a lsmod to see if the kernel modules are loaded (btusb and others). Then we bring up the device, and tell it to scan:

 hciconfig hci0 up piscan

We give the service a name

 hciconfig hci0 name minnow

We then set the device to simple pairing mode. This prevents programming of pin-codes, and simply lets the 2 bluetooth endpoints verify each other by confirming a key.

 hciconfig hci0 sspmode 1                

Technically we are now ready to pair, but in my experiment I wanted to establish a serial protocol (SP) across bluetooth between my Android phone and my Minnowboard, so I had to enable that protocol:

 sdptool  add SP                                

Now let's go and find out who's out there! Make sure your BT device is discoverable. On my Android phone, I go to settings, bluetooth, and check the box 'make visible'

 hcitool scan                                      

You should see your device and a mac code. Now let's pair them up:

 bluez-simple-agent hci0 <my phone mac address>   

Minnow and phone will send eachother confirmation codes, which you are asked to verify, after which they are paired You really have to do this step only once, the bluetooth service remembers the fact that you're paired next boot. If, for some reason, you want to unpair:

 bluez-simple-agent hci0 <my phone mac address> remove   

For my experiment, I want to create a serial connection, so I use rfcomm to create one:

 rfcomm listen hci0 &

Your minnowboard will listen for a serial connection request from hci0 (paired with my phone). If found, rfcomm will set up a /dev/rfcomm0 node, which you can read and write from. Now I start a 'Bluetooth Terminal' app (free, see google play store) on my android phone, and connect to my paired minnow. Once connection is set up, I now have a /dev/rfcomm0 in my minnowBoard. To test out my serial communication:

 minicom -D /dev/rfcomm0

After which you should be able to type text between phone and Minnowboard.