Keep a log of every install, and stop the kit dying on a LattePanda-branded Leonardo
This commit is contained in:
parent
44f8d3b0dd
commit
5bfc558435
|
|
@ -192,6 +192,9 @@ do_preconditions() {
|
||||||
local now; now="$(cat /sys/module/usbcore/parameters/usbfs_memory_mb 2>/dev/null || echo '?')"
|
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"
|
[[ $now == 1000 ]] && say "usbfs_memory_mb = $now" || warn "usbfs_memory_mb is $now, expected 1000"
|
||||||
local lpm; lpm="$(probe_camera_lpm_path)"
|
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
|
if [[ -n $lpm ]]; then
|
||||||
[[ "$(cat "$lpm")" == 0 ]] && say "camera USB3 LPM disabled ($lpm)" \
|
[[ "$(cat "$lpm")" == 0 ]] && say "camera USB3 LPM disabled ($lpm)" \
|
||||||
|| warn "camera USB3 LPM still $(cat "$lpm") at $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
|
# The MCU has to be writable for flashing over ssh; check it the same way
|
||||||
# rather than trusting that the rule took.
|
# rather than trusting that the rule took.
|
||||||
local mcu_dev
|
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
|
if [[ -n $mcu_dev ]]; then
|
||||||
local node
|
local node
|
||||||
node="$(printf '/dev/bus/usb/%03d/%03d' "$(cat "$(dirname "$mcu_dev")/busnum")" \
|
node="$(printf '/dev/bus/usb/%03d/%03d' "$(cat "$(dirname "$mcu_dev")/busnum")" \
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,17 @@ fetch fwt_software software
|
||||||
fetch fwt_firmware firmware
|
fetch fwt_firmware firmware
|
||||||
|
|
||||||
# ---- the installer ---------------------------------------------------------
|
# ---- 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"
|
say "starting the installer"
|
||||||
cd "$BASE/software"
|
cd "$BASE/software"
|
||||||
exec scripts/install-tower "$@"
|
exec scripts/install-tower "${args[@]}"
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,14 @@ while [[ $# -gt 0 ]]; do
|
||||||
shift
|
shift
|
||||||
done
|
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' "$*"; }
|
say() { printf '>> %s\n' "$*"; }
|
||||||
warn() { printf '!! %s\n' "$*" >&2; }
|
warn() { printf '!! %s\n' "$*" >&2; }
|
||||||
die() { printf 'install-tower: %s\n' "$*" >&2; exit 1; }
|
die() { printf 'install-tower: %s\n' "$*" >&2; exit 1; }
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue