bluez: ccmp1/ccmp2: set custom MAC addresses on boot

Use an HCI vendor-specific command from Infineon on bluetooth-init
to set a custom MAC address every time the interface is started.

Valid for both CCMP1 (Murata 2AE) and CCMP2 (Murata 2FY) devices.

Signed-off-by: Gonzalo Ruiz <Gonzalo.Ruiz@digi.com>
This commit is contained in:
Gonzalo Ruiz 2025-10-28 18:15:55 +01:00
parent 7692d0ed4a
commit 6a07f42432
2 changed files with 24 additions and 3 deletions

View File

@ -40,6 +40,16 @@ bt_power() {
gpioset "${GPIO_CHIP}" "${GPIO_NUMBER}"="${1}"
}
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 }')
hcitool -i hci0 cmd 0x3f 0x0001 ${bt_addr}
hciconfig hci0 down
sleep 0.2
hciconfig hci0 up
}
is_kernel_module_loaded() {
lsmod | grep -qs -w "^${MODULE_NAME}"
}
@ -57,7 +67,8 @@ bt_init() {
# Load manually the kernel module
modprobe "${MODULE_NAME}"
sleep 1
is_kernel_module_loaded && log info "Bluetooth activated" && return 0
# Reconfigure the HCI interface with the expected MAC address
is_kernel_module_loaded && set_btaddr && log info "Bluetooth activated" && return 0
log err "Cannot initialize Bluetooth, retrying..."
done

View File

@ -29,6 +29,16 @@ bt_power() {
gpioset gpiochip11 5="${1}"
}
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 }')
hcitool -i hci0 cmd 0x3f 0x0001 ${bt_addr}
hciconfig hci0 down
sleep 0.2
hciconfig hci0 up
}
bt_init() {
for i in $(seq ${RETRIES}); do
# Perform a power cycle
@ -42,8 +52,8 @@ bt_init() {
btattach -B /dev/ttySTM1 -P bcm -S 921600 &
sleep 2
# Up the interface to be able to send hci commands
hciconfig hci0 up && log info "OK" && return 0
# Reconfigure the HCI interface with the expected MAC address
set_btaddr && log info "OK" && return 0
fi
log err "FAILED to bring hci0 up, retrying..."
killall btattach 2> /dev/null