lost
Posts: 39
Joined: Tue Dec 05, 2017 9:38 am

PI3B bluetooth issue (latest kernel update?)

Thu Aug 26, 2021 4:37 am

Hello,

I'm running a "Raspberry Pi 3 Model B Rev 1.2" for house management & (manually) triggered an update (was including kernel) last week-end. Since then, I had 3 bluetooth "stuck" issues.

Kernel : 5.10.52-v7+ #1441 SMP Tue Aug 3 18:10:09 BST 2021 armv7l GNU/Linux

In my system, I only use BT to know about family members presence to tune home management. No full connect, only a name lookup python script updating any device presence every 10s when absent & 10mn when present (to avoid draining devices battery too much with lookup request answers).

When issue occurs, no error reported from bluetooth.lookup_name() in python script. So absence flags are then faulty set for anyone after a few minutes.

Here is the btmon picture when the BT hardware is faulty (BT presence monitor script was stopped, no capture during 71s, then started):

Code: Select all

Bluetooth monitor ver 5.50
= Note: Linux version 5.10.52-v7+ (armv7l)                                                                                                                                          0.269527
= Note: Bluetooth subsystem version 2.22                                                                                                                                            0.269537
= New Index: B8:27:EB:76:XX:XX (Primary,UART,hci0)                                                                                                                           [hci0] 0.269540
= Open Index: B8:27:EB:76:XX:XX                                                                                                                                              [hci0] 0.269542
= Index Info: B8:27:EB:76:XX:XX (Broadcom Corporation)                                                                                                                       [hci0] 0.269546
@ MGMT Open: bluetoothd (privileged) version 1.18                                                                                                                          {0x0001} 0.269550
@ MGMT Open: btmon (privileged) version 1.18                                                                                                                               {0x0002} 0.269611

@ RAW Open: btDet2Domoticz. version 2.22                                                                                                                                  {0x0003} 71.701197
@ RAW Close: btDet2Domoticz.                                                                                                                                              {0x0003} 71.701261
@ RAW Open: btDet2Domoticz. version 2.22                                                                                                                           {0x0003} [hci0] 71.701333
< HCI Command: Remote Name Request (0x01|0x0019) plen 10                                                                                                                 #1 [hci0] 71.702049
        Address: D0:7F:A0:6D:YY:YY (Samsung Electronics Co.,Ltd)
        Page scan repetition mode: R2 (0x02)
        Page scan mode: Mandatory (0x00)
        Clock offset: 0x0000
> HCI Event: Command Status (0x0f) plen 4                                                                                                                                #2 [hci0] 71.703360
      Remote Name Request (0x01|0x0019) ncmd 1
        Status: Command Disallowed (0x0c)
@ RAW Close: btDet2Domoticz.                                                                                                                                       {0x0003} [hci0] 71.703781
@ RAW Open: btDet2Domoticz. version 2.22                                                                                                                                  {0x0003} 72.763926
@ RAW Close: btDet2Domoticz.                                                                                                                                              {0x0003} 72.763989
@ RAW Open: btDet2Domoticz. version 2.22                                                                                                                           {0x0003} [hci0] 72.764058
< HCI Command: Remote Name Request (0x01|0x0019) plen 10                                                                                                                 #3 [hci0] 72.764188
        Address: FC:DE:90:C6:ZZ:ZZ (OUI FC-DE-90)
        Page scan repetition mode: R2 (0x02)
        Page scan mode: Mandatory (0x00)
        Clock offset: 0x0000
> HCI Event: Command Status (0x0f) plen 4                                                                                                                                #4 [hci0] 72.765551
      Remote Name Request (0x01|0x0019) ncmd 1
        Status: Command Disallowed (0x0c)
@ RAW Close: btDet2Domoticz. 
Looks Remote Name Request are refused by hardware with Command Disallowed status???

This is a very new issue, this setup is up since more than 4 years/2 major raspbian versions on the same hardware that just recover after a "sudo hciconfig hci0 reset".

Only issue were sometimes tx timeouts reported in syslog as this PI version did not wire BT UART flow control, so /usr/bin/btuart script had hciattach default speed reduced to 460800 in noflow mode. With my usage of BT (unconnected mode), this was OK as a workaround.

Last BT service start was yesterday after a reboot:

Code: Select all

● bluetooth.service - Bluetooth service
   Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2021-08-25 14:17:05 CEST; 16h ago
     Docs: man:bluetoothd(8)
 Main PID: 482 (bluetoothd)
   Status: "Running"
    Tasks: 1 (limit: 2178)
   CGroup: /system.slice/bluetooth.service
           └─482 /usr/lib/bluetooth/bluetoothd

août 25 14:17:05 rasDomo systemd[1]: Starting Bluetooth service...
août 25 14:17:05 rasDomo bluetoothd[482]: Bluetooth daemon 5.50
août 25 14:17:05 rasDomo systemd[1]: Started Bluetooth service.
août 25 14:17:05 rasDomo bluetoothd[482]: Starting SDP server
août 25 14:17:05 rasDomo bluetoothd[482]: Bluetooth management interface 1.18 initialized
août 25 14:17:05 rasDomo bluetoothd[482]: Sap driver initialization failed.
août 25 14:17:05 rasDomo bluetoothd[482]: sap-server: Operation not permitted (1)
août 25 14:17:06 rasDomo bluetoothd[482]: Failed to set privacy: Rejected (0x0b)
Don't know if sap driver/privacy fails are new or not. This does not cause functional issues, at least immediately.

If anyone have insights/suggestion to debug/workaround this new issue? This looks to happen every 12 to 48h.

Thanks&Regards.

lost
Posts: 39
Joined: Tue Dec 05, 2017 9:38 am

Re: PI3B bluetooth issue (latest kernel update?)

Thu Aug 26, 2021 1:08 pm

An update on this one:
-Increasing lookup name timeout helps not falling in the issue, but this still happens.
-Sometime, hciconfig reset command do not restore functional bluetooth. Reason: Looks this is the (Android) BT phone side that may be stuck because after PI BT side reset and also a full PI reboot, only one BT MAC address may still not answer lookups. Stopping/restarting BT on phone side restore functionnality.
-Manually killing BT and restarting (using btuart script) shows what may be the root cause of this issue: hciattach looks for firmware file in /etc/firmware but looks real location is /lib/firmware on the PI???

Tried the dirty hack of a symlink so that btuart call does not complain anymore:

Code: Select all

bcm43xx_init
Set Controller UART speed to 460800 bit/s
[b]Flash firmware /etc/firmware/brcm/BCM43430A1.hcd[/b]
Set BDADDR UART: b8:27:eb:76:XX:XX
Set Controller UART speed to 460800 bit/s
Device setup complete
IMO, if btuart (and other startup scripts like this one, if any) output was logged, this kind of mistake would be much easier to spot.

Let's now wait to see if default BT FW was the problem. But to be able to hang up to remote side, I'm quite confident this may be a link layer issue managed by firmware.

lost
Posts: 39
Joined: Tue Dec 05, 2017 9:38 am

Re: PI3B bluetooth issue (latest kernel update?)

Mon Aug 30, 2021 7:52 am

After 3.5 days with BT patched FW correctly loaded (only change in my system), can confirm this was for sure the root cause of my lookup issue hanging PI3 bluetooth and/or (remote) dumb-phones side: Ran flawlessly instead of an average 2 silent (no errors reported to application with a BT controller completely dysfunctional) hangs per day.

Return to “Troubleshooting”