Repository navigation
Description
Goal
Bring up clockless I2S parallel-out (WS2812 / SK6812 family) on classic ESP32 / esp32dev / WROOM as a ground-up rewrite, mirroring the shape of the ESP32-S3 LCD_CAM I2S driver that already lives in this tree (src/platforms/esp/32/drivers/i2s/channel_driver_i2s.{h,cpp.hpp} + ii2s_lcd_cam_peripheral.h + peripheral esp/mock impls). At end of the port, the third-party Yves Bazin driver code — i2s_esp32dev.{h,cpp.hpp} + clockless_i2s_esp32.h — is deprecated and removed from the tree.
Today users on classic ESP32 get RMT4 (up to 8 parallel strips) and, after #3467, RX loopback via rmt_rx_4. I2S clockless is unreachable through the modern FastLED.add<>() / Channel::create<>() channel-manager path. Adding it as a first-class ChannelEngine unlocks 16+ parallel strips and gives users a second architectural path when the RMT ISR is under pressure from WiFi.
Non-goals — explicit
- Do NOT wrap
i2s_esp32dev.has a peripheral-behind-an-interface. That was proposed in an earlier draft of this issue. Direction has changed: the Yves Bazin code is deprecated. Every ESP-IDF and register-level call in the new driver is written fresh against the classic ESP32 I2S peripheral, using the same idioms the S3 LCD_CAM driver already uses. - Do NOT keep
clockless_i2s_esp32.h(the legacyaddLeds<CHIPSET, PIN>template). After the rewrite that path is either routed through the newBusTraits<Bus::FLEX_IO, 0>::instancePtr()(mirror of what RMT4 did in feat(channels): pre-bind legacy clockless to BusTraits singleton (Phase 5b of #2428) #2441 / feat(channels): gate driver aggregator + pre-bind remaining legacy clockless (Phase 5c of #2428) #2450), or the template is dropped entirely if no in-tree examples still reference it.
Reference template — the S3 LCD_CAM driver
Use src/platforms/esp/32/drivers/i2s/ as-is for the file layout. The S3 driver's shape is:
channel_driver_i2s.h -- ChannelEngineI2S : IChannelDriver
(public interface + concrete class)
channel_driver_i2s.cpp.hpp -- implementation body (~800 lines)
ii2s_lcd_cam_peripheral.h -- II2sLcdCamPeripheral virtual interface
(lifecycle + DMA buffer alloc + transmit +
callback registration; no register touches)
i2s_lcd_cam_peripheral_esp.h -- concrete real-hardware impl
i2s_lcd_cam_peripheral_esp.cpp.hpp
i2s_lcd_cam_peripheral_mock.h -- host-side mock (single-threaded, no threads,
matches the #3462 / #3463 / #3469
mock precedent)
i2s_lcd_cam_peripheral_mock.cpp.hpp
wave8_encoder_i2s.h -- bit-transpose kernel (parallel-output
waveform generator from packed RGB bytes)
ChannelEngineI2S (public class in channel_driver_i2s.h:109) implements IChannelDriver; the peripheral is injected via constructor and every ESP-IDF call goes through II2sLcdCamPeripheral. Host tests instantiate the engine with the mock and drive lifecycle synchronously via simulate* methods on the peripheral. This is exactly the shape the WROOM I2S driver should have.
Naming
Keep everything under drivers/i2s/ and colocate WROOM-specific files next to the S3-specific ones. Suggested names — bikeshed at PR time:
drivers/i2s/
├── channel_engine_i2s_esp32dev.{h,cpp.hpp}
├── ii2s_peripheral_esp32dev.h
├── i2s_peripheral_esp32dev_esp.{h,cpp.hpp}
├── i2s_peripheral_esp32dev_mock.{h,cpp.hpp}
└── wave8_encoder_i2s_esp32dev.{h,cpp.hpp} (or reuse the S3 wave8 encoder if
the bit layout matches — it might)
Parallel-IO code-review rule applies
Per agents/docs/cpp-standards.md and src/fl/channels/README.md:
Any LED channel-engine wrapping a parallel-IO peripheral (FlexIO, ObjectFLED, PARLIO, LCD_CAM, I2S, …) MUST handle both its clockless and its SPI mode in the SAME
ChannelEngineclass, returningCapabilities(true, true)and routing per-channel inshow()based ondata->isSpi()vsdata->isClockless().
Applied here:
- Classic ESP32 I2S is a parallel-IO peripheral. One engine covers both clockless (WS2812 family) and SPI (APA102 / SK9822 / HD108) modes.
- The current
drivers/i2s_spi/directory today owns the SPI half on classic ESP32 via its ownBusTraits<Bus::FLEX_IO, 0>specialisation. That directory is folded into the new engine and either deleted or reduced to a compatibility shim. - The engine reports
Capabilities(true, true), dispatches per channel atshow()time, and configures the peripheral clock + waveform generator for whichever mode the current channel needs. - No new
Bus::I2Senum row.Bus::FLEX_IO, 0stays the single dispatch slot for classic-ESP32 I2S.
Plan
Phase 1 — Draft II2sPeripheralEsp32Dev
Mirror ii2s_lcd_cam_peripheral.h (lines 126+):
initialize(config)/deinitialize()/isInitialized()allocateBuffer(size_bytes)/freeBuffer(buf)for DMA-capable memorytransmit(buffer, size_bytes)async submitwaitTransmitDone(timeout_ms)andisBusy()registerTransmitCallback(cb, user_ctx)getConfig(),getMicroseconds(),delay(ms)utilities
Config struct captures: I2S peripheral number (0 or 1), bit width (16-bit parallel typical for LEDs), pixel clock, GPIO pin list, invert flags. Wave8-style timing parameters live in the encoder, not the peripheral config.
Phase 2 — Real-hardware I2sPeripheralEsp32DevEsp
Concrete impl using ESP-IDF v4 legacy I2S APIs (driver/i2s.h + soc/i2s_struct.h register touches where the driver API doesn't expose enough). This is where the "written fresh, not lifted from Yves" work lives. Reference material: ESP-IDF 4.x I2S driver docs, soc/i2s_reg.h, and the S3 sibling for the API-shape prior art.
Phase 3 — Host mock I2sPeripheralEsp32DevMock
Follow the Rmt4PeripheralMock / I2sLcdCamPeripheralMock template exactly:
- Singleton via
fl::Singleton<Impl>. - Single-threaded by design — no
std::thread, nocondition_variable. Tests advance simulation manually viasimulateTransmitDone(). - Error-injection knobs for each fallible entry point (
setTransmitFailure,setInitializeFailure, etc.). - Per-channel state inspection so tests can assert what the engine passed to the peripheral.
Phase 4 — ChannelEngineI2sEsp32Dev
Mirror ChannelEngineI2S (channel_driver_i2s.h:109). The engine:
- Takes
fl::shared_ptr<II2sPeripheralEsp32Dev>via constructor. Overloaded factorycreate()builds a default real-hardware peripheral for production; test factory takes an injected mock. - Implements the full
IChannelDriversurface:canHandle/enqueue/show/poll/getName/getCapabilities. Capabilities(true, true).show()iterates enrolled channels, sets the wave8 encoder for the current chipset's timing, packs the bit-transposed waveform, hands toII2sPeripheralEsp32Dev::transmit().- Handles the per-channel clockless-vs-SPI mode switch inline.
Phase 5 — wave8_encoder_i2s_esp32dev
Check whether the S3 sibling's wave8_encoder_i2s.{h,cpp.hpp} can be reused as-is — the parallel-bit-transpose kernel is likely portable. If the classic-ESP32 I2S peripheral has different bit-lane ordering or clock-polarity requirements, add a WROOM-specific variant.
Phase 6 — BusTraits<Bus::FLEX_IO, 0> rewiring
Move / rewrite the BusTraits<Bus::FLEX_IO, 0> specialisation to point at the merged engine. The drivers/i2s_spi/ directory (which owns this specialisation today for SPI-only support) is deleted or reduced to a compatibility shim. BusSupports<Bus::FLEX_IO, ClocklessChipset, 0> and BusSupports<Bus::FLEX_IO, SpiChipsetConfig, 0> both become true_type because the engine now handles both.
Phase 7 — Delete deprecated files
Remove from the tree:
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 equivalent template in RMT-land,idf4_clockless_rmt_esp32.h, was 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 new engine
Update _build.cpp.hpp in drivers/i2s/ and remove the _build.cpp.hpp under drivers/i2s_spi/.
Phase 8 — Tests
- Host tests for the peripheral mock (contract-only, no engine wiring). Same shape as the RMT4 mock tests in test(rmt4): Rmt4PeripheralMock + 22 host unit tests, no threads (#3462) #3463 — cover: lifecycle recording, ISR cookie symmetry, per-error-injection knob,
simulateTransmitDonefires the stored callback, reset() clears state. - Host tests for the engine's channel-management state machine wired against the mock. Follow the same shape as the S3 LCD_CAM tests already in
tests/platforms/esp/32/drivers/i2s/. - On-device WROOM —
bash autoresearch --i2s. Requires adding an--i2sflag to the autoresearch harness. Success = 4+ parallel WS2812B strips decoded via rmt_rx_4 loopback with matching timing.
Phase 9 — README
Document the new driver at src/platforms/esp/32/drivers/i2s/README.md. Call out the parallel-IO unified-engine rule as the design invariant.
Out of scope
- ESP32-S3 LCD_CAM I2S driver — unchanged. It's the template for this work, not the target.
- ESP32-S2 I2S — the S2 I2S peripheral has different register semantics and there's no
wave8_encoder_i2svariant. Separate port if / when someone asks for it. - IDF 5 / IDF 6 classic-ESP32 I2S — the
PERIPH_I2S1_MODULEregister access changed in IDF 5 and was removed in IDF 6.FASTLED_ESP32_HAS_I2Salready excludes IDF 6+. This issue targets IDF 4.x on WROOM, which is what the WROOM AutoResearch harness runs today. RmtMemoryManager4extension for I2S accounting. The I2S peripheral has its own DMA descriptor pool independent of RMT symbol memory; no cross-peripheral contention on classic ESP32.
Acceptance
-
II2sPeripheralEsp32Dev+ real-hardware + host-mock impls exist underdrivers/i2s/, mirroring theII2sLcdCamPeripheralstructure line-for-line. -
ChannelEngineI2sEsp32DevimplementsIChannelDriver, returnsCapabilities(true, true), dispatches ondata->isSpi()atshow()time. -
BusTraits<Bus::FLEX_IO, 0>on classic ESP32 constructs the merged engine.BusSupports<Bus::FLEX_IO, ClocklessChipset, 0> == BusSupports<Bus::FLEX_IO, SpiChipsetConfig, 0> == true_type. -
i2s_esp32dev.{h,cpp.hpp}andclockless_i2s_esp32.hdeleted (or, for the latter, decidedly-retained-with-a-good-reason). -
drivers/i2s_spi/deleted or reduced to a shim. -
bash test --cpp— host suite green, including new peripheral-mock + engine tests. -
bash compile esp32dev --examples AutoResearch— links cleanly. - WROOM live:
bash autoresearch --i2sdecodes a WS2812B loopback capture from 4+ parallel strips. - No behavioural regression on ESP32-S3 LCD_CAM I2S (
Bus::FLEX_IO, 0on S3 still routes to the existingchannel_driver_i2s.*— the S3 gateFASTLED_ESP32_HAS_I2S_LCD_CAMis orthogonal to the classic-ESP32 gateFASTLED_ESP32_HAS_I2S).
Plan drafted with assistance from Claude Code.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
[-]Bring up clockless I2S parallel-out on classic ESP32 (esp32dev / WROOM)[/-][+]Bring up clockless I2S parallel-out on classic ESP32 (esp32dev / WROOM) — ground-up rewrite[/+]feat(i2s-esp32dev): Stage 1 — peripheral interface + singleton mock +…
zackees commentedon Jul 1, 2026
Stage 1 landed via #3473 (merged). Delivers the infrastructure that the rest of the work builds on:
II2sPeripheralEsp32Devvirtual interface with the full async DMA-streaming surface (initialize / allocateBuffer / transmit / waitTransmitDone / isBusy / registerTransmitCallback / freeBuffer). Interface is stable — Stage 2 can add the real-hardware impl without touching it.I2sPeripheralEsp32DevMocksingleton host mock following the peer pattern (RMT4/5, UART, S3 LCD_CAM, SPI, FlexIO) — nostd::thread, no async callbacks; tests advance simulation manually viasimulateTransmitDone(). Error injection knobs, transmit-history recording, allocation-count / outstanding-buffer tracking.ChannelEngineI2sEsp32Dev— theIChannelDriver,Capabilities(true, true)per the parallel-IO code-review rule, READY → BUSY → READY state machine driven by the peripheral completion callback. Stage 1 packs the scratch buffer via linear byte concatenation; Stage 2 replaces thepackScratchBuffer()body with the real bit-transpose + wave8 slot expansion..coderabbit.yamlandagents/docs/cpp-standards.md. Codifies what every peer mock already did but was never explicitly required.Stage 2 (real-hardware
I2sPeripheralEsp32DevEsp, real wave8 encoding,BusTraits<Bus::FLEX_IO, 0>switch, deletion of the Yves Bazini2s_esp32dev.*+clockless_i2s_esp32.h+ folding-in ofdrivers/i2s_spi/, and on-device WROOM validation) is now tracked separately as #3474 because on-device validation is blocked on the local box by the pre-existing fbuild spec-file backslash regression.Closing this issue to reflect Stage 1 landed. Stage 2 continues at #3474.