From b293197ace916d9bae8c861df03dd4abdd5da8b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Martin?= Date: Fri, 2 Oct 2026 09:05:15 +0200 Subject: [PATCH] flash.sh: auto-detect the Cardputer serial port The port number changes when the device re-enumerates (ttyACM0 -> ttyACM1). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT --- README.md | 4 ++-- scripts/flash.sh | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d041512..c2f1356 100644 --- a/README.md +++ b/README.md @@ -20,11 +20,11 @@ This runs the host-side unit tests (`test/`, `native` environment), then builds ## Flash -1. Connect the Cardputer by USB-C. It shows up as `/dev/ttyACM0`. +1. Connect the Cardputer by USB-C. 2. Run: ```sh - scripts/flash.sh # or: scripts/flash.sh /dev/ttyACM1 + scripts/flash.sh # auto-detects the port; or: scripts/flash.sh /dev/ttyACM1 ``` This uploads the firmware, then opens the serial monitor. Quit the monitor with `Ctrl+C`. diff --git a/scripts/flash.sh b/scripts/flash.sh index ca689a2..7a962ef 100755 --- a/scripts/flash.sh +++ b/scripts/flash.sh @@ -1,8 +1,9 @@ #!/usr/bin/env bash # Flash the firmware over USB, then open the serial monitor. -# Usage: scripts/flash.sh [/dev/ttyACM0] +# Usage: scripts/flash.sh [port] (default: the first Espressif device found) set -euo pipefail -PORT="${1:-/dev/ttyACM0}" +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_EXTRA=(--device "$PORT" --group-add "$(stat -c %g "$PORT")" -it)