Files
ESP32-S3-Touch-LCD-5B/docs/COMMANDS.md
T
2026-09-28 10:21:06 +02:00

195 lines
8.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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 <path>\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 <path>\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 <name> <value> 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 <n> | duty <n> | both <rpm> <duty> bench test of B's outputs, never saved
cfg reset
```
### `wifi`
```
wifi status connection, saved network, ESP-NOW health
wifi join <ssid> [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 <hex> 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 <addr> <hex...> 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/<owner>/<repo>/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
```