firmware-murata-infineon: add a retry to init script

The BT interface initialization is occasionally failing with the hci0
interface not being fully up.
Adding the retry solves all those initialization failures.

https://onedigi.atlassian.net/browse/DEL-9287

Signed-off-by: Isaac Hermida <isaac.hermida@digi.com>
This commit is contained in:
Isaac Hermida 2025-01-30 13:23:07 +01:00
parent 2f5ccac0c6
commit 6ac00bf590
1 changed files with 21 additions and 15 deletions

View File

@ -14,7 +14,7 @@
#=============================================================================== #===============================================================================
SCRIPTNAME="$(basename ${0})" SCRIPTNAME="$(basename ${0})"
export MBT_TRANSPORT=/dev/ttySTM1 RETRIES=3
log() { log() {
if type "systemd-cat" >/dev/null 2>/dev/null; then if type "systemd-cat" >/dev/null 2>/dev/null; then
@ -30,21 +30,27 @@ bt_power() {
} }
bt_init() { bt_init() {
for i in $(seq ${RETRIES}); do
# Perform a power cycle
bt_power 0 bt_power 0
sleep 0.5 sleep 0.5
bt_power 1 bt_power 1
# Load Bluetooth firmware on device # Load Bluetooth firmware on device
mbt download /lib/firmware/brcm/CYW55500A1.hcd if MBT_TRANSPORT=/dev/ttySTM1 timeout 10 mbt download /lib/firmware/brcm/CYW55500A1.hcd; then
# Attach serial UART to the Bluetooth stack # Attach serial UART to the Bluetooth stack
btattach -B /dev/ttySTM1 -P bcm -S 921600 & btattach -B /dev/ttySTM1 -P bcm -S 921600 &
sleep 2 sleep 2
# Up the interface to be able to send hci commands # Up the interface to be able to send hci commands
if ! hciconfig hci0 up; then hciconfig hci0 up && log info "OK" && return 0
log err "FAILED (hci0 up)"
exit
fi fi
log info "OK" log err "FAILED to bring hci0 up, retrying..."
killall btattach 2> /dev/null
done
log err "FAILED (hci0 up)"
return 1
} }
bt_stop() { bt_stop() {