uzbek-plus/r2/t1-watch.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

53 lines
3.4 KiB
Bash
Executable file

#!/bin/bash
# T1 watcher (480s, read-only on board): for every new SBL1 start in the UART log, classify A/B from SBL1 telemetry,
# wait for Linux /init, then dump PM8916 PON block 0x800-0x8FF (+ MISC 0x900 non-zero) over the UART console.
L=~/doc/modem/jz08-aurora/logs/uart/b6-20260930-160910.log
OUT=~/doc/modem/jz08-aurora/logs/r2/t1; mkdir -p $OUT
TTY=/dev/ttyUSB0
dumpcmd() { # $1 = id
printf '%s\r' "grep -q ' /sys/kernel/debug ' /proc/mounts || mount -t debugfs debugfs /sys/kernel/debug; R=/sys/kernel/debug/regmap/0-00/registers; { dd if=\$R bs=9 skip=2048 count=256 2>/dev/null; dd if=\$R bs=9 skip=2304 count=256 2>/dev/null | grep -v ': 00\$'; } > /tmp/t1.txt; echo T1-BEGIN-$1; sed 's/^/T1R /' /tmp/t1.txt; echo T1-SUM-$1 \$(md5sum < /tmp/t1.txt) up=\$(cut -d' ' -f1 /proc/uptime); echo T1-END-$1" > $TTY
}
capture() { # $1 id, $2 start line
for try in 1 2 3; do
dumpcmd $1-$try
for i in $(seq 1 20); do sleep 1; tail -n +$2 $L | grep -a -q "^.\{13\}T1-END-$1-$try" && break; done
seg=$(tail -n +$2 $L | sed -n "/^.\{13\}T1-BEGIN-$1-$try/,/^.\{13\}T1-END-$1-$try/p")
body=$(echo "$seg" | grep -a "^.\{13\}T1R " | cut -c18-)
want=$(echo "$seg" | grep -a -o "T1-SUM-$1-$try [0-9a-f]*" | awk '{print $2}')
got=$(printf '%s\n' "$body" | md5sum | awk '{print $1}')
if [ -n "$want" ] && [ "$want" = "$got" ]; then printf '%s\n' "$body" > $OUT/$1-regs.txt; echo "$seg" | grep -a "T1-SUM" >> $OUT/$1-meta.txt; return 0; fi
echo "try $try md5 mismatch want=$want got=$got" >> $OUT/$1-meta.txt
done; return 1
}
pos=$(wc -l < $L); pos=$((pos+1))
[ "$1" = now ] && { id=t1-$(date +%H%M%S)-baseline; echo "baseline (current boot)" > $OUT/$id-meta.txt; capture $id $pos && echo "$id OK" || echo "$id FAIL"; exit; }
echo "watching from line $pos"
while true; do
n=$(tail -n +$pos $L | grep -a -n "SBL1, Start" | head -1 | cut -d: -f1)
if [ -z "$n" ]; then sleep 1; continue; fi
s=$((pos+n-1)); ts=$(sed -n "${s}p" $L | cut -c1-8 | tr -d :)
sleep 3
sbl=$(sed -n "${s},$((s+40))p" $L)
sblS=$(echo "$sbl" | grep -a -o "B - *[0-9]* - SBL1, Start" | awk '{print $3}' | head -1)
pmd=$(echo "$sbl" | grep -a -o "D - *[0-9]* - pm_device_init" | awk '{print $3}' | head -1)
cls=U; [ -n "$pmd" ] && { if [ "$pmd" -lt 11500 ]; then cls=A; elif [ "$pmd" -gt 15000 ]; then cls=C; else cls=B; fi; }
id=t1-$ts-$cls
{ echo "start line $s time $ts sblS=$sblS pm_device_init=$pmd class=$cls"; echo "$sbl" | grep -a -E "batt_voltage|D - .*(pm_driver_init|SBL1, Delta|boot_config)"; } > $OUT/$id-meta.txt
echo "$(date +%T) new start $id"
# wait for Linux init marker of THIS boot (stop if another SBL1 start appears first)
ok=0
for i in $(seq 1 120); do
sleep 1
seg=$(tail -n +$((s+1)) $L)
if echo "$seg" | grep -a -q "SBL1, Start"; then echo "re-start before Linux" >> $OUT/$id-meta.txt; break; fi
echo "$seg" | grep -a -q "EMMC-RO-SUMMARY" && { ok=1; break; }
done
pos=$((s+1))
if [ $ok = 1 ]; then
sleep 8
if tail -n +$((s+1)) $L | grep -a -q "SBL1, Start"; then echo "re-start during wait" >> $OUT/$id-meta.txt; continue; fi
capture $id $((s+1)) && echo "$(date +%T) $id captured" || echo "$(date +%T) $id capture FAILED"
else
echo "$(date +%T) $id did not reach Linux in 120 s (or restarted)"; grep -a "SBL1, End\|welcome to lk\|target_init\|Booting Linux" <(sed -n "${s},\$p" $L | head -400) | head -5 | sed 's/^/ /' >> $OUT/$id-meta.txt
fi
done