@@ -15,6 +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]] — **design (2026-09-27, agreed)**: B pulls its own signed release over Wi-Fi; A hands over the credentials once (paired key exchanged over the wire, then encrypted ESP-NOW unicast) and the trigger; B reports version/phase back; same manifest + key as A; work order and risks
- [[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
@@ -58,3 +58,7 @@ A gained a hand-coded LVGL Gauge Tuning screen (Home → right → Driveline →
Mirror of the A-side clean-up. `include/ui/` (SquareLine export) deleted; the screen is now `src/modules/gauge_screen.cpp` - same layout minus the engine-oil cell (user decision, closes open question #8: the M57N has no oil temperature sensor), battery centred at the bottom. Kept the two fonts and six icons the screen uses as plain LVGL arrays in `src/assets/`. New `DisplayInit::lock()/unlock()` recursive mutex: `lvglTask` renders under it and `loop()` updates under it - before, the higher-priority render task could preempt `loop()` mid-`lv_label_set_text()`, the bug class that froze A. Labels, colours and icons are written only on change. `DebugMonitor` now records A's debug flag in the receiver and applies it from `loop()` under the lock (it used to touch LVGL from the ESP-NOW callback). `lv_conf.h`: 128 KB pool in PSRAM, logging off, `LV_TICK_CUSTOM` from `millis()`. `platformio.ini`: flash declared 16 MB with `default_16MB.csv` (two 6.5 MB OTA slots; NVS unchanged so the cached gauge config survives), stale `-mfix-esp32-psram-cache-issue` and include paths removed. Waveshare's page adds nothing new for firmware (Arduino core 2.0.x, LVGL 8.3.7 demo, 800 mA LDO); no operating-temperature figure. Built and flashed COM13. Updated [[esp32-s3-lcd-1-3]], [[open-questions]] #8, index; root CLAUDE.md and README.
## [2026-09-27] query | OTA for B: pull design chosen, written up
User asked about updating B "via ESP-NOW". Compared A-pushes-chunks vs B-pulls-itself; user chose the pull design. Facts checked: B's Arduino 2.0.17 `qio_opi` sdkconfig has bootloader rollback, ECDSA P-256 and PEM parsing enabled (no core rebuild), 235 KB internal free after today's clean-up, partition table already has two OTA slots. Design page [[controller-b-ota]]: credential handoff via a pairing key exchanged over the UART wire on the bench then encrypted ESP-NOW unicast (both repos are public, so a compiled-in key would protect nothing); STATUS frames B→A for version + phase and A's Updates page gets a Controller B row; OTA_CMD trigger behind A's parking gate; B's OTA module = port of A's with link-data gate and a small on-screen notice; B CI workflow + `BMW_NISSAN_FIRMWARE_SIGNING_KEY` secret on the B repo (user action). New frame types 0x03–0x06, PACKET_VERSION stays 2. Open question #12 added.
Design agreed 2026-09-27 (user chose this over A streaming the image through ESP-NOW): **B pulls its own signed release from Gitea over Wi-Fi; A only hands B the network credentials and the trigger, over the existing link.** Everything reuses what already works on A ([[ota-updates]] in the sibling wiki).
## Why pull, not push
| | A pushes over ESP-NOW | B pulls itself (chosen) |
|---|---|---|
| Transport | ~4,400 × 250-byte frames, needs acks/resends both ways (new protocol) | one HTTPS download, TCP does the rest |
| Code | new chunk protocol on both boards | port of A's `ota_update.cpp` (729 lines, proven) |
| RAM | image transits A's scarce internal RAM | B has 235 KB internal free after the 2026-09-27 clean-up `(verified)`; TLS fits without the PSRAM tricks A needs |
| Integrity | same signed manifest | same signed manifest, same public key, `target=patrol-b` |
| New risk | protocol bugs mid-flash | Wi-Fi credentials must reach B once |
## Prerequisites — all in place `(verified 2026-09-27)`
- B's partition table: two 6.5 MB OTA slots (`default_16MB.csv`), NVS untouched.
- B has 8 MB PSRAM and a Wi-Fi radio already running in STA mode for ESP-NOW.
## The pieces
### 1. Credential handoff (A → B, once)
A knows the remembered network (`WiFiManager`, NVS namespace `wifi`). B must learn it without it being broadcast in the clear — the ESP-NOW data link is unencrypted broadcast and both repos are public, so a compiled-in key would protect nothing.
- **Pairing on the bench, over the wire**: a console command on A (`link pair`) generates a random 16-byte key, sends it to B **only over UART1** (the physical wire, not ESP-NOW), both sides store it in NVS. Done once; survives reflashes (NVS).
- After pairing, the credential frame goes **ESP-NOW unicast, encrypted** with that key (ESP-NOW peer with `encrypt=true`, LMK = the pairing key, PMK fixed). B learns A's MAC from the frames it already receives; A learns B's MAC from B's status frames (below).
- B stores the credentials in its own NVS so a later update does not need A awake — and `wifi forget` on A also tells B to forget.
### 2. Status back-channel (B → A)
New frame type `STATUS` (B → A, ESP-NOW unicast to A's MAC, every 5 s): B's firmware version, OTA phase, uptime, free heap. A shows it on Settings → Updates as a second row, **Controller B: vX.Y.Z**, with its own Check / Install. This also gives A the MAC it needs for the encrypted unicast.
### 3. Trigger (A → B)
New frame type `OTA_CMD` (A → B, unicast): `check` or `install`. A applies its own parking gate first (engine off, shaft still, lever P/N — the same one that guards A's install) and refuses otherwise. B additionally refuses while it sees rpm > 0 in the link data.
### 4. B's OTA module
`src/modules/ota_update.cpp` on B = A's module with these changes:
- gate: link data (rpm == 0, no shaft) instead of the CAN driver; A's gate already ran.
- no `Tunables::flush()`; `GaugeOutputs` are forced low for the duration (parked anyway).
- notice on the 240×240 screen: a small "Updating vX — N %" line under the gear (SPI panel, no flicker problem).
-`OTA_TARGET "patrol-b"`, `OTA_REPO "art/ESP32-S3-LCD-1.3"`, same public key as A (`tools/ota/firmware_signing_pub.pem`), same Let's Encrypt roots.
-`verifyRollbackLater()` override + confirm after 30 s of healthy uptime, else the bootloader rolls back — identical to A.
- Wi-Fi: join with the stored credentials only for the job, then `WiFi.disconnect()` back to a bare STA so ESP-NOW hopping resumes. (During the join B's channel follows the AP; A follows the same AP, so the link keeps working — and the gauges are idle while parked.)
- Console on B (CH343 serial): `ota status | check | install [force] | rollback`, `wifi status | forget`.
### 5. Release pipeline for B
A copy of A's `.gitea/workflows/firmware.yml` in the B repo: `pio run` (no core rebuild — B is on the stock espressif32@6 platform, so upstream PlatformIO is fine there), tag `v*` → signed release with `manifest.txt` (`target=patrol-b`), `main` → unsigned `main-latest`. Needs the repo secret **`BMW_NISSAN_FIRMWARE_SIGNING_KEY`** on the B repo (or as an organisation secret) — *user action*.
### 6. Shared header
`automotive_data.h` gains `PACKET_TYPE_STATUS 0x03`, `PACKET_TYPE_OTA_CMD 0x04`, `PACKET_TYPE_WIFI_CREDS 0x05` (+ `PACKET_TYPE_PAIR 0x06` on the wire only) with their payload structs. DATA/CONFIG unchanged, so `PACKET_VERSION` stays 2 and an older B simply ignores the new types. The header stays byte-identical in both repos.
## Order of work
1. Shared header + B: STATUS frames out, A: receive callback + Updates row (visible progress from day one).
2. Pairing over the wire + encrypted credential handoff; B stores and can join (`wifi status` on B shows it).
3. B OTA module port + on-screen notice + gauge hold; console-driven test with a **dev release** (see below).
4. B CI workflow; first signed `v0.1.0` for B; end-to-end from A's screen.
5. Wiki + CLAUDE.md on both sides.
Test without the secret: nothing can be signed locally (the private key exists only as a Gitea secret), so step 3 is tested against A's signature path by pointing B's `OTA_REPO` at the B repo's first CI release — i.e. step 4 precedes the end-to-end test. Everything up to "manifest signature OK" can be exercised earlier with A's release (target mismatch is the expected, correct refusal).
## Risks
- **Wi-Fi + ESP-NOW coexistence on B** while joined to the AP: same situation as on A (works, channel follows the AP). If B's ESP-NOW receive stalls during the download it does not matter — parked.
- **Internal RAM on B during TLS**: 235 KB free today; A needed ~40 KB internal per TLS session. Fine, but measure once.
- **A's Updates page** grows a second row; A's LVGL pool is in PSRAM, no concern.
- **Pairing key lost** (NVS erase on either side): re-pair on the bench. The car has no wire today (open question in [[controller-link]]) — pairing must be done at home.
@@ -22,6 +22,8 @@ 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 2026-09-27 → [[controller-b-ota]]. Open inside it: the signing secret on the B repo (user), pairing key exchange on the bench, first B release.
## Hardware
9.**Operating temperature and power draw are not on Waveshare's product wiki** for this board `(source: waveshare-wiki-esp32-s3-lcd-1-3)`. The 5B's spec is 0–65 °C; assume similar until a datasheet says otherwise. Dashboard mounting in a Patrol will see both extremes.
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.