Skip to content

fix(esp32-s3): LCD_CLOCKLESS GPIO crash fix + autoresearch --lcd/--lcd-spi - #2269

Closed
zackees wants to merge 2 commits into
masterfrom
feat/lcd-isr-buffer-refill
Closed

zackees wants to merge 2 commits into
masterfrom
feat/lcd-isr-buffer-refill

Conversation

@zackees

@zackees zackees commented Apr 17, 2026 •

Copy link
Copy Markdown
Member

Summary

Hardware bring-up for the LCD_CAM drivers added in #2260 (merged). Fixes a boot crash in LCD_CLOCKLESS and wires the autoresearch CLI so --lcd and --lcd-spi both pass on an ESP32-S3.

Crash fix

ChannelDriverLcdClockless defaulted dc_gpio=22 and clock_gpio=21. GPIO 22 does not exist on common ESP32-S3 packages, so esp_lcd_new_i80_bus → lcd_i80_bus_configure_gpio → gpio_func_sel hit an error-log path that detected heap poisoning and triggered a Guru Meditation panic.

Changed both defaults to GPIO 0, matching the legacy I2S LCD_CAM driver this replaces (the strapping pin tolerates being multiplexed to the unused PCLK/DC peripheral functions).

autoresearch CLI

  • --lcd now maps to LCD_CLOCKLESS (was the legacy I2S name).
  • New --lcd-spi flag maps to LCD_SPI (APA102/SK9822 via LCD_CAM I80).
  • Both auto-select the esp32s3 environment and are included in --all.

autoresearch RX decoder

examples/AutoResearch/AutoResearchTest.cpp now recognises LCD_CLOCKLESS and reconstructs the RX timing for wave3 or wave8 encoding using the same fl::canUseWave3() eligibility check the firmware uses at runtime.

GPIO pre-test timing

Bumped RpcClient boot_wait from 3s to 8s and enabled drain_boot in ci/autoresearch/gpio.py. The ESP32-S3 AutoResearch setup() takes ~5-7s before the RPC dispatcher is ready, so the old 3s wait raced the first ping against setup and produced intermittent GPIO PRE-TEST TIMEOUT failures.

Hardware verification (ESP32-S3 @ COM13, jumper GPIO 1 → GPIO 2)

Driver Result
LCD_SPI 4/4 patterns pass (passed:true)
LCD_CLOCKLESS 4/4 patterns pass (passed:true, after GPIO fix)

Test plan

  • Host unit tests: 299/299 pass
  • Lint clean
  • LCD_SPI single-driver hardware test passes
  • LCD_CLOCKLESS single-driver hardware test passes (crash fixed)
  • bash autoresearch --lcd end-to-end (blocked by a pre-existing FbuildSerialAdapter DTR/RTS race — tracked separately; direct JSON-RPC path is reliable)

Follow-up to #2260.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added LCD_SPI driver for ESP32-S3 with chunked DMA streaming and ISR-assisted transmission.
    • Added LCD_CLOCKLESS driver supporting clockless LED chipsets via LCD_CAM I80 bus.
    • Introduced --lcd-spi CLI flag for driver selection.
  • Bug Fixes

    • Increased RPC client connection timeout for improved reliability.
    • Corrected LCD driver naming from I2S to LCD_CLOCKLESS.
  • Tests

    • Added comprehensive unit tests for both new LCD drivers.

zackees and others added 2 commits April 15, 2026 13:53
…drivers

Refactor the LCD_CAM SPI driver (ChannelDriverLcdSpi) and add a new
clockless driver (ChannelDriverLcdClockless) for ESP32-S3. Both use
ISR-driven 3-buffer ring architecture for chunked DMA streaming,
modeled after the PARLIO driver.

Key changes:
- SPI driver: ISR callback transposes next chunk on DMA completion
- Clockless driver: wave3/wave8 auto-select via canUseWave3(), uses
  wave3Transpose_16/wave8Transpose_16 for encoding in ISR context
- Mock simulateTransmitComplete() drains full ISR callback chain
- Chunk size capped at ~100 LEDs (SPI) / ~30 LEDs (clockless)
- LCD clockless registered in channel manager, replacing misnamed
  "I2S" driver on ESP32-S3

22 new test cases across both drivers. All 299 tests pass,
ASAN/LSAN/UBSAN clean, lint clean.

Closes #2258

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…-spi

Hardware bring-up for PR #2260 (LCD_CAM ISR-driven chunked DMA).

Crash fix
  ChannelDriverLcdClockless defaulted dc_gpio=22 and clock_gpio=21.
  GPIO 22 does not exist on common ESP32-S3 packages, so
  esp_lcd_new_i80_bus -> lcd_i80_bus_configure_gpio -> gpio_func_sel
  hit an error-log path that detected heap poisoning and triggered a
  Guru Meditation panic. Changed both defaults to GPIO 0 (same
  convention as the legacy I2S LCD_CAM driver this replaces).

autoresearch CLI
  --lcd now maps to LCD_CLOCKLESS (was the legacy I2S name).
  Added --lcd-spi mapping to LCD_SPI (APA102/SK9822 via LCD_CAM I80).
  Both auto-select the esp32s3 environment and are included in --all.

autoresearch RX decoder
  AutoResearchTest.cpp recognises LCD_CLOCKLESS and reconstructs the
  RX timing for wave3 or wave8 encoding using the same
  fl::canUseWave3() eligibility check the firmware uses at runtime.

GPIO pre-test timing
  Bumped RpcClient boot_wait from 3s to 8s and enabled drain_boot in
  gpio.py. The ESP32-S3 AutoResearch setup() takes ~5-7s before the
  RPC dispatcher is ready, so the old 3s wait raced the first ping
  against setup and produced intermittent GPIO PRE-TEST timeouts.

