From da9f84cf7ebfccbf432d204c4f63265bcacb91b2 Mon Sep 17 00:00:00 2001 From: Luca Giovenzana Date: Wed, 25 Mar 2020 17:53:51 +0100 Subject: [PATCH] Attempt to fix bluetooth communication problem on rpi3b This problem is referenced in many different issues, some of them: Bluetooth: hci0: Frame reassembly failed (-84) https://github.com/raspberrypi/firmware/issues/1150 Error communicating with local bluetooth adapter (RPi3) https://github.com/home-assistant/core/issues/30147 Xiaomi BLE Temperature and Humidity sensor no longer working after update from 0.95.4 to .096.5 https://github.com/home-assistant/core/issues/25704 Xiaomi BLE Temperature and Humidity sensor https://github.com/home-assistant/core/issues/24313#issuecomment-578554315 Solution seemed to reeduce the boud rate of the serial connection to BT on rpi3b where flow control is missing. The patch to the original btuart file is to reduce the baudrate only for rpi3b models where flow control is missing: - $HCIATTACH /dev/serial1 bcm43xx 921600 noflow - $BDADDR + $HCIATTACH /dev/serial1 bcm43xx 460800 noflow - $BDADDR I'm not a buildroot expert but the best way seemed to move the upstream btuart download in a PRE_PATCH_HOOK so that standard buildroot way of patching can be applied. --- .../0001-btuart-reduced-baud-rate-rpi3b.patch | 16 ++++++++++++++++ .../package/bluetooth-bcm43xx/Config.in | 2 +- .../bluetooth-bcm43xx/bluetooth-bcm43xx.mk | 4 +++- 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 buildroot-external/package/bluetooth-bcm43xx/0001-btuart-reduced-baud-rate-rpi3b.patch diff --git a/buildroot-external/package/bluetooth-bcm43xx/0001-btuart-reduced-baud-rate-rpi3b.patch b/buildroot-external/package/bluetooth-bcm43xx/0001-btuart-reduced-baud-rate-rpi3b.patch new file mode 100644 index 00000000000..ce7f42d9e08 --- /dev/null +++ b/buildroot-external/package/bluetooth-bcm43xx/0001-btuart-reduced-baud-rate-rpi3b.patch @@ -0,0 +1,16 @@ +Bluetooth: hci0: Frame reassembly failed (-84) +https://github.com/raspberrypi/firmware/issues/1150 + +Signed-off-by: Luca Giovenzana + +--- btuart.orig 2020-03-25 03:05:24.491176583 +0100 ++++ btuart 2020-03-25 03:05:43.603107833 +0100 +@@ -19,7 +19,7 @@ if [ "$uart0" = "$serial1" ] ; then + if [ "$uart0_pins" = "16" ] ; then + $HCIATTACH /dev/serial1 bcm43xx 3000000 flow - $BDADDR + else +- $HCIATTACH /dev/serial1 bcm43xx 921600 noflow - $BDADDR ++ $HCIATTACH /dev/serial1 bcm43xx 460800 noflow - $BDADDR + fi + else + $HCIATTACH /dev/serial1 bcm43xx 460800 noflow - $BDADDR diff --git a/buildroot-external/package/bluetooth-bcm43xx/Config.in b/buildroot-external/package/bluetooth-bcm43xx/Config.in index 05add93bf40..d0895b057ee 100644 --- a/buildroot-external/package/bluetooth-bcm43xx/Config.in +++ b/buildroot-external/package/bluetooth-bcm43xx/Config.in @@ -3,4 +3,4 @@ config BR2_PACKAGE_BLUETOOTH_BCM43XX depends on BR2_PACKAGE_BLUEZ5_UTILS_CLIENT select BR2_PACKAGE_BLUEZ5_UTILS_DEPRECATED help - Install bluetooth for bcm43xx. + Install bluetooth for bcm43xx. diff --git a/buildroot-external/package/bluetooth-bcm43xx/bluetooth-bcm43xx.mk b/buildroot-external/package/bluetooth-bcm43xx/bluetooth-bcm43xx.mk index 8df6d77b44f..7902d5aa5a2 100644 --- a/buildroot-external/package/bluetooth-bcm43xx/bluetooth-bcm43xx.mk +++ b/buildroot-external/package/bluetooth-bcm43xx/bluetooth-bcm43xx.mk @@ -10,7 +10,7 @@ BLUETOOTH_BCM43XX_LICENSE_FILES = $(BR2_EXTERNAL_HASSOS_PATH)/../LICENSE BLUETOOTH_BCM43XX_SITE = $(BR2_EXTERNAL_HASSOS_PATH)/package/bluetooth-bcm43xx BLUETOOTH_BCM43XX_SITE_METHOD = local -define BLUETOOTH_BCM43XX_BUILD_CMDS +define BLUETOOTH_BCM43XX_FIRMWARE_AND_HELPERS_DOWNLOAD curl -L -o $(@D)/BCM43430A1.hcd https://raw.githubusercontent.com/RPi-Distro/bluez-firmware/fff76cb15527c435ce99a9787848eacd6288282c/broadcom/BCM43430A1.hcd curl -L -o $(@D)/BCM4345C0.hcd https://raw.githubusercontent.com/RPi-Distro/bluez-firmware/fff76cb15527c435ce99a9787848eacd6288282c/broadcom/BCM4345C0.hcd curl -L -o $(@D)/btuart https://raw.githubusercontent.com/RPi-Distro/pi-bluetooth/cbdbcb66bcc5b9af05f1a9fffe2254c872bb0ace/usr/bin/btuart @@ -18,6 +18,8 @@ define BLUETOOTH_BCM43XX_BUILD_CMDS curl -L -o $(@D)/90-pi-bluetooth.rules https://raw.githubusercontent.com/RPi-Distro/pi-bluetooth/cbdbcb66bcc5b9af05f1a9fffe2254c872bb0ace/lib/udev/rules.d/90-pi-bluetooth.rules endef +BLUETOOTH_BCM43XX_PRE_PATCH_HOOKS += BLUETOOTH_BCM43XX_FIRMWARE_AND_HELPERS_DOWNLOAD + define BLUETOOTH_BCM43XX_INSTALL_TARGET_CMDS $(INSTALL) -d $(TARGET_DIR)/etc/systemd/system/hassos-hardware.target.wants $(INSTALL) -m 0644 $(@D)/bluetooth-bcm43xx.service $(TARGET_DIR)/usr/lib/systemd/system/