├── debian ├── changelog ├── control ├── copyright ├── pi-bluetooth.bthelper@.service ├── pi-bluetooth.hciuart.service ├── pi-bluetooth.install ├── pi-bluetooth.lintian-overrides ├── pi-bluetooth.postinst ├── rules └── source │ └── format ├── lib └── udev │ └── rules.d │ └── 90-pi-bluetooth.rules └── usr └── bin ├── bthelper └── btuart /debian/changelog: -------------------------------------------------------------------------------- 1 | pi-bluetooth (0.1.19) bullseye; urgency=medium 2 | 3 | [ Phil Elwell ] 4 | * Add AA:AA:AA:AA:AA:AA as an "unprogrammed" address 5 | 6 | [ Serge Schneider ] 7 | * hciuart: change WantedBy to dev-serial1.device 8 | 9 | -- Serge Schneider Wed, 13 Apr 2022 14:34:48 +0100 10 | 11 | pi-bluetooth (0.1.18) buster; urgency=medium 12 | 13 | * Do not start hciuart service on install or upgrade 14 | 15 | -- Serge Schneider Fri, 10 Sep 2021 16:33:21 +0100 16 | 17 | pi-bluetooth (0.1.17) buster; urgency=medium 18 | 19 | [ Phil Elwell ] 20 | * Another systemd service adjustment 21 | 22 | -- Serge Schneider Fri, 21 May 2021 15:36:01 +0100 23 | 24 | pi-bluetooth (0.1.16) buster; urgency=medium 25 | 26 | [ Phil Elwell ] 27 | * bthelper: Detect unprogrammed devices instead 28 | * Multiple fixes 29 | 30 | [ Dave Jones ] 31 | * Widen match for CM4 compatibility 32 | 33 | [ Petar Obradović ] 34 | * Change service unit type to "oneshot" (#17) 35 | 36 | [ Cameron Miller ] 37 | * Fixes RPI-Distro/pi-bluetooth#18 38 | 39 | -- Serge Schneider Fri, 14 May 2021 11:55:01 +0100 40 | 41 | pi-bluetooth (0.1.15) buster; urgency=medium 42 | 43 | [ Phil Elwell ] 44 | * bthelper: Change BT address with hcitool instead 45 | * bthelper: FIX: Only run for onboard BT modems 46 | 47 | -- Serge Schneider Wed, 19 Aug 2020 15:45:46 +0100 48 | 49 | pi-bluetooth (0.1.14) buster; urgency=medium 50 | 51 | [ Phil Elwell ] 52 | * bthelper: Add the ability to set the Pi BDADDR 53 | 54 | -- Serge Schneider Wed, 29 Jul 2020 09:24:14 +0100 55 | 56 | pi-bluetooth (0.1.13) buster; urgency=medium 57 | 58 | [ Phil Elwell ] 59 | * bthelper: Force reinitialisation to allow Secure Simple Pairing 60 | 61 | -- Serge Schneider Tue, 26 May 2020 07:13:54 +0100 62 | 63 | pi-bluetooth (0.1.12) buster; urgency=medium 64 | 65 | [ Phil Elwell ] 66 | * bthelper: Recognise Pi 4 OUI (#10) 67 | 68 | -- Serge Schneider Tue, 05 Nov 2019 13:00:15 +0000 69 | 70 | pi-bluetooth (0.1.11) buster; urgency=medium 71 | 72 | * Don't override the BT address on Pi 4 73 | * Update control file for Buster 74 | 75 | -- Serge Schneider Tue, 18 Jun 2019 12:04:46 +0100 76 | 77 | pi-bluetooth (0.1.10) stretch; urgency=medium 78 | 79 | * Improved hciuart service condition 80 | 81 | -- Serge Schneider Mon, 29 Oct 2018 12:02:55 +0000 82 | 83 | pi-bluetooth (0.1.9) stretch; urgency=medium 84 | 85 | * Do not wait for hciuart before staring bluetoothd 86 | 87 | -- Serge Schneider Thu, 09 Aug 2018 13:40:13 +0100 88 | 89 | pi-bluetooth (0.1.8) stretch; urgency=medium 90 | 91 | * For on-board BT, route SCO packets to the HCI interface (enables HFP/HSP) 92 | 93 | -- Serge Schneider Mon, 04 Jun 2018 14:53:18 +0100 94 | 95 | pi-bluetooth (0.1.7) stretch; urgency=medium 96 | 97 | * Change package type to 'all' 98 | 99 | -- Serge Schneider Tue, 06 Feb 2018 11:51:55 +0000 100 | 101 | pi-bluetooth (0.1.6) stretch; urgency=medium 102 | 103 | * btuart: Set BT MAC address using hciattach 104 | 105 | -- Serge Schneider Wed, 23 Aug 2017 16:38:41 +0100 106 | 107 | pi-bluetooth (0.1.4) stretch; urgency=medium 108 | 109 | * Add 'Wants' for dev-serial1.device 110 | * Change btuart shell to /bin/sh 111 | 112 | -- Serge Schneider Thu, 13 Jul 2017 14:09:39 +0100 113 | 114 | pi-bluetooth (0.1.3) jessie; urgency=medium 115 | 116 | * Set flow control and baud rate depending on detected hardware 117 | 118 | -- Simon Long Thu, 16 Feb 2017 12:37:52 +0000 119 | 120 | pi-bluetooth (0.1.2) jessie; urgency=medium 121 | 122 | * Add dependency on raspberrypi-sys-mods, which must be present for 123 | /dev/serial1 to exist 124 | * Do not restart service on upgrade 125 | 126 | -- Serge Schneider Mon, 23 Jan 2017 13:31:12 +0000 127 | 128 | pi-bluetooth (0.1.1) jessie; urgency=medium 129 | 130 | * Use /dev/serial1 131 | 132 | -- Serge Schneider Tue, 10 May 2016 21:39:57 +0100 133 | 134 | pi-bluetooth (0.1.0) jessie; urgency=low 135 | 136 | * Initial Release. 137 | 138 | -- Serge Schneider Thu, 25 Feb 2016 03:45:33 +0000 139 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: pi-bluetooth 2 | Section: misc 3 | Priority: optional 4 | Maintainer: Serge Schneider 5 | Build-Depends: debhelper-compat (= 11) 6 | Standards-Version: 4.3.0 7 | Homepage: https://github.com/RPi-Distro/pi-bluetooth 8 | 9 | Package: pi-bluetooth 10 | Architecture: all 11 | Depends: ${misc:Depends}, 12 | bluez (>= 5.50-1.2~deb10u1+rpt1), 13 | bluez-firmware, 14 | raspberrypi-sys-mods 15 | Description: Raspberry Pi 3 bluetooth 16 | Loads BCM43430A1 firmware on boot 17 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Upstream-Name: pi-bluetooth 3 | Source: https://github.com/RPi-Distro/pi-bluetooth 4 | 5 | Files: * 6 | Copyright: 2016 Raspberry Pi (Trading) Ltd. 7 | License: BSD-3-Clause 8 | 9 | License: BSD-3-Clause 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions 12 | are met: 13 | 1. Redistributions of source code must retain the above copyright 14 | notice, this list of conditions and the following disclaimer. 15 | 2. Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 3. Neither the name of the University nor the names of its contributors 19 | may be used to endorse or promote products derived from this software 20 | without specific prior written permission. 21 | . 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE HOLDERS OR 26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | -------------------------------------------------------------------------------- /debian/pi-bluetooth.bthelper@.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Raspberry Pi bluetooth helper 3 | Requires=hciuart.service bluetooth.service 4 | After=hciuart.service 5 | Before=bluetooth.service 6 | 7 | [Service] 8 | Type=oneshot 9 | ExecStart=/usr/bin/bthelper %I 10 | RemainAfterExit=yes 11 | -------------------------------------------------------------------------------- /debian/pi-bluetooth.hciuart.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Configure Bluetooth Modems connected by UART 3 | ConditionFileNotEmpty=/proc/device-tree/soc/gpio@7e200000/bt_pins/brcm,pins 4 | After=dev-serial1.device 5 | 6 | [Service] 7 | Type=forking 8 | ExecStart=/usr/bin/btuart 9 | 10 | [Install] 11 | WantedBy=dev-serial1.device 12 | -------------------------------------------------------------------------------- /debian/pi-bluetooth.install: -------------------------------------------------------------------------------- 1 | usr 2 | lib 3 | -------------------------------------------------------------------------------- /debian/pi-bluetooth.lintian-overrides: -------------------------------------------------------------------------------- 1 | no-manual-page usr/bin/bthelper 2 | no-manual-page usr/bin/btuart 3 | systemd-service-file-refers-to-unusual-wantedby-target lib/systemd/system/hciuart.service dev-serial1.device 4 | -------------------------------------------------------------------------------- /debian/pi-bluetooth.postinst: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | # deb-systemd-helper doesn't properly update the link from multi-user.target to dev-serial1.device 5 | # We do so manually here: 6 | if [ "$1" = "configure" ] && dpkg --compare-versions "$2" lt-nl "0.1.19" ; then 7 | if deb-systemd-helper --quiet was-enabled 'hciuart.service'; then 8 | systemctl --quiet reenable 'hciuart.service' 9 | fi 10 | fi 11 | 12 | #DEBHELPER# 13 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | 3 | %: 4 | dh $@ 5 | 6 | override_dh_installsystemd: 7 | dh_installsystemd --name=hciuart --no-start 8 | dh_installsystemd --name=bthelper@ --no-start 9 | -------------------------------------------------------------------------------- /debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (native) 2 | -------------------------------------------------------------------------------- /lib/udev/rules.d/90-pi-bluetooth.rules: -------------------------------------------------------------------------------- 1 | # Raspberry Pi bluetooth module: enable routing of SCO packets to the HCI interface 2 | ACTION=="add", SUBSYSTEM=="bluetooth", KERNEL=="hci[0-9]", TAG+="systemd", ENV{SYSTEMD_WANTS}+="bthelper@%k.service" 3 | -------------------------------------------------------------------------------- /usr/bin/bthelper: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # For on-board BT, configure the BDADDR if necessary and route SCO packets 3 | # to the HCI interface (enables HFP/HSP) 4 | 5 | set -e 6 | 7 | if [ "$#" -ne 1 ]; then 8 | echo "Usage: $0 " 9 | exit 0 10 | fi 11 | 12 | dev=$1 13 | 14 | # Need to bring hci up before looking at MAC as it can be all zeros during init 15 | /bin/hciconfig $dev up 16 | if ! /bin/hciconfig $dev | grep -q "Bus: UART"; then 17 | echo Not a UART-attached BT Modem 18 | exit 0 19 | fi 20 | 21 | if ( /usr/bin/hcitool -i $dev dev | grep -q -E '\s43:4[35]:|AA:AA:AA:AA:AA:AA' ); then 22 | SERIAL=`cat /proc/device-tree/serial-number | cut -c9-` 23 | B1=`echo $SERIAL | cut -c3-4` 24 | B2=`echo $SERIAL | cut -c5-6` 25 | B3=`echo $SERIAL | cut -c7-8` 26 | BDADDR=`printf '0x%02x 0x%02x 0x%02x 0xeb 0x27 0xb8' $((0x$B3 ^ 0xaa)) $((0x$B2 ^ 0xaa)) $((0x$B1 ^ 0xaa))` 27 | 28 | /usr/bin/hcitool -i $dev cmd 0x3f 0x001 $BDADDR 29 | /bin/hciconfig $dev reset 30 | else 31 | echo Raspberry Pi BDADDR already set 32 | fi 33 | 34 | # Route SCO packets to the HCI interface (enables HFP/HSP) 35 | /usr/bin/hcitool -i $dev cmd 0x3f 0x1c 0x01 0x02 0x00 0x01 0x01 > /dev/null 36 | 37 | # Force reinitialisation to allow extra features such as Secure Simple Pairing 38 | # to be enabled, for currently unknown reasons. This requires bluetoothd to be 39 | # running, which it isn't yet. Use this kludge of forking off another shell 40 | # with a delay, pending a complete understanding of the issues. 41 | (sleep 5; /usr/bin/bluetoothctl power off; /usr/bin/bluetoothctl power on) & 42 | -------------------------------------------------------------------------------- /usr/bin/btuart: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | HCIATTACH=/usr/bin/hciattach 4 | if grep -q "raspberrypi,4" /proc/device-tree/compatible; then 5 | BDADDR= 6 | else 7 | SERIAL=`cat /proc/device-tree/serial-number | cut -c9-` 8 | B1=`echo $SERIAL | cut -c3-4` 9 | B2=`echo $SERIAL | cut -c5-6` 10 | B3=`echo $SERIAL | cut -c7-8` 11 | BDADDR=`printf b8:27:eb:%02x:%02x:%02x $((0x$B1 ^ 0xaa)) $((0x$B2 ^ 0xaa)) $((0x$B3 ^ 0xaa))` 12 | fi 13 | 14 | # Bail out if the kernel is managing the Bluetooth modem initialisation 15 | if ( dmesg | grep -q -E "hci[0-9]+: BCM: chip" ); then 16 | # On-board bluetooth is already enabled 17 | exit 0 18 | fi 19 | 20 | uart0="`cat /proc/device-tree/aliases/uart0`" 21 | serial1="`cat /proc/device-tree/aliases/serial1`" 22 | 23 | if [ "$uart0" = "$serial1" ] ; then 24 | uart0_pins="`wc -c /proc/device-tree/soc/gpio@7e200000/uart0_pins/brcm\,pins | cut -f 1 -d ' '`" 25 | if [ "$uart0_pins" = "16" ] ; then 26 | $HCIATTACH /dev/serial1 bcm43xx 3000000 flow - $BDADDR 27 | else 28 | $HCIATTACH /dev/serial1 bcm43xx 921600 noflow - $BDADDR 29 | fi 30 | else 31 | $HCIATTACH /dev/serial1 bcm43xx 460800 noflow - $BDADDR 32 | fi 33 | --------------------------------------------------------------------------------