Skip to content

Commit

Permalink
xiaomi-elish: Generate bluetooth mac address from machine-id
Browse files Browse the repository at this point in the history
Since v6.9 default mac bluetooth address of QCA6390
"00:00:00:00:5a:ad" is no longer usable. So we have to generate
a new one.
  • Loading branch information
amazingfate committed Jun 11, 2024
1 parent 9a59cfd commit 1c63698
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions config/boards/xiaomi-elish.conf
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ function post_family_tweaks_bsp__xiaomi-elish_firmware() {
install -Dm655 $SRC/packages/bsp/usb-gadget-network/remove-usbgadget-network.sh $destination/usr/local/bin/
install -Dm644 $SRC/packages/bsp/usb-gadget-network/usbgadget-rndis.service $destination/usr/lib/systemd/system/

# Bluetooth MAC addr setup service
install -Dm655 $SRC/packages/bsp/generate-bt-mac-addr/bt-fixed-mac.sh $destination/usr/local/bin/
install -Dm644 $SRC/packages/bsp/generate-bt-mac-addr/bt-fixed-mac.service $destination/usr/lib/systemd/system/

# Kernel postinst script to update abl boot partition
install -Dm655 $SRC/packages/bsp/xiaomi-elish/zz-update-abl-kernel $destination/etc/kernel/postinst.d/

Expand Down Expand Up @@ -71,6 +75,7 @@ function post_family_tweaks__xiaomi-elish_enable_services() {
chroot_sdcard systemctl enable usbgadget-rndis.service
chroot_sdcard systemctl enable pd-mapper.service
chroot_sdcard systemctl enable tqftpserv.service
chroot_sdcard systemctl enable bt-fixed-mac.service
return 0
}

Expand Down
11 changes: 11 additions & 0 deletions packages/bsp/generate-bt-mac-addr/bt-fixed-mac.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=Bluetooth Fixed Mac Address
After=bluetooth.service systemd-machine-id-commit.service
Wants=bluetooth.service
[Service]
Type=oneshot
RemainAfterExit=yes
SyslogIdentifier=bt-fixed-mac
ExecStart=/usr/local/bin/bt-fixed-mac.sh
[Install]
WantedBy=bluetooth.target
6 changes: 6 additions & 0 deletions packages/bsp/generate-bt-mac-addr/bt-fixed-mac.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

mac="$(echo $(cat /etc/machine-id; echo bluetooth)| sha256sum -)"
bt_mac=$(echo "42:${mac:0:2}:${mac:4:2}:${mac:8:2}:${mac:12:2}:${mac:16:2}")
echo $bt_mac
/usr/bin/bluetoothctl mgmt.public-addr $bt_mac

0 comments on commit 1c63698

Please sign in to comment.