Update: Korg Microkey Air 37 Bluetooth MIDI Keyboard with Raspberry Pi4 and Buster

  • by

Last year, in https://mclarenlabs.com/blog/2019/01/15/korg-microkey-air-37-bluetooth-midi-keyboard-with-raspberry-pi/, I described how to compile a Bluetooth update for your Pi and how to connect a Korg Bluetooth keyboard to your Pi wirelessly. Raspbian “Buster” includes bluez-5.50. The code for version 5.50 includes support for Bluetooth MIDI, but it is not enabled in the “Buster” distribution. This article describes what I discovered in compiling bluez-5.50 for “Buster” and how I installed it to get Bluetooth MIDI working on my Raspberry Pi4.

A Pristine Buster System

Before we start, let’s look at what is installed where in a standard Buster system.

In /etc/init.d/bluetooth, we see

DAEMON=/usr/sbin/bluetooth

and we see that /usr/sbin/bluetoothd is a symbolic link to /usr/lib/bluetooth/bluetoothd.

We see that /etc/systemd/system/bluetooth.target.wants/bluetooth.service is a hard link to (same file as) /etc/systemd/system/debus-org.bluez.service. In this file we see

[Service]
...
ExecStart=/usr/lib/bluetooth/bluetoothd

So anything starting bluetoothd is starting /usr/lib/bluetooth/bluetoothd.

Compile Bluez from Source

Using the instructions from our blog article a year ago, get compile and install bluez but this time get bluez-5.50. Here’s a quick summary.

$ curl -OL# http://www.kernel.org/pub/linux/bluetooth/bluez-5.50.tar.xz
$ tar -xvf bluez-5.50.tar.xz
$ cd bluez-5.50
$ ./configure --prefix=/usr --mandir=/usr/share/man --sysconfdir=/etc --localstatedir=/var --enable-experimental --enable-midi
$ make -j4
$ sudo make install

When you are all done, you will see another copy of bluetooth. This one is in /usr/libexec/bluetooth/bluetoothd. If we look in /etc/systemd/system/bluetooth.target.wants/bluetooth.service, we’ll see that the reference to the binary is updated to the new one. But it we look in /etc/init.d/bluetoothd, we’ll see that it is pointing to /usr/sbin/bluetoothd, which is a link to /usr/lib/bluetooth/bluetoothd, which is the old one.

We now have two copies of bluetoothd on our system and we need to sort it all out. Here is what I did.

$ pushd /usr/sbin
$ sudo mv bluetoothd bluetoothd.orig
$ sudo ln -s /usr/libexec/bluetooth/bluetoothd bluetoothd

Reboot and Pair

Now, if you reboot your system, you will get the new version of bluetoothd, with BLE MIDI enabled. Follow the instructions from before to disable SSP mode.

$ sudo hciconfig hci0 sspmode 0

and you should be able to pair your Korg Microkey Air 37 Bluetooth MIDI Keyboard with your Raspberry Pi4!

You can re-enable sspmode at this point if you want. The keyboard is already paired with the computer.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.