#!/usr/bin/env bash # Build + flash the uSEQ-CV **expander** firmware (firmware/useq-celium/expander). # Target: uSEQ USEQHARDWARE_EXPANDER_OUT_0_1 (RP2040). Any extra args are passed # to pio (e.g. --upload-port /dev/ttyACM1). set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" BOARD_DIR="$SCRIPT_DIR/../firmware/useq-celium/expander" ENV="expander" if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then echo "Usage: scripts/flash-useq-expander.sh [extra pio args]" echo " Builds firmware/useq-celium/expander and uploads it to the uSEQ EXPANDER board." exit 0 fi # Resolve PlatformIO (nix-friendly: fall back to an ephemeral nix-shell). run_pio() { if command -v pio >/dev/null 2>&1; then pio "$@" elif command -v platformio >/dev/null 2>&1; then platformio "$@" elif command -v nix-shell >/dev/null 2>&1; then nix-shell -p platformio --run "pio $*" else echo "error: PlatformIO not found. Install it, e.g.:" >&2 echo " nix-shell -p platformio # or: pipx install platformio" >&2 exit 1 fi } echo "==> Build + flash uSEQ EXPANDER (env: $ENV)" echo " If the upload can't auto-reset the board, hold BOOTSEL while plugging in USB." cd "$BOARD_DIR" run_pio run -e "$ENV" -t upload "$@" echo "==> Done. The expander LEDs sweep when the main board forwards an Identify."