Fix RPI issues with u-boot / firmware (#503)

* Fix RPI issues with u-boot / firmware

* Cleanup bluetooth handling

* Use RC4 for u-boot on rpi4
This commit is contained in:
Pascal Vizeli
2019-12-10 19:07:16 +01:00
committed by GitHub
parent 09cf67cb73
commit d340e79bea
35 changed files with 213 additions and 1333 deletions

View File

@@ -1,18 +0,0 @@
#!/bin/sh
HCIATTACH=/usr/bin/hciattach
SERIAL=`cat /proc/device-tree/serial-number | cut -c9-`
B1=`echo $SERIAL | cut -c3-4`
B2=`echo $SERIAL | cut -c5-6`
B3=`echo $SERIAL | cut -c7-8`
BDADDR=`printf b8:27:eb:%02x:%02x:%02x $((0x$B1 ^ 0xaa)) $((0x$B2 ^ 0xaa)) $((0x$B3 ^ 0xaa))`
if [ "$(cat /proc/device-tree/aliases/uart0)" = "$(cat /proc/device-tree/aliases/serial1)" ] ; then
if [ "$(wc -c /proc/device-tree/soc/gpio@7e200000/uart0_pins/brcm\,pins | cut -f 1 -d ' ')" = "16" ] ; then
$HCIATTACH /dev/serial1 bcm43xx 3000000 flow - $BDADDR
else
$HCIATTACH /dev/serial1 bcm43xx 921600 noflow - $BDADDR
fi
else
$HCIATTACH /dev/serial1 bcm43xx 460800 noflow - $BDADDR
fi

View File

@@ -11,21 +11,28 @@ BLUETOOTH_BCM43XX_SITE = $(BR2_EXTERNAL_HASSOS_PATH)/package/bluetooth-bcm43xx
BLUETOOTH_BCM43XX_SITE_METHOD = local
define BLUETOOTH_BCM43XX_BUILD_CMDS
curl -L -o $(@D)/BCM43430A1.hcd https://raw.githubusercontent.com/RPi-Distro/bluez-firmware/96eefffcccc725425fd83be5e0704a5c32b79e54/broadcom/BCM43430A1.hcd
curl -L -o $(@D)/BCM4345C0.hcd https://raw.githubusercontent.com/RPi-Distro/bluez-firmware/96eefffcccc725425fd83be5e0704a5c32b79e54/broadcom/BCM4345C0.hcd
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
curl -L -o $(@D)/bthelper https://raw.githubusercontent.com/RPi-Distro/pi-bluetooth/cbdbcb66bcc5b9af05f1a9fffe2254c872bb0ace/usr/bin/bthelper
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
define BLUETOOTH_BCM43XX_INSTALL_TARGET_CMDS
$(INSTALL) -d $(TARGET_DIR)/etc/systemd/system/hassos-hardware.target.wants
$(INSTALL) -m 0755 $(@D)/bluetooth-bcm43xx $(TARGET_DIR)/usr/sbin/
$(INSTALL) -m 0644 $(@D)/bluetooth-bcm43xx.service $(TARGET_DIR)/usr/lib/systemd/system/
$(INSTALL) -m 0644 $(@D)/bthelper@.service $(TARGET_DIR)/usr/lib/systemd/system/
ln -fs /usr/lib/systemd/system/bluetooth-bcm43xx.service $(TARGET_DIR)/etc/systemd/system/hassos-hardware.target.wants/
$(INSTALL) -d $(TARGET_DIR)/usr/bin
$(INSTALL) -m 0755 $(@D)/btuart $(TARGET_DIR)/usr/bin/
$(INSTALL) -m 0755 $(@D)/bthelper $(TARGET_DIR)/usr/bin/
$(INSTALL) -d $(TARGET_DIR)/lib/firmware/brcm
$(INSTALL) -m 0644 $(@D)/*.hcd $(TARGET_DIR)/lib/firmware/brcm/
$(INSTALL) -d $(TARGET_DIR)/usr/lib/udev/rules.d
$(INSTALL) -m 0644 $(@D)/bluetooth-bcm43xx.rules $(TARGET_DIR)/usr/lib/udev/rules.d/
$(INSTALL) -m 0644 $(@D)/90-pi-bluetooth.rules $(TARGET_DIR)/usr/lib/udev/rules.d/
endef
$(eval $(generic-package))

View File

@@ -1,22 +0,0 @@
KERNEL=="ttyAMA[01]", PROGRAM="/bin/sh -c '\
ALIASES=/proc/device-tree/aliases; \
if cmp -s $ALIASES/uart0 $ALIASES/serial0; then \
echo 0;\
elif cmp -s $ALIASES/uart0 $ALIASES/serial1; then \
echo 1; \
else \
exit 1; \
fi\
'", SYMLINK+="serial%c"
KERNEL=="ttyS0", PROGRAM="/bin/sh -c '\
ALIASES=/proc/device-tree/aliases; \
if cmp -s $ALIASES/uart1 $ALIASES/serial0; then \
echo 0; \
elif cmp -s $ALIASES/uart1 $ALIASES/serial1; then \
echo 1; \
else \
exit 1; \
fi \
'", SYMLINK+="serial%c"

View File

@@ -1,12 +1,13 @@
[Unit]
Description=Bluetooth for BCM43xx
Before=bluetooth.service
After=dev-ttyAMA0.device
Requires=dev-serial1.device
After=dev-serial1.device
ConditionFileNotEmpty=/proc/device-tree/soc/gpio@7e200000/bt_pins/brcm,pins
[Service]
Type=forking
ExecStart=/usr/sbin/bluetooth-bcm43xx
ExecStart=/usr/bin/btuart
[Install]
WantedBy=hassos-hardware.target

View File

@@ -0,0 +1,8 @@
[Unit]
Description=Raspberry Pi bluetooth helper
Requires=bluetooth.service
After=bluetooth.service
[Service]
Type=simple
ExecStart=/usr/bin/bthelper %I