diff --git a/hardware/common/kit.sh b/hardware/common/kit.sh index 00e814b..7c1b58c 100644 --- a/hardware/common/kit.sh +++ b/hardware/common/kit.sh @@ -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")" \ diff --git a/scripts/bootstrap-tower b/scripts/bootstrap-tower index 0d02247..8a7bdfe 100755 --- a/scripts/bootstrap-tower +++ b/scripts/bootstrap-tower @@ -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[@]}" diff --git a/scripts/install-tower b/scripts/install-tower index 83f58aa..6138cef 100755 --- a/scripts/install-tower +++ b/scripts/install-tower @@ -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; }