From bb0895674a13045c0f8806d0522a8d3ee82686a6 Mon Sep 17 00:00:00 2001 From: Julian Cuni Date: Sat, 26 Sep 2026 22:37:08 +0200 Subject: [PATCH] OTA bring-up fixes: loop-task jobs + PSRAM TLS, ESP-NOW survives Wi-Fi, wifi console - 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 --- CLAUDE.md | 4 +-- src/main.cpp | 5 ++-- src/modules/espnow_link.cpp | 18 +++++++++++- src/modules/ota_update.cpp | 53 ++++++++++++++++++++++++++-------- src/modules/wifi_manager.cpp | 56 ++++++++++++++++++++++++++++++++---- src/modules/wifi_manager.h | 6 ++++ wiki/log.md | 4 +++ wiki/pages/open-questions.md | 2 ++ wiki/pages/ota-updates.md | 17 ++++++++++- 9 files changed, 142 insertions(+), 23 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 1b46d93..92335b8 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -231,11 +231,11 @@ Settings persist across power cycles via ESP32 NVS (Non-Volatile Storage): ### OTA updates (`ota` console) -`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: `ota status | check | install [force] | rollback` - the future password-gated Diagnostics screen will call the same code. 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`). Never put secrets in firmware source - the repo and its release binaries are public. Details: `wiki/pages/ota-updates.md`. +`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: `ota status | check | install [force] | rollback` - the future password-gated Diagnostics screen will call the same code. 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`). 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). `wifi join [pass] | status | off` (in `wifi_manager.cpp`) joins a network from the console. Details: `wiki/pages/ota-updates.md`. ### 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 (it no longer calls `WiFi.mode(WIFI_OFF)`). If Wi-Fi joins an AP the channel follows the AP; B hops to find it. +`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. ### UI State Synchronization diff --git a/src/main.cpp b/src/main.cpp index c871448..9e1194d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -113,9 +113,10 @@ void onDebugToggle(lv_event_t *e) } // extern "C" -// Console lines `cfg` doesn't recognise: diagnostic probe, then OTA. +// Console lines `cfg` doesn't recognise: diagnostic probe, OTA, Wi-Fi. static bool consoleExtraCommand(const char* line) { - return DiagProbe::handleCommand(line) || Ota::handleCommand(line); + return DiagProbe::handleCommand(line) || Ota::handleCommand(line) || + WiFiManager::handleCommand(line); } // ============================================================================ diff --git a/src/modules/espnow_link.cpp b/src/modules/espnow_link.cpp index 2de791f..b469b97 100644 --- a/src/modules/espnow_link.cpp +++ b/src/modules/espnow_link.cpp @@ -62,14 +62,30 @@ bool init() { return true; } +// Anything that restarts the Wi-Fi driver drops ESP-NOW with it. Re-init at +// most once a second instead of failing every frame from then on. +static void reinitIfDue() { + static uint32_t last = 0; + if (millis() - last < 1000) return; + last = millis(); + g_ready = false; + ESP_LOGW("EspNow", "ESP-NOW not initialised - re-initialising"); + init(); +} + bool send(const uint8_t* frame, size_t len) { - if (!g_ready || len == 0 || len > ESP_NOW_MAX_DATA_LEN) return false; + if (len == 0 || len > ESP_NOW_MAX_DATA_LEN) return false; + if (!g_ready) { + reinitIfDue(); + if (!g_ready) return false; + } esp_err_t err = esp_now_send(BROADCAST_MAC, frame, len); if (err == ESP_OK) { g_sent++; return true; } g_fail++; + if (err == ESP_ERR_ESPNOW_NOT_INIT) reinitIfDue(); return false; } diff --git a/src/modules/ota_update.cpp b/src/modules/ota_update.cpp index 8e3c330..bfd368d 100644 --- a/src/modules/ota_update.cpp +++ b/src/modules/ota_update.cpp @@ -25,6 +25,8 @@ #include #include #include +#include +#include #include // Take over Arduino's rollback hook: by default initArduino() marks a new image @@ -41,6 +43,12 @@ static const uint32_t OTA_CONFIRM_MS = OTA_CONFIRM_S * 1000; static const uint32_t BUS_SILENT_MS = 2000; // no frames for this long = ignition off / bench static const uint32_t STALL_TIMEOUT_MS = 15000; // download aborts if no bytes arrive this long static const size_t CHUNK = 4096; +// Jobs run inside the Arduino loop task (8 KB internal stack), not a task of +// their own: with the display + Wi-Fi up, internal RAM has no block big enough +// for another TLS-capable stack (measured 2026-09-26: 15.9 KB free, largest +// block 7.6 KB), and the stack can't go to PSRAM because esp_ota_write() +// disables the flash cache. The loop (screen value ticks, console) pauses +// while a job runs - acceptable: parked, and an install ends in a reboot. typedef struct { char tag[32]; @@ -54,7 +62,8 @@ typedef struct { enum job_t { JOB_CHECK, JOB_INSTALL, JOB_INSTALL_FORCE }; -static volatile bool g_busy = false; +static bool g_job_pending = false; +static job_t g_job = JOB_CHECK; static bool g_pending_verify = false; // ============================================================================ @@ -378,23 +387,38 @@ static void check() { same ? " - up to date" : " - `ota install` to update"); } -static void jobTask(void* arg) { - job_t job = (job_t)(intptr_t)arg; +// This core's mbedtls is built with CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC: every TLS +// session wants ~40 KB of *internal* RAM, which the display + Wi-Fi leave no +// room for. Route mbedtls to PSRAM (internal as fallback) while a job runs. +// Both allocators free with heap_caps_free(), so swapping them is always safe. +static void* tlsCallocPsram(size_t n, size_t size) { + return heap_caps_calloc_prefer(n, size, 2, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT, + MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT); +} +static void* tlsCallocInternal(size_t n, size_t size) { + return heap_caps_calloc(n, size, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT); +} + +static void printHeap(const char* when) { + print("[ota] heap %s: internal free %u (largest block %u), PSRAM free %u", when, + (unsigned)heap_caps_get_free_size(MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT), + (unsigned)heap_caps_get_largest_free_block(MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT), + (unsigned)heap_caps_get_free_size(MALLOC_CAP_SPIRAM)); +} + +static void runJob(job_t job) { + mbedtls_platform_set_calloc_free(tlsCallocPsram, heap_caps_free); if (job == JOB_CHECK) check(); else install(job == JOB_INSTALL_FORCE); - g_busy = false; - vTaskDelete(NULL); + mbedtls_platform_set_calloc_free(tlsCallocInternal, heap_caps_free); + print("[ota] loop stack headroom after job: %u B", (unsigned)uxTaskGetStackHighWaterMark(NULL)); } static void startJob(job_t job) { - if (g_busy) { print("[ota] busy - an ota job is already running"); return; } if (!gate(true, job != JOB_CHECK)) return; // checking is harmless; installing needs parked - g_busy = true; - // TLS needs a deep stack; core 0 alongside the other network tasks. - if (xTaskCreatePinnedToCore(jobTask, "ota", 16384, (void*)(intptr_t)job, 1, NULL, 0) != pdPASS) { - g_busy = false; - print("[ota] could not start the ota task (out of memory?)"); - } + g_job = job; + g_job_pending = true; // runs on the next tick(), in the loop task + print("[ota] working - console and screen values pause until done"); } // ============================================================================ @@ -420,6 +444,7 @@ static void status() { } } print("[ota] updates from %s/%s/releases (%s)", OTA_SERVER, OTA_REPO, OTA_TARGET); + printHeap("now"); } static void rollback() { @@ -474,6 +499,10 @@ void init() { } void tick() { + if (g_job_pending) { + g_job_pending = false; + runJob(g_job); + } if (g_pending_verify && millis() > OTA_CONFIRM_MS) { esp_ota_mark_app_valid_cancel_rollback(); g_pending_verify = false; diff --git a/src/modules/wifi_manager.cpp b/src/modules/wifi_manager.cpp index 63adecb..4ff90a1 100644 --- a/src/modules/wifi_manager.cpp +++ b/src/modules/wifi_manager.cpp @@ -3,6 +3,7 @@ */ #include "wifi_manager.h" +#include "espnow_link.h" #include "display/lvgl_v8_port.h" // External UI element references (from ui_Settings_Screen.c) @@ -91,10 +92,15 @@ static String formatNetworkName(const wifi_network_t& network) { * @note Must be called with LVGL lock held OR will acquire lock internally */ static void showConnectionResult(bool success, const char* message) { - lvgl_port_lock(0); + // Wait for the lock (a 0 ms try-lock whose result was ignored used to race + // the LVGL task). Widgets are NULL whenever the Settings screen isn't + // loaded - e.g. a `wifi join` from the console - so check before touching. + lvgl_port_lock(-1); // Hide loading spinner - lv_obj_add_flag(uic_Settings_Loading_Container, LV_OBJ_FLAG_HIDDEN); + if (uic_Settings_Loading_Container != NULL) { + lv_obj_add_flag(uic_Settings_Loading_Container, LV_OBJ_FLAG_HIDDEN); + } if (success) { // Connection successful @@ -331,7 +337,7 @@ static void wifiTask(void* parameter) { case WIFI_UI_EVENT_TOGGLE_OFF: Serial.println("WiFi Task: Disabling WiFi..."); - WiFi.disconnect(true); + WiFi.disconnect(); // NOT (true): that powers the radio off and kills ESP-NOW // Radio stays in STA mode: the ESP-NOW link to Controller B // rides on it. "WiFi off" here means scanning/association off. g_wifi_state = WIFI_STATE_OFF; @@ -358,7 +364,7 @@ static void wifiTask(void* parameter) { g_wifi_state = WIFI_STATE_CONNECTED; // Will be updated based on result // Attempt connection - WiFi.disconnect(true); // Clear any previous connection + WiFi.disconnect(); // Clear any previous connection (radio stays on: ESP-NOW rides on it) delay(100); if (strlen(creds->password) > 0) { @@ -401,7 +407,7 @@ static void wifiTask(void* parameter) { case WIFI_UI_EVENT_DISCONNECT: Serial.println("WiFi Task: Disconnecting..."); - WiFi.disconnect(true); + WiFi.disconnect(); // NOT (true): that powers the radio off and kills ESP-NOW g_wifi_state = WIFI_STATE_SCANNING; g_wifi_scan_requested = true; break; @@ -757,4 +763,44 @@ void onSelectSSID(lv_event_t *e) { Serial.println("onSelectSSID() called - but dynamic buttons handle clicks now"); } + +// ============================================================================ +// CONSOLE (`wifi ...`) - join a network without the Settings screen, e.g. for OTA +// ============================================================================ + +bool handleCommand(const char* line) { + char buf[128]; + strncpy(buf, line, sizeof(buf) - 1); + buf[sizeof(buf) - 1] = 0; + char* argv[4] = {0}; + int argc = 0; + for (char* t = strtok(buf, " \t"); t && argc < 4; t = strtok(NULL, " \t")) argv[argc++] = t; + if (argc == 0 || strcmp(argv[0], "wifi") != 0) return false; + + if (argc >= 3 && !strcmp(argv[1], "join")) { + // SSIDs with spaces aren't supported here; use the Settings screen. + Serial.printf("[wifi] joining '%s'...\n", argv[2]); + connectToWiFi(argv[2], argc >= 4 ? argv[3] : NULL); // result logged by the WiFi task + } else if (argc == 2 && !strcmp(argv[1], "off")) { + wifi_queue_event_t evt = {WIFI_UI_EVENT_TOGGLE_OFF, NULL}; + if (g_wifi_event_queue) xQueueSend(g_wifi_event_queue, &evt, 0); + Serial.println("[wifi] scanning/association off (radio stays up for ESP-NOW)"); + } else if (argc == 2 && !strcmp(argv[1], "status")) { + if (WiFi.status() == WL_CONNECTED) { + Serial.printf("[wifi] connected to '%s', IP %s, RSSI %d dBm, channel %d\n", + WiFi.SSID().c_str(), WiFi.localIP().toString().c_str(), + (int)WiFi.RSSI(), (int)WiFi.channel()); + } else { + Serial.printf("[wifi] not connected (state %d), channel %d\n", (int)g_wifi_state, (int)WiFi.channel()); + } + Serial.printf("[wifi] ESP-NOW %s, sent %lu, failed %lu\n", EspNowLink::isReady() ? "ready" : "DOWN", + (unsigned long)EspNowLink::sentCount(), (unsigned long)EspNowLink::failCount()); + } else { + Serial.println("wifi status connection, IP, channel, ESP-NOW health"); + Serial.println("wifi join [pass] join a network (no spaces in the SSID)"); + Serial.println("wifi off stop scanning/association (radio stays on)"); + } + return true; +} + } // namespace WiFiManager diff --git a/src/modules/wifi_manager.h b/src/modules/wifi_manager.h index 50e11ac..f448a0b 100644 --- a/src/modules/wifi_manager.h +++ b/src/modules/wifi_manager.h @@ -113,6 +113,12 @@ wifi_state_t getState(); */ uint8_t getNetworkCount(); +/** + * @brief Console handler for `wifi status | join [pass] | off`. + * @return false if the line isn't a wifi command + */ +bool handleCommand(const char* line); + // ============================================================================ // EVENT HANDLERS (Called from SquareLine Studio UI) // ============================================================================ diff --git a/wiki/log.md b/wiki/log.md index a285d8d..51c00ce 100644 --- a/wiki/log.md +++ b/wiki/log.md @@ -113,3 +113,7 @@ Tightened the live-data findings after checking the full capture: the Launch use ## [2026-09-26] build | OTA updates for Controller A Repartitioned A to dual OTA slots (2 x 7.9 MB, SPIFFS dropped, nvs/otadata offsets kept - tunables v150 survived the one-time USB flash on COM10, verified). New src/modules/ota_update.cpp + include/config/ota_config.h: manual `ota status|check|install|rollback` console; HTTPS pull from the (now public) Gitea repo's latest release, ECDSA P-256 signature over "patrol-a|version|sha256" checked before download, image hashed while streaming, parked gate before download and before slot switch, rollback via verifyRollbackLater() override + 30 s confirm. TLS trusts ISRG Root X1 + Root YR (both verified against the server chain). CI: .gitea/workflows/firmware.yml (main -> rolling unsigned pre-release main-latest; v* tag -> signed release with manifest.txt). Decisions: manual trigger (future Diagnostics screen), public repos instead of a device token, Controller B to be updated by A over ESP-NOW (wire is one-way). Wrote pages/ota-updates.md. Pending: BMW_NISSAN_FIRMWARE_SIGNING_KEY repo secret, enable repo Actions, first v* tag to test end-to-end. + +## [2026-09-26] build | OTA bring-up: Wi-Fi switch, ESP-NOW, memory + +First CI runs green (main-latest built with version main-1ec93dc baked in; v0.1.0 signed release verified off-device: sha256 + signature + /releases/latest). Bring-up on the board found: (1) the Settings Wi-Fi switch has been LV_STATE_DISABLED since the first SquareLine export - re-enabled at runtime; (2) WiFi.disconnect(true) in the Wi-Fi task powered the radio off and killed ESP-NOW whenever Wi-Fi was used - fixed + ESP-NOW self-heal; (3) internal RAM has 15.9 KB free / 7.6 KB largest block with Wi-Fi up, so neither a TLS task stack nor mbedtls's internal-only buffers fit - OTA jobs now run in the loop task with mbedtls routed to PSRAM; `ota check` then worked on-device (signature verified on the board, 3.6 KB stack headroom). Added `wifi join|status|off` console. v0.1.0 must not be installed (pre-fix OTA can't run once installed). Updated pages/ota-updates.md, CLAUDE.md. diff --git a/wiki/pages/open-questions.md b/wiki/pages/open-questions.md index 35aa629..12b9816 100644 --- a/wiki/pages/open-questions.md +++ b/wiki/pages/open-questions.md @@ -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. diff --git a/wiki/pages/ota-updates.md b/wiki/pages/ota-updates.md index 9d86795..0723c4e 100644 --- a/wiki/pages/ota-updates.md +++ b/wiki/pages/ota-updates.md @@ -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 [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.