#!/usr/bin/env bash # Flash the firmware over USB, then open the serial monitor. # Usage: scripts/flash.sh [port] (default: the first Espressif device found) set -euo pipefail PORT="${1:-$(readlink -f /dev/serial/by-id/*Espressif* 2>/dev/null | head -1)}" [ -n "$PORT" ] || { echo "No Cardputer found on USB (is it plugged in / attached to the VM?)" >&2; exit 1; } source "$(dirname "$0")/_docker.sh" docker rm -f roro9stack-serial >/dev/null 2>&1 || true # a serial log would hold the port DOCKER_EXTRA=(--device "$PORT" --group-add "$(stat -c %g "$PORT")" -it) run_in_container bash -c "git config --global --add safe.directory /work && pio run -e cardputer-adv -t upload --upload-port $PORT && pio device monitor -p $PORT -b 115200"