From cf27d3e201dc0ef17218bfe6e4c313adcda36cae Mon Sep 17 00:00:00 2001 From: Isaac Hermida Date: Tue, 2 Dec 2025 12:27:49 +0100 Subject: [PATCH] bluetooth-init: get the BT MAC address from the DT node Retrieve the Bluetooth MAC address from the device tree (DT) node rather than from the environment. U-Boot will populate this address by default, but it can be overridden with a custom MAC address specified directly in the DT, which then takes priority. Signed-off-by: Isaac Hermida --- .../bluez/bluez5-init/ccimx9/bluetooth-init | 4 +++- .../bluez/bluez5-init/ccmp1/bluetooth-init | 4 +++- .../bluez/bluez5-init/ccmp2/bluetooth-init | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/meta-digi-dey/recipes-connectivity/bluez/bluez5-init/ccimx9/bluetooth-init b/meta-digi-dey/recipes-connectivity/bluez/bluez5-init/ccimx9/bluetooth-init index e2ea10d99..1834dd70d 100644 --- a/meta-digi-dey/recipes-connectivity/bluez/bluez5-init/ccimx9/bluetooth-init +++ b/meta-digi-dey/recipes-connectivity/bluez/bluez5-init/ccimx9/bluetooth-init @@ -33,7 +33,9 @@ power() { set_btaddr() { hciconfig ${HCI_IFACE} up sleep 0.2 - bt_addr=$(echo "$(fw_printenv -n btaddr)" | awk -F ":" '{ for(i=NF;i>=1;i--) printf "0x%s ", $i }') + bt_addr=$(hexdump -v -e '1/1 "%02X "' /proc/device-tree/bluetooth/mac-address \ + | awk '{ for(i=NF; i>0; i--) printf "0x%s ", $i }' \ + | sed 's/ $//') hcitool -i ${HCI_IFACE} cmd 0x3f 0x0022 0xfe 0x06 ${bt_addr} hciconfig ${HCI_IFACE} down sleep 0.2 diff --git a/meta-digi-dey/recipes-connectivity/bluez/bluez5-init/ccmp1/bluetooth-init b/meta-digi-dey/recipes-connectivity/bluez/bluez5-init/ccmp1/bluetooth-init index 2f9c940e4..cb197c4ed 100644 --- a/meta-digi-dey/recipes-connectivity/bluez/bluez5-init/ccmp1/bluetooth-init +++ b/meta-digi-dey/recipes-connectivity/bluez/bluez5-init/ccmp1/bluetooth-init @@ -43,7 +43,9 @@ bt_power() { set_btaddr() { hciconfig hci0 up sleep 0.2 - bt_addr=$(echo "$(fw_printenv -n btaddr)" | awk -F ":" '{ for(i=NF;i>=1;i--) printf "0x%s ", $i }') + bt_addr=$(hexdump -v -e '1/1 "%02X "' /proc/device-tree/bluetooth/mac-address \ + | awk '{ for(i=NF; i>0; i--) printf "0x%s ", $i }' \ + | sed 's/ $//') hcitool -i hci0 cmd 0x3f 0x0001 ${bt_addr} hciconfig hci0 down sleep 0.2 diff --git a/meta-digi-dey/recipes-connectivity/bluez/bluez5-init/ccmp2/bluetooth-init b/meta-digi-dey/recipes-connectivity/bluez/bluez5-init/ccmp2/bluetooth-init index 0a9eaeefa..f1fbbb907 100644 --- a/meta-digi-dey/recipes-connectivity/bluez/bluez5-init/ccmp2/bluetooth-init +++ b/meta-digi-dey/recipes-connectivity/bluez/bluez5-init/ccmp2/bluetooth-init @@ -32,7 +32,9 @@ bt_power() { set_btaddr() { hciconfig hci0 up sleep 0.2 - bt_addr=$(echo "$(fw_printenv -n btaddr)" | awk -F ":" '{ for(i=NF;i>=1;i--) printf "0x%s ", $i }') + bt_addr=$(hexdump -v -e '1/1 "%02X "' /proc/device-tree/bluetooth/mac-address \ + | awk '{ for(i=NF; i>0; i--) printf "0x%s ", $i }' \ + | sed 's/ $//') hcitool -i hci0 cmd 0x3f 0x0001 ${bt_addr} hciconfig hci0 down sleep 0.2