Difference between revisions of "Minnowboard:Adding Bluetooth Support To Your Kernel"
(→Setting up Bluetooth) |
m (corrected path) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
Requirements: | Requirements: | ||
# You have made it to the "Customize Your Build" step on the [http://elinux.org/Minnowboard:Building_Angstrom_Linux_for_the_MinnowBoard Building Angstrom Linux for the MinnowBoard] guide. | # You have made it to the "Customize Your Build" step on the [http://elinux.org/Minnowboard:Building_Angstrom_Linux_for_the_MinnowBoard Building Angstrom Linux for the MinnowBoard] guide. | ||
− | # A USB Bluetooth adapter. I used | + | # A USB Bluetooth adapter. I used an [http://lm-technologies.com/wireless-adapters/lm506-class-1-bluetooth-4-0-usb-adapter/ LM506] Bluetooth 4.0 USB adapter, but many other devices should work |
=== Adding kernel configs to the kernel recipe === | === Adding kernel configs to the kernel recipe === | ||
Line 66: | Line 66: | ||
== 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 useful script 'bluez-simple-agent', which can be used for pairing. | + | 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 bluez-simple-agent root@<your_minnowboard_ip>:/usr/local/bin | + | 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: | Now plug in your bluetooth USB dongle, and let's start pairing up with some Bluetooth devices! First, we start the service: | ||
Line 114: | Line 114: | ||
rfcomm listen hci0 & | 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' (free, see google play store) | + | 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 | minicom -D /dev/rfcomm0 | ||
− | After which you | + | After which you should be able to type text between phone and Minnowboard. |
Latest revision as of 08:08, 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:
- You have made it to the "Customize Your Build" step on the Building Angstrom Linux for the MinnowBoard guide.
- A USB Bluetooth adapter. I used an LM506 Bluetooth 4.0 USB adapter, but many other devices should work
Contents
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 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:
hciconfig
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.