From 6ac00bf5904947664b3ef602c71eebc0e964c601 Mon Sep 17 00:00:00 2001 From: Isaac Hermida Date: Thu, 30 Jan 2025 13:23:07 +0100 Subject: [PATCH] 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 --- .../cyw55512-bluetooth | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) 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() {