Files
makronix/mobile/tools/boot-loop.sh
T
lotherkandClaude Opus 5.5 a2c6cd1347 mobile: hotdogb bt-address as a service with re-probe, rmtfs waits for tqftpserv, boot-loop tool, handoff
- bt-address runs as a runit service (no longer from udev, where its wait
  for wlan0 held up the WLAN modules); on failure it re-probes the
  controller (unbind/bind of hci_uart_qca), three attempts.
- rmtfs (which starts the modem) waits for tqftpserv.
- tools/boot-loop.sh: N reboots with a check per boot, every wait
  bounded; tools/checks/ holds the checks.
- docs/HANDOFF.md: how to work with the phone, what works, what is open
  (WLAN missing in 2-3 boots of 15 -- the modem's WLAN QMI service never
  appears -- first).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 07:14:26 +00:00

51 lines
1.8 KiB
Bash

#!/bin/sh
#
# Reboot the phone N times and run CHECK (a file of POSIX sh, fed to sh on
# the phone) in each boot once its uptime has reached WAIT_UP seconds (default 45);
# one line per boot, "run I: <CHECK's output>", to LOG. Every step finds
# the phone anew (phone_addr: its IPv4 address, else its IPv6 link-local
# one -- the host's USB address comes and goes with the gadget) and every
# wait has a limit, so a boot that does not come back ends the loop
# instead of hanging it. tools/display-loop.sh is the same with a camera.
#
# Usage: boot-loop.sh N LOG CHECKFILE
set -u
. "$(dirname "$0")/lib.sh"
[ $# -eq 3 ] || { echo "usage: $0 N LOG CHECKFILE" >&2; exit 2; }
[ -r "$3" ] || die "no $3"
n=$1 log=$2 check=$3
up=${WAIT_UP:-45}
wait_phone() { # wait_phone SECONDS: the address, once it answers
_t=0
while [ "$_t" -lt "$1" ]; do
_a=$(phone_addr 2>/dev/null) && { echo "$_a"; return 0; }
sleep 3; _t=$((_t + 3))
done
return 1
}
i=1
while [ "$i" -le "$n" ]; do
a=$(wait_phone 60) || { echo "run $i: phone not reachable before the reboot" | tee -a "$log"; exit 1; }
old=$(phone_ssh "$a" 'cut -d. -f1 /proc/uptime' 2>/dev/null)
timeout 20 sh -c ". '$(dirname "$0")/lib.sh'; phone_ssh '$a' 'sync; reboot'" >/dev/null 2>&1
sleep 20
a=$(wait_phone 180) || { echo "run $i: NOT REACHABLE after the reboot" | tee -a "$log"; exit 1; }
now=$(phone_ssh "$a" 'cut -d. -f1 /proc/uptime' 2>/dev/null)
if [ -n "$old" ] && [ -n "$now" ] && [ "$now" -ge "$old" ]; then
echo "run $i: did not reboot (uptime $now s)" | tee -a "$log"
continue
fi
t=0
while [ "$t" -lt 180 ]; do
a=$(phone_addr 2>/dev/null) &&
phone_ssh "$a" "[ \$(cut -d. -f1 /proc/uptime) -ge $up ]" 2>/dev/null && break
sleep 3; t=$((t + 3))
done
echo "run $i: $(timeout 60 sh -c ". '$(dirname "$0")/lib.sh'; phone_ssh '$a' 'sh -s'" < "$check" 2>&1 | tr '\n' ' ')" | tee -a "$log"
i=$((i + 1))
done