@@ -1903,16 +1903,25 @@ btfwloaded() {
19031903 # Retry/transient hints: if success exists and we see these, we likely want WARN.
19041904 transient_re=" ${BTFW_TRANSIENT_RE:- Retry BT power ON|retry bt power on|reset|re-init|reinit|failed.* \\ (-110\\ )} "
19051905
1906- # ---- Collect recent relevant dmesg ----
1907- # Filter for BT/QCA/WCN related lines; keep a reasonable window.
1908- out=" $(
1909- dmesg 2> /dev/null \
1910- | grep -i -E ' Bluetooth|hci[0-9]|QCA|wcn|btqca|WCN' \
1911- | tail -n " ${BTFW_DMESG_TAIL:- 600} "
1912- ) "
1906+ # ---- Collect recent relevant current-boot kernel log ----
1907+ # Prefer get_kernel_log() so we can use journalctl -k -b when available
1908+ # instead of relying only on the live dmesg ring buffer.
1909+ if command -v get_kernel_log > /dev/null 2>&1 ; then
1910+ out=" $(
1911+ get_kernel_log 2> /dev/null \
1912+ | grep -i -E ' Bluetooth|hci[0-9]|QCA|wcn|btqca|WCN' \
1913+ | tail -n " ${BTFW_DMESG_TAIL:- 600} "
1914+ ) "
1915+ else
1916+ out=" $(
1917+ dmesg 2> /dev/null \
1918+ | grep -i -E ' Bluetooth|hci[0-9]|QCA|wcn|btqca|WCN' \
1919+ | tail -n " ${BTFW_DMESG_TAIL:- 600} "
1920+ ) "
1921+ fi
19131922
19141923 if [ -z " $out " ]; then
1915- log_warn " btfwloaded: no recent Bluetooth/QCA/WCN messages in dmesg ."
1924+ log_warn " btfwloaded: no Bluetooth/QCA/WCN messages found in current-boot kernel log ."
19161925 return 1
19171926 fi
19181927
@@ -1922,15 +1931,15 @@ btfwloaded() {
19221931 printf ' %s\n' " $out " \
19231932 | awk -v IGNORECASE=1 -v re=" $success_re " '
19241933 $0 ~ re { n=NR }
1925- END { if (n> 0) print n; else print 0 }
1934+ END { if (n > 0) print n; else print 0 }
19261935 '
19271936 ) "
19281937
19291938 last_fatal=" $(
19301939 printf ' %s\n' " $out " \
19311940 | awk -v IGNORECASE=1 -v re=" $fatal_re " '
19321941 $0 ~ re { n=NR }
1933- END { if (n> 0) print n; else print 0 }
1942+ END { if (n > 0) print n; else print 0 }
19341943 '
19351944 ) "
19361945
@@ -1945,32 +1954,32 @@ btfwloaded() {
19451954
19461955 # ---- Decision tree ----
19471956 if [ " $last_success " -eq 0 ]; then
1948- log_warn " btfwloaded: no final success marker found (pattern: $success_re ). Recent tail:"
1957+ log_warn " btfwloaded: no final success marker found (pattern: $success_re ). Recent kernel-log tail:"
19491958 printf ' %s\n' " $out " | tail -n 30 >&2
19501959 return 1
19511960 fi
19521961
19531962 # Fatal after success => FAIL (setup looked done, but then errors happened later)
19541963 if [ " $last_fatal " -gt " $last_success " ]; then
1955- log_warn " btfwloaded: fatal BT/QCA errors occurred after final setup marker; treating as FAIL."
1964+ log_warn " btfwloaded: fatal BT/QCA errors occurred after final setup marker in kernel log, treating as FAIL."
19561965 printf ' %s\n' " $out " | tail -n 40 >&2
19571966 return 1
19581967 fi
19591968
19601969 # Fatal before success OR transient hints => WARN (retry scenario)
19611970 if [ " $last_fatal " -gt 0 ] && [ " $last_fatal " -lt " $last_success " ]; then
1962- log_warn " btfwloaded: transient errors occurred before final setup marker; treating as WARN."
1971+ log_warn " btfwloaded: transient errors occurred before final setup marker in kernel log, treating as WARN."
19631972 printf ' %s\n' " $out " | tail -n 30 >&2
19641973 return 2
19651974 fi
19661975
19671976 if [ " $saw_transient " -eq 1 ]; then
1968- log_warn " btfwloaded: retry/transient indicators seen; final setup marker present; treating as WARN."
1977+ log_warn " btfwloaded: retry/transient indicators seen in kernel log, final setup marker present, treating as WARN."
19691978 printf ' %s\n' " $out " | tail -n 30 >&2
19701979 return 2
19711980 fi
19721981
1973- log_info " btfwloaded: firmware load/setup completed cleanly (no fatal errors after final setup marker)."
1982+ log_info " btfwloaded: firmware load/setup completed cleanly from current-boot kernel log (no fatal errors after final setup marker)."
19741983 return 0
19751984}
19761985
0 commit comments