Error in Bluetooth Status - Raspberry Pi - "Failed to set privacy: Rejected (0x0b)"

12.5k Views Asked by At

I'm in the very early stages of doing some Bluetooth Mesh work on my Raspberry Pi 4.

From the instructions I have found that a rebuild of the Kernel is required to enable the Crypto APIs that Mesh requires.

I am starting with

pi@pi-4:~ $ uname -a
Linux pi-4 5.10.63-v7l+ #1459 SMP Wed Oct 6 16:41:57 BST 2021 armv7l GNU/Linux
pi@pi-4:~ $ bluetoothd -v
5.55

And rebuilt the kernel using

git clone --depth=1 https://github.com/raspberrypi/linux
cd linux

KERNEL=kernel7l
make bcm2711_defconfig
vi .config # to customize the local name of the kernel build
make menuconfig

Of note, I have seen varying documents on which kernel options to set so I went with the superset of options. Set via a combination of vi and the UI. The resulting edits were

CONFIG_EXPERT=y
CONFIG_TIMERFD=y
CONFIG_EVENTFD=y
CONFIG_NET=y
CONFIG_BT=y
CONFIG_BT_RFCOMM=y
CONFIG_BT_RFCOMM_TTY=y
CONFIG_BT_BNEP=y
CONFIG_BT_BNEP_MC_FILTER=y
CONFIG_BT_BNEP_PROTO_FILTER=y
CONFIG_BT_HIDP=y
CONFIG_RFKILL=y
CONFIG_CRYPTO_USER=y
CONFIG_CRYPTO_USER_API_HASH=y
CONFIG_CRYPTO_USER_API_SKCIPHER=y
CONFIG_CRYPTO_MD5=y
CONFIG_CRYPTO_SHA1=y
CONFIG_KEY_DH_OPERATIONS=y
CONFIG_CRYPTO_USER_API_AEAD=y
CONFIG_CRYPTO_USER_API_HASH=y
CONFIG_CRYPTO_AES=y
CONFIG_CRYPTO_CCM=y
CONFIG_CRYPTO_AEAD=y
CONFIG_CRYPTO_CMAC=y

I also edited the statup command line option to turn off the SAP plug-in to get rid of that startup error.

KERNEL=kernel7l
make -j4 zImage modules dtbs
sudo make modules_install
sudo cp arch/arm/boot/dts/*.dtb /boot/
sudo cp arch/arm/boot/dts/overlays/*.dtb* /boot/overlays/
sudo cp arch/arm/boot/dts/overlays/README /boot/overlays/
sudo cp arch/arm/boot/zImage /boot/$KERNEL.img

pi@pi-4-x:~/ell-0.9/linux $ sudo reboot now
Connection to pi-4-x closed by remote host.
Connection to pi-4-x closed.
.
. reconnect
.

pi@pi-4:~ $ uname -a
Linux pi-4 5.10.90-v7l-With-BlueZ-Crypto+ #2 SMP Fri Jan 14 16:00:58 EST 2022 armv7l GNU/Linux

Now I am looking at this error when I check the status. This error is the SAME when using the BlueZ shipped with the distribution (5.55) and when rebuilding from source (5.63).

Any ideas?

Failed to set privacy: Rejected (0x0b)

pi@pi-4:~/linux $ sudo service bluetooth status
● bluetooth.service - Bluetooth service
     Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2022-01-18 11:32:44 EST; 11min ago
       Docs: man:bluetoothd(8)
   Main PID: 1726 (bluetoothd)
     Status: "Running"
      Tasks: 1 (limit: 3715)
        CPU: 59ms
     CGroup: /system.slice/bluetooth.service
             └─1726 /usr/libexec/bluetooth/bluetoothd --noplugin=sap

Jan 18 11:32:44 pi-4 systemd[1]: Starting Bluetooth service...
Jan 18 11:32:44 pi-4 bluetoothd[1726]: Bluetooth daemon 5.55
Jan 18 11:32:44 pi-4 systemd[1]: Started Bluetooth service.
Jan 18 11:32:44 pi-4 bluetoothd[1726]: Starting SDP server
Jan 18 11:32:44 pi-4 bluetoothd[1726]: Excluding (cli) sap
Jan 18 11:32:44 pi-4 bluetoothd[1726]: Bluetooth management interface 1.18 initialized
Jan 18 11:32:44 pi-4 bluetoothd[1726]: Failed to set privacy: Rejected (0x0b)
Jan 18 11:32:44 pi-4 bluetoothd[1726]: Endpoint registered: sender=:1.21 path=/MediaEndpoint/A2DPSink/sbc
Jan 18 11:32:44 pi-4 bluetoothd[1726]: Endpoint registered: sender=:1.21 path=/MediaEndpoint/A2DPSource/sbc
1

There are 1 best solutions below

3
On

Looks like this is caused by a timing issue in the service startup, where delay in a helper service fixes the problem (credit to the link provided by @ukBaz above). The solution that worked for me is shown below. I modified my prior answer to ensure the change would survive updates, by using a configuration override:

  1. Edit the file bthelper service configuration file via an override, using the example command below:
 sudo systemctl edit bthelper@
  1. Insert the following lines at to the top of the file, matching the example below:
 ### Editing /etc/systemd/system/[email protected]/override.conf
 ### Anything between here and the comment below will become the new contents of the file
 
 [Unit]
 After=hciuart.service bluetooth.service
 Before=
 
 [Service]
 ExecStartPre=/bin/sleep 5
 
 ### Lines below this comment will be discarded
  1. Checking the status after rebooting verifies the error has gone:
 $ service bluetooth status
 
 ● bluetooth.service - Bluetooth service
      Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
      Active: active (running) since Sat 2023-04-08 11:02:46 AEST; 1min 14s ago
        Docs: man:bluetoothd(8)
    Main PID: 560 (bluetoothd)
      Status: "Running"
       Tasks: 1 (limit: 4915)
         CPU: 69ms
      CGroup: /system.slice/bluetooth.service
              └─560 /usr/libexec/bluetooth/bluetoothd --noplugin=sap
 
 Apr 08 11:02:46 systemd[1]: Starting Bluetooth service...
 Apr 08 11:02:46 bluetoothd[560]: Bluetooth daemon 5.55
 Apr 08 11:02:46 systemd[1]: Started Bluetooth service.
 Apr 08 11:02:46 bluetoothd[560]: Starting SDP server
 Apr 08 11:02:46 bluetoothd[560]: Excluding (cli) sap
 Apr 08 11:02:46 bluetoothd[560]: Bluetooth management interface 1.21 initialized