Files
m5stack-dashboard/scripts/deploy.sh
T
2026-08-01 23:57:41 +02:00

36 lines
942 B
Bash

#!/usr/bin/env bash
set -euo pipefail
# Build + flash the M5Stack Dashboard project via PlatformIO on Linux/macOS.
#
# Usage:
# ./scripts/deploy.sh # auto-detect USB port
# ./scripts/deploy.sh /dev/ttyUSB0 # force a specific port
#
# This script intentionally does NOT open the serial monitor afterwards.
# Uses the same local virtualenv as build.sh, created automatically if missing.
cd "$(dirname "$0")/.."
VENV_DIR=".venv-platformio"
if [ ! -d "$VENV_DIR" ]; then
echo "Creating local virtualenv in $VENV_DIR ..."
python3 -m venv "$VENV_DIR"
"$VENV_DIR/bin/pip" install --upgrade pip
"$VENV_DIR/bin/pip" install platformio
fi
PIO="$VENV_DIR/bin/pio"
if [ "$#" -ge 1 ]; then
PORT="$1"
echo "Using forced upload port: $PORT"
"$PIO" run --target upload --upload-port "$PORT"
else
echo "Auto-detecting upload port..."
"$PIO" run --target upload
fi
echo "Build + flash complete."