Hardware verification (ESP32-S3 @ COM13, jumper GPIO 1 -> GPIO 2)
  LCD_SPI:       4/4 patterns pass (passed:true)
  LCD_CLOCKLESS: 4/4 patterns pass (passed:true, after GPIO fix)

Host unit tests: 299/299 pass. Lint clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Apr 17, 2026 •

Copy link
Copy Markdown

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR introduces a new ESP32-S3 clockless LED driver using the LCD_CAM I80 bus, refactors the existing LCD_SPI driver to use ISR-driven chunked DMA streaming instead of single-buffer blocking, adds CLI support for the new driver variant, increases GPIO RPC timeouts, and provides comprehensive unit test coverage for both drivers.

Changes

Cohort / File(s) Summary
CLI Arguments and Driver Selection
ci/autoresearch/args.py, ci/autoresearch/phases.py
Added --lcd-spi CLI flag and lcd_spi boolean argument; updated driver selection logic to map --lcd to LCD_CLOCKLESS, add LCD_SPI driver variant, auto-select esp32s3 environment when lcd_spi is set, and expand --all matrix to include both LCD drivers.
GPIO RPC Timeouts
ci/autoresearch/gpio.py
Increased RPC client boot-wait from 3.0s to 8.0s, set drain_boot=True during connection, and added explicit 15.0s timeout to GPIO pretest ping call.
New Clockless LED Driver
src/platforms/esp/32/drivers/lcd_spi/channel_driver_lcd_clockless.h, channel_driver_lcd_clockless.cpp.hpp
Implemented ChannelDriverLcdClockless: a new IChannelDriver for clockless chipsets (WS2812/SK6812) using ESP32-S3 LCD_CAM I80 bus with wave3/wave8 encoding selection, ISR-driven chunked DMA, ring-buffered transmission, and factory function createLcdClocklessEngine().
Refactored LCD_SPI Driver
src/platforms/esp/32/drivers/lcd_spi/channel_driver_lcd_spi.h, channel_driver_lcd_spi.cpp.hpp
Converted from blocking single-buffer DMA to ISR-driven chunked streaming: replaced mBuffer with 3-slot ring buffers (mRingBuffers), added ISR completion callback and context struct, updated transposeToWords to accept byte range, and restructured beginTransmission to support per-chunk encoding and incremental DMA submission.
Driver Registration
src/platforms/esp/32/drivers/channel_manager_esp32.cpp.hpp
Added LCD_CLOCKLESS driver registration via addLcdClocklessIfPossible(), conditionally creating createLcdClocklessEngine() at priority 1 when FASTLED_ESP32_HAS_LCD_SPI is defined, called before existing addI2sIfPossible().
Build Configuration
src/platforms/esp/32/drivers/lcd_spi/_build.cpp.hpp
Added Unity-build include for channel_driver_lcd_clockless.cpp.hpp.
Peripheral Mock
src/platforms/esp/32/drivers/lcd_spi/lcd_spi_peripheral_mock.cpp.hpp
Updated simulateTransmitComplete() to loop while mPendingTransmits > 0, allowing ISR callbacks to enqueue additional chunks, setting mBusy = false only when queue drains completely.
Driver Tests
tests/platforms/esp/32/drivers/lcd_spi/channel_driver_lcd_clockless.cpp, channel_driver_lcd_spi.cpp
Added comprehensive unit tests for clockless driver (creation, wave3 selection, single/multi-chunk transmission, multi-lane behavior, ring-buffer wrap, reuse cycles, error handling) and extended LCD_SPI tests with 10 new chunked-streaming test cases covering various chunk size scenarios, multi-lane configs, ring-buffer wraparound, and transmit failures.
Test Framework
examples/AutoResearch/AutoResearchTest.cpp
Extended capture timing logic to recognize LCD_CLOCKLESS driver, added wave3 support via fl::canUseWave3(), introduced separate uses_wave3 and uses_wave8 booleans with corresponding timing computations, increased RX decode tolerance to 200ns for wave3/wave8 or 170ns otherwise.

Sequence Diagram

sequenceDiagram
    participant App as Application
    participant Driver as ChannelDriverLcdSpi<br/>(or Clockless)
    participant ISR as ISR Handler
    participant DMA as DMA Hardware
    participant Ring as Ring Buffers
    
    App->>Driver: enqueue(data)
    App->>Driver: show()
    activate Driver
    Driver->>Ring: allocate ring buffers
    Driver->>Ring: transpose chunk 0
    Driver->>DMA: submit chunk 0 (register ISR)
    deactivate Driver
    
    DMA->>ISR: interrupt on chunk complete
    activate ISR
    alt more chunks exist
        ISR->>Ring: transpose next chunk
        ISR->>DMA: submit next chunk
    else all chunks done
        ISR->>Driver: set mStreamComplete flag
    end
    deactivate ISR
    
    App->>Driver: poll()
    alt stream complete
        Driver->>Ring: free ring buffers
        Driver-->>App: return READY
    else transmitting
        Driver-->>App: return DRAINING
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related issues

Possibly related PRs

Poem

🐰 A clockless driver hops into place, with ISR chunks at a dancing pace—
Ring buffers waltz through DMA's embrace, while the SPI driver finds its new grace.
Wave3 waves, wave8 sways, chunked streaming days! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 41.18% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: fixing LCD_CLOCKLESS GPIO crash and adding autoresearch CLI options (--lcd/--lcd-spi).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/lcd-isr-buffer-refill
⚔️ Resolve merge conflicts
  • Resolve merge conflict in branch feat/lcd-isr-buffer-refill

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant