Files
ESP32-S3-Touch-LCD-5B/wiki/pages/esp32-s3-touch-lcd-5b.md
T
julian 766019a01e
Firmware / build (push) Successful in 4m24s
Fix UI freeze/reboots: LVGL pool to PSRAM, dangling SSID buttons, scan policy
- lv_conf: LVGL widget pool 48 KB internal -> 512 KB PSRAM (LV_MEM_POOL_ALLOC).
  It ran out after a few Settings visits (87% used, 31% frag, 4.5 KB biggest
  block; lv_mem_buf_get() failed in a label draw - decoded backtrace). Also
  frees 48 KB of internal RAM: free 16 -> 69 KB, largest block 7.6 -> 31.7 KB
- lv_conf: LV_ASSERT_HANDLER abort() instead of while(1), which spun inside the
  task holding the LVGL lock and froze the UI + console
- wifi_manager: SSID buttons clear their g_ssid_buttons[] slot on
  LV_EVENT_DELETE (SquareLine deletes the Settings screen on leave; stale
  pointers were lv_obj_del()'d on the next scan). Scan only while the list is
  on screen and not connected - 10 s background scans caused the display dots
- main: `mem` console command (internal heap, PSRAM, LVGL pool)
- docs: board page lessons, open-questions #13/#14, ota-updates, CLAUDE.md, log

Verified: 10 Settings visits + 9 list rebuilds, pool peak 4%, 0 crashes; user
confirms no freeze, no reboot, no dots, swipes better.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 00:32:18 +02:00

6.7 KiB
Raw Blame History

type, tags, updated
type tags updated
entity
hardware
waveshare
display
2026-09-27

Waveshare ESP32-S3-Touch-LCD-5B

Controller A of the dual-controller-architecture — the main in-cabin display. SKU 28151, the 1024×600 capacitive-touch variant of the LCD-5 family. Primary reference: esp32-s3-touch-lcd-5b-waveshare-wiki.

Specs (source: waveshare-wiki)

  • ESP32-S3-WROOM-1-N16R8 module: dual-core LX7 @ 240 MHz, 16 MB flash, 8 MB OPI PSRAM
  • 5" IPS 1024×600, 65K colors (16-bit), 550 cd/m², GT911 5-point capacitive touch, tempered glass
  • 2.4 GHz Wi-Fi + BLE 5, onboard antenna (keep metal away from antenna area)
  • Runs LVGL 8.4.0 via ESP32_Display_Panel v1.0.4 (repo). Real render FPS has never been measured: the Debug-panel "FPS" counts loop() passes (and loop() sleeps 100 ms), and the old "~50 FPS" figure had no measurement behind it (verified 2026-09-26)

Power (source: waveshare-wiki)

  • 7–36 V DC wide-input terminal — vehicle 12 V feeds it directly, no external regulator needed. ✅ resolves most of the power question
  • Alternative inputs: USB Type-C 5 V; optional single-cell 3.7 V LiPo (CS8501 charge/boost, 580 mA)
  • Draw: ~450 mA @ 5 V (~2.3 W)
  • Remaining caveat: automotive transient/load-dump spikes (ISO 7637) can exceed 36 V (unverified) → open-questions

[!warning] Operating temperature 0–65 °C (source: waveshare-wiki) Tight for a car: sub-zero winters and sun-baked dashboards both fall outside spec. → open-questions

CAN interface (source: waveshare-wiki)

  • Onboard TJA1051T/3/1J transceiver, CAN 2.0, on a 3.5 mm terminal block — wire CAN-H/L straight in. ✅ resolves the transceiver question
    • Non-isolated — its ground must be common with the vehicle. Simplest: power the board from vehicle 12 V (the 7–36 V input's negative is the CAN reference). Grounding-only + USB power also works, but keep the logging laptop on battery to avoid a mains-earth ↔ chassis ground loop.
  • 120 Ω termination switch, OFF by default — leave it off when tapping an existing vehicle bus (the bus is already terminated at both ends).
  • Firmware drives it via TWAI on GPIO 15 TX / 16 RX, 500 kbps, TWAI_MODE_NORMAL (repo) — it ACKs the bus (active participant), not LISTEN_ONLY as older docs claimed. Deliberate, to stop transmitters retry-flooding. → can-bus-integration
  • Raw CAN logger (repo, 2026-07-15): streams every frame as CANRAW,... over native USB-CDC (Serial remapped to USB-CDC, ~1 MB/s, so it keeps up with the ~486 frame/s bus). First capture: can-capture-2026-07-15.

Other interfaces

Interface Details
RS485 SP3485, auto TX/RX direction; terminal block used for UART1 → Controller B, GPIO 43/44, 115200 baud (repo)
Isolated I/O Optocoupler digital in 5–36 V (dry/wet contact), open-drain out sinking 450 mA/ch — could read ignition-on or drive a relay later
I2C External header; CH422G expander occupies 0x20–0x27 & 0x30–0x3F, GT911 touch at 0x5D — avoid these addresses
RTC PCF85063 + CR927 coin cell
TF card SD_CS driven via CH422G EXIO4
USB Serial Native USB-CDC (Serial, enumerates 303A:1001, ~1 MB/s), console + CANRAW (repo). Opening the port with default DTR/RTS resets the board (rst:0x15) — set both low before opening (--dtr 0 --rts 0) to attach without a reboot (verified 2026-09-26)

Note: the screen occupies most GPIOs; auxiliary functions (backlight, reset, SD_CS) route through the CH422G IO expander — spare native GPIOs are scarce.

Hard-won firmware lessons (repo)

  • 8MB OPI PSRAM demands qio_opi memory type + custom board JSON — wrong setting causes screen flicker/drift.
  • LCD wants a 16 MHz pixel clock with correct PCLK polarity.
  • Backlight must be manually sequenced at boot to avoid a white flash.
  • Flashing: use the Type-C port labeled UART; hold BOOT while connecting if the port isn't recognized (source: waveshare-wiki).
  • Flash writes flicker the screen (verified 2026-09-26): flash and PSRAM share the MSPI cache, so every flash write/erase (NVS save, OTA) briefly cuts off the PSRAM framebuffer the RGB panel streams from; there is no bounce buffer (ESP_PANEL_LCD_RGB_BOUNCE_BUF_SIZE=0). CONFIG_LCD_RGB_RESTART_IN_VSYNC=y resyncs next frame → flicker, not permanent drift. Mitigated (v0.1.2): Tuning edits saved to NVS once after 3 s idle, backlight off during OTA writes. Real cure: bounce buffers + CONFIG_SPIRAM_XIP_FROM_PSRAM → open-questions #13.
  • Full-screen transitions stutter (verified 2026-09-26): a fade re-renders and alpha-blends all 614k px in software every frame into the PSRAM framebuffer. Screen switches are instant (LV_SCR_LOAD_ANIM_NONE) since v0.1.2.
  • Internal RAM was nearly full (verified 2026-09-26): 15.9 KB free, largest block 7.6 KB with display + Wi-Fi up. Half the cause was LVGL's own 48 KB widget pool (LV_MEM_SIZE) sitting in internal .bss. Moved to PSRAM and enlarged to 512 KB (2026-09-27): internal free now 69 KB, largest block 31.7 KB (verified). The 60-line LVGL draw buffer (~120 KB) is still internal, by design (render speed).
  • LVGL's widget pool ran out (verified 2026-09-27): Settings + its Wi-Fi list is ~15 KB; screen churn + list rebuilds took the 48 KB pool to 87% used / 31% fragmented / 4.5 KB biggest block, then a label draw failed lv_mem_buf_get() (backtrace decoded with addr2line). With the 512 KB PSRAM pool: 10 Settings visits + 9 list rebuilds, peak 4%, 0 crashes; swipes feel better (user).
  • 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 <addrs> (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).
  • Never power the Wi-Fi radio off (WiFi.disconnect(true), WiFi.mode(WIFI_OFF)): it de-initialises ESP-NOW, the wireless leg of the link to B → dual-controller-architecture.
  • Partition table is dual-slot OTA since 2026-09-26 (2 × 7.9 MB, no SPIFFS, NVS offset unchanged) → ota-updates.

dual-controller-architecture · can-bus-integration · ota-updates · esp32-s3-touch-lcd-5b-waveshare-wiki