uzbek-plus/r3/r3b/r3b-run.sh
q 8d7721c775 B7: add network time bootstrap and persistent B7C cache
B7A: QMI DMS time vs VNIIFTRI NTP (DMS = UTC - 0.28 s, sigma 1 ms; NITZ = DMS
truncated to 1 s). B7B: a 1970 -> 2026 date -s step is harmless for the modem
stack. B7C: aurora-modem probes DMS/NITZ along the start flow and steps
CLOCK_REALTIME once at the first valid sample (REG registered/attached), never
RTC; background SNTP check (query only) after START OK. 3/3 class-A cold boots
PASS (residual +0.04/+0.36/+0.84 s), cache 14fe453a written (B7C_WRITE_VERIFIED)
and verified by a normal power-on (V1, +0.26 s).

Also publishes the prerequisite R2 (boot-hang / lk eMMC investigation, T4
telnet baseline that B7C builds on) and R3 (autonomous cold boot, NCM loss)
material, and extends tools/publish-sanitize.py to r2/, r3/, b7/.
Binary images, initramfs, busybox and raw logs stay out (see b7/*/SHA256SUMS).
2026-10-02 20:18:25 +03:00

36 lines
3.5 KiB
Bash

#!/bin/sh
# R3B one-shot run on 480s: observers -> pre snapshot -> board observer -> 30 s baseline -> aurora-ncm down 60 s -> up -> 60 s -> post snapshot.
cd ~/doc/modem/jz08-aurora; O=logs/r3/r3b; mkdir -p $O; UU=34c357f3-43af-4c53-8151-a1f88a1514a6; DEV=enp60s0u1u2u1
A=$O/r3b-actions.txt; act() { echo "$(date +%H:%M:%S.%3N) $*" | tee -a $A; }
tn() { { sleep 1; sed "s/\$/\r/" "$1"; sleep $2; } | ncat 172.16.42.1 23 | tr -d "\000\r"; }
act "R3B-RUN-BEGIN"
OLD=$(ps -eo pid,cmd | grep "[u]artlog.py /dev/ttyUSB0" | awk '{print $1}'); [ -n "$OLD" ] && { kill $OLD; act "old uartlog PID $OLD killed"; }; sleep 1
TS=$(date +%Y%m%d-%H%M%S); U=logs/uart/r3b-$TS; echo $U > $O/uart-base.txt
setsid nohup python3 tools/uartlog.py /dev/ttyUSB0 $U > $U.stderr 2>&1 < /dev/null & act "uartlog PID $! -> $U.log"
setsid nohup logs/r3/r3a/host-ping-observer.sh $O/r3b-host-ping.txt > /dev/null 2>&1 < /dev/null & HP=$!; act "host ping observer PID $HP"
setsid sh -c 'nmcli monitor | while IFS= read -r l; do echo "$(date +%H:%M:%S.%3N) $l"; done' >> $O/r3b-nm-monitor.txt 2>&1 < /dev/null & NM=$!; act "nm monitor PGID $NM"
ab() { act "ABORT: $*"; kill $HP 2>/dev/null; kill -TERM -- -$NM 2>/dev/null; exit 1; }
act "NM: $(nmcli -g GENERAL.CONNECTION,GENERAL.STATE dev show $DEV | tr '\n' ' ') addr: $(ip -4 -o addr show dev $DEV | awk '{print $4}')"
nmcli -g GENERAL.CONNECTION dev show $DEV | grep -qx aurora-ncm || ab "$DEV not on aurora-ncm"
act "pre snapshot"; tn logs/r3/r3a/r3a-snap.cmds 45 > $O/r3b-pre-snapshot.txt
grep -q "R3A-SNAP-END" $O/r3b-pre-snapshot.txt || ab "pre snapshot incomplete"
printf 'mkdir -p /run/r3b; nc -l -p 9931 > /run/r3b/obs.sh &\n' > $O/.c1; tn $O/.c1 2 > /dev/null
ncat --send-only 172.16.42.1 9931 < $O/r3b-board-obs.sh; sleep 1
printf 'rm -f /run/r3b/obs.log; sha256sum /run/r3b/obs.sh; setsid sh /run/r3b/obs.sh > /dev/null 2>&1 < /dev/null & echo OBS_PID=$!\nsleep 8; ps | grep "[o]bs.sh"; tail -2 /run/r3b/obs.log\n' > $O/.c2
tn $O/.c2 12 > $O/r3b-obs-start.txt; act "board observer: $(grep -o 'OBS_PID=[0-9]*' $O/r3b-obs-start.txt) local sha $(sha256sum $O/r3b-board-obs.sh | cut -c1-16) board $(grep obs.sh $O/r3b-obs-start.txt | grep -o '^[0-9a-f]\{16\}' | head -1)"
grep -q "host=up" $O/r3b-obs-start.txt || ab "board observer not running"
act "baseline 30 s"; sleep 30
act "NCM DOWN: nmcli con down uuid $UU"; nmcli con down uuid $UU 2>&1 | tee -a $A
act "after down: $(ip -4 -o addr show dev $DEV | awk '{print $4}') / NM $(nmcli -g GENERAL.STATE dev show $DEV)"
sleep 60
act "NCM UP: nmcli con up uuid $UU"; nmcli con up uuid $UU 2>&1 | tee -a $A
i=0; until ping -c1 -W1 172.16.42.1 >/dev/null 2>&1; do i=$((i+1)); [ $i -ge 60 ] && break; done; act "ping 172.16.42.1 after up: $(ping -c1 -W1 172.16.42.1 >/dev/null 2>&1 && echo OK || echo FAIL) (tries $i)"
act "observe 60 s"; sleep 60
act "post snapshot"; tn logs/r3/r3a/r3a-snap.cmds 45 > $O/r3b-post-snapshot.txt
act "post snapshot complete: $(grep -c R3A-SNAP-END $O/r3b-post-snapshot.txt)"
printf 'P=$(ps | grep "[o]bs.sh" | awk "{print \\$1}"); echo OBS_KILL=$P; kill $P; sleep 1; echo OBS-LOG-BEGIN; cat /run/r3b/obs.log; echo OBS-LOG-END; dmesg | grep -E "r3b-obs|aurora-modem" | tail -60\n' > $O/.c3
tn $O/.c3 8 > $O/r3b-obs-fetch.txt
sed -n '/^OBS-LOG-BEGIN/,/^OBS-LOG-END/p' $O/r3b-obs-fetch.txt | grep -v '^OBS-LOG' > $O/r3b-board-obs.log
kill $HP; kill -TERM -- -$NM 2>/dev/null; act "host observers stopped; uartlog keeps running"
grep -a -E "r3b-obs|aurora-modem|usb|ncm|remoteproc|wwan|rmtfs|SBL1|Linux version" $U.log | cut -c1-220 > $O/r3b-uart-markers.txt; cp $U.log $O/r3b-uart.log
act "R3B-RUN-END"