2012/05/12

Adding Bluetooth support to the TonidoPlug2


I'm planning to use my TonidoPlug2 (TP2) for reading out the electricity production of my solar panels. I attached a very small USB bluetooth dongle to my TP2. The USB bluetooth device is detected, but the default kernel has no bluetooth support:
root@TonidoPlug2:~# lsusb 
... 
Bus 001 Device 003: ID 0a5c:4500 Broadcom Corp. BCM2046B1 USB 2.0 Hub (part of BCM2046 Bluetooth) 
... 
The only solution to this problem is to build a new TP2 kernel with bluetooth enabled. The next section details the specific steps that did the trick for me.
Important note: Do NOT change the kernel on the internal flash memory as it might brick your device! Configure your TP2 to boot from the SATA HD first. I created a dedicated 32GB boot partition on my SATA device. Details:
Once you are booting from the SATA HD, you can proceed with the instructions below.

Building a TP2 kernel with bluetooth
The arm-kernel can be built on a linux desktop. I used my regular Ubuntu laptop.
First start with building a normal TP2 kernel:
After you built the kernel and modules you can enable bluetooth by modifying the .config file:
   make menuconfig 
  • Options to enable: (toggle by pressing 'space' until an * or M appears)
    • Networking → <*>Bluetooth subsystem support (CONFIG_BT)
    • Networking → Bluetooth subsystem support → <*>L2CAP protocol support (CONFIG_BT_L2CAP)
    • Networking → Bluetooth subsystem support → <*>SCO links support (CONFIG_BT_SCO)
    • Networking → Bluetooth subsystem support → <*>RFCOMM protocol support (CONFIG_BT_RFCOMM)
    • Networking → Bluetooth subsystem support → [*]RFCOMM TTY support (CONFIG_BT_RFCOMM_TTY)
    • Networking → Bluetooth subsystem support → <*>BNEP protocol support (CONFIG_BT_BNEP)
    • Networking → Bluetooth subsystem support → <*>HID protocol support (CONFIG_BT_HID)
    • Networking → Bluetooth subsystem support → Bluetooth device drivers → HCI USB driver (CONFIG_BT_HCIUSB)
  • this is how my .config file was modified:
    ~/tonido/kernel-2.6.31$ diff .config.old .config 
    4c4 
    < # Sat May 12 21:21:58 2012 
    --- 
    > # Sat May 12 22:24:11 2012 
    654c654,673 
    < # CONFIG_BT is not set 
    --- 
    > 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 is not set 
    > # CONFIG_BT_BNEP_PROTO_FILTER is not set 
    > CONFIG_BT_HIDP=y 
    >  
    > # 
    > # Bluetooth device drivers 
    > # 
    > CONFIG_BT_HCIBTUSB=m 
    > # CONFIG_BT_HCIBTSDIO is not set 
    > # CONFIG_BT_HCIUART is not set 
    > # CONFIG_BT_HCIBCM203X is not set 
    > # CONFIG_BT_HCIBPA10X is not set 
    > # CONFIG_BT_HCIBFUSB is not set 
    > # CONFIG_BT_HCIVHCI is not set 
    1351a1371,1372 
    > CONFIG_HID_APPLE=y 
    > CONFIG_HID_WACOM=y 
    
