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() {
bt_power 0 for i in $(seq ${RETRIES}); do
sleep 0.5 # Perform a power cycle
bt_power 1 bt_power 0
# Load Bluetooth firmware on device sleep 0.5
mbt download /lib/firmware/brcm/CYW55500A1.hcd bt_power 1
# Attach serial UART to the Bluetooth stack
btattach -B /dev/ttySTM1 -P bcm -S 921600 &
sleep 2
# Up the interface to be able to send hci commands # Load Bluetooth firmware on device
if ! hciconfig hci0 up; then if MBT_TRANSPORT=/dev/ttySTM1 timeout 10 mbt download /lib/firmware/brcm/CYW55500A1.hcd; then
log err "FAILED (hci0 up)" # Attach serial UART to the Bluetooth stack
exit btattach -B /dev/ttySTM1 -P bcm -S 921600 &
fi sleep 2
log info "OK"
# Up the interface to be able to send hci commands
hciconfig hci0 up && log info "OK" && return 0
fi
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() {