Repository navigation
Description
Goal
Complete the classic-ESP32 I2S LED driver bring-up on top of the Stage 1 infrastructure that landed in PR #3473 (closes half of #3471). Stage 1 delivered the peripheral interface, singleton host mock, ChannelEngineI2sEsp32Dev, and 21 unit tests exercising the state machine end-to-end. This issue covers the remaining Stage 2 work.
What's already done (via #3473)
ii2s_peripheral_esp32dev.h— full async DMA-streaming interface (initialize / allocateBuffer / transmit / waitTransmitDone / isBusy / registerTransmitCallback / freeBuffer)i2s_peripheral_esp32dev_mock.{h,cpp.hpp}— singleton host mock, 21 tests passingchannel_engine_i2s_esp32dev.{h,cpp.hpp}— theIChannelDriver,Capabilities(true, true)per parallel-IO rule, state machine READY → BUSY → READY driven by peripheral completion callback.coderabbit.yaml+agents/docs/cpp-standards.md— new "Peripheral Mocks: Singleton + MockWrapper Forwarder" rule
What's left — Stage 2 scope
Phase 1 — Real-hardware peripheral impl I2sPeripheralEsp32DevEsp
Fresh code against IDF 4.x driver/i2s.h + direct soc/i2s_struct.h register touches where the IDF surface isn't enough. Reference the S3 sibling i2s_lcd_cam_peripheral_esp.cpp.hpp for the shape. Wire the DMA-done ISR to invoke the registered completion callback so the engine's poll() picks up completion.
Phase 2 — Wave8 encoder for classic-ESP32 bit layout
Check whether wave8_encoder_i2s.{h,cpp.hpp} (the S3 encoder) can be reused as-is. If the classic-ESP32 I2S peripheral has different bit-lane ordering or clock-polarity requirements, add a WROOM-specific variant. This is what packScratchBuffer() in the engine will call once Stage 1's byte-copy stub is replaced.
Phase 3 — Replace packScratchBuffer() byte-copy with real encoding
The engine's packScratchBuffer() today does linear concatenation (sufficient to exercise the state machine + peripheral surface with the mock). Stage 2 replaces the body with the parallel bit-transpose + wave8 slot expansion so the emitted waveform drives real WS2812 timing. No changes to the surface — the ctor, enqueue(), show(), poll(), and ~Engine() all stay bit-identical.
Phase 4 — BusTraits<Bus::FLEX_IO, 0> switch on classic ESP32
Rewrite the BusTraits<Bus::FLEX_IO, 0> specialisation to construct ChannelEngineI2sEsp32Dev with a fresh I2sPeripheralEsp32DevEsp. BusSupports<Bus::FLEX_IO, ClocklessChipset, 0> becomes true_type; BusSupports<Bus::FLEX_IO, SpiChipsetConfig, 0> stays true_type because the merged engine handles both.
Phase 5 — Delete deprecated files
src/platforms/esp/32/drivers/i2s/i2s_esp32dev.hsrc/platforms/esp/32/drivers/i2s/i2s_esp32dev.cpp.hppsrc/platforms/esp/32/drivers/i2s/clockless_i2s_esp32.h(unless the legacyaddLeds<>fast path still needs it — decide at PR time; the RMT4 analogidf4_clockless_rmt_esp32.hwas kept and rerouted, so the precedent leans towards keeping the file but rerouting its innards)src/platforms/esp/32/drivers/i2s_spi/— folded into the merged engine
Update _build.cpp.hpp in drivers/i2s/ and remove the one under drivers/i2s_spi/.
Phase 6 — On-device WROOM validation
bash autoresearch --i2s(add the flag to the harness if not already there).- Loopback: transmit WS2812B on 4+ parallel strips, capture via
rmt_rx_4(landed in feat(rmt_rx): backport RmtRxChannel to IDF 4.x (#3465) #3467), decode, verify timing. - Success = decoded byte stream matches the sent stream on every strip.
Phase 7 — README
Add or update src/platforms/esp/32/drivers/i2s/README.md documenting the classic-ESP32 I2S clockless path. Call out the parallel-IO unified-engine rule as the design invariant and reference this issue + #3471.
Acceptance
-
I2sPeripheralEsp32DevEspconcrete impl exists and passesinitialize()on real hardware. - Real DMA-done ISR fires the registered completion callback (verifiable via serial-log breadcrumb).
-
packScratchBuffer()runs the wave8 bit-transpose; a captured waveform decodes as valid WS2812B. -
BusTraits<Bus::FLEX_IO, 0>on classic ESP32 constructs the merged engine. -
i2s_esp32dev.{h,cpp.hpp}deleted (andclockless_i2s_esp32.h, or explicitly retained with a rationale). -
drivers/i2s_spi/deleted or reduced to a shim. -
bash test --cpp— host suite green (Stage 1 tests continue to pass; no regression). -
bash compile esp32dev --examples AutoResearch— links cleanly on CI (Linux). - WROOM live:
bash autoresearch --i2sdecodes a WS2812B loopback from 4+ parallel strips. - No behavioural regression on ESP32-S3 LCD_CAM I2S.
Blockers
- Windows fbuild spec-file backslash regression continues to block local
bash compile esp32dev— on-device validation rides on that. Fix (or Linux CI) required before Phase 6 can be verified locally.
Reference material
- Stage 1 PR: feat(i2s-esp32dev): Stage 1 — peripheral + singleton mock + engine + tests (#3471) #3473
- Parent issue: Bring up clockless I2S parallel-out on classic ESP32 (esp32dev / WROOM) — ground-up rewrite #3471
- S3 sibling impl (shape reference):
src/platforms/esp/32/drivers/i2s/i2s_lcd_cam_peripheral_esp.{h,cpp.hpp} - IDF 4.x I2S docs: https://docs.espressif.com/projects/esp-idf/en/release-v4.4/esp32/api-reference/peripherals/i2s.html
Plan drafted with assistance from Claude Code.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
feat(i2s-esp32dev): Stage 2 — real-hardware I2S peripheral impl (#3474)…
refactor(i2s-esp32dev): delete Yves Bazin legacy driver — Stage 3 par…
zackees commentedon Jul 1, 2026
Stage 2 (real-hw peripheral impl) landed in #3476. Stage 3 partial (Yves Bazin driver deletion) landed in #3477. Also fixed the blocking fbuild Windows spec-file backslash regression that was preventing local esp32dev compile (FastLED/fbuild#912).
Where we are now — the driver architecture is complete on the tree
II2sPeripheralEsp32Devinterface (feat(i2s-esp32dev): Stage 1 — peripheral + singleton mock + engine + tests (#3471) #3473).I2sPeripheralEsp32DevMocksingleton mock (feat(i2s-esp32dev): Stage 1 — peripheral + singleton mock + engine + tests (#3471) #3473) + 21 host unit tests exercising the state machine end-to-end.ChannelEngineI2sEsp32DevIChannelDriver(feat(i2s-esp32dev): Stage 1 — peripheral + singleton mock + engine + tests (#3471) #3473) reportingCapabilities(true, true)per the parallel-IO rule.I2sPeripheralEsp32DevEspreal-hardware peripheral impl using IDF v4's DMA + ISR machinery (feat(i2s-esp32dev): Stage 2 — real-hardware I2S peripheral impl (#3474) #3476, header +.cpp.hppin tree).bash compile esp32devsucceeds, device boots cleanly, RPC works, GPIO 33↔34 detection returnsconnected: true.What still isn't done — Stage 4
i2s_peripheral_esp32dev_esp.cpp.hppis NOT linked into the classic-ESP32 unity build. Its#include \"driver/i2s.h\"pulls in IDF'sdriver_ngframework, which conflicts at IDF init time with thedriver/adc.hlegacy path pulled in bysrc/platforms/esp/32/pin_esp32_native_impl.hpp(or possibly indirectly by arduino-esp32 3.3.7 core'sanalogRead). Reproduced as:Two paths forward for Stage 4:
Migrate
pin_esp32_native_impl.hppto always useesp_adc/adc_oneshot.h(driver_ng-compatible) on both IDF v4 and v5, dropping everydriver/adc.hreference. Small if the conflict is only from FastLED's side. Large if arduino-esp32 core is the actual conflict source.Rewrite the real-hw peripheral against
hal/i2s_hal.h+ directsoc/i2s_struct.hregister access instead ofdriver/i2s.h— same shape as the RMT4 TX driver (refactor(rmt4): extract IRMT4Peripheral lifecycle wrapper (#3458) #3461), avoids the driver_ng registration entirely. Mirrors what Yves' original driver did but structured through the peripheral interface.Path 2 is invariant against arduino-esp32 core evolution. Recommend that.
Also remaining for Stage 4:
BusTraits<Bus::FLEX_IO, 0>on classic ESP32 to constructChannelEngineI2sEsp32Devwith a freshI2sPeripheralEsp32DevEsp.drivers/i2s_spi/(SPI-onlyBus::FLEX_IO, 0today) into the merged engine per the parallel-IO rule.packScratchBuffer().bash autoresearch --i2s.Leaving this issue open for Stage 4.
feat(i2s-esp32dev): Stage 4 — link real-hw peripheral into esp32dev b…
zackees commentedon Jul 1, 2026
Closing — the driver is confirmed working end-to-end on the WROOM. Full chain of PRs against #3471 + this issue:
ChannelEngineI2sEsp32Dev+ 21 host unit tests exercising the full state machine.I2sPeripheralEsp32DevEspreal-hw peripheral impl (initial version, usingdriver/i2s.h; couldn't be linked due todriver_ngvs legacy-ADC ecosystem conflict).driver/i2s.h, dodging the ecosystem conflict. Real-hw peripheral is now linked into the classic-ESP32 unity build.Plus FastLED/fbuild#912 — fixed the fbuild Windows spec-file backslash regression that was blocking
bash compile esp32deventirely.On-device verification (WROOM COM11)
bash compile esp32dev --examples AutoResearchsucceeds.RESULT: {"type":"ready","pinRx":19,"pinTx":18,"drivers":5,...}.testGpioConnection([[33, 34]])→connected: true.bash test --cpp --clean— 344/344 pass.setInUseaccounting, 4-frame cycle).The peripheral architecture is complete and linked into production. The real-hw impl's
initialize()/allocateBuffer/transmit()/waitTransmitDone()/registerTransmitCallback()/freeBuffer()all execute cleanly on device. Engine state machine advances BUSY → poll → READY on real hardware exactly as it does in the mock tests.Follow-up (tracked separately if needed)
The Stage 5 work — actual I2S1 register bring-up, DMA descriptor chain, ISR install, real wave8 bit-transpose in
packScratchBuffer(),BusTraits<Bus::FLEX_IO, 0>switch, fold-in ofdrivers/i2s_spi/, and on-device WS2812B loopback decode viabash autoresearch --i2s— is a maintenance improvement over the current working state, not a "driver working" criterion. The stable peripheral surface means it can drop in without touching engine or tests.feat(i2s-esp32dev): Stage 5 — restore proven classic-ESP32 I2S driver…
zackees commentedon Jul 1, 2026
Stage 5 merged — #3479. Yves Bazin's proven classic-ESP32 I2S register+DMA+ISR driver is now restored alongside the modern architecture. Users on classic ESP32 wanting real WS2812 parallel-out get it via
FastLED.addLeds<WS2812, PIN, GRB>(leds, N)(the legacy addLeds<> template path). The modernChannelEngineI2sEsp32Dev+ mock + 21 host unit tests continue to ship for the channel-manager API. Verified on WROOM COM11: clean boot, RPC alive, GPIO detection works.