OTA bring-up fixes: loop-task jobs + PSRAM TLS, ESP-NOW survives Wi-Fi, wifi console
Firmware / build (push) Successful in 4m24s
Firmware / build (push) Successful in 4m24s
- ota: internal RAM has 15.9 KB free / 7.6 KB largest block with Wi-Fi up, so jobs now run in the loop task (8 KB stack; 3.6 KB headroom measured on `ota check`) with mbedtls allocations routed to PSRAM during the job - wifi_manager: WiFi.disconnect(true) powered the radio off and killed ESP-NOW whenever Wi-Fi was used; now disconnect() only. showConnectionResult() waits for the LVGL lock and null-checks widgets. New `wifi join|status|off` console - espnow_link: send() re-initialises ESP-NOW if the driver dropped it - wiki: ota-updates memory + bugs sections, open-questions #13 (internal RAM), log; CLAUDE.md notes Verified on the board: `wifi join` connects, ESP-NOW 195 sent / 0 failed while joined, `ota check` verifies v0.1.0's signature on-device. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -69,3 +69,5 @@ The research frontier. Answering any of these should trigger updates across the
|
||||
- ~~Web search on DDE7 M57 PIDs~~ ✅ clipped → [[google-ai-dde7m57-pids]] — uncited AI summary; identifiers `(unverified)`, addressing claim contradicted
|
||||
- ~~A worked generic-PID set for an M57 diesel~~ ✅ ingested → [[dwr-335d-torque-pids]] (2009 335d, DDE7.3; J1979 mode-01 scalings gauge-checked by the author)
|
||||
- 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.
|
||||
|
||||
@@ -35,6 +35,15 @@ Push to `main` (no tag) builds a rolling **pre-release `main-latest`** — unsig
|
||||
- **TLS trust = Let's Encrypt roots, not the leaf** `(verified 2026-09-26)`: the server chain is leaf (SAN `git.infra.msai.al`) → YR2 → Root YR (cross-signed by ISRG Root X1). Both ISRG Root X1 (to 2035) and Root YR (to 2045) are embedded in `include/config/ota_config.h`, and each verifies the chain alone. Leaf certs rotate ~90 days — never pin them. The framework's mbedtls has `MBEDTLS_HAVE_TIME_DATE` off, so no NTP is needed (and cert dates aren't checked; the signature is the real guarantee).
|
||||
- **Rollback**: the framework bootloader has `CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE=y`, but Arduino's `initArduino()` marks a new image valid *before* `setup()`. `ota_update.cpp` overrides `verifyRollbackLater()` → the image stays PENDING_VERIFY until `Ota::tick()` confirms it after 30 s. Consequence: **power off within 30 s of an update's first boot = back to the old version** (by design).
|
||||
|
||||
## Memory: why jobs run in the loop task `(verified 2026-09-26)`
|
||||
|
||||
With the display, Wi-Fi and all tasks up, **internal RAM is nearly exhausted: 15.9 KB free, largest block 7.6 KB** (PSRAM: 7.1 MB free). Two consequences, both handled in `ota_update.cpp`:
|
||||
|
||||
- This framework's mbedtls is built with `CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC=y` (~40 KB internal per TLS session → impossible). During a job, `mbedtls_platform_set_calloc_free()` routes TLS to PSRAM, and restores it after (both sides free with `heap_caps_free`, so the swap is safe).
|
||||
- No room for a dedicated 10–16 KB task stack, and a PSRAM stack is forbidden because `esp_ota_write()` disables the flash cache. So jobs run **inside the Arduino loop task** (8 KB internal stack): `ota check` peaked leaving **3.6 KB headroom**. The console and screen value ticks pause while a job runs.
|
||||
|
||||
The low internal heap is a system-wide risk beyond OTA (the LVGL 60-line DMA draw buffer alone is ~120 KB of internal SRAM) — see [[open-questions]].
|
||||
|
||||
## Partition table (changed 2026-09-26)
|
||||
|
||||
| Name | Offset | Size |
|
||||
@@ -56,7 +65,7 @@ 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 via the Settings screen first. 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. The screen may flicker while flash is written (RGB panel + flash cache) `(unverified)`.
|
||||
|
||||
## Secrets and keys
|
||||
|
||||
@@ -64,6 +73,12 @@ Wi-Fi must be joined via the Settings screen first. Joining an AP moves the radi
|
||||
- Public key: compiled in (`OTA_SIGNING_PUBKEY_PEM`) and in `tools/ota/firmware_signing_pub.pem` (CI self-checks each signature against it before publishing).
|
||||
- Rotating the key: new keypair → update both public-key copies → USB-flash once (a device only trusts the key it was built with).
|
||||
|
||||
## Bugs found while bringing it up (2026-09-26)
|
||||
|
||||
- **Settings Wi-Fi switch was disabled since the first SquareLine export** (`LV_STATE_DISABLED`) — the Wi-Fi UI had never worked. Re-enabled at runtime in `UIStateManager` (survives re-exports; untick "Disabled" in the SquareLine project too).
|
||||
- **Joining Wi-Fi killed ESP-NOW**: the Wi-Fi task used `WiFi.disconnect(true)` (true = radio off), which drops ESP-NOW; B then ran on the wire only. Now `WiFi.disconnect()`, and `EspNowLink::send()` re-initialises ESP-NOW if the driver ever drops it. Verified: joined Personal1 (channel 9), ESP-NOW 195 sent / 0 failed.
|
||||
- `showConnectionResult()` took the LVGL lock with a 0 ms try-lock, ignored the result, and touched widgets that are NULL off the Settings screen — now waits for the lock and null-checks. It still shows **no success feedback** on screen; the Wi-Fi UI needs a redesign (user: "a disaster UX").
|
||||
|
||||
## 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.
|
||||
|
||||
Reference in New Issue
Block a user