#!/bin/sh # 480s side, B8F boot K MODE. MODE=ram: RESET-held power-on -> lk1st fastboot -> `fastboot boot` B8F RAM image (pre-write autostart test). # MODE=cold: normal power-on (no RESET, no fastboot) -> lk2nd extlinux from eMMC cache. Script only observes + reads over telnet; # nothing is written to eMMC. Phone/AP check is done separately (needs the operator). K=$1; MODE=$2; case "$MODE" in ram|cold) ;; *) echo "usage: $0 K ram|cold"; exit 2;; esac cd ~/doc/modem/jz08-aurora; O=logs/b8/b8f/$MODE$K; mkdir -p $O; IMG=b8/b8f/out/aurora-b8f.img A=$O/host-actions.txt; act() { echo "$(date -u +%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"; } OLD=$(ps -eo pid,cmd | grep "[u]artlog.py /dev/ttyUSB0" | awk '{print $1}'); [ -n "$OLD" ] && kill $OLD; sleep 1 U=logs/uart/b8f-$MODE$K-$(date +%Y%m%d-%H%M%S); setsid nohup python3 tools/uartlog.py /dev/ttyUSB0 $U > $U.stderr 2>&1 < /dev/null & if [ $MODE = ram ]; then echo "355cc3bbb9a4d165382bde2664f27a525039900ab736b1ea28244c99591b9173 $IMG" | sha256sum -c || exit 1 act "B8F $MODE$K: waiting for fastboot (power off >= 90 s, then RESET held + battery -> USB)" if fastboot devices 2>/dev/null | grep -q ; then act "already in fastboot - wait for power-off"; until ! fastboot devices 2>/dev/null | grep -q ; do sleep 1; done; fi i=0; until fastboot devices 2>/dev/null | grep -q ; do i=$((i+1)); [ $i -ge 600 ] && { act "ABORT: no fastboot"; exit 1; }; sleep 2; done act "fastboot present"; { fastboot boot $IMG 2>&1; echo "rc=$?"; } | tee -a $A else act "B8F $MODE$K: waiting for the board to go away (power off >= 90 s), then normal power-on WITHOUT RESET" until ! ping -c1 -W1 172.16.42.1 >/dev/null 2>&1; do sleep 1; done; act "board unreachable (powered off)" until ping -c1 -W1 172.16.42.1 >/dev/null 2>&1; do fastboot devices 2>/dev/null | grep -q && { act "ABORT: board is in fastboot - RESET was held?"; exit 1; }; sleep 1; done fi i=0; until ping -c1 -W1 172.16.42.1 >/dev/null 2>&1; do i=$((i+1)); [ $i -ge 180 ] && { act "ABORT: NCM not up"; cp $U.log $O/uart.log; exit 1; }; sleep 1; done; act "NCM ping ok" R=$(grep -a "rtc-pm8xxx.*setting system clock" $U.log | tail -1 | sed -n 's/.*(\([0-9]*\)).*/\1/p'); C=B; [ -n "$R" ] && [ "$R" -lt 40 ] && C=A; act "RTC at boot ${R:-?} s -> class $C" printf 'cat /proc/device-tree/model; echo; uname -r; grep -E "START OK|FAIL in|rollback" /run/aurora-modem/lifecycle.log | tail -1\n' > $O/.w i=0; until tn $O/.w 3 | grep -qE "^\[[0-9.]+\] .*(=== START OK|FAIL in|rollback)"; do i=$((i+1)); [ $i -ge 80 ] && { act "no START OK/FAIL after ~12 min"; break; }; sleep 6; done tn $O/.w 3 | grep -aE "Aurora|aurora-b8|START OK|FAIL" | tee -a $A printf 'grep -E "AP ENABLED|FAIL" /run/aurora-wifi/wifi.log | tail -1\n' > $O/.a i=0; until tn $O/.a 3 | grep -qE "^\[[0-9.]+\] (=== AP ENABLED|FAIL)"; do i=$((i+1)); [ $i -ge 20 ] && { act "no AP ENABLED/FAIL after ~3 min"; break; }; sleep 6; done act "wifi: $(tn $O/.a 3 | grep -E '^\[[0-9.]+\] (=== AP ENABLED|FAIL)' | tail -1)" printf 'grep -E "SNTP (check|STEP|: )" /run/aurora-modem/lifecycle.log | tail -2\n' > $O/.s i=0; until tn $O/.s 3 | grep -qE "^\[[0-9.]+\] SNTP"; do i=$((i+1)); [ $i -ge 15 ] && break; sleep 4; done; act "sntp: $(tn $O/.s 3 | grep -E '^\[[0-9.]+\] SNTP' | tail -2 | tr '\n' ' ')" cat > $O/.c <<'C' echo SNAP-BEGIN; cat /proc/uptime; date -u; cat /proc/device-tree/model; echo; uname -a; cat /proc/cmdline echo ---time; cat /run/aurora-modem/time-set; grep -E "TIME|SNTP" /run/aurora-modem/lifecycle.log | tail -4 echo ---modem; /etc/init.d/aurora-modem status echo ---wifi; /etc/init.d/aurora-wifi status; echo ---wifilog; cat /run/aurora-wifi/wifi.log; cat /run/aurora-wifi/service.log; echo ---hostapdlog; cat /run/aurora-wifi/hostapd.log for r in /sys/class/remoteproc/*; do echo "RP $(cat $r/name)=$(cat $r/state)"; done; iw dev echo ---dmesg-wifi; dmesg | grep -iE "wcn36xx|wcnss|a204000|cfg80211|aurora-wifi|crash|watchdog" echo ---ping; ping -c4 -W3 -I wwan0 77.88.8.8 | tail -2 echo ---emmc; awk "{print \"w=\"\$5\" s=\"\$7}" /sys/block/mmcblk0/stat echo SNAP-END C tn $O/.c 25 > $O/snapshot.txt; act "snapshot: $(grep -c SNAP-END $O/snapshot.txt) end markers; $(grep -E '^RP a204' $O/snapshot.txt)" printf 'dmesg > /tmp/dm.txt; nc -l -p 9881 < /tmp/dm.txt &\n' > $O/.d; tn $O/.d 3 >/dev/null; sleep 1; ncat --recv-only 172.16.42.1 9881 > $O/dmesg.full cp $U.log $O/uart.log; act "B8F $MODE$K END - phone check next"