Restore unconditional BAM-DMUX wwan0 open for ModemManager and add primary-SIM QMI VOICE USSD fallback

MMPluginQcomSoc requires net/wwan0 to export /org/freedesktop/ModemManager1/Modem/0, so gating --dpm-open-port on type=gsm NetworkManager profiles left ModemManager with 'No modems were found' on Wi-Fi-only setups while bam-dmux already runtime-suspends in 1000 ms (pc_state=0) when idle.

- Always open the BAM-DMUX QMI DPM port in msm8909-modem-wwan-port before ModemManager starts and keep wwan0 registered across NetworkManager down events.
- Add -d qrtr://0 fallback and late-open mmcli rescan handling in bananarchy-dpm.sh and msm-modem-uim-selection provision_slot().
- Resolve mm_modem via mmcli -L in msm-modem-uim-selection ussd and fall back to direct AF_QIPCRTR QMI VOICE USSD (sub=0) on the primary SIM alongside sub=1 on the secondary SIM.
- Rebuild and pin nokia-argon and nokia-beatles a1114 (carbonara) images and update guards and docs.
This commit is contained in:
Luxferre committed 2026-11-12 20:41:00 +02:00
1 parent c95a84c69c
commit b2cf028808
8 files changed
+246 -120

No files matched your search

