From 7a74c02b206f8dd14d4ade7b6d4ec02772615022 Mon Sep 17 00:00:00 2001 From: Julian Cuni Date: Mon, 28 Sep 2026 10:21:06 +0200 Subject: [PATCH] docs: COMMANDS.md - build, upload, monitor and console cheat-sheet for both controllers --- CLAUDE.md | 2 + README.md | 2 + docs/COMMANDS.md | 194 ++++++++++++++++++++++++++++++++ src/modules/settings_screen.cpp | 4 +- 4 files changed, 200 insertions(+), 2 deletions(-) create mode 100644 docs/COMMANDS.md diff --git a/CLAUDE.md b/CLAUDE.md index ffbddf2..659d93e 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -12,6 +12,8 @@ Automotive display controller for **Waveshare ESP32-S3-Touch-LCD-5B** (1024x600 ## Build & Development Commands +The complete cheat-sheet for BOTH controllers (build, upload, monitor, every console command, pairing, releasing) is `docs/COMMANDS.md`. Keep it current when a command changes. + ### PlatformIO CLI ```bash diff --git a/README.md b/README.md index 2327007..d0ef58b 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,8 @@ pip install -U platformio ## Build & Upload +Full cheat-sheet for both controllers (build, upload, serial monitor, every console command, pairing, releases): [`docs/COMMANDS.md`](docs/COMMANDS.md). + ### Using PlatformIO CLI ```bash diff --git a/docs/COMMANDS.md b/docs/COMMANDS.md new file mode 100644 index 0000000..d8bb3ab --- /dev/null +++ b/docs/COMMANDS.md @@ -0,0 +1,194 @@ +# Commands cheat-sheet — both controllers + +Everything you type to build, flash, watch and drive the two boards. Kept in the +Controller A repo (this one); the Controller B repo's README points here. + +| | Controller A | Controller B | +|---|---|---| +| Board | Waveshare ESP32-S3-Touch-LCD-5B (5" touch) | Waveshare ESP32-S3-LCD-1.3 (1.3" round) | +| Repo / branch | `ESP32-S3-Touch-LCD-5B`, `main` | `ESP32-S3-LCD-1.3`, `master` | +| Platform | pioarduino (Arduino 3.3.3 / IDF 5.5) | espressif32@6 (Arduino 2.0.17 / IDF 4.4) | +| Serial | native USB-CDC | CH343 UART | +| Bench port (2026-09-28) | COM14 | COM10 | +| OTA target / release | `patrol-a`, `v*` tags → signed release | `patrol-b`, `v*` tags → signed release | + +Windows ports move around: `pio device list` shows what is plugged in. + +--- + +## 1. Rules of the road (Windows, this machine) + +- **PowerShell only.** `pio` refuses to run from Git Bash (`MSys/Mingw is not supported`). +- `pio` lives at `$env:USERPROFILE\.platformio\penv\Scripts\pio.exe` (no global install). The commands below assume this alias: + ```powershell + Set-Alias pio "$env:USERPROFILE\.platformio\penv\Scripts\pio.exe" + ``` +- **The two projects share one PlatformIO environment.** Consequences: + - The first `pio run` after building the *other* project reinstalls the Arduino core and may fail once with `TypeError: expected str, bytes or os.PathLike object, not NoneType`. Run it again. + - After **any B build**, repair the environment before building A, or A fails with `Failed to install Python dependencies into penv`: + ```powershell + .\tools\fix_penv_deps.ps1 # run inside the A repo + ``` + - Never build both projects at the same time. +- **A serial monitor on a port blocks uploads to that port.** Close it (Ctrl+C) first. +- Opening a port with DTR/RTS asserted resets the board. Always monitor with `--dtr 0 --rts 0`. + +--- + +## 2. Build and upload + +Run inside the respective repo folder. + +### Controller A +```powershell +cd \ESP32-S3-Touch-LCD-5B +pio run # build only (dev build, version "dev") +pio run -t upload --upload-port COM14 # build + flash over USB +pio run -t clean # wipe the build directory +``` +First build after a `platformio.ini` change rebuilds the ESP-IDF core (~20 min, `custom_sdkconfig`); later builds take 1–3 min. + +### Controller B +```powershell +cd \ESP32-S3-LCD-1.3 +pio run +pio run -t upload --upload-port COM10 +..\ESP32-S3-Touch-LCD-5B\tools\fix_penv_deps.ps1 # ALWAYS after a B build, before the next A build +``` + +A USB flash writes bootloader, partition table, `boot_app0` and the app into slot 0. It does **not** touch NVS: saved Wi-Fi network, tunables, pairing key and B's cached gauge config survive. + +--- + +## 3. Serial monitor + +```powershell +pio device monitor -p COM14 -b 115200 --dtr 0 --rts 0 --echo # Controller A +pio device monitor -p COM10 -b 115200 --dtr 0 --rts 0 --echo # Controller B +``` +Type a command, press Enter. `--echo` shows what you type. Ctrl+C leaves. + +One-shot commands and logging from a script (A repo, `tools/`): +```powershell +python tools\serial_cmd.py COM14 "link status" 3 # send one line, print 3 s of reply +python tools\serial_logger.py COM14 # log a port to wiki\raw\ until Ctrl+C +python tools\serial_logger.py COM14,COM10 # both ports at once +python tools\perf_session.py COM14 # display-performance session (PERF lines) +python tools\diag_session.py COM14 "diag pids" "diag vin" # scripted OBD probe run with log +``` + +--- + +## 4. Controller A console + +Type `help` for the list. Unknown lines are reported. + +### `cfg` — Patrol gauge calibration and alert thresholds (saved in NVS, pushed to B) +``` +cfg show +cfg set tach_ppr tach_trim tach_min_hz tach_max_hz + temp_hz temp_slope(x100) temp_offset temp_min temp_duty_max + tach_en temp_en coolant_hot gearbox_hot batt_low(x100) +cfg override off | rpm | duty | both bench test of B's outputs, never saved +cfg reset +``` + +### `wifi` +``` +wifi status connection, saved network, ESP-NOW health +wifi join [pass] join and remember a network (no spaces in the SSID) +wifi forget drop the remembered network (B is told to forget too) +wifi scan list networks in range +wifi on | off +``` + +### `ota` — this controller's own updates +``` +ota status version, slot, rollback state +ota check ask Gitea for the latest release (needs Wi-Fi) +ota install [force] download, verify, flash the idle slot, reboot (parked only) +ota rollback boot the previous slot (parked only) +``` + +### `link` — Controller B over the link +``` +link status B's version, pairing, update phase, credentials +link pair new shared key → B over the UART WIRE (bench, wire connected) +link unpair forget the key here +link creds send the remembered Wi-Fi network to B now (normally automatic) +link ota check | install [force] | rollback drive B's updater (A must be on Wi-Fi, parked) +``` + +### `diag` — OBD-II probe (the only thing that ever transmits on the CAN bus) +``` +diag pids scan mode-01 supported-PID bitmaps +diag pid one mode-01 request (0C rpm, 70 boost, ...) +diag dtc mode 03, stored generic DTCs +diag vin mode 09 PID 02 +diag ecu mode 09 PID 0A +diag ident [addr] BMW KWP 1A 80 identification (default 12 = DDE) +diag bmw raw BMW request on 0x6F1, read-only services only +diag raw on | off CANRAW frame logging +diag status +``` + +### Diagnostics +``` +mem internal heap, PSRAM, LVGL pool +perf one PERF line (fps, flush cost, CPU idle, heap, panel vsync) +perf on [sec] | perf off +``` + +--- + +## 5. Controller B console + +``` +help +link status pairing, A's MAC, STATUS/SECURE counters, credentials +link unpair forget the pairing key (re-pair from A over the wire) +wifi status stored network name (password never shown) +wifi forget +ota status version, slot, rollback state +ota check join Wi-Fi, ask Gitea for the latest release, leave +ota install [force] download, verify, flash, reboot (parked only) +ota rollback +``` +B prints a stats line every 5 s (`applied=… uart … espnow …`) — `uart alive` means the wire works. + +--- + +## 6. Procedures + +### Pair a Controller B (once per board pair) +1. Wire: 5B terminal `485_A` → B `IO1`, GND → GND (a real wire, not just the USB hub), 5B's 120 Ω switch OFF. Both powered. B's stats line must say `uart alive`. +2. A console: `link pair`. Within 5 s A logs `Controller B confirmed pairing (fingerprint XXXX)`; B logs `PAIRED over the wire`. +3. `link status` on A: `key XXXX (matches)`. About 15 s later `Wi-Fi creds yes` (A pushes them by itself; `link creds` forces it). + +The key lives in NVS on both boards and survives every flash and update. Re-pair only after an NVS erase, `link unpair`, or a board swap. + +### Release a version +```powershell +git tag -a vX.Y.Z -m "what changed" +git push --follow-tags origin main # A (B: origin master) +``` +One push, so only the tag build runs. Gitea builds, signs (`BMW_NISSAN_FIRMWARE_SIGNING_KEY`) and publishes `firmware.bin` + `manifest.txt`: A takes 7–20 min, B 2–5 min. Check: `https://git.infra.msai.al///releases`. Version strings must stay under 16 characters. + +### Update A from the screen +Settings → Updates → Controller A → **Check** → **Install vX.Y.Z** (parked, Wi-Fi joined). Progress bar, restart, `A vX.Y.Z` bottom-right. A reset in the first 30 s rolls back. + +### Update B from the screen +Settings → Updates → Controller B → **Check** → **Install** (A on Wi-Fi, parked, B paired). B's round screen shows `Updating vX.Y.Z N%`, the card on A shows the percentage, B restarts and confirms itself after 30 s. Console equivalent: `link ota check`, `link ota install`. + +### Something is wrong after an update +`ota rollback` on the affected controller's console (B: `link ota rollback` from A also works). A reset within 30 s of the first boot of a new image rolls back on its own. + +--- + +## 7. Git on several machines + +Fetch before you start on another machine; the wikis are edited from every machine: +```powershell +git fetch origin +git status -sb # "behind" → git pull --ff-only before touching anything +``` diff --git a/src/modules/settings_screen.cpp b/src/modules/settings_screen.cpp index 68134e0..00af4a6 100644 --- a/src/modules/settings_screen.cpp +++ b/src/modules/settings_screen.cpp @@ -599,7 +599,7 @@ static void refreshUpdatesA() { case Ota::PHASE_AVAILABLE: snprintf(msg, sizeof(msg), "Version %s is available.", o.latest); col = UI_COL_ACCENT; break; case Ota::PHASE_FAILED: snprintf(msg, sizeof(msg), LV_SYMBOL_WARNING " %s", o.message); col = UI_COL_WARN; break; default: - snprintf(msg, sizeof(msg), "%s", wifi_ok ? "Tap Check to look for a new version." : "Connect to Wi-Fi to check for updates."); + snprintf(msg, sizeof(msg), "%s", wifi_ok ? ""); break; } if (g_upd_refusal[0]) { @@ -654,7 +654,7 @@ static void refreshUpdatesB() { case LINK_OTA_UP_TO_DATE: snprintf(msg, sizeof(msg), LV_SYMBOL_OK " Controller B is up to date."); col = UI_COL_OK; break; case LINK_OTA_AVAILABLE: snprintf(msg, sizeof(msg), "Version %s is available for Controller B.", p.st.latest); col = UI_COL_ACCENT; break; case LINK_OTA_FAILED: snprintf(msg, sizeof(msg), LV_SYMBOL_WARNING " %s", p.st.message); col = UI_COL_WARN; break; - default: snprintf(msg, sizeof(msg), "Tap Check to look for a new version for Controller B."); break; + default: snprintf(msg, sizeof(msg), ""); break; } if (p.st.flags & LINK_STATUS_PENDING_VERIFY) { size_t n = strlen(msg);