Add perf console (render fps, flush cost, CPU idle, heap) for the display work; record idle baseline
Firmware / build (push) Successful in 4m8s

This commit is contained in:
2026-09-27 16:43:53 +02:00
parent 43ca6b96ec
commit d3e499efed
8 changed files with 277 additions and 4 deletions
+6 -1
View File
@@ -82,6 +82,7 @@ src/
espnow_link.cpp # ESP-NOW broadcast leg of the link
tuning_screen.cpp # Hand-coded Gauge Tuning screen, 4 tabs (swipe right from Driveline)
diag_probe.cpp # On-demand OBD-II requests ('diag' console) - the ONLY CAN transmitter
perf_monitor.cpp # 'perf' console: render fps, flush cost, LVGL/CPU idle, heap (display experiments)
ota_update.cpp # Manual firmware updates from Gitea releases ('ota' console)
settings_manager.cpp # NVS persistent storage
ui_state_manager.cpp # Debug flag (performance overlay, sent to B)
@@ -103,7 +104,7 @@ include/
**src/main.cpp** (~1530 lines)
- Main application logic, event handlers, FreeRTOS task implementations
- Console command routing (`cfg`, `diag`, `ota`, `wifi`, `mem`), setup order, `loop()` ticks for the three screens
- Console command routing (`cfg`, `diag`, `ota`, `wifi`, `mem`, `perf`), setup order, `loop()` ticks for the three screens
**include/protocol/automotive_data.h**
- **Shared with Controller B, must stay byte-identical in both repos.** Protocol v2 (2026-09-21).
@@ -213,6 +214,10 @@ Settings persist across power cycles via ESP32 NVS (Non-Volatile Storage):
`src/modules/ota_update.cpp` pulls signed firmware from this repo's Gitea releases (`include/config/ota_config.h`: server, repo, Let's Encrypt roots, signing public key). Manual only: Settings → Updates (Check, then Install behind a confirm dialog; verified end-to-end from the screen 2026-09-27) or the console `ota status | check | install [force] | rollback`. `Ota::getStatus()` gives the screen a phase + latest tag + failure reason. Install is refused unless parked (engine off, shaft still, lever not in a drive gear; silent bus = parked), checked before download and again before the slot switch. The manifest's ECDSA P-256 signature over `patrol-a|version|sha256` is checked before download; the streamed image must match that sha256. `verifyRollbackLater()` is overridden so a new image stays pending until `Ota::tick()` confirms it after 30 s - a reset before that rolls back. CI: `.gitea/workflows/firmware.yml` (push `main` -> rolling unsigned pre-release `main-latest`; tag `v*` -> signed release, needs repo secret `BMW_NISSAN_FIRMWARE_SIGNING_KEY`). Release with one push so only the tag build runs: `git tag -a vX.Y.Z -m "..." && git push --follow-tags origin main` (a main push skips itself when its commit is tagged, or when it only touches `wiki/**` / `*.md`). Never put secrets in firmware source - the repo and its release binaries are public. Jobs run inside the loop task (8 KB stack) with mbedtls routed to PSRAM - internal RAM is too tight for a TLS task (15.9 KB free, largest block 7.6 KB with Wi-Fi up). Wi-Fi is joined on the Settings screen (remembered) or with `wifi join`. Details: `wiki/pages/ota-updates.md`.
### Performance monitor (`perf` console)
`src/modules/perf_monitor.cpp` hooks the LVGL port (`monitor_cb` per rendered frame, a timer around `drawBitmap()` in `flush_callback`) and reads FreeRTOS run-time stats. `perf` prints one `PERF,` CSV line (ts, fps, avg/max ms per frame, kpx per frame, ms per second spent copying into the PSRAM framebuffer, LVGL idle %, core 0/1 idle %, internal free/largest, PSRAM free); `perf on [sec]` prints one every few seconds while a symptom is provoked; `perf off`. This is the measuring stick for the display work in wiki open-questions #13 - record numbers before and after every change. Baseline (idle Driveline, bench, 2026-09-27): ~9.7 fps rendered, ~30 ms per frame, ~52 ms/s in flushes, LVGL idle ~68 %, core 1 idle ~66 %.
### ESP-NOW link
`src/modules/espnow_link.cpp` broadcasts every frame on Wi-Fi channel `ESPNOW_CHANNEL` (1). The radio stays in STA mode permanently — `WiFiManager`'s "off" only stops scanning/association. Never call `WiFi.disconnect(true)` or `WiFi.mode(WIFI_OFF)`: powering the radio off de-initialises ESP-NOW (`send()` re-inits it as a safety net). If Wi-Fi joins an AP the channel follows the AP; B hops to find it.