diff --git a/meta-digi-arm/recipes-bsp/firmware-murata-infineon/firmware-murata-infineon/cyw55512-bluetooth b/meta-digi-arm/recipes-bsp/firmware-murata-infineon/firmware-murata-infineon/cyw55512-bluetooth index a5f0db006..2df3373a1 100644 --- a/meta-digi-arm/recipes-bsp/firmware-murata-infineon/firmware-murata-infineon/cyw55512-bluetooth +++ b/meta-digi-arm/recipes-bsp/firmware-murata-infineon/firmware-murata-infineon/cyw55512-bluetooth @@ -14,7 +14,7 @@ #=============================================================================== SCRIPTNAME="$(basename ${0})" -export MBT_TRANSPORT=/dev/ttySTM1 +RETRIES=3 log() { if type "systemd-cat" >/dev/null 2>/dev/null; then @@ -30,21 +30,27 @@ bt_power() { } bt_init() { - bt_power 0 - sleep 0.5 - bt_power 1 - # Load Bluetooth firmware on device - mbt download /lib/firmware/brcm/CYW55500A1.hcd - # Attach serial UART to the Bluetooth stack - btattach -B /dev/ttySTM1 -P bcm -S 921600 & - sleep 2 + for i in $(seq ${RETRIES}); do + # Perform a power cycle + bt_power 0 + sleep 0.5 + bt_power 1 - # Up the interface to be able to send hci commands - if ! hciconfig hci0 up; then - log err "FAILED (hci0 up)" - exit - fi - log info "OK" + # Load Bluetooth firmware on device + if MBT_TRANSPORT=/dev/ttySTM1 timeout 10 mbt download /lib/firmware/brcm/CYW55500A1.hcd; then + # 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 + 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() {