From b80207298952d09f319c910cafc59f06ff59d659 Mon Sep 17 00:00:00 2001 From: Srikanth Muppandam Date: Tue, 21 Apr 2026 16:12:02 +0530 Subject: [PATCH 1/2] fix: add BT readiness wait and extend firmware detection for RB4 layouts Add a reusable bt_wait_ready() helper to wait for bluetooth.service and HCI availability during early boot, reducing bring-up races on targets where Bluetooth comes up shortly after userspace starts. Also extend btfwpresent() to detect additional Qualcomm firmware naming patterns used on RB4-class platforms, including hpbtfw*/hpnv* and related variants, so firmware presence is reported correctly across newer and legacy layouts. Signed-off-by: Srikanth Muppandam --- Runner/utils/lib_bluetooth.sh | 63 ++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/Runner/utils/lib_bluetooth.sh b/Runner/utils/lib_bluetooth.sh index b8e6b8b3..8fce0f0c 100755 --- a/Runner/utils/lib_bluetooth.sh +++ b/Runner/utils/lib_bluetooth.sh @@ -1891,7 +1891,13 @@ btfwpresent() { "msbtfw*.tlv" \ "msnv*.bin" \ "cmbtfw*.tlv" \ - "cmnv*.bin" + "cmnv*.bin" \ + "hpbtfw*.tlv" \ + "wcnhpbtfw*.tlv" \ + "hmtbtfw*.tlv" \ + "hmtnv*.bin" \ + "hpnv*.bin" \ + "wcnhpnv*.bin" do for file in "$d"/$pattern; do if [ -e "$file" ]; then @@ -1906,6 +1912,61 @@ btfwpresent() { return 1 } +bt_wait_ready() { + max_wait="${1:-60}" + sleep_step="${2:-2}" + waited=0 + started_service=0 + + if [ -z "$max_wait" ]; then + max_wait=60 + fi + if [ -z "$sleep_step" ]; then + sleep_step=2 + fi + + case "$max_wait" in + ''|*[!0-9]*) + max_wait=60 + ;; + esac + case "$sleep_step" in + ''|*[!0-9]*) + sleep_step=2 + ;; + esac + + if [ "$max_wait" -le 0 ] 2>/dev/null; then + max_wait=60 + fi + if [ "$sleep_step" -le 0 ] 2>/dev/null; then + sleep_step=2 + fi + + while [ "$waited" -lt "$max_wait" ]; do + if btsvcactive && bthcipresent; then + log_info "Bluetooth runtime became ready after ${waited}s." + return 0 + fi + + if [ "$started_service" -eq 0 ]; then + if command -v systemctl >/dev/null 2>&1; then + if ! btsvcactive; then + log_info "Bluetooth service not active yet, attempting start." + systemctl start bluetooth.service >/dev/null 2>&1 || true + fi + fi + started_service=1 + fi + + sleep "$sleep_step" + waited=$((waited + sleep_step)) + done + + log_warn "Bluetooth runtime did not become ready within ${max_wait}s." + return 1 +} + btfwloaded() { # ---- Configurable patterns (override via env if needed) ---- # "Final success" (strongest marker that FW+UART setup completed) From a48ccfb21927bf7ec60a54d1635d3960691cb307 Mon Sep 17 00:00:00 2001 From: Srikanth Muppandam Date: Tue, 21 Apr 2026 16:12:19 +0530 Subject: [PATCH 2/2] fix: wait for BT runtime readiness and preserve failures in BT_FW_KMD_Service Update BT_FW_KMD_Service to wait for Bluetooth runtime readiness through the shared bt_wait_ready() helper before evaluating service/HCI state, making the testcase more reliable on targets that bring up Bluetooth slightly later in boot. Also improve result handling so a missing adapter no longer overwrites earlier failures with SKIP, and refresh the firmware warning text to cover the expanded Qualcomm firmware filename patterns checked by lib_bluetooth.sh. Signed-off-by: Srikanth Muppandam --- .../Bluetooth/BT_FW_KMD_Service/run.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Runner/suites/Connectivity/Bluetooth/BT_FW_KMD_Service/run.sh b/Runner/suites/Connectivity/Bluetooth/BT_FW_KMD_Service/run.sh index 60b56cbc..f371d5b4 100755 --- a/Runner/suites/Connectivity/Bluetooth/BT_FW_KMD_Service/run.sh +++ b/Runner/suites/Connectivity/Bluetooth/BT_FW_KMD_Service/run.sh @@ -77,6 +77,11 @@ if ! check_dependencies bluetoothctl hciconfig lsmod; then echo "$TESTNAME SKIP" > "$RES_FILE" exit 0 fi + +# ---------- Bluetooth runtime check/ readiness ---------- +log_info "Waiting for Bluetooth runtime readiness..." +bt_wait_ready 60 2 || true + # ---------- Bluetooth service / daemon ---------- log_info "Checking if bluetoothd (or bluetooth.service) is running..." if btsvcactive; then @@ -196,11 +201,15 @@ else fi if [ -z "$ADAPTER" ]; then - log_warn "No HCI adapter found; skipping BT FW/KMD test." - echo "$TESTNAME SKIP" > "./$TESTNAME.res" + log_warn "No HCI adapter found." + + if [ "$FAIL_COUNT" -gt 0 ]; then + echo "$TESTNAME FAIL" > "$RES_FILE" + else + echo "$TESTNAME SKIP" > "$RES_FILE" + fi exit 0 fi - # ---------- BD address sanity check ---------- if [ -n "$ADAPTER" ]; then if btbdok "$ADAPTER"; then