Rename -> Inst. Cluster (user); power manager: deep sleep on link silence, wake on IO1 or 60 s probe boot; Ota::isBusy; sleep bit in shared header
Firmware / build (push) Successful in 2m59s

This commit is contained in:
2026-09-28 16:38:23 +02:00
parent 43697f3cc8
commit 6854aa1c46
33 changed files with 266 additions and 97 deletions
+8 -8
View File
@@ -4,7 +4,7 @@ tags: [ota, wifi, esp-now, security, verified]
updated: 2026-09-27
---
# Over-the-air updates for Controller B
# Over-the-air updates for Inst. Cluster
**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).
@@ -12,13 +12,13 @@ updated: 2026-09-27
| Step | State |
|---|---|
| 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 |
| 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 Inst. Cluster 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 | `(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 |
| `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: `Inst. Cluster 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 |
| Screen path (Inst. Cluster 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
@@ -34,7 +34,7 @@ updated: 2026-09-27
### 1. Pairing (once, on the bench, over the wire)
`link pair` on A's console. A generates a random 32-byte key, sends `PAIR` (magic, key, A's STA MAC) **three times over UART1 only** and stores the key in NVS (`linkpeer/key`). B accepts `PAIR` only from the UART source (a `PAIR` heard on the radio is dropped and logged), stores key + A's MAC in NVS (`linkpeer/key`, `linkpeer/amac`) and answers with a STATUS carrying `key_fp` = first two bytes of SHA-256(key). A logs `Controller B confirmed pairing (fingerprint XXXX)` when it matches. Both repos are public, so this is the only secret and it never travels by radio. Survives reflashes (NVS); an NVS erase on either side means re-pairing at home — the car has no wire today ([[controller-link]]).
`link pair` on A's console. A generates a random 32-byte key, sends `PAIR` (magic, key, A's STA MAC) **three times over UART1 only** and stores the key in NVS (`linkpeer/key`). B accepts `PAIR` only from the UART source (a `PAIR` heard on the radio is dropped and logged), stores key + A's MAC in NVS (`linkpeer/key`, `linkpeer/amac`) and answers with a STATUS carrying `key_fp` = first two bytes of SHA-256(key). A logs `Inst. Cluster confirmed pairing (fingerprint XXXX)` when it matches. Both repos are public, so this is the only secret and it never travels by radio. Survives reflashes (NVS); an NVS erase on either side means re-pairing at home — the car has no wire today ([[controller-link]]).
### 2. SECURE frames (A → B, ESP-NOW unicast)
@@ -49,7 +49,7 @@ Everything A sends B by radio that matters goes inside `PACKET_TYPE_SECURE`: `no
### 4. A's Updates page
Settings → Updates now has two cards, **Controller A** and **Controller B**, each with Installed / Latest / a status line / Check / Install. B's buttons are enabled only when B is heard, paired with *this* key and holds credentials; the status line otherwise says which of those is missing. Install asks for confirmation, then `LinkPeer::requestInstall()` applies A's parking gate (engine off, shaft still, lever P/N — `Ota::isParked()`), requires **A itself to be on Wi-Fi** (same network as B ⇒ same radio channel ⇒ B's STATUS frames keep arriving while B is joined) and sends the `OTA_CMD`.
Settings → Updates now has two cards, **Main CTRL** and **Inst. Cluster**, each with Installed / Latest / a status line / Check / Install. B's buttons are enabled only when B is heard, paired with *this* key and holds credentials; the status line otherwise says which of those is missing. Install asks for confirmation, then `LinkPeer::requestInstall()` applies A's parking gate (engine off, shaft still, lever P/N — `Ota::isParked()`), requires **A itself to be on Wi-Fi** (same network as B ⇒ same radio channel ⇒ B's STATUS frames keep arriving while B is joined) and sends the `OTA_CMD`.
### 5. B's updater (`src/modules/ota_update.cpp`)
@@ -67,9 +67,9 @@ Port of A's module. Differences: gate = link data (`rpm == 0`, lever P/N/unknown
1. Bench: both boards on USB, `485_A → IO1`, GND → GND, 5B's 120 Ω switch OFF. B's 5-second stats line must say `uart alive`.
2. A console: `link pair` → A prints the fingerprint; within 5 s `link status` shows `key XXXX (matches)` and B's console printed `PAIRED over the wire`.
3. A on Wi-Fi with its remembered network → within ~15 s A logs `Wi-Fi credentials for '<ssid>' sent to Controller B (encrypted)`, B logs `stored`, `link status` shows `Wi-Fi creds yes`.
3. A on Wi-Fi with its remembered network → within ~15 s A logs `Wi-Fi credentials for '<ssid>' sent to Inst. Cluster (encrypted)`, B logs `stored`, `link status` shows `Wi-Fi creds yes`.
4. Tag this repo (`git tag -a v0.1.0 -m ... && git push --follow-tags origin master`), wait for the Gitea release with `manifest.txt`.
5. A: Settings → Updates → Controller B → Check → "Version v0.1.0 is available for Controller B" → Install → confirm. B's screen shows "Updating v0.1.0 N%", A's card shows the percentage, B restarts, its STATUS says `v0.1.0` with "new firmware, confirming..." for 30 s, then plain. Console alternative: `link ota check`, `link ota install`.
5. A: Settings → Updates → Inst. Cluster → Check → "Version v0.1.0 is available for Inst. Cluster" → Install → confirm. B's screen shows "Updating v0.1.0 N%", A's card shows the percentage, B restarts, its STATUS says `v0.1.0` with "new firmware, confirming..." for 30 s, then plain. Console alternative: `link ota check`, `link ota install`.
## Risks / open
+2 -2
View File
@@ -6,10 +6,10 @@ updated: 2026-09-21
# Controller Link (A → B)
The system is two ESP32-S3 boards. Controller A (Waveshare ESP32-S3-Touch-LCD-5B, sibling repo) reads the BMW PT-CAN bus and owns all decoding; Controller B ([[esp32-s3-lcd-1-3]], this repo) is a **slave / extension**: it consumes a compact packet, displays it, and will drive the Patrol gauges from it ([[patrol-gauge-outputs]]).
The system is two ESP32-S3 boards. Main CTRL (Waveshare ESP32-S3-Touch-LCD-5B, sibling repo) reads the BMW PT-CAN bus and owns all decoding; Inst. Cluster ([[esp32-s3-lcd-1-3]], this repo) is a **slave / extension**: it consumes a compact packet, displays it, and will drive the Patrol gauges from it ([[patrol-gauge-outputs]]).
```
BMW PT-CAN ──▶ Controller A (5B) ──UART 5 Hz──▶ Controller B (1.3)
BMW PT-CAN ──▶ Main CTRL (5B) ──UART 5 Hz──▶ Inst. Cluster (1.3)
╰── BLE (planned, redundant) ──╯ → [[link-redundancy]]
```
+2 -2
View File
@@ -6,7 +6,7 @@ updated: 2026-09-27
# Waveshare ESP32-S3-LCD-1.3
Controller B of the [[controller-link]] — the compact secondary unit. Receives the sensor stream from Controller A, shows it on a 1.3" round-masked display, and is the board chosen to drive the Patrol cluster gauges ([[patrol-gauge-outputs]]) because it is the only one of the two with free hardware-PWM pins on a header.
Inst. Cluster of the [[controller-link]] — the compact secondary unit. Receives the sensor stream from Main CTRL, shows it on a 1.3" round-masked display, and is the board chosen to drive the Patrol cluster gauges ([[patrol-gauge-outputs]]) because it is the only one of the two with free hardware-PWM pins on a header.
## Specs (source: waveshare-wiki-esp32-s3-lcd-1-3)
@@ -56,7 +56,7 @@ Header GPIOs and their current use `(repo)`:
| GPIO | Use today | Note |
|---|---|---|
| IO1 | UART1 RX from Controller A | keep |
| IO1 | UART1 RX from Main CTRL | keep |
| IO2 | UART1 TX (link is receive-only, so idle) | effectively free |
| IO3 | free | S3 strapping pin (JTAG select) — avoid |
| IO4, IO5 | free | |
+2 -2
View File
@@ -6,7 +6,7 @@ updated: 2026-09-21
# Open Questions
The research frontier for Controller B. Answering any of these should trigger updates across the wiki. Ordered roughly by how much they block progress.
The research frontier for Inst. Cluster. Answering any of these should trigger updates across the wiki. Ordered roughly by how much they block progress.
## Blocking
@@ -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** — **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).
12. **OTA for Inst. Cluster** — **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 Inst. Cluster 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