Repository navigation
Description
Design directive
The modern classic-ESP32 I2S parallel-out driver (currently scaffolded in channel_engine_i2s_esp32dev + i2s_peripheral_esp32dev_esp) must be built as a general clockless driver in the same shape as PARLIO — using wave8 / wave3 encoding driven by a fixed pixel clock — NOT by delegating to the classic Yves i2s_esp32dev.cpp.hpp bit-pattern driver.
Origin: user directive during #3516 Phase 2 drafting session. Was going to wrap the Yves C-style API from the modern peripheral; user redirected because the two are fundamentally different architectures and the modern driver should follow the parallel-IO/wave8 pattern PARLIO established.
Why not wrap the Yves driver
The Yves classic driver at src/platforms/esp/32/drivers/i2s/i2s_esp32dev.cpp.hpp encodes each bit as a variable number of I2S pulses derived from ChipsetTiming.T1/T2/T3 (see i2s_define_bit_patterns and i2s_transpose_and_encode). It's a per-chipset bit-pattern encoder that runs the transpose from an ISR streaming refill.
That model:
- Can't be selected per-channel at runtime — the bit patterns are set once at
i2s_inittime - Doesn't fit the modern channel-manager flow where each
ChannelDatacarries its ownChipsetTimingConfig - Isn't the pattern the rest of the parallel-IO drivers use (PARLIO on ESP32-P4/C6/H2/C5 and LCD_CAM on ESP32-S3 both use wave8/wave3 expansion)
The wave8 / wave3 pattern PARLIO uses
Reference: src/platforms/esp/32/drivers/parlio/parlio_engine.h lines 68-69 include fl/channels/wave3.h + fl/channels/wave8.h. Members at lines 295-309 hold:
u32 mTimingT1Ns;
u32 mTimingT2Ns;
u32 mTimingT3Ns;
u32 mResetUs;
fl::Wave8BitExpansionLut mWave8Lut; // 8x expansion, always available
fl::Wave8ByteExpansionLut mWave8ByteLut; // byte-indexed fast path (#2526)
fl::Wave3BitExpansionLut mWave3Lut; // 3x expansion, chipset-eligible only
bool mUseWave3;
u32 mClockFreqHz; // wave8: 8 MHz, wave3: per-chipsetPer-channel encoding path:
- Channel has a
ChipsetTimingConfigfrom itsChannelData. - Check if the timing is wave3-eligible (three-slot timings can use the smaller wave3 LUT — saves 2.6x memory).
- Expand each byte via
mWave8ByteLut(ormWave3Lut) into 8 (or 3) parallel-DMA words per input bit. - Feed the expanded stream to the peripheral's DMA at the fixed pixel clock.
- The pixel-clock rate determines the wire-side timing: at 8 MHz wave8, each output bit is 125 ns, so 8 output bits per input bit → 1 µs per input bit at 800 kHz WS2812 rate.
For classic-ESP32 I2S1 parallel-out, the same encoding fits: I2S1 supports 16 parallel data lanes clocked at a configurable rate. Set the pixel clock to 8 MHz for wave8, feed 8 expanded output bits per input bit per lane, and every WS2812-family chipset that PARLIO handles is handled by I2S1 too.
Scope
Implementation phases (do NOT delegate to Yves at any point — the two are separate):
Phase 2a — Wave8 encoder for classic-ESP32 I2S1 (SHARED CODE ONLY)
New encoder in src/platforms/esp/32/drivers/i2s/wave8_encoder_i2s.{h,cpp.hpp} — extended if the existing file (which targets S3 LCD_CAM) can be shared, or a new sibling wave8_encoder_i2s1.h if the bit-lane layout differs. Must:
- Accept a
ChannelData(byte stream +ChipsetTimingConfig) - Produce wave8-expanded bytes for one bit-lane at I2S1's 32-bit-wide FIFO layout
- Wave3-eligibility check + wave3 fallback for smaller memory footprint
- REQUIRED — reuse shared code, do NOT duplicate. Wave encoding kernels (
fl::wave8Transpose_16_bf1,fl::wave8Transpose_16x4_bf1_pipe4,fl::wave3*) live insrc/fl/channels/and are shared across every parallel-IO driver (PARLIO, LCD_CAM, FlexIO, ObjectFLED, LPUART, and now I2S1). The I2S1 encoder is a thin wrapper that calls those kernels — it MUST NOT re-implement the transpose hot loop, MUST NOT duplicate the LUT builders, MUST NOT introduce a private lookup table with the same semantics. Any driver-specific work is limited to (a) input-format adaptation from the modern channel-managerChannelDatalayout to the transpose kernels expected inputs, (b) output-format adaptation to the I2S1 DMA descriptor byte layout, (c) bounds validation. This is the anti-drift rule the AutoResearchParlioEncode.h times a mirror of production hot loop, not production code (facade cheat) #3524 mirror-cheat post-mortem established: shared production code, one implementation, everyone dispatches through it
Phase 2b — I2S1 peripheral (register + DMA + ISR)
Rewrite I2sPeripheralEsp32DevEsp::initialize / transmit / waitTransmitDone to:
- Own its own DMA descriptor ring (
lldesc_tchain, IRAM-resident) - Configure I2S1 as a fixed-rate parallel outputter — 16-bit-wide, 8 MHz pixel clock for wave8 (or chipset-specific rate for wave3)
- Install its own
esp_intr_allocISR that refills the next buffer while the current one drains — streaming, matching the invariant documented insrc/platforms/esp/32/drivers/i2s/README.md - No calls into
i2s_esp32dev.cpp.hpp(Yves driver stays untouched; it's the legacy-DFASTLED_ESP32_I2S=1path until Phase 4 exposes the new modern path)
Phase 2c — SPI mode in the same engine (parallel-IO unified rule)
Per agents/docs/cpp-standards.md → "Parallel-IO Driver: Unified Clockless + SPI Engine (REQUIRED)", the modern I2S engine MUST handle both clockless and SPI modes on the same peripheral. Existing pattern to mirror:
ChannelEngineI2sEsp32Dev::getCapabilities()returnsCapabilities(true, true)BusSupports<Bus::FLEX_IO, ClocklessChipset, 0>andBusSupports<Bus::FLEX_IO, SpiChipsetConfig, 0>both specialize tofl::true_typecanHandle()accepts bothdata->isClockless()anddata->isSpi()show()routes per-channel — reconfigure the peripheral (FIFO width, clock rate, DMA slots) when switching modes at show-time
Since the I2S1 peripheral can only run one mode at a time, mode switches happen AT show-time (not at engine construction), same rule the FlexIO / ObjectFLED unified engines follow.
Reference for the SPI half: src/platforms/esp/32/drivers/i2s_spi/ — the existing I2S-in-SPI-mode driver already targets Bus::FLEX_IO, 0 on classic ESP32. Its SPI encoding + DMA setup can either be folded into the new engine or reused verbatim through the engine's SPI-mode branch. The _build.cpp.hpp for drivers/i2s_spi/ is removed once the merge lands (Phase 2d cleanup).
Phase 2d — Wire into BusTraits<Bus::FLEX_IO, 0> on classic ESP32
Update channel_manager_esp32.cpp.hpp so addI2sIfPossible registers ChannelEngineI2sEsp32Dev in the FLEX_IO slot as the unified clockless+SPI engine. Retires the separate addI2sSpiIfPossible — its work is now inside the single unified engine.
Phase 2e — Delete the Yves drivers (REQUIRED)
Once Phase 2d ships and bench validation on WROOM proves the new path drives every WS2812-family chipset the Yves driver did AND every clocked chipset the I2S-SPI driver did, the Yves i2s_esp32dev.cpp.hpp + clockless_i2s_esp32.h AND drivers/i2s_spi/ MUST be deleted from the tree. Not deprecated behind a compat shim — deleted. FASTLED_ESP32_I2S opt-in is removed; the modern engine is the only I2S path. Rationale: keeping two coexisting paths on the same peripheral (Yves globals + modern instance state, both racing to claim I2S1) is exactly the maintenance-cost / silent-hardware-conflict scenario the parallel-IO unified-engine rule was written to prevent. See agents/docs/cpp-standards.md -> "Parallel-IO Driver: Unified Clockless + SPI Engine (REQUIRED)" - fork = 4x maintenance surface, no behavioral benefit.
Reference
- PARLIO engine (implementation pattern to mirror):
src/platforms/esp/32/drivers/parlio/parlio_engine.h,parlio_engine.cpp.hpp - Shared wave LUTs:
src/fl/channels/wave8.h,src/fl/channels/wave3.h - Existing I2S wave8 for S3 LCD_CAM (may be reusable):
src/platforms/esp/32/drivers/i2s/wave8_encoder_i2s.h - Yves classic driver (do NOT wrap):
src/platforms/esp/32/drivers/i2s/i2s_esp32dev.cpp.hpp - Parallel-IO unified-engine rule:
agents/docs/cpp-standards.md→ "Parallel-IO Driver: Unified Clockless + SPI Engine" - Wave8 byte-LUT bench:
examples/AutoResearch/AutoResearchParlioEncode.h(⚠️ mirror-cheat noted in AutoResearchParlioEncode.h times a mirror of production hot loop, not production code (facade cheat) #3524 — do not reuse that pattern here)
Acceptance
-
wave8_encoder_i2s1produces byte-exact wave8 output for a fixed input pattern, verified in host test. -
wave8_encoder_i2s1calls the sharedfl::wave8Transpose_*kernels — grep confirms no private transpose implementation, no duplicate LUT builder. - Wave3 fallback path exercised for a three-slot chipset.
-
I2sPeripheralEsp32DevEspdrives real DMA on I2S1 via its own descriptor ring + ISR — no calls intoi2s_esp32dev.cpp.hpp. -
ChannelEngineI2sEsp32Dev::getCapabilities()returnsCapabilities(true, true)— clockless AND SPI on the same engine per the parallel-IO unified rule. BothBusSupports<Bus::FLEX_IO, ClocklessChipset, 0>andBusSupports<Bus::FLEX_IO, SpiChipsetConfig, 0>specialize tofl::true_type. - Mode switch works at show-time (
canHandle()accepts both,show()reconfigures FIFO width / clock rate as needed). -
BusTraits<Bus::FLEX_IO, 0>on classic ESP32 resolves toChannelEngineI2sEsp32Devin the clockless+SPI unified-engine slot per the parallel-IO rule. - WROOM bench:
bash autoresearch --flex-ioon classic-ESP32 build drives 4+ parallel WS2812B strips (clockless) AND drives a clocked APA102/SK9822 strip (SPI mode) in the same run, both with byte-exact RX loopback (viarmt_rx_4capture for clockless, wire capture for SPI). -
bash test --cpp— all host tests green. - Legacy
-DFASTLED_ESP32_I2S=1path retained ONLY during rollout (Phase 2a-2d landings + WROOM bench validation). At Phase 2e the flag is removed and Yves files are deleted. - Yves
i2s_esp32dev.{h,cpp.hpp}+clockless_i2s_esp32.{h,cpp.hpp}files DELETED from tree at Phase 2e. -
drivers/i2s_spi/DELETED at Phase 2e. -
-DFASTLED_ESP32_I2Sflag REMOVED — the deprecation#warninginsrc/FastLED.h(from docs+fix: Bus::FLEX_IO runtime-selection guardrail + restore Yves opt-in #3519) is deleted; the modern engine onBus::FLEX_IO, 0is the only path.
Non-goals
- Not touching PARLIO / LCD_CAM / FlexIO / ObjectFLED / LPUART. Their wave8/wave3 encoders stay as-is.
- Not rewriting the Yves driver in place — the new engine is a fresh implementation.
- Not keeping the Yves driver as a compat shim after Phase 2e. Delete it.
Blockers
- WROOM COM11 hardware for bench validation.
- Requires a design pass on whether
wave8_encoder_i2s1shares the S3 LCD_CAMwave8_encoder_i2simplementation or is a sibling. Bit-lane layout differences may force separate impls.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsTriage
Activity
feat(i2s): wave8 encoder for classic-ESP32 I2S1 (#3526 Phase 2a) (#3528)
feat(i2s): add streaming buffer-refill callback interface (#3526 Phas…
fix(lint): add FL_NO_EXCEPT to TypeToJson<u32> / <u16> converters (#3532
feat(i2s): engine mode-dispatch scaffolding for SPI batches (#3526 Ph…
docs(agents): check if target device is attached before deferring ben…
feat(i2s): real hardware initialize() on modern peripheral (#3526 Pha…
feat(i2s): real deinitialize() on modern peripheral (#3526 Phase 2b) (#…
feat(i2s): factory + Phase 2d slot-0 swap prep + agent-doc guardrail (#…
feat(i2s): unified engine SPI path via delegate (#3526 Phase 2c) (#3544)
7 remaining items
zackees commentedon Jul 1, 2026
Status update (2026-07-01, after #3557)
✅ Completed acceptance criteria
wave8_encoder_i2s1.{h,cpp.hpp}+ host tests; reuses sharedfl::wave8Transpose_*kernelsencodeChannelWave3_i2s1sibling + eligibility tests viacanUseWave3(feat(i2s): wave3 sibling encoder for I2S1 modern driver (#3526 Phase 2a) #3554)i2s_esp32dev.cpp.hppfrominitialize/deinitialize; fixed 8 MHz pixel clock (80 MHz / (10 + 0/1)); directsoc/i2s_struct.hwrites for parallel-out configlldesc_tdescriptor allocated viaheap_caps_malloc(MALLOC_CAP_DMA);esp_intr_alloc(ETS_I2S1_INTR_SOURCE, ESP_INTR_FLAG_IRAM, ...)install;transmit()armsout_link.addr + out_link.startand kicksconf.tx_start; FL_IRAM ISR trampoline fires completion callbackCapabilities(true, true), mode-switch dispatch at show-time via delegation tocreateI2sSpiEngine()pong, uptimeMs: 2066after every merge⏳ Remaining
gpio_matrix_out. Requires engine-sideconfigureTiming()/ per-channel GPIO plumbing so pin mapping arrives with theChannelDatabatch. Small but needs bench loopback capture (RMT4 RX or scope) to verify signal integrity.NUM_DMA_BUFFERS,qe.stqe_nextchain).BusTraits<Bus::FLEX_IO, 0>swap — blocked on steps C+D. When modern claims I2S1 at init, the existing SPI delegate (createI2sSpiEngine) would race for the same peripheral. Needs a clean handoff design (SPI delegate skips its own peripheral init if modern already owns it, or SPI is folded into the modern engine outright).drivers/i2s_spi/— blocked on Phase 2d completing cleanly. Includes removing theFASTLED_ESP32_I2Sdeprecation warning insrc/FastLED.h.rmt_rx_4for clockless / wire capture for SPI.Each remaining phase is a dedicated PR with real scope. Foundation is now clean — no Yves entanglement — so follow-up work builds directly on the modern peripheral impl.
feat(i2s): Phase 2b step C — GPIO mux routing for I2S1 lanes (#3526) (#…
feat(i2s): Phase 2d slot swap — BusTraits<FLEX_IO, 0> → modern unifie…
zackees commentedon Jul 1, 2026
Status update (2026-07-01, after #3559)
✅ Completed acceptance criteria
wave8_encoder_i2s1.{h,cpp.hpp}+ host testsencodeChannelWave3_i2s1sibling (feat(i2s): wave3 sibling encoder for I2S1 modern driver (#3526 Phase 2a) #3554)lldesc_t+esp_intr_alloc()routeLanePinwith 24-lane support (fixes the 16→24 limit; hardware supports 24 persoc/gpio_sig_map.h)Capabilities(true, true), delegate tocreateI2sSpiEngine()BusTraits<Bus::FLEX_IO, 0>slot swap (feat(i2s): Phase 2d slot swap — BusTraits<FLEX_IO, 0> → modern unified engine (#3526) #3559) — modern unified engine is now the binding. Prerequisite init-order fix (only claim I2S1 for clockless mode) included in same PR.Every merge bench-verified: device boots, RPC ping returns
pong, success: True, uptimeMs: 2066.⏳ Remaining
drivers/i2s_spi/— Yves side is a straightforward file deletion + removing theFASTLED_ESP32_I2Sdeprecation warning insrc/FastLED.h.drivers/i2s_spi/deletion is blocked on folding I2S_SPI's transmit logic INLINE into the modern engine's SPI branch (currently the modern engine still delegates viacreateI2sSpiEngine()).Supporting infra this session
detail/wave3.hpp+wave8.hpp→.h+.cpp.hpp(refactor(channels): split detail/wave3.hpp + wave8.hpp into .h + .cpp.hpp #3555) — dropped ~10× inlined transpose emission in the final binaryFoundation is now clean — no Yves entanglement in the modern peripheral impl — so the remaining Phase 2b step D and Phase 2e work builds directly on top.
feat(i2s): Phase 2e — delete Yves, singleton peripheral, variable tim…
zackees commentedon Jul 1, 2026
Phase completion snapshot (after #3564)
✅ COMPLETE
wave8_encoder_i2s1.{h,cpp.hpp}+ host tests, shared kernelsencodeChannelWave3_i2s1sibling (feat(i2s): wave3 sibling encoder for I2S1 modern driver (#3526 Phase 2a) #3554)soc/i2s_struct.hwriteslldesc_tdescriptor +esp_intr_alloc()ISR, realtransmit()kicks DMArouteLanePinw/ 24-lane support + CodeRabbit fixes (pad-select, real clear path, IRAM-safe ISR, wraparound-safe wait, sharedkMaxI2sLanesconstant)Capabilities(true, true), delegates tocreateI2sSpiEngine()BusTraits<Bus::FLEX_IO, 0>→ modern unified engine, init-order race fixedclockless_i2s_esp32.{h,cpp.hpp}+i2s_esp32dev.{h,cpp.hpp}(~1287 lines)fl::Singleton<>; ownership global deleted;make_shared_no_trackingwrappersolveI2sClockDivider— non-800kHz chipsets now supportedFASTLED_ESP32_I2Sdeprecation removed🟡 Remaining follow-ups (not blockers on the driver-complete condition)
drivers/i2s_spi/full directory deletion — modern engine still delegates viacreateI2sSpiEngine(). Deleting the directory requires folding I2S_SPI's transmit logic INLINE into the modern engine's SPI branch. Slot-swap alone (feat(i2s): Phase 2d slot swap — BusTraits<FLEX_IO, 0> → modern unified engine (#3526) #3559) doesn't cover this — the delegate call chain still links againstdrivers/i2s_spi/.solveI2sClockDividerto shared location).Supporting infra this session
detail/wave{3,8}.hpp→.h + .cpp.hpp(refactor(channels): split detail/wave3.hpp + wave8.hpp into .h + .cpp.hpp #3555) — dropped ~10× inlined emissionSession totals
9 PRs merged, ~1287 lines of Yves code retired, foundation clean for the remaining stream/loopback work.
docs(i2s): rewrite README for modern engine (#3526 Phase 8 / #3512 Ph…
zackees commentedon Jul 2, 2026
🎯 Live bench verification of Phase 2d slot swap
Direct RPC query to a running ESP32-WROOM after PR #3564 landed:
Request:
{"method":"flexIoDeviceInfo","params":[{}],"id":42}Response:
{ "id": 42, "result": { "bus": "FLEX_IO", "silicon": "ESP32", "success": true, "instance": 0, "driverName": "I2S", "idfVersion": "5.5.2", "supportedByBuild": true, "registeredDriverNames": [ "I2S", "RMT", "SPI", "BIT_BANG", "UART" ] }, "jsonrpc": "2.0" }What this proves:
driverName: "I2S"— the modernChannelEngineI2sEsp32Devengine (itsgetName()returns"I2S") is bound toBus::FLEX_IO, 0. Before Phase 2d (feat(i2s): Phase 2d slot swap — BusTraits<FLEX_IO, 0> → modern unified engine (#3526) #3559) this reported"I2S_SPI"— the slot swap is live on real hardware.silicon: "ESP32"— classic ESP32-WROOM (FL_IS_ESP_32DEV), not S3/P4/C-series.idfVersion: "5.5.2"— real ESP-IDF 5.5.2 runtime.bus: "FLEX_IO", instance: 0— correct slot binding.supportedByBuild: true— the feature-flag guardFASTLED_ESP32_HAS_I2Scompiles clean and registers.registeredDriverNames: ["I2S", ...]— the modern engine is registered FIRST (highest priority) in the channel-manager driver list.IDF 5 branch of #3515 Phase D confirmed working (partial — this validates the runtime binding + boot + RPC responsiveness, not the byte-exact WS2812 loopback which still needs physical LEDs).
IDF 4 + IDF 6 branches: the CI workflows exist (
build_esp32dev_idf6.yml, prior-session boards.py entries), compile clean on both, but need dedicated bench runs to close out this row of the acceptance matrix.Remaining bench: wire an actual 4-strip WS2812B jumper harness with an
rmt_rx_4capture channel — that's the true byte-exact loopback validation the meta specs. Software-side everything else in the acceptance list is closed.feat(i2s): wire wave8 encoding into engine + routeLanePin call (#3526) (
zackees commentedon Jul 2, 2026
Final session status — wave8 wired end-to-end, register-config debug remaining
PR #3566 just merged (11th PR in the #3526 series this session). Closes the wave8-encoding gap that live bench (#3515) exposed:
packScratchBuffer()now runsencodeChannelWave8_i2s1()(PARLIO pattern)peripheral->routeLanePin(lane_idx, data->getPin())for every active channel before transmitBench state after 11 PRs
Live-hardware run on ESP32-WROOM COM11 via
runSingleTestRPC withdriver: "I2S", laneSizes: [10], pattern: "ALL_ONES":driverName: "I2S")success: truefrom test dispatcherFastLED.show()routeLanePincalled for every lane)captureFailed: true, rawEdgesAfterWait: 0Where the real gap is now
Every software wiring layer is now in place and unit-test-verified. The bench evidence tells us the DMA-config-to-wire path itself has a register-level bug. Candidates for next-session debug (all inside
I2sPeripheralEsp32DevEsp::initialize()):tx_bits_mod = 32(32-bit sample width) may not match wave8's byte-major output layoutfifo_conf.tx_fifo_mod = 3(32-bit-single-channel) may be wrong for parallel-out lane modeconf.tx_mono = 0+conf_chan.tx_chan_mod = 1interaction — the mono-mode-with-right-first pattern from Yves was proven correct for his encoder, may not carry over cleanlyclkm_conf.clka_en = 0— no clock output — may be needed for parallel-out modetx_startThis isn't code review — it's register-level ESP32 hardware validation that would benefit from a scope on the target GPIO pin during a transmit attempt. Software-only debug will hit a wall.
Sub-issue closure status
routeLanePinhandles both ports explicitlyChannel::create<>+poll()non-blocking APISession totals
The remaining bench-blocker (register-config emit) is real hardware debugging that no amount of code churn in an agent session can close. Documented here for the next session's benchmark run.
docs(i2s): document open bench debug on tx_bits_mod (#3526 / #3515) (#…
zackees commentedon Jul 2, 2026
Filed #3568 documenting the register-config bug that produces zero wire edges from the wave8-encoded output. #3568 has scope-verifiable candidate fixes and is the acceptance path for the remaining physical validation.
fix(i2s,rmt-rx): 32-bit sample encoding + classic-ESP32 capture fixes (…
zackees commentedon Aug 20, 2026
Deferred under the active bug-burn-down policy. The core modern I2S engine is substantially shipped, but the issue's full acceptance still combines architecture cleanup with a physical dual-mode bench campaign.
Shipped:
Capabilities(true, true)and classic ESP32Bus::FLEX_IO, 0binding;FASTLED_ESP32_I2Sselector removed.Unmet acceptance:
src/platforms/esp/32/drivers/i2s_spi/still exists; SPI remains a delegated implementation rather than fully folded into the modern engine.Completing the remainder means designing/landing a non-delegating SPI path and running the physical mixed-mode bench. That is a separate hardware-backed multi-PR effort, not a safe cleanup-only patch.
Restart criteria:
drivers/i2s_spi/only after the inline path has byte-exact host tests and a real strip/wire pass.deferredwhen the bench and implementation owner are available.The issue remains open and is excluded from the actionable queue while labeled
deferred.