85 lines
18 KiB
Markdown
85 lines
18 KiB
Markdown
# Log
|
||
|
||
Append-only. `grep "^## \[" log.md | tail -5` for recent activity.
|
||
|
||
## [2026-09-21] setup | Wiki instantiated
|
||
|
||
Created schema (`CLAUDE.md`, modelled on the sibling 5B wiki with a sibling-reference convention and a no-files-outside-this-repo directive), `index.md`, `log.md`, and four seed pages from repo knowledge plus the day's investigation: [[esp32-s3-lcd-1-3]], [[controller-link]], [[link-redundancy]], [[patrol-gauge-outputs]], [[open-questions]]. Two sources: [[pinout-photo-details-7]] (photo copied from `.docs/` into `raw/`) and [[waveshare-wiki-esp32-s3-lcd-1-3]] (condensed web fetch, flagged for a verbatim re-clip). Deleted Obsidian's default `Welcome.md`.
|
||
|
||
Findings recorded during setup:
|
||
- Header pinout verified from the photo: IO1–5 and IO7–14, 13 free-function GPIOs; the wiring guide's IO35–42 table is wrong.
|
||
- Main CTRL cannot drive the Patrol gauges (no free native GPIO; DO terminals are I2C-expander + optocoupler). B can, via LEDC on IO7/IO8 — proposal only.
|
||
- A transmits on GPIO 44 (code), not 43 (two stale docs). GPIO 44 leaves the 5B only as an RS485 A/B pair — how that reaches B's IO1 is unknown and is now open question #1.
|
||
- The two repos' `gear_position_t` enums have drifted (Sport/Manual vs M1–M6 at values 4+). Open question #2.
|
||
- The packet has no RPM field; A has RPM verified from CAN 0x0AA. `engine_oil_temp` has no real source on this engine.
|
||
- Redundancy design space captured (RS485 / BLE GATT / ESP-NOW; failover on B; A transmits on both paths always). Nothing decided.
|
||
|
||
## [2026-09-21] update | .docs folder retired; root CLAUDE.md created
|
||
|
||
The repo's `.docs/` folder (14 files) was deleted (user decision). Its still-true content — verified display pins, brightness API, SquareLine export rules, CH343 serial notes, link facts — was distilled into a new root `CLAUDE.md`; the stale parts (backlight on GPIO 2/15, SPI on 10/11, native USB-CDC, the IO35–IO42 header table, the phase roadmap, the pin-hunting guides) were dropped. `UART_PROTOCOL.md` now exists only in the 5B repo at `docs/UART_PROTOCOL.md`. `README.md` repointed to `CLAUDE.md` and `wiki/`. Wiki citations that named `.docs/` files were reworded to "former … (deleted 2026-09-21)"; [[open-questions]] wishlist gained the Waveshare schematic and demo-zip URLs recovered from the old troubleshooting doc. No page content changed otherwise.
|
||
|
||
## [2026-09-21] update | Tach = 4 pulses/rev (user); coolant gauge characterisation procedure
|
||
|
||
User states the Patrol cluster's tachometer expects **4 pulses per revolution** (recorded as user-stated, not bench-verified). Clarified that the coolant gauge is a current/resistance meter with no pulse count; added a bench procedure (pot sweep for the resistance → needle curve, sender-wire voltage to tell bimetal/regulated from series coil, series current for MOSFET sizing, PWM 500 Hz–2 kHz clear of any instrument-voltage-regulator chopper, empirical °C → duty lookup, tach pull-up check and two-frequency verification) to [[patrol-gauge-outputs]]. [[open-questions]] #3 and #7 reworded accordingly.
|
||
|
||
## [2026-09-21] ingest | temp_stage.cfd — the user's old CANNY 5.3 pico temp-gauge program decoded
|
||
|
||
`raw/temp_stage.cfd` (CannyLab, proprietary binary) walked as 165 `[type][len][payload]` records; block names, constants, wiring and an Albanian comment recovered → [[temp-stage-cfd]]. Result: CAN 500k, filter 0x1D0, low byte of D1:D0 minus 48 = °C (matches the 5B's verified decode), **duty = ((T − 40)·15 + 1100)/10 = 1.5·T + 50 on a 0–255 PWM period**, output enabled above a minimum temperature, push-pull pin with PWM pull-up. Not in the file: PWM base clock and the external drive circuit. [[patrol-gauge-outputs]] gained a prior-art section and a starting LEDC law; [[open-questions]] #7 partly answered, #13 added; index updated.
|
||
|
||
## [2026-09-21] update | Calibration parameters to live on A; ESP32 as frequency meter for the CANNY
|
||
|
||
User has the CANNY unit but no scope, and wants tunable variables on the 5B for both gauges. Recorded on [[patrol-gauge-outputs]]: the proposed `gauge_calibration_t` (tach ppr/trim/clamps; temp PWM Hz, slope/offset, min-temp gate, clamp; enables; calibration override) pushed A → B in a v2 config packet, and the plan to measure the CANNY's PWM frequency/duty with a 1.3 header GPIO + pulse counter instead of a scope. Suggested order: counter sketch → v2 header → A NVS/config TX/serial tuning → B RX + LEDC → A settings UI.
|
||
|
||
## [2026-09-21] update | Frequency-counter sketch demoted to fallback
|
||
|
||
User decision: do not measure the CANNY's PWM first; implement the v2 protocol and B's LEDC outputs directly, and only feed the CANNY's PWM pin into a free 1.3 header GPIO for troubleshooting if the gauges misbehave. Coolant PWM frequency will default to 1 kHz (tunable from A) in the absence of a measurement. Proposed implementation defaults awaiting the user's go: split gear bytes (lever + target/engaged nibbles), A-side alert bitmap (coolant ≥ 100 °C, gearbox ≥ 130 °C, gearbox cooling demand, battery < 11.0 V, gear mismatch), 16-bit rpm, config packet from A's NVS via serial console first, B outputs tach IO7 / temp IO8 on separate LEDC timers, off when link down or value invalid.
|
||
|
||
## [2026-09-21] update | Bench wiring for the A→B link specified
|
||
|
||
Added a bench-wiring section to [[controller-link]]: 3.3 V RS485→TTL module on B (MAX3485/SP3485), 5B `485_A`/`485_B`/GND → module → RO to IO1, VCC from 3V3, DE/RE low; termination note (shared CAN/RS485 switch, OFF before the car); the bare-A-line shortcut flagged as unreliable; a v1 baseline check (CAN toggle ON → default packets at 5 Hz → B reports established, zero errors) to run before the v2 protocol work. Running this check answers open question #1.
|
||
|
||
## [2026-09-21] update | No RS485 module on hand — zero-parts bench options
|
||
|
||
User has no RS485→TTL module. Re-assessed the bare `485_A` → IO1 shortcut against the 5B schematic: SP3485 at 3.3 V, auto-direction drives only zeros, 4.7 kΩ bias holds A high → effectively a 3.3 V UART signal when unterminated; recorded on [[controller-link]] as the bench-only first try (unverified). Wireless leg (ESP-NOW first, BLE later) to be built alongside the v2 protocol regardless; B-as-I2C-slave noted and not pursued.
|
||
|
||
## [2026-09-21] update | Bench link VERIFIED on the bare A line; both boards reflashed
|
||
|
||
Both boards flashed from current sources (5B → COM11, 1.3 → COM10). Bench check with `485_A` → IO1 + GND, no transceiver on B, 120 Ω OFF: B reports connection established, 38 packets / 10 s, 0 checksum / 0 framing errors, valid flags 0x3F, debug flag mirrored; A logs 23-byte packets on GPIO 44 every 200 ms (UART auto-started from NVS). Open question #1 answered for the bench and re-scoped to "will it survive the car". [[controller-link]] updated. Note: opening the 5B's USB-CDC port from the PC resets the board.
|
||
|
||
## [2026-09-21] update | Protocol v2 + ESP-NOW + gauge outputs implemented and bench-verified
|
||
|
||
Implemented in both repos (not yet committed): shared header v2 (typed DATA/CONFIG frames, `gear_lever` + target/engaged nibbles, `engine_rpm`, `alerts` bitmap, `link_config_t`); A: `Tunables` (NVS + `cfg` serial console), `EspNowLink` (broadcast leg, radio held in STA), UART manager sends every frame on both paths, CAN driver publishes gear pieces + evaluates alerts; B: `UARTReceiver::processFrame()` shared by the UART framing task and the new `EspNowReceiver` (channel hopping), dedupe on packet_id, CONFIG cache in NVS, `GaugeOutputs` (tach IO7 14-bit LEDC, coolant IO8 8-bit PWM), gear label pulses while target != engaged and turns red on mismatch, icons driven by A's alert bits. Bench: 42/42/42 frames applied/uart/espnow with 42 duplicates and 0 errors; ESP-NOW locked on ch 1; CONFIG on both paths; `cfg override rpm 2000` -> 133.3 Hz on IO7; coolant 89 C -> duty 183. Two bench-found fixes: tach needs 14-bit LEDC resolution (8-bit cannot reach 100 Hz) and the shared temperature formatter must not emit a degree sign (B's font lacks the glyph). Pages updated: [[controller-link]], [[link-redundancy]], [[patrol-gauge-outputs]], [[open-questions]] (#2, #4, BLE-vs-ESP-NOW and tunables-location moved to Answered; #5/#5b reworded); index updated.
|
||
|
||
## [2026-09-21] update | Gauge Tuning touchscreen page on A; calibration procedure filed
|
||
|
||
A gained a hand-coded LVGL Gauge Tuning screen (Home → right → Driveline → right): −/+ rows for every `link_config_t` field, enable switches, and an override panel with RPM/duty sliders; changes go through `Tunables` (saved + pushed), overrides never persisted (A's NVS save strips them). Built and flashed. Step-by-step needle calibration procedure added to [[patrol-gauge-outputs]].
|
||
|
||
## [2026-09-27] update | SquareLine retired on Inst. Cluster; LVGL lock; oil quadrant dropped; 16 MB flash declared
|
||
|
||
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 Inst. Cluster 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.
|
||
|
||
|
||
## [2026-09-27] update | Inst. Cluster 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 | Inst. Cluster 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 `Inst. Cluster 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.
|
||
|
||
## [2026-09-27] update | Round-panel redesign of B's screen: warning ring, tell-tales, whole-degree values
|
||
|
||
User asked for an automotive look, a Wi-Fi indicator and a sense of urgency on crossed thresholds. `gauge_screen.cpp` rebuilt for the circle: a 6 px ring at the rim acts as a warning lamp (dim; red blinking at 2 Hz while any red alert bit is set; amber while the gearbox asks for cooling), the affected value's digits and icon go red, temperatures show whole degrees and the battery a tenth (fewer, bigger digits), coolant/gearbox sit at 10 and 2 o'clock as icon + digits, the 110 px gear stays in the centre, battery centred low; tell-tales at 9 o'clock (Wi-Fi: green only while joined for an update) and 3 o'clock (red `!` when the link to A is lost). Everything is positioned absolutely inside the circle - the old flex column overflowed 240 px, so the battery digits sat partly off-panel. Built and flashed COM13; the user has not yet looked at it. The bench cannot show an alert (A's alerts come from CAN frames only), so the ring/red-value path is untested until the car.
|
||
|
||
## [2026-09-28] update | B's screen: arc gauges with needles instead of digits (user's design)
|
||
|
||
User saw the 2026-09-27 layout ("not bad") and redesigned it: no temperature digits; coolant as an arc on the LEFT rim from compass 230° (bottom-left, cold) to 320° (top-left, hot) with a needle, gearbox oil mirrored on the RIGHT from 140° to 40°; arcs blue when cool grading to red at the hot end; each icon just past the hot end, upper-left / upper-right; battery digits stay at the bottom. Implemented in `gauge_screen.cpp`: gradient = 9-10 `lv_arc` segments of 10° (1° overlap, no seams) coloured blue→neutral→red, needle = 3 px white `lv_line` from r 92 to 113 recomputed only on an angle change, band r 100-110 inside the 6 px warning ring, icons centred at r 66 (angles 245° / 295° LVGL). Scales: coolant 50-120 °C, gearbox 40-150 °C (thresholds 100 / 130 sit at ~70 % / ~80 % of the sweep). Ring blink / red icons / tell-tales unchanged. Built and flashed COM13, clean boot; the user is looking at it.
|
||
|
||
## [2026-09-28] verify | Renamed Inst. Cluster; deep sleep on link silence with wire + timer wake, verified on the bench
|
||
|
||
User renamed the boards (Controller A → Main CTRL, Controller B → Inst. Cluster) across the repo. New `power_manager.cpp`: when the Main CTRL's "Sleep when the car is off" switch arrives as `CFG_SLEEP_WHEN_SILENT` (bit 7 of `out_enable`, cached in NVS with the gauge config), the board deep-sleeps after 60 s without a DATA frame (gauges low, backlight off), waking on UART RX IO1 (ext0, pull-up) or a 60 s timer. A timer wake is a *probe boot*: setup skips the serial waits, the panel stays dark, 4 s of listening, then sleep again unless the Main CTRL is heard. `Ota::isBusy()` blocks sleep during a job. Console `sleep status | now`. Bench, timestamps from the console: `t=60442 ms: link silent for 60 s - deep sleep` → `rst:0x5 (DSLEEP)` **60.1 s later** → `probe boot (timer)` → `t=4043 ms: probe: nothing heard - deep sleep`. Bug found and fixed on the way: the flag was printed at init before `GaugeOutputs::init()` had loaded the cached config ("off" while it was on). Not verified: wake through the wire (needs the Main CTRL awake and the wire), and how the probe boot looks on the panel (should stay dark).
|