Difference between revisions of "Minnowboard:Adding Bluetooth Support To Your Kernel"

From eLinux.org
Jump to: navigation, search
(Created page with " 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 Min...")
 
(Configuring wireless ethernet once your image is running)
Line 57: Line 57:
 
First install the Bluez4 package. You can do this by adding it to your build, as described in [http://elinux.org/Minnowboard:Adding_Additional_Packages_To_Your_Build Adding Additional Packages To Your Build], by adding a reference in your "setup-scripts/conf/local.conf" file:
 
First install the Bluez4 package. You can do this by adding it to your build, as described in [http://elinux.org/Minnowboard:Adding_Additional_Packages_To_Your_Build Adding Additional Packages To Your Build], by adding a reference in your "setup-scripts/conf/local.conf" file:
  
IMAGE_INSTALL_append=" bluez4"
+
IMAGE_INSTALL_append=" bluez4"
  
Note that installing bluez5 resulted in build-errors for me, not sure why, so I reverted back to 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 Monniwboard by doing:
 
Alternatively, you can install Bluez it after your build on your Monniwboard by doing:
  
opkg install bluez4
+
opkg install bluez4
  
=== Setting up Bluetooth ===
+
== Setting up Bluetooth ==
  
Unfortunately, if you install the bluez4 package during build-time, the Angstrom image seems to be missing the very usefull script
+
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. You can copy this Python script from Ubuntu to your Minnowboard:
 +
 
 +
  scp -r bluez-simple-agent root@<your_Minnowboard_ip>:/usr
 +
 
 +
Now plug in your bluetooth USB dingle, 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:
 +
 
 +
  hciconfig
 +
 
 +
We should see an hci0. If not, do a lsusb to see if the dingle 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                                      #lists available devices, my phone was found
 +
 
 +
bluez-simple-agent hci0 <my phone mac address>  # Note I had to copy this script from another system, it was not on my image
 +
 
 +
#  Minnow and phone will ask a few questions, after which they are paired
 +
# Now set up serial connection through phone
 +
 
 +
rfcomm listen hci0 &
 +
 
 +
# Now I start a 'Bluetooth Terminal' app on my android phone, and connect to my paired minnow. Once connection is set up, I now have a /dev/rfcomm0 in my minnowBoard. Test out serial communication:
 +
 
 +
minicom -D /dev/rfcomm0
 +
 
 +
# now I can type text between phone and minnowboard.

Revision as of 05:44, 28 August 2014

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

Requirements:

  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 a 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:

CONFIG_BT=m CONFIG_BT_RFCOMM=m CONFIG_BT_RFCOMM_TTY=y CONFIG_BT_BNEP=m CONFIG_BT_BNEP_MC_FILTER=y CONFIG_BT_BNEP_PROTO_FILTER=y CONFIG_BT_CMTP=m CONFIG_BT_HIDP=m CONFIG_BT_L2CAP=m CONFIG_BT_SCO=m CONFIG_BT_HCIUSB=m CONFIG_BT_HCIUSB_SCO=m CONFIG_BT_HCIBTUSB=m CONFIG_BT_HCIBTSDIO=m CONFIG_BT_HCIUART=m CONFIG_BT_HCIUART_H4=y CONFIG_BT_HCIUART_BCSP=y CONFIG_BT_HCIUART_ATH3K=y CONFIG_BT_HCIUART_LL=y CONFIG_BT_HCIUART_3WIRE=y CONFIG_BT_HCIBCM203X=m CONFIG_BT_HCIBPA10X=m CONFIG_BT_HCIBFUSB=m CONFIG_BT_HCIDTL1=m CONFIG_BT_HCIBT3C=m CONFIG_BT_HCIBLUECARD=m CONFIG_BT_HCIBTUART=m CONFIG_BT_HCIVHCI=m CONFIG_BT_MRVL=m CONFIG_BT_MRVL_SDIO=m CONFIG_BT_ATH3K=m CONFIG_BT_WILINK=m


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 \
             file://bluetooth.cfg"

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 wireless ethernet 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 Monniwboard 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. You can copy this Python script from Ubuntu to your Minnowboard:

 scp -r bluez-simple-agent root@<your_Minnowboard_ip>:/usr

Now plug in your bluetooth USB dingle, 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:

 hciconfig

We should see an hci0. If not, do a lsusb to see if the dingle 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                                      #lists available devices, my phone was found

bluez-simple-agent hci0 <my phone mac address> # Note I had to copy this script from another system, it was not on my image

  1. Minnow and phone will ask a few questions, after which they are paired
  2. Now set up serial connection through phone

rfcomm listen hci0 &

  1. Now I start a 'Bluetooth Terminal' app on my android phone, and connect to my paired minnow. Once connection is set up, I now have a /dev/rfcomm0 in my minnowBoard. Test out serial communication:

minicom -D /dev/rfcomm0

  1. now I can type text between phone and minnowboard.