Wiki sweep for the OTA/display session
Firmware / build (push) Successful in 6s

- ota-updates: status table of every OTA cycle (incl. the 570 B abort and the
  clean failure path), v0.1.3 published/not installed, 'installs are done by the
  running firmware', flicker cause verified, Wi-Fi lost on reboot, console
  without reset, B repo now public
- esp32-s3-touch-lcd-5b: drop the unmeasured ~50 FPS claim, USB serial is
  native CDC with the DTR/RTS reset gotcha, new lessons (flash-write flicker,
  fade stutter, internal RAM, never power the radio off, dual-slot partitions)
- dual-controller-architecture: ESP-NOW/Wi-Fi radio sharing, disconnect(true)
  bug, B updates via A over ESP-NOW
- open-questions #14: Wi-Fi UX redesign, remember network, delete v0.1.0
- CLAUDE.md: same FPS / USB-serial corrections; index + log

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-27 00:05:13 +02:00
parent 29711fa25e
commit 842f270398
7 changed files with 42 additions and 17 deletions
+3 -3
View File
@@ -54,7 +54,7 @@ Use PlatformIO extension toolbar:
The application uses **dual-core architecture** to maximize performance:
- **Core 1** (Arduino core): LVGL rendering task (Priority 2)
- UI rendering at ~50 FPS @ 1024x600 resolution
- UI rendering @ 1024x600 (real render FPS never measured - the Debug "FPS" counts loop() passes)
- Touch input handling
- CPU load ~80% under normal operation
@@ -355,7 +355,7 @@ xTaskCreatePinnedToCore(
- **CAN Bus**: GPIO 15 (TX), GPIO 16 (RX) - 500 Kbps, TWAI_MODE_NORMAL, onboard TJA1051 on the terminal block
- **UART1**: GPIO 44 (TX), GPIO 43 (RX, unused) - reaches the terminal block only as the RS485 A/B pair (SP3485), 115200 baud. Bench: `485_A` straight into B's IO1 + GND works (verified 2026-09-21)
- **USB Serial**: UART0 (default Serial) - 115200 baud for debug output
- **USB Serial**: native USB-CDC (`Serial`, 303A:1001). Opening the port with default DTR/RTS resets the board - attach with `pio device monitor -p COM10 --dtr 0 --rts 0 --echo`
### Display Panel
@@ -401,7 +401,7 @@ xTaskCreatePinnedToCore(
## Performance Metrics
- **FPS**: ~50 FPS @ 1024x600 resolution
- **FPS**: not measured yet (the Debug-panel counter counts loop() passes, not frames) - see wiki open-questions #13
- **CPU Load**: ~80% on Core 1 (LVGL rendering)
- **WiFi Scan**: 1-3 seconds for 10-20 networks
- **UART Overhead**: +1-2% CPU @ 5Hz transmission rate
+3 -3
View File
@@ -1,6 +1,6 @@
---
type: index
updated: 2026-09-26
updated: 2026-09-27
---
# Index
@@ -12,7 +12,7 @@ Catalog of every page in the wiki. Read this first when answering questions. Kee
- [[patrol-instrument-cluster]] — **what the Patrol cluster expects on its inputs**: tach = 2 pulses/rev (verified by calibration), temp = NTC sender 2.1–2.9 kΩ cold → ~250 Ω at 90 °C; the 1 kHz PWM needle-flutter problem and the mitigation ladder (fixed-duty test → 20 kHz → hardware damping)
- [[bmw-m57n-engine]] — the 3.0L BMW diesel whose CAN bus we read; E60/E65 donor (confirmed), DDE ECU, auto box with EGS on bus
- [[nissan-patrol-swap]] — the target vehicle: Patrol receiving the M57N + BMW auto; the tapped bus is a BMW island in a Nissan
- [[esp32-s3-touch-lcd-5b]] — Waveshare 5" display board (Controller A); onboard TJA1051 CAN transceiver, 7–36 V input, pinout, PSRAM/LCD gotchas
- [[esp32-s3-touch-lcd-5b]] — Waveshare 5" display board (Controller A); onboard TJA1051 CAN transceiver, 7–36 V input, pinout, PSRAM/LCD gotchas — **flash writes flicker the RGB panel, full-screen fades stutter, internal RAM nearly full, opening the serial port resets the board unless DTR/RTS are low**
## Concepts
@@ -20,7 +20,7 @@ Catalog of every page in the wiki. Read this first when answering questions. Kee
- [[driveline-speed-signals]] — **engine / turbine / output-shaft speeds**: turbine speed as physical proof of gear engagement, and the output-shaft field that is our **only road-speed source** (no DSC on this bus) — the feedback variable for a future cruise-control PoC, with the safety envelope that would require
- [[dual-controller-architecture]] — Controller A → UART1 + ESP-NOW, protocol v2 → Controller B (1.3" display + Patrol gauge outputs); A owns alerts and the gauge tunables (`cfg` console)
- [[obd-diagnostic-polling]] — **why boost / MAF / rail / injection / DTCs never appear on the sniffer** and how a tester gets them: Route A generic OBD-II mode 01 on `0x7DF` and Route B BMW KWP on `0x6F1` → `0x612` — **BOTH VERIFIED WORKING 2026-09-23** (minimal PID set, no boost PID, mode 09 silent; `1A 86` ident identifies the donor; DTCs read via mode 03), the capture-with-Launch procedure (still wanted for the `22 D1xx` live-data identifiers), and why polling is a transmit-on-the-bus design decision
- [[ota-updates]] — **Controller A updates itself from Gitea releases**: tag `v*` → CI builds + signs (ECDSA P-256) → `ota install` (manual, parked, Wi-Fi) pulls over HTTPS from the public repo, verifies, flashes the idle slot, 30 s confirm-or-rollback; **verified end-to-end 2026-09-26 (dev → v0.1.1)**; dual-slot partition table; plan for updating Controller B through A over ESP-NOW
- [[ota-updates]] — **Controller A updates itself from Gitea releases**: tag `v*` → CI builds + signs (ECDSA P-256) → `ota install` (manual, parked, Wi-Fi) pulls over HTTPS from the public repo, verifies, flashes the idle slot, 30 s confirm-or-rollback; **verified end-to-end 2026-09-26 (dev → v0.1.1 → v0.1.2; v0.1.3 published)**, release with `git push --follow-tags origin main`; dual-slot partition table; plan for updating Controller B through A over ESP-NOW
## Synthesis
+4
View File
@@ -129,3 +129,7 @@ User reported heavy flicker during OTA and on Gauge Tuning taps, and laggy swipe
## [2026-09-26] build | CI: no duplicate / docs-only builds; v0.1.3
v0.1.3 released (OTA download loop no longer aborts on a momentary TLS connected()==false; a forced reinstall had stalled at 570 B once, retry succeeded). Pushing main then the tag ran two identical builds, and every wiki commit rebuilt firmware: the workflow's new "Skip?" step makes a main push skip itself when its commit carries a v* tag or only touches wiki/** / *.md (in-job, so tag builds are never path-filtered). Release with `git push --follow-tags origin main`. Logic dry-run locally against the real remote (tagged/untagged/docs/mixed cases).
## [2026-09-27] lint | Session sweep: OTA status, board gotchas, Wi-Fi follow-ups
Brought the wiki in line with the whole 2026-09-26 session. ota-updates: status table of every cycle (dev->v0.1.1->v0.1.2, forced reinstall with the 570 B abort + clean failure path, v0.1.3 published but not installed), "installs are done by the running firmware" rule, flicker cause marked verified, Wi-Fi lost on reboot, console-without-reset recipe, B repo now public. esp32-s3-touch-lcd-5b: removed the unmeasured "~50 FPS" claim, USB serial is native CDC (not UART0) with the DTR/RTS reset gotcha, new lessons (flash-write flicker, fade stutter, internal RAM, never power the radio off, dual-slot partitions). dual-controller-architecture: ESP-NOW/Wi-Fi radio sharing + the disconnect(true) bug, B updates via A over ESP-NOW. open-questions #14: Wi-Fi UX redesign, remember network, delete v0.1.0 release. Pending user confirmations: dark-screen OTA shows no flicker; version label placement; instant swipes; Tuning taps.
+3 -1
View File
@@ -1,7 +1,7 @@
---
type: concept
tags: [architecture, uart]
updated: 2026-09-21
updated: 2026-09-27
---
# Dual-Controller Architecture
@@ -21,6 +21,8 @@ BMW M57N CAN bus ──▶ Controller A ──UART1 + ESP-NOW, 5 Hz──▶ Con
`0xAA | 0x02 | type | length | payload | XOR | 0x55`, identical on UART1 (GPIO 44 → SP3485 → `485_A`/`485_B`) and ESP-NOW broadcast (channel 1). DATA frames (lever, target/engaged gear nibbles, rpm, temps, battery, alert bitmap, valid flags) every 200 ms; CONFIG frames (`link_config_t`: Patrol gauge calibration + alert thresholds, edited on A via the `cfg` serial console and stored in NVS) on change and every 5 s. Alerts are decided here; B only renders them. Spec: `docs/UART_PROTOCOL.md`. Bench-verified with both transports live and B deduplicating every frame `(verified 2026-09-21)`.
**ESP-NOW and Wi-Fi share the radio** `(verified 2026-09-26)`. When A joins a Wi-Fi network (for OTA), its channel follows the AP (seen: 6, 9, 11) and B hops to find it; ESP-NOW kept running (6,410 frames, 0 failed). Until 2026-09-26 the Wi-Fi code powered the radio off on connect/disconnect (`WiFi.disconnect(true)`), which silently killed ESP-NOW and left B on the wire only — fixed, and `EspNowLink::send()` now re-initialises ESP-NOW if the driver drops it. Planned: **Controller B's firmware updates will travel from A over ESP-NOW** (bidirectional, unlike the one-way wire) → [[ota-updates]].
Controller B's side of this (receiver, ESP-NOW channel hopping, gauge outputs, bench wiring) is documented in the sibling wiki: `../../ESP32-S3-LCD-1.3/wiki/pages/controller-link.md` and `patrol-gauge-outputs.md`.
## Why it matters for the wiki
+9 -4
View File
@@ -1,7 +1,7 @@
---
type: entity
tags: [hardware, waveshare, display]
updated: 2026-07-16
updated: 2026-09-27
---
# Waveshare ESP32-S3-Touch-LCD-5B
@@ -13,7 +13,7 @@ Controller A of the [[dual-controller-architecture]] — the main in-cabin displ
- ESP32-S3-WROOM-1-N16R8 module: dual-core LX7 @ 240 MHz, 16 MB flash, 8 MB OPI PSRAM
- 5" IPS 1024×600, 65K colors (16-bit), 550 cd/m², GT911 5-point capacitive touch, tempered glass
- 2.4 GHz Wi-Fi + BLE 5, onboard antenna (keep metal away from antenna area)
- Runs LVGL 8.4.0 at ~50 FPS via ESP32_Display_Panel v1.0.4 `(repo)`
- Runs LVGL 8.4.0 via ESP32_Display_Panel v1.0.4 `(repo)`. Real render FPS has **never been measured**: the Debug-panel "FPS" counts `loop()` passes (and `loop()` sleeps 100 ms), and the old "~50 FPS" figure had no measurement behind it `(verified 2026-09-26)`
## Power (source: waveshare-wiki)
@@ -42,7 +42,7 @@ Controller A of the [[dual-controller-architecture]] — the main in-cabin displ
| I2C | External header; CH422G expander occupies 0x20–0x27 & 0x30–0x3F, GT911 touch at 0x5D — avoid these addresses |
| RTC | PCF85063 + CR927 coin cell |
| TF card | SD_CS driven via CH422G EXIO4 |
| USB Serial | UART0, debug @ 115200 `(repo)` |
| USB Serial | Native USB-CDC (`Serial`, enumerates 303A:1001, ~1 MB/s), console + CANRAW `(repo)`. **Opening the port with default DTR/RTS resets the board** (`rst:0x15`) — set both low before opening (`--dtr 0 --rts 0`) to attach without a reboot `(verified 2026-09-26)` |
Note: the screen occupies most GPIOs; auxiliary functions (backlight, reset, SD_CS) route through the CH422G IO expander — spare native GPIOs are scarce.
@@ -52,7 +52,12 @@ Note: the screen occupies most GPIOs; auxiliary functions (backlight, reset, SD_
- LCD wants a 16 MHz pixel clock with correct PCLK polarity.
- Backlight must be manually sequenced at boot to avoid a white flash.
- Flashing: use the Type-C port labeled UART; hold BOOT while connecting if the port isn't recognized (source: waveshare-wiki).
- **Flash writes flicker the screen** `(verified 2026-09-26)`: flash and PSRAM share the MSPI cache, so every flash write/erase (NVS save, OTA) briefly cuts off the PSRAM framebuffer the RGB panel streams from; there is no bounce buffer (`ESP_PANEL_LCD_RGB_BOUNCE_BUF_SIZE=0`). `CONFIG_LCD_RGB_RESTART_IN_VSYNC=y` resyncs next frame → flicker, not permanent drift. Mitigated (v0.1.2): Tuning edits saved to NVS once after 3 s idle, backlight off during OTA writes. Real cure: bounce buffers + `CONFIG_SPIRAM_XIP_FROM_PSRAM` → [[open-questions]] #13.
- **Full-screen transitions stutter** `(verified 2026-09-26)`: a fade re-renders and alpha-blends all 614k px in software every frame into the PSRAM framebuffer. Screen switches are instant (`LV_SCR_LOAD_ANIM_NONE`) since v0.1.2.
- **Internal RAM is nearly full** `(verified 2026-09-26)`: 15.9 KB free, largest block 7.6 KB with display + Wi-Fi up (PSRAM 7.1 MB free); the 60-line LVGL draw buffer is ~120 KB of it. Blocked a TLS task outright → [[ota-updates]], [[open-questions]] #13.
- **Never power the Wi-Fi radio off** (`WiFi.disconnect(true)`, `WiFi.mode(WIFI_OFF)`): it de-initialises ESP-NOW, the wireless leg of the link to B → [[dual-controller-architecture]].
- **Partition table is dual-slot OTA** since 2026-09-26 (2 × 7.9 MB, no SPIFFS, NVS offset unchanged) → [[ota-updates]].
## Related
[[dual-controller-architecture]] · [[can-bus-integration]] · [[esp32-s3-touch-lcd-5b-waveshare-wiki]]
[[dual-controller-architecture]] · [[can-bus-integration]] · [[ota-updates]] · [[esp32-s3-touch-lcd-5b-waveshare-wiki]]
+3 -1
View File
@@ -1,7 +1,7 @@
---
type: synthesis
tags: [meta, todo]
updated: 2026-09-26
updated: 2026-09-27
---
# Open Questions
@@ -71,3 +71,5 @@ The research frontier. Answering any of these should trigger updates across the
- DWR's **Testo parameter list** (e90post "Testo" thread, post 175, German→English names of the DDE's non-standard values) — the pointer for Route B identifiers if our own Launch capture is not enough
13. **Internal RAM is nearly exhausted (found 2026-09-26).** With display + Wi-Fi up: 15.9 KB internal free, largest block 7.6 KB (PSRAM 7.1 MB free). OTA works around it ([[ota-updates]]), but anything else that needs an internal allocation (another task, a TLS client, a bigger Wi-Fi burst) can fail. Biggest known consumer: the LVGL 60-line DMA draw buffer (~120 KB). Options: shrink it to ~30–40 lines, or measure what else lives in internal RAM first (`heap_caps_print_heap_info`). Not urgent, but it limits every future feature. **Same project as the display flicker/lag (2026-09-26):** flash writes flicker the PSRAM-fed RGB panel (no bounce buffer) and full-screen transitions stutter. Espressif's cure is bounce buffers + `CONFIG_SPIRAM_XIP_FROM_PSRAM` (needs pioarduino `custom_sdkconfig`), and bounce buffers need internal RAM — so free RAM, add bounce buffers, and measure real render FPS (LVGL perf monitor; the Debug "FPS" counts `loop()` passes, not frames) in one bench session. Quick mitigations shipped in v0.1.2 (instant screen switches, deferred NVS saves, dark screen during OTA).
14. **Wi-Fi UX (found 2026-09-26).** The Settings Wi-Fi screen had never worked (switch shipped disabled) and, now usable, is "a disaster UX" (user): SquareLine-generated, runtime SSID buttons + floating keyboard + loading overlay, **no on-screen confirmation of a successful join**. Also: A **forgets the network on every reboot** (each boot needs `wifi join`). To do: redesign as a hand-coded screen (like Driveline/Tuning, safe from SquareLine re-exports), show connection state, remember the network in NVS and auto-join; consider housing it on the Diagnostics screen (#12) next to the OTA controls, since Wi-Fi now mainly serves updates. Housekeeping: **delete the `v0.1.0` release** on Gitea — installing it would strand the board without working OTA (USB only). → [[ota-updates]]
+17 -5
View File
@@ -1,7 +1,7 @@
---
type: concept
tags: [ota, firmware, gitea, ci, security, signing, design-decision, controller-a]
updated: 2026-09-26
updated: 2026-09-27
---
# OTA Firmware Updates
@@ -30,9 +30,17 @@ Push to `main` (no tag) builds a rolling **pre-release `main-latest`** — unsig
## Status: VERIFIED end-to-end `(verified 2026-09-26, bench, USB power, Wi-Fi Personal1)`
`dev` (USB-flashed) → `ota install` → **v0.1.1** from CI: 1.65 MB downloaded + written in ~60 s (~27 KB/s), sha256 + signature OK, rebooted into `app1` as PENDING_VERIFY, ESP-NOW up, **confirmed after 30 s**. The installed v0.1.1 then ran `ota check` itself ("up to date") — it can take the next update. Previous image kept in `app0` for `ota rollback`.
| Cycle (performed by the *running* firmware) | Result |
|---|---|
| `dev` (USB-flashed) → **v0.1.1**, into `app1` | ✅ 1.65 MB in ~60 s (~27 KB/s), confirmed after 30 s; v0.1.1 then passed `ota check` itself |
| v0.1.1 → **v0.1.2**, into `app0` | ✅ slots alternate as designed |
| v0.1.2 → v0.1.2 (`ota install force`), attempt 1 | ❌ download aborted at 570 B — the loop treated a momentary TLS `connected()==false` as a drop. The **failure path worked**: aborted cleanly, "Update failed / still running v0.1.2" notice, stayed on v0.1.2 |
| same, attempt 2 | ✅ into `app1`, confirmed — first install run by the dark-screen code |
| **v0.1.3** (published 2026-09-26) | fixes the 570 B abort (a drop only counts after 2 s of silence); **not yet installed** — the board runs v0.1.2 |
During the write the backlight is off (flash writes flicker the PSRAM-fed panel): a full-screen notice "Updating to vX … do not switch off" shows for 3 s first, then "Installed vX / Restarting" or "Update failed / still running vY" (v0.1.2+). The running version is always shown bottom-right on every screen.
Always remember: an install is performed by the firmware that is **already running**, so a fix to the install path only takes effect on the update *after* the one that delivers it (v0.1.1 → v0.1.2 still flickered because v0.1.1 did the writing).
**Dark-screen writes (v0.1.2+).** Flash writes flicker the PSRAM-fed panel (cause below, and [[esp32-s3-touch-lcd-5b]]), so the backlight is off while the image is written: a full-screen notice "Updating to vX — the screen goes dark for about a minute — do not switch off" shows for 3 s first, then "Installed vX / Restarting…" or "Update failed / Still running vY". Ran for real on the forced reinstall; the user's visual confirmation of "no flicker" is still pending `(unverified)`. The running version is always shown bottom-right on every screen (`A v0.1.2`).
Known quirk: `ota status` shows the *other* slot's "built" date from the framework's precompiled app descriptor (e.g. "Nov 4 2025"), not our build time — ignore it.
@@ -75,7 +83,11 @@ SPIFFS (3.4 MB, unused by any code) was dropped. Firmware is ~1.65 MB (19.8 % of
| `ota install [force]` | full install; `force` reinstalls the same version |
| `ota rollback` | boot the other slot (or reject an unconfirmed image) — parked only |
Wi-Fi must be joined first — `wifi join <ssid> [pass]` on the console (`wifi status`, `wifi off`), or the Settings screen. **Do not install `v0.1.0`**: it predates the loop-task/PSRAM-TLS fix, so once installed it can't run OTA again (it boots fine, so rollback won't save it — USB only). Joining an AP moves the radio channel; the ESP-NOW link to B follows it (B hops). `diag raw off` first keeps CANRAW from burying the progress lines. The screen may flicker while flash is written (RGB panel + flash cache) `(unverified)`.
Wi-Fi must be joined first — `wifi join <ssid> [pass]` on the console (`wifi status`, `wifi off`), or the Settings screen. **Do not install `v0.1.0`**: it predates the loop-task/PSRAM-TLS fix, so once installed it can't run OTA again (it boots fine, so rollback won't save it — USB only). Joining an AP moves the radio channel; the ESP-NOW link to B follows it (B hops). `diag raw off` first keeps CANRAW from burying the progress lines.
- **Wi-Fi does not survive a reboot** — every boot (including the one that ends an update) needs a new `wifi join`; remembering the network is future work ([[open-questions]] #14).
- **Open the console without resetting the board**: `pio device monitor -p COM10 -b 115200 --dtr 0 --rts 0 --echo` (pio lives at `%USERPROFILE%\.platformio\penv\Scripts\pio.exe`). Opening the port with default DTR/RTS resets it (`rst:0x15 USB_UART_CHIP_RESET`), which drops the Wi-Fi join `(verified 2026-09-26)`.
- **Flicker cause** `(verified 2026-09-26)`: flash and PSRAM share the MSPI cache; every flash write stalls the PSRAM framebuffer the RGB panel streams from (no bounce buffer). Hence the dark screen above.
## Secrets and keys
@@ -91,7 +103,7 @@ Wi-Fi must be joined first — `wifi join <ssid> [pass]` on the console (`wifi s
## Controller B (not built yet)
Plan agreed 2026-09-26: B is updated **by A over ESP-NOW**, not by the RS485 wire (the wire is one-way A→B; ESP-NOW is bidirectional and faster). A downloads B's signed image (target `patrol-b`) from B's repo releases, sends it with acks, B verifies the signature and swaps slots with the same rollback scheme. Prerequisites: B moves off the stock `default.csv` (1.25 MB slots, 1.07 MB firmware → too tight) to a 16 MB layout (confirm B's flash size first; one USB flash); ESP-NOW pairing/encryption so only A can talk to B; protocol frames for the transfer (shared `automotive_data.h` → version bump in both repos). B's repo still answered 404 anonymously on 2026-09-26 — check its visibility setting. Wire stays for gauge-data redundancy.
Plan agreed 2026-09-26: B is updated **by A over ESP-NOW**, not by the RS485 wire (the wire is one-way A→B; ESP-NOW is bidirectional and faster). A downloads B's signed image (target `patrol-b`) from B's repo releases, sends it with acks, B verifies the signature and swaps slots with the same rollback scheme. Prerequisites: B moves off the stock `default.csv` (1.25 MB slots, 1.07 MB firmware → too tight) to a 16 MB layout (confirm B's flash size first; one USB flash); ESP-NOW pairing/encryption so only A can talk to B; protocol frames for the transfer (shared `automotive_data.h` → version bump in both repos). B's repo is public since 2026-09-27 (anonymous API 200). Wire stays for gauge-data redundancy.
## Related