Add multi-panel Pico UDP firmware and Python LED control.
Pico panels get static IPs on 10.1.1.10–14 with per-panel LED counts, Makefile deploy targets, and Python examples for animations, sync tests, and direct Pi SPI control. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
116
scripts/panel_deploy.sh
Executable file
116
scripts/panel_deploy.sh
Executable file
@@ -0,0 +1,116 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build and upload portal panel firmware over USB.
|
||||
#
|
||||
# Usage:
|
||||
# ./scripts/panel_deploy.sh
|
||||
# ./scripts/panel_deploy.sh --build-only
|
||||
# ./scripts/panel_deploy.sh --upload-only
|
||||
#
|
||||
# Options:
|
||||
# --build-only Build, do not upload
|
||||
# --upload-only Upload existing build, skip compile
|
||||
# --panel-id N Pass -DPANEL_ID_BUILD=N to cmake
|
||||
# --no-dhcp Pass -DPORTAL_USE_DHCP=OFF to cmake
|
||||
# --num-leds N Pass -DNUM_LEDS_BUILD=N to cmake
|
||||
#
|
||||
# Environment:
|
||||
# PICO_SDK_PATH Path to pico-sdk (default: ~/pico/pico-sdk)
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
BUILD_DIR="${ROOT}/firmware/panel/build"
|
||||
PICO_SDK_PATH="${PICO_SDK_PATH:-${HOME}/pico/pico-sdk}"
|
||||
JOBS="$(nproc)"
|
||||
|
||||
DO_BUILD=1
|
||||
DO_UPLOAD=1
|
||||
CMAKE_EXTRA=()
|
||||
|
||||
die() {
|
||||
echo "Error: $*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
usage() {
|
||||
sed -n '2,16p' "$0" | sed 's/^# \{0,1\}//'
|
||||
exit "${1:-0}"
|
||||
}
|
||||
|
||||
while (($# > 0)); do
|
||||
case "$1" in
|
||||
--build-only)
|
||||
DO_UPLOAD=0
|
||||
shift
|
||||
;;
|
||||
--upload-only)
|
||||
DO_BUILD=0
|
||||
shift
|
||||
;;
|
||||
--panel-id)
|
||||
[[ $# -ge 2 ]] || die "--panel-id requires a number"
|
||||
CMAKE_EXTRA+=("-DPANEL_ID_BUILD=${2}")
|
||||
shift 2
|
||||
;;
|
||||
--no-dhcp)
|
||||
CMAKE_EXTRA+=("-DPORTAL_USE_DHCP=OFF")
|
||||
shift
|
||||
;;
|
||||
--num-leds)
|
||||
[[ $# -ge 2 ]] || die "--num-leds requires a number"
|
||||
CMAKE_EXTRA+=("-DNUM_LEDS_BUILD=${2}")
|
||||
shift 2
|
||||
;;
|
||||
-h|--help)
|
||||
usage 0
|
||||
;;
|
||||
*)
|
||||
die "unknown option: $1 (try --help)"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
build_firmware() {
|
||||
[[ -d "${PICO_SDK_PATH}" ]] || die "pico-sdk not found at ${PICO_SDK_PATH} (set PICO_SDK_PATH)"
|
||||
command -v cmake >/dev/null || die "cmake is required"
|
||||
command -v make >/dev/null || die "make is required"
|
||||
|
||||
export PICO_SDK_PATH
|
||||
mkdir -p "${BUILD_DIR}"
|
||||
|
||||
echo "==> Building panel firmware in ${BUILD_DIR}"
|
||||
if [[ ! -f "${BUILD_DIR}/CMakeCache.txt" ]]; then
|
||||
cmake -S "${ROOT}/firmware/panel" -B "${BUILD_DIR}" "${CMAKE_EXTRA[@]}"
|
||||
elif ((${#CMAKE_EXTRA[@]} > 0)); then
|
||||
cmake -S "${ROOT}/firmware/panel" -B "${BUILD_DIR}" "${CMAKE_EXTRA[@]}"
|
||||
fi
|
||||
cmake --build "${BUILD_DIR}" -j "${JOBS}"
|
||||
|
||||
[[ -f "${BUILD_DIR}/panel.uf2" ]] || die "build did not produce panel.uf2"
|
||||
echo "==> Build OK: ${BUILD_DIR}/panel.uf2"
|
||||
}
|
||||
|
||||
upload_usb() {
|
||||
command -v picotool >/dev/null || die "picotool not found (install from https://github.com/raspberrypi/picotool)"
|
||||
if picotool version 2>&1 | grep -q 'without USB support'; then
|
||||
die "picotool was built without USB support; rebuild with libusb-1.0-0-dev installed"
|
||||
fi
|
||||
|
||||
echo "==> Uploading over USB"
|
||||
if ! picotool load -x -f "${BUILD_DIR}/panel.uf2" 2>&1 | tee /tmp/picotool_load.log; then
|
||||
die "picotool load failed"
|
||||
fi
|
||||
if ! grep -q 'Loading into Flash' /tmp/picotool_load.log; then
|
||||
die "picotool did not flash (hold BOOTSEL, plug USB, retry)"
|
||||
fi
|
||||
echo "==> USB upload OK"
|
||||
}
|
||||
|
||||
if ((DO_BUILD)); then
|
||||
build_firmware
|
||||
fi
|
||||
|
||||
if ((DO_UPLOAD)); then
|
||||
[[ -f "${BUILD_DIR}/panel.uf2" ]] || die "panel.uf2 not found; run without --upload-only first"
|
||||
upload_usb
|
||||
fi
|
||||
Reference in New Issue
Block a user