Add CircuitPython RLCD migration prototype
This commit is contained in:
Executable
+74
@@ -0,0 +1,74 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
PORT="${PORT:-/dev/ttyACM0}"
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
FIRMWARE="$ROOT/firmware/adafruit-circuitpython-espressif_esp32s3_devkitc_1_n8r8-en_US-10.2.1.bin"
|
||||
CIRCUITPY_MOUNT="${CIRCUITPY_MOUNT:-}"
|
||||
|
||||
if [[ ! -f "$FIRMWARE" ]]; then
|
||||
echo "Firmware not found: $FIRMWARE" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -r "$PORT" || ! -w "$PORT" ]]; then
|
||||
cat >&2 <<EOF
|
||||
Cannot access $PORT as $(id -un).
|
||||
|
||||
Temporary fix from a local terminal:
|
||||
sudo chmod 666 $PORT
|
||||
|
||||
Permanent fix:
|
||||
sudo usermod -aG dialout $(id -un)
|
||||
# then log out/in, or start a new shell with: newgrp dialout
|
||||
EOF
|
||||
exit 2
|
||||
fi
|
||||
|
||||
echo "==> Probing ESP32-S3 on $PORT"
|
||||
uvx esptool --chip esp32s3 --port "$PORT" flash-id
|
||||
|
||||
echo "==> Erasing flash"
|
||||
uvx esptool --chip esp32s3 --port "$PORT" erase-flash
|
||||
|
||||
echo "==> Flashing CircuitPython N8R8 firmware"
|
||||
uvx esptool --chip esp32s3 --port "$PORT" --baud 460800 write-flash -z 0x0 "$FIRMWARE"
|
||||
|
||||
echo "==> Waiting for CIRCUITPY mount"
|
||||
for _ in $(seq 1 60); do
|
||||
if [[ -n "$CIRCUITPY_MOUNT" && -d "$CIRCUITPY_MOUNT" ]]; then
|
||||
break
|
||||
fi
|
||||
for candidate in \
|
||||
"/media/$USER/CIRCUITPY" \
|
||||
"/run/media/$USER/CIRCUITPY" \
|
||||
"/media/$(id -un)/CIRCUITPY" \
|
||||
"/Volumes/CIRCUITPY"; do
|
||||
if [[ -d "$candidate" ]]; then
|
||||
CIRCUITPY_MOUNT="$candidate"
|
||||
break 2
|
||||
fi
|
||||
done
|
||||
sleep 1
|
||||
done
|
||||
|
||||
if [[ -z "$CIRCUITPY_MOUNT" || ! -d "$CIRCUITPY_MOUNT" ]]; then
|
||||
cat >&2 <<EOF
|
||||
Flashing finished, but CIRCUITPY did not auto-mount.
|
||||
Reset the board once, then rerun just deployment with:
|
||||
CIRCUITPY_MOUNT=/path/to/CIRCUITPY bash circuitpython/deploy_only.sh
|
||||
EOF
|
||||
exit 3
|
||||
fi
|
||||
|
||||
echo "==> Deploying prototype to $CIRCUITPY_MOUNT"
|
||||
mkdir -p "$CIRCUITPY_MOUNT/lib"
|
||||
cp "$ROOT/circuitpython/code.py" "$CIRCUITPY_MOUNT/code.py"
|
||||
cp "$ROOT/circuitpython/lib/"*.py "$CIRCUITPY_MOUNT/lib/"
|
||||
cp "$ROOT/circuitpython/lib/"*.mpy "$CIRCUITPY_MOUNT/lib/"
|
||||
sync
|
||||
|
||||
echo "==> Deployed. Files on CIRCUITPY:"
|
||||
find "$CIRCUITPY_MOUNT" -maxdepth 2 -type f | sort
|
||||
|
||||
echo "==> Done. Reset the board if it does not reload automatically."
|
||||
Reference in New Issue
Block a user