OTA updates for Controller A: dual-slot partitions, signed Gitea releases
- partition table: two 7.9 MB OTA slots, SPIFFS dropped, nvs/otadata offsets unchanged (tunables survived the one-time USB flash) - ota_update.cpp: manual `ota status|check|install|rollback` console; HTTPS pull from the public repo's latest release, ECDSA P-256 signature over "patrol-a|version|sha256" checked before download, streamed image must match, parked gate before download and before the slot switch, 30 s confirm-or-rollback (verifyRollbackLater override) - ota_config.h: server/repo, ISRG Root X1 + Root YR, signing public key - .gitea/workflows/firmware.yml: main -> rolling unsigned pre-release main-latest; v* tag -> signed release (needs secret FIRMWARE_SIGNING_KEY) - wiki: pages/ota-updates.md (design, decisions, B-over-ESP-NOW plan); CLAUDE.md, index, log, open-questions #12 updated Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+2
-1
@@ -1,6 +1,6 @@
|
||||
---
|
||||
type: index
|
||||
updated: 2026-09-23
|
||||
updated: 2026-09-26
|
||||
---
|
||||
|
||||
# Index
|
||||
@@ -20,6 +20,7 @@ Catalog of every page in the wiki. Read this first when answering questions. Kee
|
||||
- [[driveline-speed-signals]] — **engine / turbine / output-shaft speeds**: turbine speed as physical proof of gear engagement, and the output-shaft field that is our **only road-speed source** (no DSC on this bus) — the feedback variable for a future cruise-control PoC, with the safety envelope that would require
|
||||
- [[dual-controller-architecture]] — Controller A → UART1 + ESP-NOW, protocol v2 → Controller B (1.3" display + Patrol gauge outputs); A owns alerts and the gauge tunables (`cfg` console)
|
||||
- [[obd-diagnostic-polling]] — **why boost / MAF / rail / injection / DTCs never appear on the sniffer** and how a tester gets them: Route A generic OBD-II mode 01 on `0x7DF` and Route B BMW KWP on `0x6F1` → `0x612` — **BOTH VERIFIED WORKING 2026-09-23** (minimal PID set, no boost PID, mode 09 silent; `1A 86` ident identifies the donor; DTCs read via mode 03), the capture-with-Launch procedure (still wanted for the `22 D1xx` live-data identifiers), and why polling is a transmit-on-the-bus design decision
|
||||
- [[ota-updates]] — **Controller A updates itself from Gitea releases**: tag `v*` → CI builds + signs (ECDSA P-256) → `ota install` (manual, parked, Wi-Fi) pulls over HTTPS from the public repo, verifies, flashes the idle slot, 30 s confirm-or-rollback; dual-slot partition table (2026-09-26); plan for updating Controller B through A over ESP-NOW
|
||||
|
||||
## Synthesis
|
||||
|
||||
|
||||
@@ -109,3 +109,7 @@ The capture-with-Launch session, finally run (engine idling, our read-only seria
|
||||
## [2026-09-23] lint | Clarify self-poll requirements; record Diagnostics-screen plan
|
||||
|
||||
Tightened the live-data findings after checking the full capture: the Launch used only 1A/2C/22/23 - NO 10 (session), 27 (security), or 3E (tester-present). So self-polling a 2C value (e.g. rail pressure) needs only the 2C 10 15E0 define + 2C 10 00DF poll, no secret; the earlier 21-block NRCs (0x22/0x33) are a different mechanism and do not gate 2C. Corrected the "needs session/define handshake" wording in launch-capture-2026-09-23.md and obd-diagnostic-polling. Recorded the design decision (user, 2026-09-23): active polling, if built, lives behind a password-protected Diagnostics screen (authorized-tech gate, manual, refuses while scan tool connected, read-oriented services) - open-questions #12, and a project memory so the capability is not re-researched later.
|
||||
|
||||
## [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: FIRMWARE_SIGNING_KEY repo secret, enable repo Actions, first v* tag to test end-to-end.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
type: synthesis
|
||||
tags: [meta, todo]
|
||||
updated: 2026-09-23
|
||||
updated: 2026-09-26
|
||||
---
|
||||
|
||||
# Open Questions
|
||||
@@ -24,7 +24,7 @@ The research frontier. Answering any of these should trigger updates across the
|
||||
|
||||
## Design decisions (parked, not blocking)
|
||||
|
||||
12. **The "Diagnostics" screen (planned 2026-09-23).** Active diagnostic polling — replaying the `2C` live-data reads we decoded ([[launch-capture-2026-09-23]]) so values like rail pressure appear on Controller A without the Launch — is now technically unblocked (no session/security needed). Intended design when built: a **password-protected Diagnostics screen**, authorized-technician access only, manual trigger, refuses while a scan tool is connected, read-oriented services only. The same gate covers the general transmit-on-the-bus decision. This is deliberately deferred, but the capability, the byte sequences, and these guard rails are recorded so the work resumes from here, not from scratch. → [[obd-diagnostic-polling]], [[dual-controller-architecture]]
|
||||
12. **The "Diagnostics" screen (planned 2026-09-23).** Active diagnostic polling — replaying the `2C` live-data reads we decoded ([[launch-capture-2026-09-23]]) so values like rail pressure appear on Controller A without the Launch — is now technically unblocked (no session/security needed). Intended design when built: a **password-protected Diagnostics screen**, authorized-technician access only, manual trigger, refuses while a scan tool is connected, read-oriented services only. The same gate covers the general transmit-on-the-bus decision. This is deliberately deferred, but the capability, the byte sequences, and these guard rails are recorded so the work resumes from here, not from scratch. **Also the home of the OTA "check / install" controls (2026-09-26)** — today they are the `ota` console; the password must be stored as a salted hash in NVS because the firmware is public. → [[obd-diagnostic-polling]], [[dual-controller-architecture]], [[ota-updates]]
|
||||
|
||||
## Project context
|
||||
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
---
|
||||
type: concept
|
||||
tags: [ota, firmware, gitea, ci, security, signing, design-decision, controller-a]
|
||||
updated: 2026-09-26
|
||||
---
|
||||
|
||||
# OTA Firmware Updates
|
||||
|
||||
How Controller A updates itself from this repo's Gitea releases, why each piece is the way it is, and what is still to do (Controller B). Built 2026-09-26. Design decisions by the user are marked **(decision)**.
|
||||
|
||||
## The pipeline
|
||||
|
||||
```
|
||||
git push tag vX.Y.Z ──► Gitea Actions (.gitea/workflows/firmware.yml, runner ubuntu-latest)
|
||||
pio run (-DFW_VERSION="vX.Y.Z")
|
||||
sign "patrol-a|vX.Y.Z|<sha256>" with secret FIRMWARE_SIGNING_KEY
|
||||
release vX.Y.Z: firmware.bin + firmware.elf + manifest.txt
|
||||
│ public repo, HTTPS, no token
|
||||
Controller A `ota install` ◄──────┘ (parked, Wi-Fi joined)
|
||||
GET /api/v1/repos/art/ESP32-S3-Touch-LCD-5B/releases/latest → tag
|
||||
GET /releases/download/<tag>/manifest.txt → verify signature FIRST
|
||||
GET /releases/download/<tag>/firmware.bin → idle slot, hashed while streaming
|
||||
sha256 == signed sha256 → esp_ota_end → parked again? → switch slot → reboot
|
||||
new image PENDING_VERIFY → confirmed after 30 s uptime, else bootloader rolls back
|
||||
```
|
||||
|
||||
Push to `main` (no tag) builds a rolling **pre-release `main-latest`** — unsigned, no manifest, for bench/USB testing. `/releases/latest` skips pre-releases, so the car is never offered it `(repo)`.
|
||||
|
||||
## Decisions and why
|
||||
|
||||
- **Manual trigger only (decision, 2026-09-26).** An install ends in a reboot, which blanks Controller B's gauges; nothing checks or installs in the background. Today the trigger is the `ota` serial console; the intended home is the password-gated **Diagnostics screen** ([[open-questions]] #12), the same gate as active CAN polling.
|
||||
- **Parked gate** `(repo)`: refused if engine rpm > 0 / run state running or starting, output shaft turning, or lever in a drive gear. A silent bus (>2 s no frames: ignition off, bench) counts as parked. Checked before the download **and again** before the slot switch. `ota check` is exempt (read-only).
|
||||
- **HTTPS pull from a public repo (decision).** Both repos were made public 2026-09-26 so the device needs **no token** — the same reasoning as `parking_solution`'s public releases mirror: a read token in shipped firmware leaks with the device. History was scanned before/after going public: no secrets, no full VIN (only the 10-char prefix in ident logs), no SSIDs `(verified 2026-09-26)`.
|
||||
- **Signed images (decision).** HTTPS only proves the file came from the server; the ECDSA P-256 signature proves it came from our CI key. The signed statement is `target|version|sha256`, so a Controller B image can't be installed on A even with a shared key, and the manifest version can't be swapped. The firmware contains no secrets, so public binaries are fine — **keep it that way**: the future Diagnostics-screen password must be a salted hash in NVS, never a literal in source.
|
||||
- **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).
|
||||
|
||||
## Partition table (changed 2026-09-26)
|
||||
|
||||
| Name | Offset | Size |
|
||||
|---|---|---|
|
||||
| nvs | 0x9000 | 20 KB — **unchanged offset, settings survive** |
|
||||
| otadata | 0xE000 | 8 KB |
|
||||
| app0 (ota_0) | 0x10000 | 7.9 MB |
|
||||
| app1 (ota_1) | 0x800000 | 7.9 MB |
|
||||
| coredump | 0xFF0000 | 64 KB |
|
||||
|
||||
SPIFFS (3.4 MB, unused by any code) was dropped. Firmware is ~1.65 MB (19.8 % of a slot). Moving to this layout needed **one USB flash** (done 2026-09-26 on COM10; tunables v150 survived — `(verified)`).
|
||||
|
||||
## Console
|
||||
|
||||
| Command | What |
|
||||
|---|---|
|
||||
| `ota status` | version, build time, running slot + state, other slot's image |
|
||||
| `ota check` | latest release vs running, signature checked (Wi-Fi only, no parked gate) |
|
||||
| `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)`.
|
||||
|
||||
## Secrets and keys
|
||||
|
||||
- `FIRMWARE_SIGNING_KEY` — Gitea **repo secret** (Settings → Actions → Secrets), the EC P-256 private key PEM. Generated 2026-09-26; keep an offline backup. Losing it means devices only accept updates after one USB flash with a new public key.
|
||||
- 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).
|
||||
|
||||
## 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.
|
||||
|
||||
## Related
|
||||
|
||||
[[dual-controller-architecture]] · [[esp32-s3-touch-lcd-5b]] · [[open-questions]] · [[obd-diagnostic-polling]]
|
||||
Reference in New Issue
Block a user