You can continue with the instructions for building a TP2 kernel at step 15:
make uImage 
... 
Some attention points with the last activation step:
  • remove two unnecessary symlinks before running scp:
    ~/tonido/kernel-2.6.31$ rm ../current_kernel/lib/modules/2.6.31.8-topkick1281p2-001-004-20101214/build 
    ~/tonido/kernel-2.6.31$ rm ../current_kernel/lib/modules/2.6.31.8-topkick1281p2-001-004-20101214/source 
    
  • run scp (don't forget the -r for a directory):
    ~/tonido/kernel-2.6.31$ scp ../current_kernel/boot/uImage root@tp2-ip:/boot 
    ~/tonido/kernel-2.6.31$ scp -r ../current_kernel/lib/modules root@tp2-ip:/lib/ 
    
  • double-check if all transfers were OK before rebooting
If the TP2 booted successfully you can now enable and test bluetooth:
  • apt-get install bluez
  • test with hcitool:
    root@TonidoPlug2:~# hcitool scan 
    Scanning ... 
     E4:D5:3D:EB:EA:E4 ubuntu-0 
     00:80:25:1F:9A:F4 SMA001d SN: ... 
    
Background info:

2 comments:

Anonymous said...

Hi,I tried the procedure and it failed to build the new kernel.

It started going wring from:
root@TonidoPlug2:/newkernel/kernel-2.6.31# make uImage
/opt/arm-marvell-linux-gnueabi/bin/arm-marvell-linux-gnueabi-gcc: 1:EL4X4: not found
/opt/arm-marvell-linux-gnueabi/bin/arm-marvell-linux-gnueabi-gcc: 2: Syntax error: "(" unexpected (expecting ")")
scripts/kconfig/conf -s arch/arm/Kconfig
/opt/arm-marvell-linux-gnueabi/bin/arm-marvell-linux-gnueabi-gcc: 1:EL4X4: not found
/opt/arm-marvell-linux-gnueabi/bin/arm-marvell-linux-gnueabi-gcc: 2: Syntax error: "(" unexpected (expecting ")")
CHK include/linux/version.h
UPD include/linux/version.h
Generating include/asm-arm/mach-types.h
CHK include/linux/utsrelease.h
UPD include/linux/utsrelease.h
SYMLINK include/asm -> include/asm-arm
CC kernel/bounds.s
/opt/arm-marvell-linux-gnueabi/bin/arm-marvell-linux-gnueabi-gcc: 1:EL4X4: not found
/opt/arm-marvell-linux-gnueabi/bin/arm-marvell-linux-gnueabi-gcc: 2: Syntax error: "(" unexpected (expecting ")")
make[1]: *** [kernel/bounds.s] Error 2
make: *** [prepare0] Error 2
root@TonidoPlug2:/newkernel/kernel-2.6.31# make modules
/opt/arm-marvell-linux-gnueabi/bin/arm-marvell-linux-gnueabi-gcc: 1:EL4X4: not found
/opt/arm-marvell-linux-gnueabi/bin/arm-marvell-linux-gnueabi-gcc: 2: Syntax error: "(" unexpected (expecting ")")
CHK include/linux/version.h
make[1]: `include/asm-arm/mach-types.h' is up to date.
CHK include/linux/utsrelease.h
SYMLINK include/asm -> include/asm-arm
CC kernel/bounds.s
/opt/arm-marvell-linux-gnueabi/bin/arm-marvell-linux-gnueabi-gcc: 1:EL4X4: not found
/opt/arm-marvell-linux-gnueabi/bin/arm-marvell-linux-gnueabi-gcc: 2: Syntax error: "(" unexpected (expecting ")")
make[1]: *** [kernel/bounds.s] Error 2
make: *** [prepare0] Error 2
root@TonidoPlug2:/newkernel/kernel-2.6.31# mkdir ../current_kernel
root@TonidoPlug2:/newkernel/kernel-2.6.31# mkdir ../current_kernel/boot
root@TonidoPlug2:/newkernel/kernel-2.6.31# make INSTALL_MOD_PATH=../current_kernel modules_install
/opt/arm-marvell-linux-gnueabi/bin/arm-marvell-linux-gnueabi-gcc: 1:EL4X4: not found
/opt/arm-marvell-linux-gnueabi/bin/arm-marvell-linux-gnueabi-gcc: 2: Syntax error: "(" unexpected (expecting ")")
DEPMOD 2.6.31.8-topkick1281p2-001-004-20101214
root@TonidoPlug2:/newkernel/kernel-2.6.31# cp arch/arm/boot/uImage ../current_kernel/boot/
cp: cannot stat `arch/arm/boot/uImage': No such file or directory
root@TonidoPlug2:/newkernel/kernel-2.6.31# cp arch/arm/boot/uImage ../current_kernel/boot/
cp: cannot stat `arch/arm/boot/uImage': No such file or directory
root@TonidoPlug2:/newkernel/kernel-2.6.31#

Thanks fro the help. I am trying to add a usb realtek rt8187.
I think i am taking the long way round!

Got any ideas?

Michaël said...

@anonymous:
It seems like you're trying to build a kernel from the TP2.
I built the kernel from a regular ubuntu-machine and then transferred (with scp) the kernel / modules to the TP2.