Showing posts with label Linux Mint. Show all posts
Showing posts with label Linux Mint. Show all posts

Monday, October 5, 2020

Linux Mint: Install the proper firmware and set-up the USB-BT400 for linux

Objective


I wanted to set up my new USB-BT400 adapter working with Linux Mint.

Motivation


As a consequence of the actual corona-situation I had to use my headset in order to work from home. Since now, I only had a cheap wired one that I rarely used. Recently, my old headset somehow disassembled itself. Therefore, I thought, maybe it's better to buy a good one instead of a crappy cheap one, because I have to use it at a daily bases from now on. The headset should be of good quality and also fit well regarding UX, which means "no cables" anymore. My decision felt on the Sony XB900N. I also wanted to be able to use it not only with my laptop, but also with my desktop computer. Unfortunately, I have no bluetooth adapter assembled on it's mainboard. Therefore I decided to buy a bluetooth adapter, as well. My decision here, felt on the USB-BT400. The adapter and the headset worked well on Windows. I even could use the headset with my laptop out-of-the-box. Unfortunatelly, I recognized, when I wanted to use the bluetooth adapter in combination with the bluetooth headset on my desktop computer running my favorite OS Linux Mint Ulyana, the speakers of the headset work well, but the microphone was not recognized at all. Time to fix this!

Prerequisites


  • Linux Mint 20.0 Ulyana - Cinnamon (64 Bit)
  • USB-BT400
  • Any bluetooth headset with microphone (e.g. Sony XB900N)

Solution


Test if all works


First plug-in the bluetooth adapter into a free USB slot. Turn bluetooth on. Open the bluetooth device manager (e.g. default or blueman) and try find your bluetooth headset. Set it up, try to pair it and connect. If everything works fine, Good! Otherwise...

Check what the problem is


Open a terminal and type the following command:

$> sudo dmesg | egrep -i 'blue|firm'

you'll see some output similar to this:

[ 0.196061] Spectre V2 : Enabling Restricted Speculation for firmware calls
[ 1.011797] usb 3-6: Product: BCM920702 Bluetooth 4.0
[ 4.962537] Bluetooth: Core ver 2.22
[ 4.962552] Bluetooth: HCI device and connection manager initialized
...
[ 5.169217] Bluetooth: hci0: BCM20702A1 (001.002.014) build 1346
[ 5.172387] bluetooth hci0: Direct firmware load for brcm/BCM20702A1-0b05-17cb.hcd failed with error -2
[ 5.172390] Bluetooth: hci0: BCM: Patch brcm/BCM20702A1-0b05-17cb.hcd not found


Get the missing firmware and install it.


Navigate to USB-BT400 firmware and download the correct firmware for your device mentioned from the error message above, mine is BCM20702A1-0b05-17cb.hcd
$> cd /lib/firmware/brcm/
$> wget https://github.com/winterheart/broadcom-bt-firmware/
   blob/master/brcm/BCM20702A1-0b05-17cb.hcd
   && sudo mv BCM20702A1-0b05-17cb.hcd /lib/firmware/brcm/

you'll see some output similar to this:

Resolving github.com (github.com)... 140.82.121.3
Connecting to github.com (github.com)|140.82.121.3|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘BCM20702A1-0b05-17cb.hcd’
BCM20702A1-0b05-17cb.hcd [ <=> ] 80,47K --.-KB/s in 0,03s
2020-10-05 19:23:04 (2,26 MB/s) - ‘BCM20702A1-0b05-17cb.hcd’ saved [82403]


Verify that all is fine now


Reboot, and check again.
$> sudo dmesg | egrep -i 'blue|firm'

you'll see some output similar to this:

[ 0.196061] Spectre V2 : Enabling Restricted Speculation for firmware calls
[ 1.011797] usb 3-6: Product: BCM920702 Bluetooth 4.0
[ 4.962537] Bluetooth: Core ver 2.22
[ 4.962552] Bluetooth: HCI device and connection manager initialized
...
[ 5.979445] Bluetooth: hci0: BCM20702A1 (001.002.014) build 1467
[ 5.995451] Bluetooth: hci0: Broadcom Bluetooth Device


Open the bluetooth device manager (e.g. default or blueman) and try find your bluetooth headset. Set it up, try to pair it and connect. Navigate with your browser to a page to test your microphone online. Done!

References:

  1. Ubuntu forum discussing the issue
  2. Broadcom Bluetooth firmware for Linux kernel
  3. USB-BT400 firmware
  4. Online webcam, speaker and microphone test page

Friday, May 15, 2015

Install multiple versions of gcc at the same time

Objective


Install gcc/g++ version 4.9 and 5.1 on my current Linux Mint 17.1 Rebecca distribution. Use gcc 4.9 to compile the VirtualBox kernel driver.

Motivation


Recently I upgraded my gcc to version 5.1 via the Synaptic package manager as an suggested update. By doing this, my already installed version of gcc version 4.9 got lost. Few days later I updated my VirtualBox 4.3.26 to version 4.3.28. As a consequence of the update, all VirtualBox guest-systems refused to start, by claiming that I have update also the kernel drivers for virtualbox. Ok, no problem, as it gave me the command to do so ... but wait, I am running on an yet not officially supported kernel (as I explained in a previous post). The command updating or let's say compiling the kernel driver for VirtualBox miserably failed, due to a missing header file in gcc 5.1.

Prerequisites


  • Linux Mint 17.1 Rebecca
  • Kernel version 3.17.1
  • VirtualBox 4.3.28

