#!/bin/sh # 480s side, B9L: RESET-held power-on -> current lk1st fastboot -> `fastboot boot IMG` (2nd-stage lk2nd, RAM only). # Nothing is flashed. Logs UART + fastboot identity before/after. usage: b9l-fb.sh TAG IMG SHA256 T=$1; IMG=$2; SHA=$3; cd ~/doc/modem/jz08-aurora; O=logs/b9/b9l/$T; mkdir -p $O; A=$O/host-actions.txt act() { echo "$(date -u +%H:%M:%S.%3N) $*" | tee -a $A; } echo "$SHA $IMG" | sha256sum -c || exit 1 OLD=$(ps -eo pid,cmd | grep "[u]artlog.py /dev/ttyUSB0" | awk '{print $1}'); [ -n "$OLD" ] && kill $OLD; sleep 1 U=logs/uart/b9l-$T-$(date +%Y%m%d-%H%M%S); setsid nohup python3 tools/uartlog.py /dev/ttyUSB0 $U > $U.stderr 2>&1 < /dev/null & echo $U > $O/uartlog-path act "B9L $T: waiting for lk1st fastboot (power off >= 90 s, then RESET held + battery -> USB)" 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: product=$(fastboot getvar product 2>&1 | sed -n 's/^product: //p')" { fastboot boot $IMG 2>&1; echo "rc=$?"; } | tee -a $A act "waiting for second-stage fastboot (or Linux NCM)" i=0; while [ $i -lt 90 ]; do if fastboot devices 2>/dev/null | grep -q ; then act "fastboot present again: product=$(fastboot getvar product 2>&1 | sed -n 's/^product: //p') version-bootloader=$(fastboot getvar version-bootloader 2>&1 | sed -n 's/^version-bootloader: //p')"; break; fi if ping -c1 -W1 172.16.42.1 >/dev/null 2>&1; then act "Linux NCM ping ok"; break; fi i=$((i+1)); sleep 2 done sleep 3; cp $U.log $O/uart.log; act "B9L $T END"