metronome/rust/run.sh
Me Here 8f4264f4d2 pm-kit: defmt+probe-rs diagnostics + flip-link toolchain
Adopt proper embedded tooling for the blank-screen debug (user has a Pi Debug Probe):
- flip-link linker (baked into pm-rust:2): stack overflow faults cleanly instead of
  silently corrupting .bss/.data (the SPI buffer -> black screen class of bug).
- defmt + defmt-rtt + panic-probe: firmware logs boot/heap-free/display/parse/loop
  heartbeat over RTT; panics print message+location. .cargo runner = probe-rs run.
- Restore the full live metronome (from 08b0940) as the instrumented target.
- deploy + serve pm-kit.elf (probe-rs decodes defmt strings from the ELF).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-01 08:30:35 -05:00

25 lines
1 KiB
Bash
Executable file

#!/usr/bin/env bash
# Build (first time) and run the PM Rust container with the repo mounted.
#
# ./run.sh # cargo test (runs the golden-vector conformance suite)
# ./run.sh cargo build
# ./run.sh bash # interactive shell in rust/track-format/
#
# Override the runtime with RUNTIME=docker ./run.sh ...
set -euo pipefail
IMG="pm-rust:2"
RUST_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # rust/
REPO_DIR="$(cd "$RUST_DIR/.." && pwd)" # repo root
RUNTIME="${RUNTIME:-podman}"
if ! "$RUNTIME" image inspect "$IMG" >/dev/null 2>&1; then
echo ">> building $IMG (first run, a few minutes)…" >&2
"$RUNTIME" build -t "$IMG" "$RUST_DIR"
fi
# Mount the whole repo so the crate's tests can read tests/fixtures/ ; land in the crate dir.
flags=(--rm -v "$REPO_DIR":/work:Z -w /work/rust/track-format)
[[ -t 0 ]] && flags+=(-it)
if [[ $# -eq 0 ]]; then set -- cargo test; fi # default command (multi-word, so set positional args)
exec "$RUNTIME" run "${flags[@]}" "$IMG" "$@"