@@ -479,6 +479,19 @@ provision_slot() {
return 2
fi
if [ ! -d /sys/class/net/wwan0 ]; then
if [ -x /usr/bin/bananarchy-dpm.sh ]; then
/usr/bin/bananarchy-dpm.sh open >/dev/null 2>&1 || true
else
$QMICLI_MODEM --dpm-open-port=hw-data-ep-type=bam-dmux,hw-data-ep-iface-number=1,hw-data-rx-id=1,hw-data-tx-id=1 >/dev/null 2>&1 || true
_w=0
while [ "$_w" -lt 20 ] && [ ! -d /sys/class/net/wwan0 ]; do
sleep 0.1
_w=$((_w + 1))
done
fi
fi
QMI_CARDS="$($QMICLI_MODEM --uim-get-card-status 2>/dev/null || true)"
count=0
while : ; do
@@ -1462,14 +1475,14 @@ PY
sec_slot="${SECONDARY_GW_SLOT:-0}"
fi
fi
# If requested SIM is Secondary GW, use QMI VOICE USSD on sub=1
if [ "$req_sim" = "$sec_slot" ] && [ "$sec_slot" != "0" ] && command -v python3 >/dev/null 2>&1; then
qmi_ussd="$(python3 - "$ussd_mode" "$ussd_code" "1" << 'PY' 2>/dev/null || true
run_qmi_voice_ussd() {
command -v python3 >/dev/null 2>&1 || return 1
python3 - "$1" "$2" "$3" << 'PY' 2>/dev/null
import os, socket, struct, select, sys, time
mode = sys.argv[1]
code = sys.argv[2]
sub = int(sys.argv[3]) if len(sys.argv) > 3 and sys.argv[3].isdigit() else 1
sub = int(sys.argv[3]) if len(sys.argv) > 3 and sys.argv[3].isdigit() else 0
AF_QIPCRTR = 42
QRTR_PORT_CTRL = 0xfffffffe
QRTR_TYPE_NEW_SERVER = 4
@@ -1603,112 +1616,137 @@ while time.time() < deadline:
s.close()
sys.exit(1)
PY
)"
}
# If requested SIM is Secondary GW, use QMI VOICE USSD on sub=1
if [ "$req_sim" = "$sec_slot" ] && [ "$sec_slot" != "0" ]; then
qmi_ussd="$(run_qmi_voice_ussd "$ussd_mode" "$ussd_code" "1" || true)"
if [ -n "$qmi_ussd" ]; then
printf "%s\n" "$qmi_ussd"
exit 0
fi
fi
mm_out=""
if [ "$req_sim" = "$prim_slot" ]; then
mm_state="$(mmcli -m any -K 2>/dev/null | awk -F':[[:space:]]*' '{gsub(/[[:space:]]+$/, "", $1); if ($1 == "modem.generic.state") {print $2; exit}}' || true)"
if [ "$mm_state" = "disabled" ] || [ -z "$mm_state" ]; then
mmcli -m any -e >/dev/null 2>&1 || true
sleep 1
qmi_sess=""
[ -r /tmp/sxmo_ussd_session_state ] && { read -r qmi_sess < /tmp/sxmo_ussd_session_state 2>/dev/null || qmi_sess=""; }
mm_modem=""
if [ "$ussd_mode" != "respond" ] || [ "$qmi_sess" != "user-response" ]; then
mm_modem="$(mmcli -L 2>/dev/null | awk '{for (i=1; i<=NF; i++) if ($i ~ /^\/org\/freedesktop\/ModemManager1\/Modem\/[0-9]+$/) {print $i; exit}}')"
fi
modem_dbus_path="$(mmcli -m any -K 2>/dev/null | awk -F':[[:space:]]*' '{gsub(/[[:space:]]+$/, "", $1); if ($1 == "modem.dbus-path") {print $2; exit}}' || true)"
[ -z "$modem_dbus_path" ] && modem_dbus_path="/org/freedesktop/ModemManager1/Modem/0"
get_ussd_prop() {
prop_name="$1"
if [ -n "$modem_dbus_path" ] && command -v busctl >/dev/null 2>&1 && command -v jq >/dev/null 2>&1; then
busctl -j get-property org.freedesktop.ModemManager1 "$modem_dbus_path" \
org.freedesktop.ModemManager1.Modem.Modem3gpp.Ussd "$prop_name" 2>/dev/null | \
jq -r '.data // empty' 2>/dev/null || true
if [ -n "$mm_modem" ]; then
rm -f /tmp/sxmo_ussd_session_state
mm_state="$(mmcli -m "$mm_modem" -K 2>/dev/null | awk -F':[[:space:]]*' '{gsub(/[[:space:]]+$/, "", $1); if ($1 == "modem.generic.state") {print $2; exit}}' || true)"
if [ "$mm_state" = "disabled" ] || [ -z "$mm_state" ]; then
mmcli -m "$mm_modem" -e >/dev/null 2>&1 || true
sleep 1
fi
}
get_ussd_state() {
mmcli -m any --3gpp-ussd-status -K 2>/dev/null | \
awk -F':[[:space:]]*' '{gsub(/[[:space:]]+$/, "", $1); if ($1 == "modem.3gpp.ussd.status" || $1 == "modem.3gpp.ussd.state") {print $2; exit}}' || true
}
prev_notif="$(get_ussd_prop NetworkNotification)"
prev_req="$(get_ussd_prop NetworkRequest)"
ussd_st="$(get_ussd_state)"
if [ "$ussd_mode" = "respond" ] && [ "$ussd_st" != "user-response" ]; then
case "$ussd_code" in
\**\#|\#*\#)
ussd_mode="initiate"
;;
esac
fi
ev_file="/tmp/ussd_dbus_$$.log"
rm -f "$ev_file"
if command -v dbus-monitor >/dev/null 2>&1; then
dbus-monitor --system "interface='org.freedesktop.DBus.Properties',member='PropertiesChanged',arg0='org.freedesktop.ModemManager1.Modem.Modem3gpp.Ussd'" >"$ev_file" 2>/dev/null &
ev_pid=$!
else
ev_pid=""
fi
cleanup_ev() {
if [ -n "${ev_pid:-}" ]; then
kill "$ev_pid" 2>/dev/null || true
wait "$ev_pid" 2>/dev/null || true
modem_dbus_path="$mm_modem"
get_ussd_prop() {
prop_name="$1"
if [ -n "$modem_dbus_path" ] && command -v busctl >/dev/null 2>&1 && command -v jq >/dev/null 2>&1; then
busctl -j get-property org.freedesktop.ModemManager1 "$modem_dbus_path" \
org.freedesktop.ModemManager1.Modem.Modem3gpp.Ussd "$prop_name" 2>/dev/null | \
jq -r '.data // empty' 2>/dev/null || true
fi
}
get_ussd_state() {
mmcli -m "$mm_modem" --3gpp-ussd-status -K 2>/dev/null | \
awk -F':[[:space:]]*' '{gsub(/[[:space:]]+$/, "", $1); if ($1 == "modem.3gpp.ussd.status" || $1 == "modem.3gpp.ussd.state") {print $2; exit}}' || true
}
prev_notif="$(get_ussd_prop NetworkNotification)"
prev_req="$(get_ussd_prop NetworkRequest)"
ussd_st="$(get_ussd_state)"
if [ "$ussd_mode" = "respond" ] && [ "$ussd_st" != "user-response" ]; then
case "$ussd_code" in
\**\#|\#*\#)
ussd_mode="initiate"
;;
esac
fi
ev_file="/tmp/ussd_dbus_$$.log"
rm -f "$ev_file"
}
mm_rc=0
mm_out=""
if [ "$ussd_mode" = "respond" ]; then
mm_out="$(mmcli --timeout=30 -m any --3gpp-ussd-respond="$ussd_code" 2>&1)" || mm_rc=$?
else
if [ "$ussd_st" = "active" ] || [ "$ussd_st" = "user-response" ]; then
mmcli -m any --3gpp-ussd-cancel >/dev/null 2>&1 || true
if command -v dbus-monitor >/dev/null 2>&1; then
dbus-monitor --system "interface='org.freedesktop.DBus.Properties',member='PropertiesChanged',arg0='org.freedesktop.ModemManager1.Modem.Modem3gpp.Ussd'" >"$ev_file" 2>/dev/null &
ev_pid=$!
else
ev_pid=""
fi
mm_out="$(mmcli --timeout=30 -m any --3gpp-ussd-initiate="$ussd_code" 2>&1)" || mm_rc=$?
fi
if [ "$mm_rc" -eq 0 ] && [ -n "$mm_out" ]; then
reply="$(printf "%s\n" "$mm_out" | sed \
-e "1s/^USSD session initiated; new reply from network: '//" \
-e "1s/^response successfully sent in USSD session; new reply from network: '//" \
-e "1s/^USSD response sent; new reply from network: '//" \
-e "\$s/'$//")"
if [ -n "$reply" ]; then
cleanup_ev
printf "%s\n" "$reply"
exit 0
cleanup_ev() {
if [ -n "${ev_pid:-}" ]; then
kill "$ev_pid" 2>/dev/null || true
wait "$ev_pid" 2>/dev/null || true
fi
rm -f "$ev_file"
}
mm_rc=0
if [ "$ussd_mode" = "respond" ]; then
mm_out="$(mmcli --timeout=30 -m "$mm_modem" --3gpp-ussd-respond="$ussd_code" 2>&1)" || mm_rc=$?
else
if [ "$ussd_st" = "active" ] || [ "$ussd_st" = "user-response" ]; then
mmcli -m "$mm_modem" --3gpp-ussd-cancel >/dev/null 2>&1 || true
fi
mm_out="$(mmcli --timeout=30 -m "$mm_modem" --3gpp-ussd-initiate="$ussd_code" 2>&1)" || mm_rc=$?
fi
fi
# Check if the USSD response arrived asynchronously via D-Bus properties
w=0
while [ "$w" -lt 15 ]; do
cur_req="$(get_ussd_prop NetworkRequest)"
cur_notif="$(get_ussd_prop NetworkNotification)"
cur_st="$(get_ussd_state)"
if [ -n "$cur_req" ] && { [ "$cur_req" != "$prev_req" ] || [ "$cur_st" = "user-response" ] || grep -q "NetworkRequest" "$ev_file" 2>/dev/null; }; then
cleanup_ev
printf "%s\n" "$cur_req"
exit 0
if [ "$mm_rc" -eq 0 ] && [ -n "$mm_out" ]; then
reply="$(printf "%s\n" "$mm_out" | sed \
-e "1s/^USSD session initiated; new reply from network: '//" \
-e "1s/^response successfully sent in USSD session; new reply from network: '//" \
-e "1s/^USSD response sent; new reply from network: '//" \
-e "\$s/'$//")"
if [ -n "$reply" ]; then
cleanup_ev
printf "%s\n" "$reply"
exit 0
fi
fi
if [ -n "$cur_notif" ] && { [ "$cur_notif" != "$prev_notif" ] || grep -q "NetworkNotification" "$ev_file" 2>/dev/null || printf "%s" "$mm_out" | grep -q "USSD terminated by network"; }; then
cleanup_ev
printf "%s\n" "$cur_notif"
exit 0
fi
if [ "$cur_st" != "active" ] && [ "$w" -ge 3 ]; then
if [ -n "$cur_req" ]; then
# Check if the USSD response arrived asynchronously via D-Bus properties
w=0
while [ "$w" -lt 15 ]; do
cur_req="$(get_ussd_prop NetworkRequest)"
cur_notif="$(get_ussd_prop NetworkNotification)"
cur_st="$(get_ussd_state)"
if [ -n "$cur_req" ] && { [ "$cur_req" != "$prev_req" ] || [ "$cur_st" = "user-response" ] || grep -q "NetworkRequest" "$ev_file" 2>/dev/null; }; then
cleanup_ev
printf "%s\n" "$cur_req"
exit 0
fi
if [ -n "$cur_notif" ]; then
if [ -n "$cur_notif" ] && { [ "$cur_notif" != "$prev_notif" ] || grep -q "NetworkNotification" "$ev_file" 2>/dev/null || printf "%s" "$mm_out" | grep -q "USSD terminated by network"; }; then
cleanup_ev
printf "%s\n" "$cur_notif"
exit 0
fi
break
fi
sleep 0.2
w=$((w + 1))
done
cleanup_ev
if [ "$cur_st" != "active" ] && [ "$w" -ge 3 ]; then
if [ -n "$cur_req" ]; then
cleanup_ev
printf "%s\n" "$cur_req"
exit 0
fi
if [ -n "$cur_notif" ]; then
cleanup_ev
printf "%s\n" "$cur_notif"
exit 0
fi
break
fi
sleep 0.2
w=$((w + 1))
done
cleanup_ev
fi
# Fallback to direct QMI VOICE USSD on sub=0 when ModemManager is unavailable or fails
qmi_ussd="$(run_qmi_voice_ussd "$ussd_mode" "$ussd_code" "0" || true)"
if [ -n "$qmi_ussd" ]; then
printf "%s\n" "$qmi_ussd"
exit 0
fi
else
fallback_sub="0"
[ "$req_sim" = "2" ] && fallback_sub="1"
qmi_ussd="$(run_qmi_voice_ussd "$ussd_mode" "$ussd_code" "$fallback_sub" || true)"
if [ -n "$qmi_ussd" ]; then
printf "%s\n" "$qmi_ussd"
exit 0
fi
fi
# Fallback to direct AT+CUSD on the requested SIM AT port
if [ "$req_sim" = "$sec_slot" ] && [ "$sec_slot" != "0" ]; then
@@ -1751,11 +1789,14 @@ PY
exit 0
fi
done
if [ -n "${mm_out:-}" ]; then
printf "%s\n" "$mm_out"
else
echo "ERROR: USSD request failed"
fi
case "${mm_out:-}" in
""|*"couldn't find modem"*)
echo "ERROR: USSD request failed"
;;
*)
printf "%s\n" "$mm_out"
;;
esac
exit 1
;;