Showing posts with label bluetooth. Show all posts
Showing posts with label bluetooth. Show all posts

2017/04/24

Lenovo Yoga 2 11" - Fixing Wifi and Bluetooth under Ubuntu 16.04.2

The Lenovo Yoga 2 11" convertible laptop has a compelling form factor and gives a solid impression. Unfortunately it's not a Linux-friendly laptop as far as wireless is concerned. Under Ubuntu 16.04.2 with a very recent 4.8 kernel, the wifi and bluetooth are not working. To add insult to injury, Lenovo has hardcoded the Broadcom wifi and bluetooth card in the UEFI bootloader, so the laptop refuses tot boot with any replacement wifi card I tested.

This post details how I managed to get the Broadcom wifi and bluetooth up and running under Ubuntu 16.04.2. Actually, I'm running KDE Neon which is built on 16.04, but the solution should be the same. I used a simple USB3 ethernet dongle for providing initial wired internet connectivity.

wifi

the following card is installed in my device:
$ lspci -nn | grep -i broad
01:00.0 Network controller [0280]: Broadcom Corporation
BCM43142 802.11b/g/n [14e4:4365] (rev 01)
steps to support the wifi card:
  • deactivate secure boot in the UEFI settings
  • install the following packages (run in a terminal)
sudo apt install bcmwl-kernel-source firmware-b43-installer
reference:  https://askubuntu.com/questions/55868/installing-broadcom-wireless-drivers

bluetooth

The bluetooth device is known in Linux as:
$ lsusb | grep Bluetooth
Bus 001 Device 006: ID 105b:e065 Foxconn International, Inc. BCM43142A0 Bluetooth module
By default, the firmware is missing due to legal concerns:
$ dmesg | grep -i blueto
[    7.060475] Bluetooth: Core ver 2.21
[    7.060503] Bluetooth: HCI device and connection manager initialized
[    7.061584] Bluetooth: HCI socket layer initialized
[    7.061593] Bluetooth: L2CAP socket layer initialized
[    7.061607] Bluetooth: SCO socket layer initialized
[    7.084378] Bluetooth: hci0: BCM: chip id 70
[    7.105106] Bluetooth: hci0: michael-Lenovo-Yoga-2-11
[    7.105112] Bluetooth: hci0: BCM (001.001.011) build 0000
[    7.110415] bluetooth hci0: Direct firmware load for brcm/BCM.hcd failed with error -2
[    7.110423] Bluetooth: hci0: BCM: Patch **brcm/BCM.hcd not found**
There is a Github repository with recent Broadcom bluetooth firmware files, so you don't have manually extract and convert the relevant files from the usb driver.

Install the BCM.hcd file in a terminal:
$ sudo apt install git
$ cd
$ git clone https://github.com/winterheart/broadcom-bt-firmware.git
$ cd broadcom-bt-firmware/brcm
$ ls -l BCM43142A*
Now pick and choose the file that matches the usb device id from the lsusb command above.
$ sudo cp BCM43142A0-105b-e065.hcd /lib/firmware/brcm/BCM.hcd
Finally power off / on your pc -- askubuntu explicitly advises against a simple reboot. In my case a simple modprobe cycle was enough:
$ sudo modprobe -r btusb
$ sudo modprobe btusb
Reference with much more in depth details: https://askubuntu.com/questions/632336/bluetooth-broadcom-43142-isnt-working


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:

2012/04/24

Bluetooth Connection of the Sunny Boy Inverter on Ubuntu


My photovoltaic panels are connected to the power grid through a Sunny Boy SB5000TL inverter. Although, this inverter comes out-of-the-box with bluetooth connectivity, this feature is only supported on Windows. Luckily, there exists a free tool that reads out the generation data on Linux: sma-bluetooth. This involves a few manual commands detailed in http://code.google.com/p/sma-bluetooth/wiki/ubuntu_compile_guide. The guide didn't work a 100% for me, so the next section details the steps I followed.

The code can be downloaded from http://code.google.com/p/sma-bluetooth.

In the terminal ( Ctl + Alt + T):
  • sudo apt-get install mysql-server mysql-client mysql-query-browser libmysqlclient-dev (the libmysqlclient-dev package is needed for compilation)
  • sudo apt-get install bluez libbluetooth-dev curl libcurl3 libcurl4-nss-dev
  • create a new Makefile in the sma-bluetooth-0.17 directory:
    gedit Makefile 
    
    Contents (make sure you use a tab, not spaces, in front of the gcc commands):
    smatool: smatool.o 
     
            gcc smatool.o -L/usr/lib -lmysqlclient -lbluetooth -lcurl -lm -o smatool  
     
    smatool.o: smatool.c 
     
            gcc -c smatool.c 
     
    
  • make
Now prepare the Bluetooth connection:
  • my bluetooth USB dongle is automatically up & read on ubuntu 11.10:
    $ lsusb | grep -i bluetooth 
    Bus 002 Device 002: ID 0a5c:4500 Broadcom Corp. BCM2046B1 USB 2.0 Hub (part of BCM2046 Bluetooth) 
    
  • hcitool scan
  • workaround if hcitool scan gives no result: (seehttps://help.ubuntu.com/community/BluetoothSetup#Setup_Devices for details)
    sudo hciconfig hci0 inqmode 0 
    
  • cp smatool.conf.new smatool.conf
  • gedit smatool.conf
    • modify the lines as explained in the comments
    • you can optionally upload your data to the excellent pvoutput.org service - see http://pvoutput.org/account.jsp for details:
      • get the API key
      • configure your unique SID
    • use the bluetooth password for 'normal' usage (by default 0000 in some devices). I had trouble with the different password reserved for maintenance.
If you use mysql:
  • install the database / create the tables (this requires a user with admin rights):
    ./smatool --INSTALL 
    
  • an empty password is not supported
Running:
  • ./smatool
  • debug & verbose can help identifying errors:
    ./smatool -d -v 
    
  • ./smatool -? lists out all options available
My pv-output: http://pvoutput.org/list.jsp?userid=9300

Next steps:
  • schedule the smatool in cron
  • replace mysql with sqlite for easier is
  • deploy the config on a plug computer