5d495f8ad1
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
70 lines
7.8 KiB
Markdown
70 lines
7.8 KiB
Markdown
---
|
||
type: entity
|
||
tags: [hardware, waveshare, display]
|
||
updated: 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).
|
||
- **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).
|
||
- **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]]
|