Ubuntu 18.0.4 for Raspberry Pi B4 で Bluetooth を使いたい

Ubuntu 18.0.4 for Raspberry Pi B4 で Bluetooth を使いたくて調べています。

ARMのUbuntu Server 18.04でBluetoothを使う(for Raspberry Pi) – Qiitaを参考にしました。

とりあえず動かせば良いので、アップデートのことは考えていません。Bluetoothを使うだけならgroupaddはいらないかもしれません。

$ sudo add-apt-repository ppa:ubuntu-pi-flavour-makers/ppa
$ sudo apt update
$ sudo groupadd -f --system gpio
$ sudo groupadd -f --system i2c
$ sudo groupadd -f --system input
$ sudo groupadd -f --system spi

linux-firmware-raspi2がpi-bluetoothとぶつかるので、下記対応をしました。
sudo systemctl unmask hciuart で /etc/systemd/system/hciuart.service が削除されてしまって、バックアップをとっていなかったので、ちょっと後悔。

$ sudo apt -y remove linux-firmware-raspi2
$ sudo apt -y install pi-bluetooth bluetooth bluez
$ cd /
$ sudo tar czf bluez-firmware.tgz lib/firmware usr/share/doc/bluez-firmware
$ list=$(cat << EOS
lib/systemd/system/bthelper@.service
lib/systemd/system/hciuart.service
lib/udev/rules.d/90-pi-bluetooth.rules
usr/bin/bthelper
usr/bin/btuart
usr/share/doc/pi-bluetooth
EOS
)
$ sudo tar czf pi-bluetooth.tgz $list
$ sudo apt -y remove bluez-firmware pi-bluetooth
$ sudo apt -y install linux-firmware-raspi2
$ sudo apt -y install raspberrypi-sys-mods rfkill
$ sudo tar xf pi-bluetooth.tgz
$ sudo tar xf bluez-firmware.tgz
$ sudo systemctl unmask hciuart
$ sudo systemctl enable hciuart
$ sudo reboot

これで、bluetoothctlコマンドが使えるようになりました。ちなみに、bluez-firmwareやpi-bluezのパッケージ一覧も記録しておきました。

bluez-firmwareのパッケージはこちら。

$ sudo dpkg -L bluez-firmware
/.
/lib
/lib/firmware
/lib/firmware/BCM2033-FW.bin
/lib/firmware/BCM2033-MD.hex
/lib/firmware/STLC2500_R4_00_03.ptc
/lib/firmware/STLC2500_R4_00_06.ssf
/lib/firmware/STLC2500_R4_02_02_WLAN.ssf
/lib/firmware/STLC2500_R4_02_04.ptc
/lib/firmware/brcm
/lib/firmware/brcm/BCM43430A1.hcd
/lib/firmware/brcm/BCM4345C0.hcd
/usr
/usr/share
/usr/share/doc
/usr/share/doc/bluez-firmware
/usr/share/doc/bluez-firmware/AUTHORS
/usr/share/doc/bluez-firmware/BCM-LEGAL.txt
/usr/share/doc/bluez-firmware/ChangeLog
/usr/share/doc/bluez-firmware/README
/usr/share/doc/bluez-firmware/README.Debian
/usr/share/doc/bluez-firmware/changelog.Debian.gz
/usr/share/doc/bluez-firmware/copyright

pi-bluetoothのパッケージはこちら。

$ sudo dpkg -L pi-bluetooth
/.
/lib
/lib/systemd
/lib/systemd/system
/lib/systemd/system/bthelper@.service
/lib/systemd/system/hciuart.service
/lib/udev
/lib/udev/rules.d
/lib/udev/rules.d/90-pi-bluetooth.rules
/usr
/usr/bin
/usr/bin/bthelper
/usr/bin/btuart
/usr/share
/usr/share/doc
/usr/share/doc/pi-bluetooth
/usr/share/doc/pi-bluetooth/changelog.gz
/usr/share/doc/pi-bluetooth/copyright
同じタグの記事: Raspberry Pi
同じタグの記事: ラズパイ
同じカテゴリの記事: Linux