Problem


The command to update the kernel driver for VirtualBox 4.3.26 was:

$> sudo /etc/init.d/vboxdrv setup

I still just had gcc 5.1 installed and unfortunatelly got the following error:

Stopping VirtualBox kernel modules ...done.
Uninstalling old VirtualBox DKMS kernel modules ...done.
Trying to register the VirtualBox kernel modules using DKMSError! Bad return status for module build on kernel: 3.17.1-031701-generic (x86_64)
Consult /var/lib/dkms/vboxhost/4.3.28/build/make.log for more information.
...failed!
(Failed, trying without DKMS)
Recompiling VirtualBox kernel modules ...failed!
(Look at /var/log/vbox-install.log to find out what went wrong)

The error in the log "/var/lib/dkms/vboxhost/4.3.28/build/make.log" mentioned above was ...

LD /var/lib/dkms/vboxhost/4.3.28/build/built-in.o
LD /var/lib/dkms/vboxhost/4.3.28/build/vboxdrv/built-in.o
CC [M] /var/lib/dkms/vboxhost/4.3.28/build/vboxdrv/linux/SUPDrv-linux.o
In file included from include/linux/compiler.h:54:0,
from /var/lib/dkms/vboxhost/4.3.28/build/vboxdrv/include/iprt/types.h:116,
from /var/lib/dkms/vboxhost/4.3.28/build/vboxdrv/include/VBox/types.h:30,
from /var/lib/dkms/vboxhost/4.3.28/build/vboxdrv/linux/../SUPDrvInternal.h:35,
from /var/lib/dkms/vboxhost/4.3.28/build/vboxdrv/linux/SUPDrv-linux.c:31:
include/linux/compiler-gcc.h:106:30: fatal error: linux/compiler-gcc5.h: No such file or directory
compilation terminated.
make[2]: *** [/var/lib/dkms/vboxhost/4.3.28/build/vboxdrv/linux/SUPDrv-linux.o] Error 1
make[1]: *** [/var/lib/dkms/vboxhost/4.3.28/build/vboxdrv] Error 2
make: *** [_module_/var/lib/dkms/vboxhost/4.3.28/build] Error 2

Solution


Install multiple versions of gcc


There is a very convenient package called update-alternatives to do the job of installing multiple versions of gcc and select the proper version for your current compile tasks.

To install just gcc/g++ 4.9 and gcc/g++ 5.1, first get rid of any other version by cleaning up the system:

$> sudo update-alternatives --remove-all gcc && sudo update-alternatives --remove-all g++

After the command returned you can install your required versions of gcc/g++:

$> sudo apt-get install gcc-4.9 gcc-5 g++-4.9 g++-5

Be patient because this may take a while if your don't have the packages allready installed.

If you get an error message like:

Paketlisten werden gelesen... Fertig
Abhängigkeitsbaum wird aufgebaut.
Statusinformationen werden eingelesen.... Fertig
Note, selecting 'gcc-4.9-base' for regex 'gcc-4.9'
E: Paket gcc-5 kann nicht gefunden werden.
E: Paket g++-4.9 kann nicht gefunden werden.
E: Mittels regulärem Ausdruck »g++-4.9« konnte kein Paket gefunden werden.
E: Paket g++-5 kann nicht gefunden werden.
E: Mittels regulärem Ausdruck »g++-5« konnte kein Paket gefunden werden.

You have to add a new repository "ppa:ubuntu-toolchain-r/test"
source first by exexuting:

$> sudo add-apt-repository ppa:ubuntu-toolchain-r/test
$> sudo apt-get update

Install the gcc versions in update-alternatives


To make update-alternatives aware of your installed compilers you have to execute the following additional installer commands:

$> sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 10
$> sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 20

$> sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 10
$> sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 20

$> sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
$> sudo update-alternatives --set cc /usr/bin/gcc

$> sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30
$> sudo update-alternatives --set c++ /usr/bin/g++

Configure update-alternatives


As a last step you have to configure the default commands for gcc, g++:
$> sudo update-alternatives --config gcc

If everything went well, you should be able to interactively choose which C-Compiler version you want to activate:

There are 2 choices for the alternative gcc (providing /usr/bin/gcc).

Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/gcc-5 20 auto mode
1 /usr/bin/gcc-4.9 10 manual mode
2 /usr/bin/gcc-5 20 manual mode

Press enter to keep the current choice[*], or type selection number: _


The same can be done for the C++-Compiler g++:

$> sudo update-alternatives --config g++

I've choosen gcc-4.9 and g++-4.9 for the moment.

Recompile the kernel module for VirtualBox with gcc 4.9


Finally, I typed again:

$> sudo /etc/init.d/vboxdrv setup

... and this time the update was successful:

Stopping VirtualBox kernel modules ...done.
Uninstalling old VirtualBox DKMS kernel modules ...done.
Trying to register the VirtualBox kernel modules using DKMS
...done.
Starting VirtualBox kernel modules ...done.
cschmidt@pippin:~$
cschmidt@pippin:~$ sudo /etc/init.d/vboxdrv setup
Stopping VirtualBox kernel modules ...done.
Uninstalling old VirtualBox DKMS kernel modules ...done.
Trying to register the VirtualBox kernel modules using DKMS ...done.
Starting VirtualBox kernel modules ...done.

As a last step I switched back to gcc/g++ 5.1 by the commands given above.

Have fun!