Skip to content

Instantly share code, notes, and snippets.

@e-minguez
Last active November 26, 2019 10:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save e-minguez/fda85d1d20d1f6dadfd4c071c50fcaae to your computer and use it in GitHub Desktop.
Save e-minguez/fda85d1d20d1f6dadfd4c071c50fcaae to your computer and use it in GitHub Desktop.
Fix Raspberry Pi 3 bluetooth issues

It is basically modify the content of the /usr/bin/btuart file to set different speed:

‎‎​#!/bin/sh

HCIATTACH=/usr/bin/hciattach
if grep -q "Pi 4" /proc/device-tree/model; then
  BDADDR=
else
  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))`
fi

uart0="`cat /proc/device-tree/aliases/uart0`"
serial1="`cat /proc/device-tree/aliases/serial1`"

if [ "$uart0" = "$serial1" ] ; then
        uart0_pins="`wc -c /proc/device-tree/soc/gpio@7e200000/uart0_pins/brcm\,pins | cut -f 1 -d ' '`"
        if [ "$uart0_pins" = "16" ] ; then
                $HCIATTACH /dev/serial1 bcm43xx 3000000 flow - $BDADDR
        else
                # This is the default one
                #$HCIATTACH /dev/serial1 bcm43xx 921600 noflow - $BDADDR
                $HCIATTACH /dev/serial1 bcm43xx 460800 noflow - $BDADDR
        fi
else
        $HCIATTACH /dev/serial1 bcm43xx 460800 noflow - $BDADDR
fi

Then reboot :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment