metronome/rust/pm-grid/build.sh
Me Here 56bff7e599 pm-grid: USB-MIDI audio + make Rust the shipping Grid firmware
Audio (the Scroll Pack has no speaker, so MIDI is the only path):
- usb-device 0.3 + usbd-midi 0.5 on the rp2040-hal UsbBus; enumerates as a
  class-compliant MIDI device 'PM_G-1 Grid'.
- tick() emits a GM note-on per lane hit on channel 10 (note from the ported
  SOUND_GM map, velocity by level) via send_bytes([0x09,0x99,note,vel]) — raw
  4-byte packets, so arbitrary GM drum notes work without the named Note enum.
- USB polled every loop iteration AND during the boot splash (so the host can
  enumerate during the ~2.5s animation).

Debug: defmt/defmt-rtt + panic-probe + flip-link; runner probe-rs run --chip
RP2040 (Pi Debug Probe). build.sh emits pm-grid.uf2 + pm-grid.elf; deploy serves
both; key info! log points + 1Hz heartbeat.

Web: drop CircuitPython from the PM_G-1 product. info-grid.html features the
Rust .uf2 download + accurate controls/views (X/Y swap, Ticker); build.sh +
deploy.sh no longer bundle/serve pm_g1_circuitpy.zip or pico-scroll-app.{py,mpy}.
pico-scroll/ stays as the reference port; editor FW_PATHS.G left for graceful
degradation.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-03 15:19:38 -05:00

24 lines
1 KiB
Bash
Executable file

#!/usr/bin/env bash
# Build pm-grid for the RP2040 and produce pm-grid.uf2.
# Flash: hold BOOTSEL on the Pico, plug in USB, drag pm-grid.uf2 onto the RPI-RP2 drive.
#
# ./build.sh
#
# Override the runtime with RUNTIME=docker ./build.sh
set -euo pipefail
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # rust/pm-grid
REPO="$(cd "$DIR/../.." && pwd)" # repo root
RUNTIME="${RUNTIME:-podman}"
IMG="pm-rust:2"
"$RUNTIME" run --rm -v "$REPO":/work:Z -w /work/rust/pm-grid "$IMG" bash -c '
set -e
rustup component add llvm-tools-preview >/dev/null 2>&1 || true
cargo build --release
OBJCOPY="$(rustc --print sysroot)/lib/rustlib/$(rustc -vV | sed -n "s/host: //p")/bin/llvm-objcopy"
"$OBJCOPY" -O binary target/thumbv6m-none-eabi/release/pm-grid pm-grid.bin
cp target/thumbv6m-none-eabi/release/pm-grid pm-grid.elf # ELF for probe-rs flash + defmt decode
'
python3 "$DIR/uf2.py" "$DIR/pm-grid.bin" "$DIR/pm-grid.uf2"
echo "$DIR/pm-grid.uf2 (hold BOOTSEL on the Pico, drag this onto the RPI-RP2 drive)"