Repository navigation
fix(esp32): resolve SPI/LCD_SPI buffer growth failure on channel reuse - #2251
Conversation
#2249) Root cause: Channel constructor called fl::pinMode(pin, InputPulldown) which reconfigured the SPI MOSI pin as GPIO input, disconnecting the SPI peripheral from the GPIO matrix. After FastLED.clear(ClearFlags::CHANNELS) + FastLED.add(), the new Channel's constructor broke the persistent SPI driver's GPIO routing. Fixes: - Remove fl::pinMode(InputPulldown) from all Channel constructors — the driver configures the pin when it first uses it - ChannelEngineSpi: reallocate ledSourceBuffer on reuse when new data exceeds existing buffer (prevents ISR-unsafe direct PSRAM fallback) - LCD_SPI peripheral: prime semaphore, blocking wait before transmit, lazy panel IO creation with recreation on size change, explicit esp_cache_msync for PSRAM - RMT RX: reset mAccumulationOffset in clear() to prevent stale write position Validated: bash autoresearch --spi --strip-sizes 100,250,100 — all pass.
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughChanges address LCD_SPI driver buffer growth failures on ESP32-S3 by refactoring pin initialization away from Channel constructors, implementing lazy panel IO creation with buffer-aware recreation, adding PSRAM cache synchronization, replacing non-blocking semaphore drains with blocking DMA waits, and enabling SPI channel buffer reallocation on size increases. Changes
Sequence Diagram(s)sequenceDiagram
participant App as Application
participant LcdSpi as LcdSpiPeripheralEsp
participant PanelIo as PanelIo Instance
participant Cache as Cache Manager
participant GDMA as GDMA/DMA
App->>LcdSpi: transmit(buffer, size_bytes)
alt size_bytes changed
LcdSpi->>PanelIo: delete old mPanelIo
LcdSpi->>PanelIo: create new mPanelIo with new size
end
LcdSpi->>Cache: esp_cache_msync() for buffer
Note over Cache: Flush PSRAM writes to DMA-visible state
LcdSpi->>GDMA: esp_lcd_panel_io_tx_color(buffer, size)
GDMA-->>LcdSpi: queued (returns ESP_OK)
LcdSpi->>LcdSpi: xSemaphoreTake(mCompleteSem, 2000ms)
Note over LcdSpi: Block until DMA completion signal
GDMA-->>LcdSpi: xSemaphoreGive() on DMA done
LcdSpi->>LcdSpi: mLastTransmitSize = size_bytes
LcdSpi-->>App: transfer complete
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
📊 Header Compilation PerformanceTotal Time: 980.46ms Top 5 Slowest Headers
Warnings
Full Report |
Summary
FastLED.clear()+FastLED.add()cyclesfl::pinMode(pin, InputPulldown)which disconnected the SPI MOSI from the GPIO matrix, breaking the persistent SPI driver's outputCloses #2249
Changes
channel.cpp.hppfl::pinMode(InputPulldown)from all 3 Channel constructors — the driver configures the pinchannel_driver_spi.cpp.hppledSourceBufferon channel reuse when data exceeds existing bufferlcd_spi_peripheral_esp.cpp.hppesp_cache_msynclcd_spi_peripheral_esp.hmLastTransmitSizefield for tracking transaction size changesrmt_rx_channel.cpp.hppmAccumulationOffsetinclear()to prevent stale write position on re-armTest plan
bash autoresearch --spi --strip-sizes 100,250— both passbash autoresearch --spi --strip-sizes 100,250,100— all 3 pass (round-trip)bash autoresearch --spi --strip-sizes 250— standalone passbash autoresearch --i2s— verify I2S LCD_CAM driver unaffectedbash autoresearch --all— full driver matrixSummary by CodeRabbit
Release Notes
Bug Fixes
Improvements