77 lines
10 KiB
Markdown
77 lines
10 KiB
Markdown
---
|
||
type: entity
|
||
tags: [hardware, waveshare, display]
|
||
updated: 2026-09-27
|
||
---
|
||
|
||
# Waveshare ESP32-S3-Touch-LCD-5B
|
||
|
||
Main CTRL 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]]
|
||
- **Power path** (source: [[esp32-s3-touch-lcd-5-schematic]]): VIN → 1N5822 reverse diode + SMAJ36CA TVS → SY8293 buck (2 A, "run the line at 2A") → 5 V rail → 3.3 V LDO. Screen alone ≈550 mA @ 5 V.
|
||
- **VOUT terminal = `I2C_VCC`, selected by solder jumper `H8`** (pad 1 = 3V3, pad 2 = VOUT, pad 3 = 5V; factory bridge 1–2 = 3.3 V). For 5 V: open 1–2, bridge 2–3, never all three. The external SDA/SCL are level-shifted (NDC7002N + 4.7 kΩ pull-ups to `I2C_VCC`), so the I2C lines follow. Headroom for a load on VOUT@5 V from the 12 V input ≈1 A `(unverified estimate)` — enough to power Inst. Cluster. Not on USB-only power.
|
||
|
||
> [!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 → Inst. Cluster, 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 | Terminal block SDA/SCL, level-shifted to `I2C_VCC` (= VOUT, 3.3 V or 5 V via `H8`); CH422G expander occupies 0x20–0x27 & 0x30–0x3F, GT911 touch at 0x5D — avoid these addresses |
|
||
| RTC | PCF85063 + CR927 coin cell |
|
||
| TF card | SPI: MOSI IO11, SCK IO12, MISO IO13; SD_CS via CH422G EXIO4 (source: schematic) |
|
||
| 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 that the bounce-buffer refill copies from (the "no bounce buffer" claim written here earlier was wrong — see 2026-09-27). `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).
|
||
- **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)`: **21 MHz** pixel clock (board header, not the 16 MHz once written here) over 1368 × 637 clocks incl. porches → 24.1 Hz; one frame = 41.5 ms. **Bounce buffers are on**: 2 × 10 lines (20 KB each, internal DMA RAM) set by the library's `BOARD_WAVESHARE_ESP32_S3_TOUCH_LCD_5_B.h`; the `platformio.ini` flag that said 0 was a dead name (removed 2026-09-27). 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]].
|
||
- **XIP from PSRAM cures the flash-write blanking** `(verified 2026-09-27, branch display-xip)`: with `CONFIG_SPIRAM_XIP_FROM_PSRAM` + `CONFIG_LCD_RGB_ISR_IRAM_SAFE` the panel kept 24 frames/s and a 41.5 ms gap through a whole OTA download (stock core: 4–8 frames/s). Costs ~1.7 MB of PSRAM for resident code and a core rebuild (`custom_sdkconfig`) → [[perf-xip-ota-2026-09-27]].
|
||
- **Dots are not dropped frames** `(verified 2026-09-27)`: with dots visible on an idle Driveline the panel completed 24 frames/s with a 41.5 ms gap — they are sub-frame FIFO underruns (a few wrong pixels, frame still on time), which the driver cannot detect; bounce buffers are the fix. **OTA collapses the panel to 4–8 frames/s** (gaps to 0.75 s) for the whole download → [[perf-dots-and-ota-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.
|
||
- **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]].
|
||
|
||
## Related
|
||
|
||
[[dual-controller-architecture]] · [[can-bus-integration]] · [[ota-updates]] · [[esp32-s3-touch-lcd-5b-waveshare-wiki]] · [[esp32-s3-touch-lcd-5-schematic]]
|