Pi 4 Bluetooth not working, Sap driver failed

Got a new Raspberry Pi 4, configured IPv6, installed and activated samba services on it. Initially I ran sudo rfkill block bluetooth and wifi as I wasn’t going to use those, but I had changed my mind as now I’d like to use a bluetooth keyboard with it. So I ran sudo rfkill unblock bluetooth

On Raspberry OS’s screen, when going to the bluetooth UI to add a new device, nothing is shown. In the terminal, typing sudo hcitool scan shows:

    pi@raspberrypi:~ $ sudo hcitool scan
    Device is not available: No such device

Running “sudo service bluetooth status” shows a lot, and then this:

    May 12 19:54:46 raspberrypi bluetoothd[626]: Bluetooth management interface 1.18 initialized
    May 12 19:54:46 raspberrypi bluetoothd[626]: Sap driver initialization failed.
    May 12 19:54:46 raspberrypi bluetoothd[626]: sap-server: Operation not permitted (1)
    May 12 19:54:46 raspberrypi bluetoothd[626]: Failed to set privacy: Rejected (0x0b)
    May 12 19:54:46 raspberrypi bluetoothd[626]: Failed to set device class: Not Powered (0x0f)

I have tried running sudo bluetoothhctl to add pi as a bluetooth agent, but pi already is one. I have added pi to the bluetooth user group, but that has done nothing. Any advice is appreciated, though I’d rather not have to format and reimage as IPv6 is a real pain to set up.

After more searching I’ve tried the method here: SAP error on bluetooth service status - Raspberry Pi Stack Exchange which involves disabling the SAP plugin (which is apparently for SIM card access?). Now the output for sudo service bluetooth status is:

May 12 20:33:20 raspberrypi bluetoothd[1583]: Bluetooth management interface 1.18 initialize
May 12 20:33:20 raspberrypi bluetoothd[1583]: Endpoint registered: sender=:1.30 path=/MediaE
May 12 20:33:20 raspberrypi bluetoothd[1583]: Endpoint registered: sender=:1.30 path=/MediaE
May 12 20:33:22 raspberrypi bluetoothd[1583]: Loading LTKs timed out for hci0
May 12 20:33:30 raspberrypi bluetoothd[1583]: Failed to set mode: Failed (0x03)

The bluetooth still does not work.

Edit: Rebooting the Pi twice has now fixed it. On the first reboot it seemed like the device had bricked, but after two minutes it booted successfully. Rebooting again makes everything work as normal. Guess this topic is just for prosperity now.

Edit 2: Actually attempting to pair a device fails consistently. The first error message was something about GDBus.Error:org.bluez.Error:Failed but I can’t remember what it said. Now all it says is GDBus.Error:org.bluez.Error.AlreadyExists: Already Exists. I cannot remove the device as it doesn’t appear in the list of the ‘Forget device’ dialog.

Hmm, have you configured your locale? The radios are disabled until you do this to prevent inadvertently breaching RF rules of different countries.

I did, from raspi-config. When logging into SSH it no longer states ‘rfkill currently blocking wifi!’ Is there another specific-to-wifi command I need to set for its locale?

The output from sudo service bluetooth status is now

May 12 20:40:36 raspberrypi bluetoothd[625]: Bluetooth management interface 1.18 initialized
May 12 20:40:36 raspberrypi bluetoothd[625]: Failed to set privacy: Rejected (0x0b)
May 12 20:40:36 raspberrypi bluetoothd[625]: Failed to set device class: Not Powered (0x0f)

Edit: I noticed this topic: Bluetooth issues with 8BitDo SN30pro on Rasp Pi 4 with Retropie - #7 by Richard154847 having a similar issue with Retropie, which lead to someone suggesting this older solution: Raspberry Pi 4 won't pair to bluetooth devices - Raspberry Pi Stack Exchange which delays the startup of the bluetooth service. I’ve tried editing the configuration file to do the same and now the output from sudo service bluetooth status is:

May 13 09:45:47 raspberrypi bluetoothd[718]: Bluetooth management interface 1.18 initialized
May 13 09:45:47 raspberrypi bluetoothd[718]: Failed to clear UUIDs: Busy (0x0a)
May 13 09:45:47 raspberrypi bluetoothd[718]: Failed to set mode: Busy (0x0a)
May 13 09:45:47 raspberrypi bluetoothd[718]: Failed to add UUID: Busy (0x0a)
May 13 09:45:47 raspberrypi bluetoothd[718]: Failed to add UUID: Busy (0x0a)
May 13 09:45:47 raspberrypi bluetoothd[718]: Failed to add UUID: Busy (0x0a)
May 13 09:45:47 raspberrypi bluetoothd[718]: Failed to set device class: Busy (0x0a)

Bluetooth scanning now appears to start

pi@raspberrypi:~ $ sudo hcitool scan
Scanning ...

however nothing ever appears…

1 Like

I have found a partial solution for anyone else looking into this, the post at RPi4 Bluetooth woes - Raspberry Pi Forums explains that this is a known issue and a fix has been deployed, but it’s not in the repositories yet. Running the following will import a static version of bthelper which should fix the issues:

wget https://raw.githubusercontent.com/RPi-Distro/pi-bluetooth/master/usr/bin/bthelper
sudo cp bthelper /usr/bin

Keep in mind that doing this will mean bthelper will never be updated again until you undo it.

Now for the sad part, I have confirmed that this is working with a pair of bluetooth speakers, however my bluetooth keyboard is just not appearing in the list of pairable devices. I’ll troubleshoot this in my own time and update this topic.

1 Like

I’m going to scream. The bluetooth keyboard enters a pretend pairing mode if it’s currently being charged, but doesn’t actually turn on its own bluetooth. When taking it off charge it connects, pairs and functions perfectly, flawllessly with my two Android devices (one old Android 6 device, and a new Android 10 device). On the Pi, the keyboard now appears in the list of pairable devices, but attempting to pair with it freezes the dialog box.

I tried turning the Pi

o f f

and then back

o n

now everything works perfectly fine.

2 Likes

Oh dear. Don’t look a gift horse in the mouth I guess!

I’m back. If I ever turn the bluetooth keyboard off and back on, it takes about two minutes for the keyboard to find and connect to the Pi. Since I intended to use the keyboard infrequently to check on the Pi when waiting on other tasks, this makes it not viable (it would be quicker to turn on my main computer, ssh into the Pi and check what I want). Unless someone has a magic bullet that could fix this issue, I’m just going to give up and buy a wireless USB keyboard.

Also if I’m using the bluetooth speaker and keyboard at the same time, they interfere with each other making both unbearably choppy/unresponsive. Not that I intended to do that, but being denied the possibility is not a good sign.

But hey at least I helped other people fix their issue so good did come out of all of this.

3 Likes