Repository navigation
Description
Summary
LCD_CLOCKLESS driver on ESP32-S3 (XIAO_ESP32S3, 8 MB OPI PSRAM, OPI flash) panics with Guru Meditation Error: Core 1 panic'ed (Interrupt wdt timeout on CPU1) within ~5 seconds of starting runSingleTest once the lane count × strip size hits 8 lanes × 256 LEDs or above. The panic always lands inside ESP-IDF SPI flash erase code (spi_flash_chip_generic_erase_block / esp_flash_erase_region) while the CPU is in ISR context, even though the LCD driver itself never erases flash.
A jumper wire connects GPIO 1 (TX) to GPIO 2 (RX) for RMT-RX loopback validation. Hardware connectivity is confirmed green before the failing test starts.
Reproduction
bash autoresearch esp32s3 --lcd --upload-port COM13 --lanes 16 --strip-sizes 256 --skip-lint --timeout 240
Same crash also reproduces with --lanes 8 --strip-sizes 256. Note: the public --lanes upper bound in examples/AutoResearch/AutoResearchRemote.cpp is currently 8 — bumping it to 16 (one-line change, included in the linked PR) is required to exercise the full 16-bit LCD_CAM bus that LCD_CLOCKLESS claims to support via wave8Transpose_16.
Environment:
- Board: Seeed XIAO ESP32-S3 (revision 0.02, 8 MB OPI PSRAM, 8 MB OPI flash, Arduino board
SEEED_XIAO_ESP32S3) - Arduino-ESP32 3.3.7 / ESP-IDF v5.5.2-729-g87912cd291
- FastLED master at 21bf87b
- Driver selection:
opts.mBus = fl::Bus::LCD_CLOCKLESS - Chipset timing:
WS2812B-V5(T1=225, T2=355, T3=645) - Encoding path: wave8 (canUseWave3 = false for WS2812B-V5)
- Per-frame DMA size: 768 source bytes × 128 output bytes per source byte × 16 lanes = 98 304 bytes
- Default chunk size: 90 source bytes → 11 520 DMA bytes per chunk → 9 chunks per frame (last chunk smaller — see Diagnosis)
Symptom
Captured serial output (trimmed):
LcdSpiPeripheralEsp: Initialized with 16 lanes, 6530612 Hz clock, owner=2
WARN: task::run re-entrancy detected, skipping nested call
Guru Meditation Error: Core 1 panic'ed (Interrupt wdt timeout on CPU1).
Core 1 register dump:
PC : 0x40385894 PS : 0x00060234
EXCCAUSE: 0x00000006
EPC1 : 0x4218580f EPC3 : 0x400570cb EPC4 : 0x40385894
Core 1 was running in ISR context:
Backtrace: 0x40385891 → spi_flash_chip_generic_erase_block
0x40386441 → spi_flash_chip_winbond_read
0x403846ce → esp_flash_erase_region
0x420f615a, 0x420f5c98, 0x4208b4e2 (user code — debug info stripped)
Core 0 is in idle hooks; only Core 1 is wedged. Reproducible 100 % of the time on this board.
Diagnosis
Two latent bugs surface together; the panic only stops reliably once both are addressed.
1. ISR re-arm path is in flash, not IRAM
channel_driver_lcd_clockless.cpp.hpp registers isrChunkDone as the on_color_trans_done user callback. The ESP-IDF trampoline lcd_spi_flush_ready is correctly IRAM_ATTR, but isrChunkDone, encodeChunk, and the EspWrapper::transmit thunk are compiled into the default .text section. When any concurrent flash op suspends the cache (NVS commit, esp_flash_erase_region, OTA write, etc.), the ISR cannot fetch its own code; interrupts stay masked past the 300 ms IWDT window; the panic backtrace ends up inside the flash erase routine that happened to be running at the time.
PARLIO solved the same class of issue by marking its workerIsrCallback FL_IRAM (src/platforms/esp/32/drivers/parlio/parlio_engine.h:241). The LCD_CLOCKLESS path needs the same treatment for isrChunkDone, encodeChunk, LcdSpiPeripheralEsp::transmit, and the wrapper transmit thunk inside createLcdClocklessEngine.
2. LcdSpiPeripheralEsp::transmit calls xSemaphoreTake from ISR
lcd_spi_flush_ready calls xSemaphoreGiveFromISR(self->mCompleteSem) before invoking the user callback, so the take is guaranteed non-blocking — but the non-FromISR variant of xSemaphoreTake asserts when invoked from an interrupt under most FreeRTOS configurations. Even when the assertion is compiled out, it leaves task-internal lists in an inconsistent state. Use xSemaphoreTakeFromISR on the ISR path (gated by xPortInIsrContext()).
3. Variable last-chunk size forces panel_io re-creation from ISR
transmit() contains:
if (size_bytes != mLastTransmitSize && mPanelIo != nullptr) {
esp_lcd_panel_io_del(mPanelIo);
mPanelIo = nullptr;
}
if (mPanelIo == nullptr) {
esp_lcd_new_panel_io_i80(...);
}With the default chunk size of 90 and a typical maxSize of 768 bytes (16 lanes × 256 LEDs × 3 bytes / 16 lanes), the last of 9 chunks per frame is only 48 source bytes ⇒ 6 144 DMA bytes vs the standard 11 520. On every frame boundary the ISR drives esp_lcd_panel_io_del and esp_lcd_new_panel_io_i80, both of which touch flash and re-allocate GDMA descriptors — this alone is enough to provoke the same IWDT panic even without the IRAM-resident-code race in (1).
Fix: pick numChunks so maxSize / numChunks is an exact divisor (numChunks walks up from ceil(maxSize / requested) until maxSize % numChunks == 0). Worst case falls back to 1-byte chunks, but for typical RGB strips (n × 3 bytes) the loop terminates in 2-3 iterations.
Status
A draft fix for all three is in branch fix/lcd-clockless-isr-iram-2026-05-30 (commits 7bfb1bb53f and 821fd8919a). It compiles and flashes cleanly. The chip still panics in the same way after the fix — telling me the IRAM/ISR-safety work is necessary but not sufficient. There is at least one more interaction (probably in the autoresearch setup path or ChannelManager driver enrollment) that triggers a long enough flash erase to trip IWDT on this XIAO board. I'm filing this so the deeper root-cause investigation has a clean record to start from.
Suggested next steps
- Land the IRAM + FromISR + equal-chunk patches as defense in depth — they are correct regardless of the remaining trigger.
- Bisect what triggers the
esp_flash_erase_regioncall seen in the backtrace. Candidates:- NVS commit during
ChannelManagerdriver enrollment (every test re-runsenableAllDrivers()which logs many "already registered" idempotent no-ops). - PHY calibration data write (
nvs:phy_init) when LCD_CAM peripheral first powers on. - OPI PSRAM access through the shared SPI memory controller being mis-decoded as flash erase by the panic dumper.
- NVS commit during
- Consider matching PARLIO's worker-task pattern: have
isrChunkDoneonly signal a high-priority task that does the encode + re-arm. This decouples the encode budget from the IWDT window entirely. - Bump the
runSingleTestlaneSizesupper bound from 8 to 16 inexamples/AutoResearch/AutoResearchRemote.cppso the autoresearch harness can actually exercise the 16-lane LCD_CAM bus. (Included in the linked branch.)
Related
- feat(esp32-s3): LCD_CAM ISR-driven buffer refill for chunked DMA streaming #2258 (LCD_CAM ISR-driven chunked DMA — the design this driver implements)
- fix(esp32-s3): LCD_CLOCKLESS GPIO crash fix + autoresearch --lcd/--lcd-spi #2273 (LCD_CLOCKLESS GPIO crash fix — fixed a different crash in the same driver)
- bug(esp32-s3): LCD_SPI and LCD_CLOCKLESS share LcdSpiPeripheralEsp singleton with fragile re-init #2270 (LCD_SPI/LCD_CLOCKLESS singleton sharing — neighbouring code)
Defaults used while researching this issue (please correct if wrong):
- I assumed ESP-IDF
xSemaphoreTakefrom ISR is undefined behaviour in release builds (it asserts in debug). - I assumed the panic backtrace's
spi_flash_chip_generic_erase_blockPC is genuine flash erase and not OPI-PSRAM read mis-labelled by the symbol table. This is consistent with the surrounding backtrace frames (esp_flash_erase_region), but on OPI-flash + OPI-PSRAM boards the two share the SPI memory controller so it deserves verification. - I assumed the test framework was correct to limit
laneSizesto 8 historically; the bump to 16 is a one-line change with no functional impact when fewer lanes are requested.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
zackees commentedon May 31, 2026
Update — bug isolated to multi-chunk ISR re-arm path
After landing the IRAM + FromISR + equal-chunk patches on branch
fix/lcd-clockless-isr-iram-2026-05-30, I ran a scan-to-find-the-edge:--lcd --lanes 1 --strip-sizes 30--lcd --lanes 1 --strip-sizes 200--lcd --lanes 8 --strip-sizes 256--lcd --lanes 16 --strip-sizes 256--rmt --lanes 1 --strip-sizes 100So the IRAM and ISR-safety patches do their job for the single-shot transmit; what's still broken is what happens inside
isrChunkDonewhen it tries to submit the next chunk from the on_color_trans_done callback.The most likely remaining culprit is
esp_lcd_panel_io_tx_color()itself when called fromon_color_trans_done. Withtrans_queue_depth = 1, the LCD I80 driver may not have retired the current transaction from its internal queue by the time the user callback fires (the callback runs from the DMA-done ISR before queue cleanup), so the back-to-backtx_color()blocks waiting for a queue slot — from ISR context. That hangs the CPU long enough for IWDT to fire.Plausible fixes (haven't tried yet — flagging for whoever picks this up):
trans_queue_depthto 2+ so the next transmit can be queued without waiting for the running one to retire.isrChunkDoneonly signals a high-priority FreeRTOS task; the task does encode +tx_color. Decouples the next-chunk submit from the ISR window entirely.Single-shot LCD_CLOCKLESS (
numChunks == 1, i.e.maxSize <= chunkInputBytes) works correctly with the branch fixes. That's a safe escape hatch: if--strip-sizesper lane is small enough that the whole frame fits one chunk, the driver delivers WS2812 data correctly.I'm leaving the issue open and the PR (#2648) in draft. Reassigning the diagnosis above to anyone with deeper LCD I80 internals familiarity than I have right now.
fix(esp32-s3): bump LCD I80 trans_queue_depth 1 → 2 (#2647 IWDT fix)
zackees commentedon May 31, 2026
Update — IWDT panic eliminated, correctness issue remains
Root cause of the IWDT panic confirmed and fixed (commit eb59d1b on
fix/lcd-clockless-isr-iram-2026-05-30):io_config.trans_queue_depth = 1is incompatible with re-armingtx_color()fromon_color_trans_done. With depth=1 the currently-running transaction has not yet been retired from the I80 queue when the user callback fires, so the re-arm blocks waiting for a queue slot — from ISR context — and trips the 300 ms IWDT. Depth=2 leaves room for the ISR-driven re-arm and the panic disappears across all configurations I tested.--lcd --lanes 1 --strip-sizes 30(single chunk)--lcd --lanes 1 --strip-sizes 200(multi-chunk)--lcd --lanes 16 --strip-sizes 256(multi-chunk)Remaining work — multi-chunk data corruption. The first chunk (encoded + submitted from
beginTransmission()in task context) survives correctly on the wire. Every subsequent chunk encoded/submitted fromisrChunkDone()emits garbled data — RX-loopback shows 87.5–91.8 % byte corruption with a "Mixed corruption pattern" diagnosis. ~21 LEDs of clean data fits inside one 64-byte chunk, which is consistent with "only chunk 1 transmits correctly."Suspect list (not yet bisected, ordered by likelihood):
esp_lcd_panel_io_tx_color()sends a brief 0x2C command phase before each transaction even withlcd_cmd_bits=0; if the total gap drifts past 50 µs the strip latches mid-frame and subsequent bits land on a fresh frame at offset 0.ChannelData::getData()is not IRAM-resident — the per-byte gather loop inencodeChunkcalls a virtual function throughshared_ptr<ChannelData>; if the dispatch lands in flash while cache is suspended the ISR reads garbage instead of stalling (no panic, just bad bytes). Marking the path FL_IRAM only helps the caller — the vtable thunk and getter still live in flash.queue_depth=2and 3 ring buffers we could in theory wrap around and re-encode buffer N while it is still in the I80 transaction queue. Worth audit.Closest defensible quick-win: adopt PARLIO's worker-task pattern so encoding happens at task priority, not from the I80 DMA-done ISR. That sidesteps both (1) (worker task can pre-fill the next chunk while the current one transmits, avoiding gap) and (2) (no flash-cache exposure from ISR context).
For now
LCD_CLOCKLESSis correct only whenmaxSize_per_lane <= kDefaultChunkInputBytes(90 bytes ≈ 30 RGB LEDs). Above that threshold the driver no longer panics but the data on the wire is wrong.PR #2648 updated with the queue_depth fix.
fix(esp32-s3): default LCD_CLOCKLESS chunk to 1024 B (workaround for #…
zackees commentedon May 31, 2026
🎉 Hardware verified — 16 lanes × 256 LEDs WS2812 passes end-to-end
With chunk size bumped to 1024 bytes (fit-the-frame-in-one-chunk workaround on top of the IWDT-panic fix),
LCD_CLOCKLESSnow passes the canonical 16-lane × 256-LED WS2812B-V5 autoresearch matrix:RX-loopback captures all 4 test patterns (
MSB_LSB_A/_B/_C/RGB-alternating) byte-perfect on lane 0.Summary of the branch (
fix/lcd-clockless-isr-iram-2026-05-30):FL_IRAMonisrChunkDone,encodeChunk,EspWrapper::transmit,LcdSpiPeripheralEsp::transmit(kept; defense in depth — neighbouring flash ops should not be able to stall the ISR even though the panic root cause was different).xSemaphoreTakeFromISRon the ISR re-arm path (kept; correct ISR-safety regardless of cache state).esp_lcd_panel_io_del+esp_lcd_new_panel_io_i80from ISR).io_config.trans_queue_depth = 1 → 2— root cause of the IWDT panic. The re-armtx_color()fromon_color_trans_doneblocked on a full queue with depth=1.kDefaultChunkInputBytes 90 → 1024— workaround that keeps typical frames in a single chunk so the still-buggy multi-chunk ISR re-arm path is bypassed.runSingleTestlane bound 8 → 16 so autoresearch can drive the full LCD_CAM 16-bit bus.Open follow-up: the multi-chunk ISR re-arm path (frames > 1024 source bytes per lane, or any
setChunkInputBytesForTest()override below frame size) still emits garbled bytes 2..N. Suspect inter-chunk gap exceeding the WS2812 50 µs reset (everytx_colorre-enters the LCD I80 dc/cmd phase) or per-byte-position virtual-call latency throughshared_ptr<ChannelData>while flash cache is suspended. The PARLIO worker-task pattern is probably the cleanest path forward; documenting here for whoever picks it up.Closing the panic + 16×256 doesn't work aspect of this issue with the merged-when-reviewed PR. Leaving the issue open with the "multi-chunk corruption" item carved out as future work.
fix(esp32-s3): LCD_CLOCKLESS chunk-ISR IRAM/ISR-safety + equal-chunk (#…
zackees commentedon Jun 3, 2026
Closing this as fixed for the original
LCD_CLOCKLESSIWDT panic / 8-16 lanes x 256 WS2812 scope.Verification:
masteras1e1bafb1d.FL_IRAMon the ISR-linked path,xSemaphoreTakeFromISR()when re-arming from ISR context, equal-size chunking,trans_queue_depth = 2, andkDefaultChunkInputBytes = 1024.master:The remaining frames-larger-than-one-chunk corruption is now tracked separately in #2693, so this issue can close cleanly as completed.