Keep a log of every install, and stop the kit dying on a LattePanda-branded Leonardo

This commit is contained in:
pgdalmeida 2026-09-28 17:20:38 +02:00
parent 44f8d3b0dd
commit 5bfc558435
Signed by: pedro.almeida
GPG Key ID: D4A6C394DF13F1D7
3 changed files with 27 additions and 2 deletions

View File

@ -192,6 +192,9 @@ do_preconditions() {
local now; now="$(cat /sys/module/usbcore/parameters/usbfs_memory_mb 2>/dev/null || echo '?')"
[[ $now == 1000 ]] && say "usbfs_memory_mb = $now" || warn "usbfs_memory_mb is $now, expected 1000"
local lpm; lpm="$(probe_camera_lpm_path)"
# The rule acts when the camera is (re)plugged, and a udev trigger does not
# always replay it (on staeffelsberg it did not): write what it would write.
if [[ -n $lpm && "$(cat "$lpm")" != 0 ]]; then echo 0 > "$lpm" 2>/dev/null || true; fi
if [[ -n $lpm ]]; then
[[ "$(cat "$lpm")" == 0 ]] && say "camera USB3 LPM disabled ($lpm)" \
|| warn "camera USB3 LPM still $(cat "$lpm") at $lpm"
@ -202,7 +205,10 @@ do_preconditions() {
# The MCU has to be writable for flashing over ssh; check it the same way
# rather than trusting that the rule took.
local mcu_dev
mcu_dev="$(grep -l "^$KIT_MCU_VID\$" /sys/bus/usb/devices/*/idVendor 2>/dev/null | head -1)"
# `|| true`: an MCU with another vendor id (the LattePanda's own Leonardo,
# 3343) finds nothing here, and under set -e -o pipefail that ended the whole
# kit - and the installer with it - without a word.
mcu_dev="$(grep -l "^$KIT_MCU_VID\$" /sys/bus/usb/devices/*/idVendor 2>/dev/null | head -1 || true)"
if [[ -n $mcu_dev ]]; then
local node
node="$(printf '/dev/bus/usb/%03d/%03d' "$(cat "$(dirname "$mcu_dev")/busnum")" \

View File

@ -80,6 +80,17 @@ fetch fwt_software software
fetch fwt_firmware firmware
# ---- the installer ---------------------------------------------------------
# It runs from the software checkout, so a file named relative to where this was
# started (--answers staeffelsberg.answers) is made absolute first.
args=()
while [[ $# -gt 0 ]]; do
args+=("$1")
if [[ $1 == --answers && $# -gt 1 ]]; then
shift
[[ $1 == /* ]] && args+=("$1") || args+=("$PWD/$1")
fi
shift
done
say "starting the installer"
cd "$BASE/software"
exec scripts/install-tower "$@"
exec scripts/install-tower "${args[@]}"

View File

@ -74,6 +74,14 @@ while [[ $# -gt 0 ]]; do
shift
done
# Everything it prints also goes to a log, so a long run can be read back and
# passed on whole - a terminal's scrollback does not keep it. The questions are
# asked on /dev/tty, so they are not affected.
mkdir -p "$LOGDIR"
RUN_LOG="$LOGDIR/install-$(date +%Y%m%d-%H%M%S).log"
exec > >(tee -a "$RUN_LOG") 2>&1
printf 'install-tower %s (this output is also in %s)\n' "$*" "$RUN_LOG"
say() { printf '>> %s\n' "$*"; }
warn() { printf '!! %s\n' "$*" >&2; }
die() { printf 'install-tower: %s\n' "$*" >&2; exit 1; }