#!/bin/sh # B6J1 snapshot of a failed registration, taken BEFORE any stop/restart. Read-only: QMI GETs, AT read queries (one port open/close). O=${1:-/tmp/j-snap}; mkdir -p $O; Q="qmicli -p -d /dev/wwan0qmi0"; D=/tmp/aurora-modem.d BAM=/sys/bus/platform/devices/4080000.remoteproc:bam-dmux; AT=${AT_PORT:-/dev/wwan0at0} ts() { echo "$(cut -d' ' -f1 /proc/uptime) $(date -u +%H:%M:%S)"; } echo "<5>[j-snap] begin" > /dev/kmsg { echo "snapshot begin [$(ts)]"; cat $D/state; } > $O/meta.txt for a in nas-get-serving-system nas-get-system-info nas-get-signal-info dms-get-operating-mode uim-get-card-status \ nas-get-cell-location-info nas-get-rf-band-info; do { echo "### [$(ts)] qmicli -p -d /dev/wwan0qmi0 --$a"; timeout 20 $Q --$a 2>&1; echo "rc=$?"; } >> $O/qmi.txt; done if pidof ModemManager >/dev/null; then i=$(mmcli -L 2>/dev/null | grep -oE "Modem/[0-9]+" | head -1 | cut -d/ -f2) { echo "### [$(ts)] mmcli -m $i"; mmcli -m $i 2>&1 | sed 's/\x1b\[[0-9;]*m//g'; } > $O/mmcli.txt else echo "[$(ts)] ModemManager not running (failure occurred before the MM stage) - mmcli -m n/a" > $O/mmcli.txt; fi # AT: open the port ONCE, keep it open for all queries, close ONCE (JZ02: rapid open/close -> modem closes the channel) if [ -c $AT ] && ! pidof ModemManager >/dev/null; then echo "[$(ts)] open $AT" > $O/at.txt exec 3<>$AT ( while IFS= read -r l <&3; do echo "[$(ts)] < $l"; done ) >> $O/at.txt 2>&1 & RP=$! for c in AT AT+CEREG? AT+CGREG? AT+CREG? AT+CGATT? AT+COPS? AT+CEER; do echo "[$(ts)] > $c" >> $O/at.txt; printf '%s\r' "$c" >&3; sleep 3; done sleep 2; kill $RP 2>/dev/null; exec 3>&-; echo "[$(ts)] closed $AT" >> $O/at.txt else echo "[$(ts)] AT skipped: $AT missing or MM holds AT ports" > $O/at.txt; fi tr -d '\r' < $O/at.txt > $O/at.clean.txt { echo "### [$(ts)] remoteproc"; for r in /sys/class/remoteproc/remoteproc*; do echo "$r $(cat $r/name) $(cat $r/state)"; done echo "### bam-dmux"; for f in runtime_status runtime_active_time runtime_suspended_time control; do echo "$f=$(cat $BAM/power/$f)"; done echo "### ip link"; ip link; echo "### ip addr"; ip addr; echo "### ip route"; ip route echo "### ps"; ps; echo "### emmc"; cat /sys/block/mmcblk0/stat; } > $O/sys.txt 2>&1 dmesg > $O/dmesg.txt; cp $D/lifecycle.log $D/rmtfs.log $O/ 2>/dev/null; cp $D/qmi-*.txt $O/ 2>/dev/null echo "snapshot end [$(ts)]" >> $O/meta.txt; echo "<5>[j-snap] end" > /dev/kmsg