diff --git a/wiki/index.md b/wiki/index.md index 4595b70..0b6be67 100644 --- a/wiki/index.md +++ b/wiki/index.md @@ -15,7 +15,7 @@ Catalog of every page in the wiki. Read this first when answering questions. Kee - [[controller-link]] — the A → B link, **protocol v2 (verified 2026-09-21)**: typed DATA/CONFIG frames on UART1 **and** ESP-NOW with dedupe, split gear fields, rpm, A-side alerts; pins (A TX = GPIO 44 → 485_A → B IO1 on the bench); the RS485-in-the-car question; v1 and the old enum drift kept for the record - [[link-redundancy]] — wired + wireless redundancy: **ESP-NOW leg built and bench-verified** (both paths carry every frame, B dedupes and hops channels); RS485 for the car and BLE still open; failover policy notes -- [[controller-b-ota]] — **implemented 2026-09-27 (STATUS + gates verified, pairing/first release pending)**: B pulls its own signed release over Wi-Fi; `link pair` on A sends a random key over the UART wire once; credentials and OTA commands travel in AES-256-GCM `SECURE` frames; B reports version/phase/progress in `STATUS` frames; A's Updates page has a Controller B card; B's updater = port of A's; CI workflow + `v0.1.0` procedure +- [[controller-b-ota]] — **implemented and verified end-to-end 2026-09-27 (B `dev` → `v0.1.0` from A's console)**: B pulls its own signed release over Wi-Fi; `link pair` on A sends a random key over the UART wire once; credentials and OTA commands travel in AES-256-GCM `SECURE` frames; B reports version/phase/progress in `STATUS` frames; A's Updates page has a Controller B card; B's updater = port of A's; CI workflow + `v0.1.0` procedure - [[patrol-gauge-outputs]] — Patrol tachometer (IO7, 14-bit LEDC, 4 ppr) and coolant gauge (IO8, 8-bit PWM, CANNY duty law) **outputs implemented and bench-verified**; tunables on A via `cfg` console; prior art from the CANNY program; driver stage and needle calibration still to do ## Synthesis diff --git a/wiki/log.md b/wiki/log.md index f9e936d..85859f8 100644 --- a/wiki/log.md +++ b/wiki/log.md @@ -66,3 +66,7 @@ User asked about updating B "via ESP-NOW". Compared A-pushes-chunks vs B-pulls-i ## [2026-09-27] update | Controller B OTA implemented on both boards; STATUS + gates verified; pairing awaits the wire Implemented the [[controller-b-ota]] design end to end. Shared header: `STATUS` 0x03 / `PAIR` 0x04 / `SECURE` 0x05 (+ inner `OTA_CMD` 0x11, `WIFI_CREDS` 0x12), `PACKET_MAX_PAYLOAD` 160, new `include/protocol/link_secure.h` (AES-256-GCM seal/open, key fingerprint; mbedtls names differ between IDF 4.4 and 5.5, handled). Decision: application-level GCM instead of ESP-NOW peer encryption (no PMK/LMK bookkeeping, no broadcast-vs-encrypted-peer doubt). B: `link_peer.cpp` (NVS key + A's MAC, credentials in namespace `wifi`, mailboxes so the Wi-Fi/UART tasks never touch NVS, STATUS every 5 s / on change, nonce replay window), `console.cpp` (line reader + handler chain, `help`), `ota_update.cpp` (port of A's: link-data gate, joins Wi-Fi only for the job, notice line on the screen via `GaugeScreen::setNotice()`, pumps STATUS from the download loop), `include/config/ota_config.h` (`patrol-b`, this repo, same roots + public key), `.gitea/workflows/firmware.yml`, `tools/ota/firmware_signing_pub.pem`. A: `link_peer.cpp` (`link status|pair|unpair|creds|ota ...`, automatic credential sync, B card on Settings → Updates), `EspNowLink` receive callback + `sendTo()`, `UARTManager::sendWire()`, `WiFiManager::getSavedCredentials()`, `Ota::isParked()`. Bench (A COM14, B COM13): B's STATUS frames reach A (MAC 10:51:DB:8F:B6:5C, `dev`, heap 234 KB); `ota check` on B refuses "no Wi-Fi credentials from A yet"; `link ota check` on A refuses "not paired"; `link pair` on A sent PAIR ×3 but B never saw it: **B's UART leg is silent (uart=0) — no wire on the bench right now**. Next: connect `485_A → IO1` + GND, `link pair`, credentials, tag `v0.1.0`, install from A's screen. Build notes: run `pio` from PowerShell (idf_tools refuses MSYS/Git Bash); the first build after switching between the two projects reinstalls the other Arduino core and can fail once with a `TypeError` — run it again. + +## [2026-09-27] verify | Controller B updated over the air from A: dev → v0.1.0, end to end + +User connected `485_A → IO1` (ground via the USB hub). B had rebooted on plug-in (A's card flipped to "not heard" for 15 s) and logged checksum-error bursts, but `uart alive` with good frames. `link pair` on A: PAIR ×3 over the wire, B `PAIRED ... fingerprint A9B7`, A `Controller B confirmed pairing` in < 5 s, then A pushed the `ArtServis` credentials by itself and B stored them. `link ota check` before the release existed: B joined the AP in ~2 s, got 404 → "no release published yet", reported to A as *failed* + reason (truncated to 32 chars), left Wi-Fi, re-locked on channel 1. CI: B's `main-latest` built in < 3 min; the `v0.1.0` tag build took ~12 min but published `firmware.bin` 1,248,432 B + `manifest.txt` (target patrol-b, sha256 `3c33d20f…3415`, ECDSA sig). `link ota check` → `update available, latest v0.1.0`; `link ota install` → download + flash to app1 in ~50 s with 0/10/…/100 % on B's console, `verified and installed v0.1.0`, reboot, `Firmware v0.1.0` banner, STATUS to A resumed, `confirmed - rollback cancelled` at 30 s, `ota status` slot app1 valid. Heap 230 KB before/after, loop stack headroom 3.4 KB. Not yet eyeballed: the Updates-page buttons on A and the progress line on B's screen (same code path as the console). Wiki [[controller-b-ota]] verification table and risks updated, [[open-questions]] #12 answered. diff --git a/wiki/pages/controller-b-ota.md b/wiki/pages/controller-b-ota.md index d88ba0c..e4d5257 100644 --- a/wiki/pages/controller-b-ota.md +++ b/wiki/pages/controller-b-ota.md @@ -1,12 +1,12 @@ --- type: concept -tags: [ota, wifi, esp-now, security, design, verified] +tags: [ota, wifi, esp-now, security, verified] updated: 2026-09-27 --- # Over-the-air updates for Controller B -**Status 2026-09-27: implemented on both controllers, bench-tested up to the pairing step.** B pulls its own signed release from Gitea over Wi-Fi; A hands B the network credentials and the trigger over the existing link, and shows B's progress on its own Updates page. Design chosen by the user over "A streams the image through ESP-NOW" (comparison below). Everything reuses A's proven pipeline ([[ota-updates]] in the sibling wiki). +**Status 2026-09-27: implemented on both controllers and VERIFIED END-TO-END on the bench - B went from `dev` to `v0.1.0` on a command typed on A, rebooted and confirmed itself.** B pulls its own signed release from Gitea over Wi-Fi; A hands B the network credentials and the trigger over the existing link, and shows B's progress on its own Updates page. Design chosen by the user over "A streams the image through ESP-NOW" (comparison below). Everything reuses A's proven pipeline ([[ota-updates]] in the sibling wiki). ## What is verified, what is not @@ -14,9 +14,11 @@ updated: 2026-09-27 |---|---| | B → A STATUS frames (version, phase, heap, uptime) over ESP-NOW unicast | `(verified 2026-09-27)` A's console `link status` lists B's MAC, `dev`, heap 234 KB; A's Updates page shows the Controller B card | | Gates on both sides (unpaired → refused, no credentials → refused, key mismatch → refused) | `(verified 2026-09-27)` each refusal text seen on the consoles | -| `link pair` over the UART wire | **not yet**: the bench had no wire connected when tested (B: `uart=0 ... uart silent`). Needs `485_A → IO1`, GND → GND, 120 Ω switch OFF ([[controller-link]] bench wiring) | -| Encrypted credential handoff, B joins the network | not yet (needs pairing) | -| `link ota check` / install from A's screen, first signed B release | not yet (needs pairing + release `v0.1.0` of this repo) | +| `link pair` over the UART wire | `(verified 2026-09-27 21:2x)` wire `485_A → IO1`, ground shared through the USB hub only. A: `PAIR sent over the wire 3 time(s); new key fingerprint A9B7`; B: `PAIRED over the wire ... A = 30:ED:A0:17:B2:4C` (+ one "re-confirmed" for the repeats); A: `Controller B confirmed pairing (fingerprint A9B7)` within 5 s | +| Encrypted credential handoff | `(verified)` A pushed `ArtServis` on its own right after pairing; B: `Wi-Fi credentials for 'ArtServis' stored`; `wifi status` on B lists the network | +| `link ota check` from A | `(verified)` B joined the AP (IP 10.0.10.101, channel 1) in ~2 s, before the release existed: `no release published yet (push a v* tag)` reported back to A as phase *failed* + message; after the release: `latest release v0.1.0 (1248432 bytes, signature OK)`, A: `update available, latest v0.1.0` | +| `link ota install` from A, first signed release `v0.1.0` | `(verified)` download + flash of 1,248,432 B into `app1` in ~50 s, `verified and installed v0.1.0`, reboot, banner `Firmware v0.1.0`, `NEW IMAGE, unconfirmed`, STATUS to A resumed within seconds (`firmware v0.1.0`), `firmware v0.1.0 confirmed - rollback cancelled` at 30 s; `ota status`: slot app1 state valid. Loop stack headroom after a job: 3.4 KB; heap 230 KB before/after | +| Screen path (Controller B card on A's Updates page, B's on-screen notice line) | same request functions as the console commands, but the buttons have **not been tapped yet** and the "Updating v0.1.0 N%" line on B's round screen was not watched - user to confirm on the next update | ## Why pull, not push @@ -71,8 +73,10 @@ Port of A's module. Differences: gate = link data (`rpm == 0`, lever P/N/unknown ## Risks / open -- **Wi-Fi + ESP-NOW coexistence on B while joined**: A and B on the same AP share the channel; B's receiver follows the AP channel while joined and hops back after `WiFi.disconnect(false)`. Not yet observed live. -- **Internal RAM on B during TLS**: 235 KB free today; the job logs heap before/after. Measure once on the first check. +- **Wi-Fi + ESP-NOW coexistence on B while joined**: `(verified)` A on `ArtServis` channel 1, B joined the same AP on channel 1, STATUS kept flowing during the download (A saw phase *installing*), B re-locked on channel 1 after `WiFi.disconnect(false)`. Untested: A **not** on Wi-Fi or on a different AP - by design A refuses B commands unless it is on Wi-Fi itself. +- **Internal RAM on B during TLS**: `(verified)` 230.7 KB free before the job, 230.4 KB after; largest block 164 KB. No PSRAM tricks needed. +- **UART wire quality on the bench**: with ground shared only through the USB hub, B logs bursts of `Checksum error on uart` (7 in a row at times) and an occasional `Framing error` / `Version mismatch got v0`; 2026-09-21 with a direct GND wire it was 0 errors. Harmless for the data (ESP-NOW copy wins, dedupe) and PAIR got through (sent 3×), but run a real GND wire next time → [[open-questions]] #1 / [[link-redundancy]]. +- **`link_status_t::message` is 32 bytes**: B's failure reason `no release published yet (push a v* tag)` arrived truncated at "(push". Cosmetic; lengthen if it ever matters. - **Pairing key lost** (NVS erase on either side): re-pair at home over the wire. - Two boards, one PlatformIO penv: the first `pio run` after switching projects reinstalls the other Arduino core and can fail once with a `TypeError`; run it again. Builds must be started from PowerShell, not Git Bash (`idf_tools.py` refuses MSYS). diff --git a/wiki/pages/open-questions.md b/wiki/pages/open-questions.md index 3e2ffbb..57d587e 100644 --- a/wiki/pages/open-questions.md +++ b/wiki/pages/open-questions.md @@ -22,7 +22,7 @@ The research frontier for Controller B. Answering any of these should trigger up 13. **CANNY 5.3 pico details**: what is the HR PWM base clock (period 255 = what frequency), and what sat between the CANNY pin and the gauge wire? The user may still have the unit and harness. → [[temp-stage-cfd]] 8. ~~**Does `engine_oil_temp` stay in the packet?**~~ **Answered 2026-09-27 (user): dropped from the screen.** The field stays in the packet (protocol v2 unchanged, never valid on this engine), but B's hand-coded screen no longer has an oil quadrant - the battery cell sits alone at the bottom. -12. **OTA for Controller B** — design agreed and **implemented 2026-09-27** → [[controller-b-ota]]. STATUS frames and every gate verified on the bench; signing secret set on the B repo (user, 2026-09-27). Still open: `link pair` over the wire (the bench had no wire connected), the automatic credential handoff, the first signed release `v0.1.0` and the first install from A's screen. +12. **OTA for Controller B** — **answered 2026-09-27** → [[controller-b-ota]]: implemented and verified end-to-end on the bench (pair over the wire, automatic credential handoff, `link ota check` / `install` from A, B `dev` → `v0.1.0`, reboot, self-confirm). Left to eyeball: the Controller B card on A's Updates page and B's on-screen progress line during the next update; the bench wire wants a proper GND (checksum-error bursts with hub-only ground). ## Hardware