diff --git a/CLAUDE.md b/CLAUDE.md index 1ada499..c22e016 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -216,7 +216,7 @@ Settings persist across power cycles via ESP32 NVS (Non-Volatile Storage): ### Performance monitor (`perf` console) -`src/modules/perf_monitor.cpp` hooks the LVGL port (`monitor_cb` per rendered frame, a timer around `drawBitmap()` in `flush_callback`) and reads FreeRTOS run-time stats. `perf` prints one `PERF,` CSV line (ts, fps, avg/max ms per frame, kpx per frame, ms per second spent copying into the PSRAM framebuffer, LVGL idle %, core 0/1 idle %, internal free/largest, PSRAM free); `perf on [sec]` prints one every few seconds while a symptom is provoked; `perf off`. This is the measuring stick for the display work in wiki open-questions #13 - record numbers before and after every change. Baseline (idle Driveline, bench, 2026-09-27): ~9.7 fps rendered, ~30 ms per frame, ~52 ms/s in flushes, LVGL idle ~68 %, core 1 idle ~66 %. +`src/modules/perf_monitor.cpp` hooks the LVGL port (`monitor_cb` per rendered frame, a timer around `drawBitmap()` in `flush_callback`) and reads FreeRTOS run-time stats. `perf` prints one `PERF,` CSV line (ts, fps, avg/max ms per frame, kpx per frame, ms per second spent copying into the PSRAM framebuffer, LVGL idle %, core 0/1 idle %, internal free/largest, PSRAM free, **panel vsync/s, longest vsync gap in µs**); `perf on [sec]` prints one every few seconds (from an esp_timer, so it keeps running while the OTA job blocks `loop()`); `perf off`. The vsync columns come from the RGB panel's refresh-finished interrupt (attached in `lvgl_v8_port.cpp` when tearing-avoidance is off): healthy = ~24/s with a 41.5 ms gap; a DMA underrun/restart (flicker, dots) stretches the gap to two frames or more - this is the direct measure for the display work in wiki open-questions #13. Idle Driveline baseline (bench, 2026-09-27, after the `setText()` fix): 0 fps rendered, 0 ms/s flushes, LVGL idle 96 %, core 1 idle 96 % (before the fix: 9.7 fps, 30 ms/frame, 52 ms/s, 68 % / 66 % - the tick re-set every label at 10 Hz). Rule for every screen `tick()`: only write a label or style when the value changed (`lv_label_set_text()` and style setters invalidate even for identical values). ### ESP-NOW link diff --git a/include/display/lvgl_v8_port.cpp b/include/display/lvgl_v8_port.cpp index 57ad98a..648a84a 100644 --- a/include/display/lvgl_v8_port.cpp +++ b/include/display/lvgl_v8_port.cpp @@ -501,6 +501,14 @@ static void monitor_callback(lv_disp_drv_t *drv, uint32_t time_ms, uint32_t px) PerfMon::onFrame(time_ms, px); } +// RGB panel "refresh finished" (vsync) interrupt - counted for the perf monitor. +static IRAM_ATTR bool onPerfVsyncCallback(void *user_data) +{ + (void)user_data; + PerfMon::onVsync(); + return false; // no context switch needed +} + static void update_callback(lv_disp_drv_t *drv) { LCD *lcd = (LCD *)drv->user_data; @@ -820,6 +828,10 @@ bool lvgl_port_init(LCD *lcd, Touch *tp) #if LVGL_PORT_AVOID_TEAR lcd->attachRefreshFinishCallback(onLcdVsyncCallback, (void *)lvgl_task_handle); +#else + if (bus_type == ESP_PANEL_BUS_TYPE_RGB) { + lcd->attachRefreshFinishCallback(onPerfVsyncCallback, nullptr); + } #endif return true; diff --git a/src/modules/driveline_screen.cpp b/src/modules/driveline_screen.cpp index 2d27b32..13b53cd 100644 --- a/src/modules/driveline_screen.cpp +++ b/src/modules/driveline_screen.cpp @@ -4,6 +4,7 @@ #include "driveline_screen.h" #include "uart_manager.h" +#include #include "display/lvgl_v8_port.h" #include "drivers/can_driver.h" #include "tuning_screen.h" @@ -67,12 +68,29 @@ static lv_obj_t* makeChip(lv_obj_t* parent, const char* text) { } /** - * @brief Set a chip's text and colour in one go. + * @brief lv_label_set_text() only if the text differs. lv_label_set_text() + * re-lays-out and invalidates the label even when the string is the + * same, and this screen refreshes at 10 Hz - with constant data that was + * ~40 kpx redrawn 10x a second for nothing, a third of core 1 and 50 ms/s + * of PSRAM writes (perf baseline 2026-09-27). + */ +static void setText(lv_obj_t* lbl, const char* text) { + if (lbl == NULL) return; + const char* cur = lv_label_get_text(lbl); + if (cur != NULL && strcmp(cur, text) == 0) return; + lv_label_set_text(lbl, text); +} + +/** + * @brief Set a chip's text and colour, touching the object only on a change + * (a style write invalidates the object even for an identical value). */ static void setChip(lv_obj_t* chip, const char* text, lv_color_t colour) { if (chip == NULL) return; - lv_label_set_text(chip, text); - lv_obj_set_style_text_color(chip, colour, 0); + setText(chip, text); + if (lv_color_to32(lv_obj_get_style_text_color(chip, 0)) != lv_color_to32(colour)) { + lv_obj_set_style_text_color(chip, colour, 0); + } } /** @@ -292,13 +310,13 @@ void tick() { // quiet with the car rather than freezing the last frame. 0x3B4 sends its // ignition nibble on-change, so this reset is effectively instant. if (!can_up || !dl.ignition_on) { - lv_label_set_text(g_gear_lbl, "--"); - lv_label_set_text(g_coolant_lbl, "--"); - lv_label_set_text(g_gearbox_lbl, "--"); - lv_label_set_text(g_rpm_lbl, "----"); - lv_label_set_text(g_torque_lbl, "--"); - lv_label_set_text(g_pedal_lbl, "--"); - lv_label_set_text(g_shaft_lbl, "--"); + setText(g_gear_lbl, "--"); + setText(g_coolant_lbl, "--"); + setText(g_gearbox_lbl, "--"); + setText(g_rpm_lbl, "----"); + setText(g_torque_lbl, "--"); + setText(g_pedal_lbl, "--"); + setText(g_shaft_lbl, "--"); lv_bar_set_value(g_rpm_bar, 0, LV_ANIM_OFF); lv_obj_add_flag(g_mismatch_lbl, LV_OBJ_FLAG_HIDDEN); // Leave the ignition chip telling the truth; mute the rest, since their @@ -319,37 +337,37 @@ void tick() { // ---- gear (composed: P/R/N, or D/S/M + engaged number) --------------- if ((gear_position_t)dl.lever != GEAR_UNKNOWN) { composeGear(dl, buf, sizeof(buf)); - lv_label_set_text(g_gear_lbl, buf); + setText(g_gear_lbl, buf); } else { - lv_label_set_text(g_gear_lbl, "--"); + setText(g_gear_lbl, "--"); } // ---- temperatures (only when the signal is real) --------------------- if (flags & VALID_FLAG_COOLANT_TEMP) { snprintf(buf, sizeof(buf), "%d.%d°C", coolant / 10, abs(coolant % 10)); - lv_label_set_text(g_coolant_lbl, buf); + setText(g_coolant_lbl, buf); } if (flags & VALID_FLAG_GEARBOX_TEMP) { snprintf(buf, sizeof(buf), "%d.%d°C", gearbox / 10, abs(gearbox % 10)); - lv_label_set_text(g_gearbox_lbl, buf); + setText(g_gearbox_lbl, buf); } // ---- speeds ---------------------------------------------------------- snprintf(buf, sizeof(buf), "%u", dl.engine_rpm); - lv_label_set_text(g_rpm_lbl, buf); + setText(g_rpm_lbl, buf); lv_bar_set_value(g_rpm_bar, dl.engine_rpm > RPM_MAX ? RPM_MAX : dl.engine_rpm, LV_ANIM_OFF); // Torque is signed (negative under overrun/braking); one decimal, matching // the 0.5 Nm resolution of the field. snprintf(buf, sizeof(buf), "%d.%d", dl.engine_torque_x10 / 10, abs(dl.engine_torque_x10 % 10)); - lv_label_set_text(g_torque_lbl, buf); + setText(g_torque_lbl, buf); snprintf(buf, sizeof(buf), "%u", dl.pedal_percent); - lv_label_set_text(g_pedal_lbl, buf); + setText(g_pedal_lbl, buf); // Provisional rpm from the single-point Launch factor (see automotive_data.h). snprintf(buf, sizeof(buf), "%u", can_output_shaft_rpm(dl.output_shaft_raw)); - lv_label_set_text(g_shaft_lbl, buf); + setText(g_shaft_lbl, buf); // ---- status chips ---------------------------------------------------- setChip(g_ign_chip, dl.ignition_on ? "IGN ON" : "IGN OFF", diff --git a/src/modules/perf_monitor.cpp b/src/modules/perf_monitor.cpp index d8436b7..6b356eb 100644 --- a/src/modules/perf_monitor.cpp +++ b/src/modules/perf_monitor.cpp @@ -28,6 +28,14 @@ static uint32_t g_flushes = 0; static uint32_t g_flush_us_sum = 0; static uint32_t g_flush_px_sum = 0; +// vsync counters: written from the panel ISR, read from the reporter. 32-bit +// aligned loads/stores are atomic on this core; no lock in the ISR. +static volatile uint32_t g_vsync_count = 0; +static volatile uint32_t g_vsync_gap_max_us = 0; +static volatile uint32_t g_vsync_last_us = 0; + +static esp_timer_handle_t g_timer = NULL; + // ---- window bookkeeping (loop) -------------------------------------------- static int64_t g_window_start_us = 0; static uint64_t g_idle_start[2] = {0, 0}; @@ -56,11 +64,15 @@ static uint64_t idleCounter(int core) { #endif } +static void timerCallback(void* arg); + static void resetWindow() { portENTER_CRITICAL(&g_mux); g_frames = g_frame_ms_sum = g_frame_ms_max = g_frame_px_sum = 0; g_flushes = g_flush_us_sum = g_flush_px_sum = 0; portEXIT_CRITICAL(&g_mux); + g_vsync_count = 0; + g_vsync_gap_max_us = 0; g_window_start_us = esp_timer_get_time(); g_idle_start[0] = idleCounter(0); g_idle_start[1] = idleCounter(1); @@ -68,6 +80,14 @@ static void resetWindow() { void init() { resetWindow(); + if (!g_timer) { + esp_timer_create_args_t a = {}; + a.callback = timerCallback; + a.arg = NULL; + a.dispatch_method = ESP_TIMER_TASK; + a.name = "perf"; + esp_timer_create(&a, &g_timer); + } } void onFrame(uint32_t time_ms, uint32_t px) { @@ -87,6 +107,17 @@ void onFlush(uint32_t time_us, uint32_t px) { portEXIT_CRITICAL(&g_mux); } +void IRAM_ATTR onVsync() { + uint32_t now = (uint32_t)esp_timer_get_time(); + uint32_t last = g_vsync_last_us; + g_vsync_last_us = now; + g_vsync_count = g_vsync_count + 1; + if (last != 0) { + uint32_t gap = now - last; + if (gap > g_vsync_gap_max_us) g_vsync_gap_max_us = gap; + } +} + /** Emit one PERF line for the window since the last reset, then reset. */ static void report() { int64_t now_us = esp_timer_get_time(); @@ -99,6 +130,10 @@ static void report() { flushes = g_flushes; fl_us = g_flush_us_sum; fl_px = g_flush_px_sum; portEXIT_CRITICAL(&g_mux); + uint32_t vsyncs = g_vsync_count; + uint32_t vgap = g_vsync_gap_max_us; + unsigned vsync_per_s = (unsigned)((uint64_t)vsyncs * 1000000ULL / win_us); + uint64_t idle0 = idleCounter(0) - g_idle_start[0]; uint64_t idle1 = idleCounter(1) - g_idle_start[1]; unsigned idle0_pct = (unsigned)((idle0 * 100) / win_us); @@ -117,7 +152,7 @@ static void report() { lv_idle = lv_timer_get_idle(); } - print("PERF,%lu,%u.%u,%u.%u,%lu,%u,%u,%u,%u,%u,%u,%u,%u", + print("PERF,%lu,%u.%u,%u.%u,%lu,%u,%u,%u,%u,%u,%u,%u,%u,%u,%lu", (unsigned long)millis(), fps10 / 10, fps10 % 10, avg_ms10 / 10, avg_ms10 % 10, @@ -128,7 +163,8 @@ static void report() { idle0_pct, idle1_pct, (unsigned)heap_caps_get_free_size(MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT), (unsigned)heap_caps_get_largest_free_block(MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT), - (unsigned)heap_caps_get_free_size(MALLOC_CAP_SPIRAM)); + (unsigned)heap_caps_get_free_size(MALLOC_CAP_SPIRAM), + vsync_per_s, (unsigned long)vgap); (void)flushes; (void)fl_px; resetWindow(); } @@ -137,7 +173,7 @@ static void help() { print("perf one PERF line for the window since the last report"); print("perf on [sec] PERF line every seconds (default 1) while you provoke symptoms"); print("perf off"); - print("PERF,ts,fps,avg_ms,max_ms,kpx/frame,flush_ms/s,lvgl_idle%%,idle0%%,idle1%%,int_free,int_largest,psram_free"); + print("PERF,ts,fps,avg_ms,max_ms,kpx/frame,flush_ms/s,lvgl_idle%%,idle0%%,idle1%%,int_free,int_largest,psram_free,vsync/s,vsync_gap_max_us"); } bool handleCommand(const char* line) { @@ -159,21 +195,30 @@ bool handleCommand(const char* line) { g_periodic = true; g_last_report_ms = millis(); resetWindow(); - print("[perf] periodic every %ld s (columns: ts,fps,avg_ms,max_ms,kpx,flush_ms/s,lv_idle,idle0,idle1,int_free,int_largest,psram)", s); + // esp_timer, not loop(): the OTA job blocks loop() for the whole download + // and that is exactly when we want to see the panel counters. + if (g_timer) esp_timer_stop(g_timer); + if (g_timer) esp_timer_start_periodic(g_timer, (uint64_t)g_period_ms * 1000ULL); + print("[perf] periodic every %ld s (columns: ts,fps,avg_ms,max_ms,kpx,flush_ms/s,lv_idle,idle0,idle1,int_free,int_largest,psram,vsync/s,vsync_gap_max_us)", s); + return true; + } + if (!strcmp(argv[1], "off")) { + g_periodic = false; + if (g_timer) esp_timer_stop(g_timer); + print("[perf] periodic off"); return true; } - if (!strcmp(argv[1], "off")) { g_periodic = false; print("[perf] periodic off"); return true; } help(); return true; } +static void timerCallback(void* arg) { + (void)arg; + if (g_periodic) report(); +} + void tick() { - if (!g_periodic) return; - uint32_t now = millis(); - if (now - g_last_report_ms >= g_period_ms) { - g_last_report_ms = now; - report(); - } + // Reporting moved to the esp_timer (see handleCommand "on"). } } // namespace PerfMon diff --git a/src/modules/perf_monitor.h b/src/modules/perf_monitor.h index e7a4e77..9d6b7b3 100644 --- a/src/modules/perf_monitor.h +++ b/src/modules/perf_monitor.h @@ -19,7 +19,11 @@ * * PERF line (CSV, greppable like CANRAW): * PERF,,,,,,, - * ,,,,, + * ,,,,,, + * , + * vsync/s is the panel's own refresh rate (constant when healthy); + * vsync_gap_max_us is the longest interval between two refreshes in the + * window - a DMA underrun/restart stretches it. */ #pragma once @@ -37,10 +41,20 @@ void onFrame(uint32_t time_ms, uint32_t px); /** Hook for the flush callback - one pixel copy into the framebuffer. */ void onFlush(uint32_t time_us, uint32_t px); +/** + * Hook for the RGB panel's refresh-finished (vsync) interrupt. ISR context: + * counts frames the panel actually completed and the longest gap between two, + * which is where a DMA underrun / restart (flicker, dots) shows up. + */ +void onVsync(); + /** Console line beginning with "perf". */ bool handleCommand(const char* line); -/** Periodic reporting. Call from loop(). */ +/** + * Kept for compatibility; periodic reporting now runs from an esp_timer so it + * survives a blocked loop() (the OTA job). Safe to call, does nothing. + */ void tick(); } // namespace PerfMon diff --git a/wiki/log.md b/wiki/log.md index e0e0c64..45d08d8 100644 --- a/wiki/log.md +++ b/wiki/log.md @@ -162,3 +162,7 @@ Step 1 of the display plan. New `src/modules/perf_monitor.cpp`: LVGL `monitor_cb `raw/perf-20260927-164620.log` (2.5 min, `perf on 1`, screens exercised: Settings, Wi-Fi scan + join, ota check, Gauge Tuning incl. hold-repeat and Simulation, ota install v0.1.6) → [[perf-baseline-2026-09-27]]. No markers were typed, timeline rebuilt from the board's log lines. Findings: (1) Driveline renders ~10 fps × 39 kpx × 30 ms with constant data — `tick()` calls `lv_label_set_text` unconditionally for rpm/torque/pedal/shaft every 100 ms `(repo)` → a third of core 1 and 51 ms/s of PSRAM writes for nothing; (2) screen switches are single 140–330 ms frames (the swipe lag) — a drawing cost, not a DMA one; (3) Simulation tab = 2 Mpx/s, 26 % of time copying to PSRAM, LVGL idle 9 %, core 1 idle 25 % — the load bounce-buffer refill must coexist with; (4) the 16:47:10 NVS save left no trace in the counters: flicker lives on the panel DMA side, so a vsync/refresh counter is needed to measure steps 2–3; (5) PERF stops during the 41 s OTA download (loop blocked). Heap flat. Plan on [[open-questions]] #13 amended (step 1b). User's visual observations for this run not recorded — asked. +## [2026-09-27] build | Step 1b: Driveline redraw stopped, panel vsync counter, timer-driven PERF + +From the baseline findings. (1) `driveline_screen.cpp`: `setText()` / `setChip()` write a label or colour only when it differs — idle Driveline went from 9.7 fps, 30 ms/frame, 52 ms/s PSRAM copies, LVGL idle 68 %, core 1 idle 66 % to **0 fps, 0 ms/s, 96 %, 96 %** `(verified bench)`. (2) `perf` now counts the RGB panel's refresh-finished interrupt (attached in the port when tearing-avoidance is off): **≈24 vsync/s, longest gap 41.5 ms** = one frame at the 16 MHz pixel clock; a DMA restart will read as ≥ 83 ms — the first direct instrument for flicker and dots. (3) Periodic PERF moved from `loop()` to an esp_timer so it keeps reporting through the OTA download. Recorded on [[open-questions]] #13 and [[esp32-s3-touch-lcd-5b]]; root CLAUDE.md gained the "write only on change" rule for screen ticks. Next: provoke session with markers, then bounce buffers. + diff --git a/wiki/pages/esp32-s3-touch-lcd-5b.md b/wiki/pages/esp32-s3-touch-lcd-5b.md index 73a2106..7787262 100644 --- a/wiki/pages/esp32-s3-touch-lcd-5b.md +++ b/wiki/pages/esp32-s3-touch-lcd-5b.md @@ -61,6 +61,8 @@ Note: the screen occupies most GPIOs; auxiliary functions (backlight, reset, SD_ - **LVGL asserts used to freeze the board**: `LV_ASSERT_HANDLER` was `while(1);`, which spins inside the calling task *while it holds the LVGL lock* — UI frozen, `loop()`/console blocked on the lock, only the link task alive. Now `abort()`: backtrace on the console, core dump to flash (ELF), reboot. Decode with `xtensa-esp32s3-elf-addr2line -pfiaC -e firmware.elf ` (CI attaches `firmware.elf` to every release). - **Background Wi-Fi scans caused the random flickering dots** `(verified by elimination 2026-09-27)`: the Wi-Fi task scanned every 10 s forever, connected or not, on any screen; Wi-Fi buffers live in PSRAM next to the framebuffer. Scanning is now limited to "network list on screen and not connected" — the dots are gone (user). - **The dots came back on v0.1.4, gone on v0.1.5** `(verified 2026-09-27, user)`: v0.1.4 limited scans to "Settings open and not connected", but it forgot the network on every restart, so after the OTA restart it sat disconnected and rescanned every 10 s whenever Settings was open. v0.1.5 remembers the network and scans only when the Wi-Fi page opens or Scan is tapped. The underlying weakness remains: the RGB panel streams from PSRAM with no bounce buffer, so heavy Wi-Fi or flash traffic can still disturb the picture ([[open-questions]] #13). +- **Panel refresh rate ≈ 24 Hz** `(verified 2026-09-27, perf vsync counter)`: 16 MHz pixel clock over 1024×600 plus blanking; one frame = 41.5 ms. A steady 41.5 ms longest-gap in `perf` means no DMA restart happened in that window; anything ≥ 83 ms is a dropped frame. +- **Idle screens must render nothing** `(verified 2026-09-27)`: the Driveline tick used to re-set every label at 10 Hz, costing a third of core 1 and 52 ms/s of PSRAM writes with constant data; writing only on change took it to 0 fps / 96 % idle → [[perf-baseline-2026-09-27]]. - **The dots are NOT fully gone** `(user, 2026-09-27)`: they still appear occasionally on v0.1.6 with scans limited — so scan policy only reduced the trigger; the PSRAM-streaming weakness itself is what shows. Structural fix (bounce buffers, then XIP-from-PSRAM) is now a committed job, not a nice-to-have → [[open-questions]] #13. - **SquareLine's screen lifecycle was the freeze risk, not LVGL**: its generated screens are deleted on leave and rebuilt on entry, so any pointer kept elsewhere dangles. Since 2026-09-27 every screen is hand-coded, built once and kept `(repo)`. - **Uploading over USB from a script on Windows**: esptool crashed printing its progress bar into a cp1252 pipe *in the middle of writing* and left the board frozen until a power cycle; the bootloader then fell back to the other OTA slot, so nothing was lost `(verified 2026-09-27)`. Set `PYTHONIOENCODING=utf-8` when piping upload output. diff --git a/wiki/pages/open-questions.md b/wiki/pages/open-questions.md index 6102b72..9db0b7e 100644 --- a/wiki/pages/open-questions.md +++ b/wiki/pages/open-questions.md @@ -75,7 +75,7 @@ The research frontier. Answering any of these should trigger updates across the **Decision 2026-09-27 (user): this is a must-fix, all steps through XIP, bench time is no constraint.** Two corrections to the record: (a) the flickering dots **still appear occasionally** on v0.1.6 — the scan policy reduced the trigger, it did not remove the weakness; (b) the dark screen during OTA is a **safety/UX defect**, not a mitigation: with no feedback a driver may switch the ignition off mid-update. Requirement: the screen stays on during an update with a visible progress bar and a "do not switch off" message — which needs Step B (flash writes must stop blanking the panel), plus an OTA progress callback on the Updates page. (The OTA design already survives a power cut — the new image is only confirmed after 30 s, else it rolls back — so the risk is a wasted update and a confused user, not a bricked board.) **Plan agreed 2026-09-27 (next display session, bench + USB, `dev` builds only until verified):** - 1. **Baseline first**: Settings → System → Performance overlay (LVGL's perf monitor = real render FPS + CPU; never measured before). Provoke each symptom on purpose: a Wi-Fi scan (dots), a Tuning edit that gets saved (flash write), an update (flash writes). Without numbers there is no telling whether a change helped. **Tooling landed 2026-09-27 `(repo)`**: the `perf` console command (`perf on 1` streams a `PERF,` CSV line per second: fps, ms/frame, flush ms/s, LVGL idle, core idle, heap). **Idle baseline, Driveline screen, bench/USB, v0.1.6+perf**: 9.7 fps rendered (= the screen's own update rate), 30 ms per frame avg (122 ms worst in the first window), ~40 kpx/frame, 52 ms/s copying into the PSRAM framebuffer, LVGL idle 68 %, core 0 idle 94 %, core 1 idle 66 %, internal 66.9 KB free / 31.7 KB largest, PSRAM 6.6 MB free. **Provoke session logged 2026-09-27 → [[perf-baseline-2026-09-27]]**: Driveline redraws ~10×/s with nothing changing (39 kpx, 30 ms, a third of core 1 — an unconditional `lv_label_set_text` every 100 ms `(repo)`); screen changes are single 140–330 ms frames (= the swipe lag; not a bounce-buffer matter); the Simulation tab is the heaviest normal load (2 Mpx/s, 26 % of the time writing PSRAM, LVGL idle 9 %); a flash write is invisible to the LVGL counters, so the monitor needs a **panel vsync/refresh counter** to see flicker and dots directly; the monitor is blind during OTA (ticks from the blocked `loop()`). Heap flat throughout (66–67 KB internal, 31.7 KB largest, 6.6 MB PSRAM). **Plan amended**: 1b = stop the Driveline redraw + add vsync counter + timer-driven PERF, re-baseline; step 2 judged on the Simulation tab and during a scan, by the refresh counter. + 1. **Baseline first**: Settings → System → Performance overlay (LVGL's perf monitor = real render FPS + CPU; never measured before). Provoke each symptom on purpose: a Wi-Fi scan (dots), a Tuning edit that gets saved (flash write), an update (flash writes). Without numbers there is no telling whether a change helped. **Tooling landed 2026-09-27 `(repo)`**: the `perf` console command (`perf on 1` streams a `PERF,` CSV line per second: fps, ms/frame, flush ms/s, LVGL idle, core idle, heap). **Idle baseline, Driveline screen, bench/USB, v0.1.6+perf**: 9.7 fps rendered (= the screen's own update rate), 30 ms per frame avg (122 ms worst in the first window), ~40 kpx/frame, 52 ms/s copying into the PSRAM framebuffer, LVGL idle 68 %, core 0 idle 94 %, core 1 idle 66 %, internal 66.9 KB free / 31.7 KB largest, PSRAM 6.6 MB free. **Provoke session logged 2026-09-27 → [[perf-baseline-2026-09-27]]**: Driveline redraws ~10×/s with nothing changing (39 kpx, 30 ms, a third of core 1 — an unconditional `lv_label_set_text` every 100 ms `(repo)`); screen changes are single 140–330 ms frames (= the swipe lag; not a bounce-buffer matter); the Simulation tab is the heaviest normal load (2 Mpx/s, 26 % of the time writing PSRAM, LVGL idle 9 %); a flash write is invisible to the LVGL counters, so the monitor needs a **panel vsync/refresh counter** to see flicker and dots directly; the monitor is blind during OTA (ticks from the blocked `loop()`). Heap flat throughout (66–67 KB internal, 31.7 KB largest, 6.6 MB PSRAM). **Plan amended**: 1b = stop the Driveline redraw + add vsync counter + timer-driven PERF, re-baseline; step 2 judged on the Simulation tab and during a scan, by the refresh counter. **Step 1b done 2026-09-27 `(verified, bench)`**: Driveline `tick()` now writes labels/chips only on change → idle Driveline 0 fps, 0 ms/s PSRAM copies, LVGL idle 96 %, core 1 idle 96 % (was 9.7 fps / 52 ms/s / 68 % / 66 %). `perf` gained the panel counters: **~24 vsync/s, longest gap 41.5 ms when healthy** — a DMA restart must show as a gap ≥ 2 frames (≈ 83 ms). Reporting runs from an esp_timer, so OTA is no longer a blind spot. **Next: re-run the provoke session with `#` markers** (scan, tuning save, OTA) to see the vsync gap during each symptom; then step 2 (bounce buffers). 2. **Step A - bounce buffers only** (`ESP_PANEL_LCD_RGB_BOUNCE_BUF_SIZE`, today 0; start at 10 lines = 1024x10 px, ~20 KB each, two buffers, internal DMA-capable RAM). The panel then reads from internal RAM that the CPU refills from PSRAM, so it tolerates short PSRAM stalls. **Expected to cure the Wi-Fi-traffic dots; will NOT cure flash-write flicker**: while flash is written the cache is disabled, so the refill has nothing to read from either. RAM: 67 KB internal free but the largest block is ~32 KB, so two 20 KB buffers may not fit - if not, shrink the LVGL draw buffer 60 -> 40 lines (frees ~40 KB) and check render speed. The refill costs CPU (measure). 3. **Step B - `CONFIG_SPIRAM_XIP_FROM_PSRAM` (+ `CONFIG_SPIRAM_RODATA`)** via pioarduino `custom_sdkconfig`: code and constants run from PSRAM, so flash writes no longer block PSRAM. **Cures flash-write flicker** (screen could stay on during OTA with a progress bar instead of going dark). Cost/risk: `custom_sdkconfig` rebuilds the Arduino core from source (much slower builds, locally and in CI), and may not work cleanly with this platform version - do it on a branch, release only once it works. 4. **Measure again after each step** (FPS, CPU, which symptoms still reproduce) and record the numbers here and on [[esp32-s3-touch-lcd-5b]].