build(v2): root Makefile for build, flash and monitor

make build / flash / monitor / flash-monitor / log / size / menuconfig /
erase / clean / test run ESP-IDF in Docker and handle rootless ownership.
Adds the helper scripts behind log and test, and a --settle option for
usb_latency.py (an ESP32-C3 driver resets when its port is opened).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
jimmyandClaude Sonnet 5.5 committed 2026-10-27 22:30:26 +13:00
1 parent f7ac4ab290
commit 899d4f2418
4 files changed
+134 -1

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
#!/usr/bin/env python3
"""Run the led-driver link and beat tests on the host (they are plain Python)."""
import os
import sys
root = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", "led-driver")
sys.path[:0] = [os.path.join(root, "src"), os.path.join(root, "tests")]
import test_beat_sync # noqa: E402
import test_espnow_rx # noqa: E402
n = 0
for mod in (test_espnow_rx, test_beat_sync):
for name, fn in vars(mod).items():
if name.startswith("test_") and callable(fn):
fn()
n += 1
print(f"{n} driver tests passed")
+19
View File
@@ -0,0 +1,19 @@
#!/usr/bin/env python3
"""Reset the board on PORT and print its console for SECS seconds (no terminal needed)."""
import sys
import time
import serial
port = sys.argv[1] if len(sys.argv) > 1 else "/dev/ttyACM0"
secs = float(sys.argv[2]) if len(sys.argv) > 2 else 10
s = serial.Serial(port, 115200, timeout=0.3)
s.dtr, s.rts = False, True # pulse reset through the USB serial lines
time.sleep(0.1)
s.rts = False
end = time.time() + secs
while time.time() < end:
data = s.read(4096)
if data:
sys.stdout.write(data.decode(errors="replace"))
sys.stdout.flush()
+4 -1
View File
@@ -105,12 +105,15 @@ def main():
ap.add_argument("--beats", type=int, default=200)
ap.add_argument("--lead-ms", type=float, default=30.0, help="CONFIG_BEAT_LEAD_MS")
ap.add_argument("--no-start", action="store_true", help="do not start the generator (it is already running)")
ap.add_argument("--settle", type=float, default=0.5,
help="seconds to wait after opening the ports; use about 14 for an ESP32-C3 driver, which "
"resets when its USB port is opened")
a = ap.parse_args()
rc = Reader(a.ctrl_port, r"\bBT (\d+) (\d+)")
rd = Reader(a.drv_port, r"\bFIRE (\d+) (\d+)")
rc.start(); rd.start()
time.sleep(0.5)
time.sleep(a.settle)
if not a.no_start:
req = urllib.request.Request(a.url + "/test/beats", data=json.dumps({"bpm": a.bpm, "count": a.beats}).encode(),
method="POST")