Repository navigation
Description
Goal
The classic-ESP32 I2S clockless driver has two coexisting paths in the tree and a hard cutoff at ESP-IDF 6. Consolidate them into a single production surface that works on every supported IDF version (v4.x, v5.x, v6.x+) and validate on real WROOM hardware via autoresearch loopback.
Current state (post #3479 / PR #3495)
Path A — Yves classic driver (WORKING on IDF 4.x/5.x, hard-stubs on 6+)
- Files:
src/platforms/esp/32/drivers/i2s/{i2s_esp32dev,clockless_i2s_esp32}.{h,cpp.hpp} - Peripheral: I2S1 in parallel mode, direct SoC register writes (
i2s_esp32dev.cpp.hpp:475-491). - DMA: N-buffer chained ring via
qe.stqe_nextat line 436-438,out_link.addrkick at line 477. - ISR:
interruptHandler()at line 145,FL_IRAM-resident,esp_intr_alloc()'d onI2S_OUT_EOF_INT. Refills freshly-emptied buffers by callinggCallback()(which routes toClocklessI2S::fillBuffer()inclockless_i2s_esp32.h:227). Streaming ping-pong pipeline confirmed working. - Entry: users call
FastLED.addLeds<WS2812, PIN, GRB>(leds, N)with-DFASTLED_ESP32_I2S=1, gated on!ESP_IDF_VERSION_6_OR_HIGHERinplatforms/esp/clockless.h:32. - IDF 6+ break:
PERIPH_I2S1_MODULEwas removed from IDF 6 (i2s_esp32dev.cpp.hpp:14). The whole TU stubs toFL_WARN_F_ONCE("I2S parallel driver is disabled")(line 583). No LL API port yet. - Global state: 10+ file-scope statics (
gCallback,gCntBuffer,dmaBuffers[],gTX_semaphore,gI2S_intr_handle, etc.) — tracked separately in singleton: migrate i2s_esp32dev driver state — 19 hits, ISR pattern (Tier 2a) #3489 for singleton migration.
Path B — Modern channel-driver architecture (SCAFFOLDED, no real hardware I/O)
- Files:
src/platforms/esp/32/drivers/i2s/{channel_engine_i2s_esp32dev,i2s_peripheral_esp32dev_esp,i2s_peripheral_esp32dev_mock}.{h,cpp.hpp}+ii2s_peripheral_esp32dev.hinterface. - Engine:
ChannelEngineI2sEsp32Devis a fullIChannelDriverwithCapabilities(true, true)per the parallel-IO unified-engine rule. State machine READY → BUSY → READY driven by peripheral completion callback (channel_engine_i2s_esp32dev.cpp.hpp:200,281). - Peripheral impl is a stub:
I2sPeripheralEsp32DevEsp::transmit()(i2s_peripheral_esp32dev_esp.cpp.hpp:153-177) accepts the buffer, does(void)buffer, fires the callback synchronously, returns true. No DMA. No ISR. No register touches. Comment on line 105: "Register-level bring-up onI2S1moves into Stage 5 alongside the DMA descriptor chain + ISR install." - Stage 5 landed the DMA/ISR work but put it in Path A instead of Path B (see feat(i2s-esp32dev): Stage 5 — restore proven classic-ESP32 I2S driver alongside modern architecture (#3474) #3479 body).
- Unity-build excluded:
i2s_peripheral_esp32dev_esp.cpp.hppisUNITY_BUILD_EXCLUDE'd (from PR chore(lint): drive pre-existing bash lint violations to zero #3496 marker). Rationale documented inline:driver/gpio.hinclude collided with the restored classic driver at link time asADC: CONFLICT! driver_ng is not allowed to be used with the legacy driverboot loop. - Host tests: 21 tests in
tests/platforms/esp/32/drivers/i2s/channel_engine_i2s_esp32dev.cpppass; 28 inchannel_driver_i2s.cpp; 17 ini2s_lcd_cam_peripheral_mock.cpp. All exercise the state machine + peripheral surface via the mock.
Why unify
- Two codepaths for one peripheral violates the parallel-IO unified-engine rule (see
agents/docs/cpp-standards.md— "Parallel-IO Driver: Unified Clockless + SPI Engine"). Path A is legacyaddLeds<>, Path B is the modernFastLED.add<Channel::create<>>()/FastLED.enableAllDrivers()surface — but they wrap the same silicon. - IDF 6+ leaves classic ESP32 with NO clockless I2S option — the fallback is RMT (which is fine, but users who explicitly opted into I2S for the 24-strip parallel win lose that on IDF 6).
- Global state in Path A can't move to
Singleton<T>cleanly until it's inside a class (singleton: migrate i2s_esp32dev driver state — 19 hits, ISR pattern (Tier 2a) #3489). Consolidating around the peripheral interface in Path B gets both wins in one pass.
Scope
Phase 1 — Root-cause the ADC: CONFLICT
The driver/gpio.h include in i2s_peripheral_esp32dev_esp.cpp.hpp is the same header used by pin_esp32_native_impl.hpp and every other classic-ESP32 driver in the tree — those don't trip the conflict. Actual root cause is likely:
- Both Path A's
periph_module_enable(PERIPH_I2S1_MODULE)AND Path B's futureinitialize()racing to configure I2S1, OR - Static-init ordering between the two TUs' file-scope state (
gI2S_intr_handlein Path A vs. peripheral state in Path B) making the linker treat both as "owner" of the same hardware.
Reproduce the crash log with both TUs linked in, get the actual failing symbol / driver-registry entry, then decide the fix.
Phase 2 — Move the working DMA+ISR machinery into Path B
Replace I2sPeripheralEsp32DevEsp::transmit()'s synchronous-callback stub with the real DMA descriptor chain kick + esp_intr_alloc ISR handler. Reference: the exact register sequence from i2s_esp32dev.cpp.hpp:444-491 (i2s_init + i2s_start). The DMA-done ISR fires the registered completion callback via onTransmitDoneTrampoline (already wired at channel_engine_i2s_esp32dev.cpp.hpp:281).
Keep the peripheral interface (ii2s_peripheral_esp32dev.h) unchanged — 21 host tests continue to pass without modification.
Phase 3 — LL API port for IDF 6+
PERIPH_I2S1_MODULE and periph_module_enable/disable were removed in IDF 6. Replace with:
i2s_ll_enable_bus_clock(1, true)— new bus-clock enablei2s_ll_reset_register(1)— peripheral reset- Include path:
#include "hal/i2s_ll.h"(private HAL, but that's what IDF 6 exposes for direct-register users)
Version-gate with #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(6, 0, 0) so IDF 4.x/5.x continue using the periph_module_* path. Confirm that soc/i2s_struct.h (the i2s_dev_t register layout used throughout Path A) survives into IDF 6 — if it doesn't, the direct-register writes need HAL equivalents too.
Phase 4 — Wire ClocklessI2S<> to the peripheral
The user-facing addLeds<WS2812, PIN, GRB>() template (via platforms/esp/clockless.h:35) currently instantiates ClocklessI2S which pokes the Path A globals directly. Rewrite ClocklessI2S to construct/reuse a Singleton<I2sPeripheralEsp32DevEsp> and use the peripheral interface for init/allocateBuffer/transmit/waitTransmitDone. Result: one hardware access surface, two user-facing entry points (legacy addLeds<> and modern FastLED.add<Channel::create<>>()).
Ping-pong buffer refill in the ISR still lives in the peripheral impl (unchanged behavior), but the fillBuffer callback now goes through registerTransmitCallback() instead of a raw file-scope function-pointer global.
Phase 5 — Unity-build re-include
Remove UNITY_BUILD_EXCLUDE(...) marker from i2s_peripheral_esp32dev_esp.cpp.hpp and add it to _build.cpp.hpp alongside the other includes. bash lint --cpp will confirm the unity build is well-formed.
Phase 6 — Global-state migration (piggyback on #3489)
Once the peripheral owns the DMA state, most of the 10+ file-scope globals in i2s_esp32dev.cpp.hpp become peripheral-instance state. Singleton<I2sPeripheralEsp32DevEsp>::instance() handles storage-elision naturally. Remove the FL_LINT_ALLOW_GLOBAL_FILE(...) marker from the top of i2s_esp32dev.cpp.hpp. Close #3489.
Phase 7 — Autoresearch validation
- Add/verify
bash autoresearch --i2sflag onAutoResearch.ino. - WROOM COM11 loopback: TX 4+ parallel WS2812B strips → capture on RX pin via
rmt_rx_4(landed in feat(rmt_rx): backport RmtRxChannel to IDF 4.x (#3465) #3467) → decode → byte-level comparison against sent stream. Success = every strip's decoded byte stream matches the pattern. - Repeat on ESP-IDF 4.x, 5.x, AND 6.x build to confirm all three version paths compile, boot cleanly, and pass the loopback.
Phase 8 — README
src/platforms/esp/32/drivers/i2s/README.md documenting the single unified path, the peripheral interface, the LL-API version-gate, and the loopback test. Reference the parallel-IO unified-engine invariant.
Acceptance criteria
- Root cause of
ADC: CONFLICT!documented (Phase 1) -
I2sPeripheralEsp32DevEsp::transmit()does real DMA+ISR — no more synchronous-callback stub (Phase 2) -
#if ESP_IDF_VERSION >= 6.0path usesi2s_ll_*and compiles/boots on real IDF 6 (Phase 3) -
ClocklessI2S<>uses the peripheral interface — no direct globals (Phase 4) -
i2s_peripheral_esp32dev_esp.cpp.hppback in unity build, noUNITY_BUILD_EXCLUDEmarker (Phase 5) -
i2s_esp32dev.cpp.hpphas no file-scope statics — closes singleton: migrate i2s_esp32dev driver state — 19 hits, ISR pattern (Tier 2a) #3489, removesFL_LINT_ALLOW_GLOBAL_FILEmarker (Phase 6) -
bash autoresearch --i2sdecodes a 4+ strip WS2812B loopback on WROOM, on all three IDF version paths (Phase 7) - Modern
FastLED.add<Channel::create<Bus::FLEX_IO, 0>()>path also drives real WS2812 output (proves both entry points hit the same peripheral) -
bash test --cpp— all 344 host tests green, no regression - README updated (Phase 8)
Non-goals
- ESP32-S3
i2s_lcd_cam_peripheral_esp.cpp.hppis a different peripheral (I2S in LCD_CAM mode) and stays separate — the parallel-IO rule allows separate drivers per silicon block, not per mode. Any refactor here is out of scope. - ESP32-P4 / C6 / H2 / C5 continue using PARLIO as the clockless default (
platforms/esp/clockless.h:38-44) — untouched.
Confirmation of what already works (baseline for this issue)
Verified during investigation (2026-07-01):
- Path A on IDF 4.x/5.x is production: PR feat(i2s-esp32dev): Stage 5 — restore proven classic-ESP32 I2S driver alongside modern architecture (#3474) #3479 landed the restored Yves driver with clean WROOM boot, RPC ready in 0.68s,
testGpioConnection([[33, 34]])passing. Real DMA descriptor chain + IRAM ISR + ping-pong refill emit WS2812 timing on I2S1. - Host test coverage of Path B is solid: 21 + 28 + 17 = 66 unit tests exercise the modern engine state machine, driver contract, and mock peripheral.
bash test --cppreports 344/344 passing on master. - What's NOT confirmed: that Path B's real-hardware impl drives real waveforms (it doesn't — it's a stub); that Path A works on IDF 6 (it doesn't — it stubs to a warning).
Reference material
- Working DMA/ISR reference:
i2s_esp32dev.cpp.hpp:145(ISR),:444(esp_intr_alloc),:477(out_link.addrkick) - Modern engine state machine:
channel_engine_i2s_esp32dev.cpp.hpp:200,281 - Peripheral interface:
ii2s_peripheral_esp32dev.h - S3 sibling for shape reference (not for reuse):
i2s_lcd_cam_peripheral_esp.cpp.hpp - Original umbrella (closed): I2S esp32dev Stage 2 — real-hardware impl + BusTraits switch + delete Yves code #3474
- Singleton migration follow-up: singleton: migrate i2s_esp32dev driver state — 19 hits, ISR pattern (Tier 2a) #3489
- Parallel-IO unified-engine rule:
agents/docs/cpp-standards.md— "Parallel-IO Driver: Unified Clockless + SPI Engine" - IDF 6 removal note for
periph_module_*: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/migration-guides/release-6.x/
Blockers
- Windows fbuild spec-file backslash regression still blocks local
bash compile esp32dev(per I2S esp32dev Stage 2 — real-hardware impl + BusTraits switch + delete Yves code #3474 body); on-device validation rides on Linux CI or fbuild fix. - Real IDF 6 build environment needed to validate Phase 3 — currently the whole tree gates against IDF 6+ i2s at
platforms/esp/clockless.h:32, so no CI target exercises it yet.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
feat(i2s-esp32dev): enable IDF 6+ via i2s_ll_* compat shim (#3511)
zackees commentedon Jul 1, 2026
Progress update
Phase 3 landed via #3511 (merged 2026-07-01T15:11:45Z):
src/platforms/esp/32/drivers/i2s/i2s_periph_compat.hwraps periph enable/reset for IDF 4/5 (publicperiph_module_enable) vs IDF 6+ (i2s_ll_enable_bus_clock+i2s_ll_reset_registerviahal/i2s_ll.h).Remaining work — external blocker on IDF 6 confirmation
IDF 6 is not a shipping target yet. Current state:
espressif/platform-espressif32binding available.ci/boards.py; the CI matrix cannot add an IDF 6 target until upstream ships.So the goal condition "confirmed working on IDF 6" is genuinely blocked on the ESP-IDF release cycle, not on FastLED. The compat shim is written against the documented IDF 6 LL-API surface (
hal/i2s_ll.h—i2s_ll_enable_bus_clock+i2s_ll_reset_register) and will work when IDF 6 ships and pioarduino publishes a platform binding.What IS confirmed:
Follow-up when IDF 6 stable ships:
ESP32_IDF_6_0_PIOARDUINOplatform string toci/boards.py.ESP32DEV_IDF6board with-DFASTLED_ESP32_I2S=1default..github/workflows/build_esp32dev_idf6.ymlcompile smoke.bash autoresearch --i2son real WROOM + IDF 6.hal/i2s_ll.hsymbol names shifted (they can across IDF minor releases), patch the compat shim.Phases 2, 4-8
Documented in the umbrella issue body. Each is scoped for its own PR:
I2sPeripheralEsp32DevEsp) — largest, requires WROOM bench validation to preserve buffer-refill ISR behavior. Not attempted in feat(i2s-esp32dev): enable IDF 6+ via i2s_ll_* compat shim (#3509 Phase 3) #3511.bash autoresearch --i2sruntime.Recommendation
Keep this issue open until IDF 6 stable ships AND Phase 2 lands. The Phase 3 enable (#3511) is the forward-compatible groundwork. Users on IDF 4/5 continue to get the production Yves path unchanged.
fix(i2s-esp32dev): wrap IDF 6 LL calls in PERIPH_RCC_ATOMIC critical …
zackees commentedon Jul 1, 2026
Additional Phase 3 correctness fix landed as PR #3514 (merged 2026-07-01T15:38:18Z).
What changed
The compat shim in #3511 called
i2s_ll_enable_bus_clock+i2s_ll_reset_registerdirectly. Direct source-code verification against real ESP-IDF master (commitfa8039b5, filecomponents/esp_hal_i2s/esp32/include/hal/i2s_ll.h) showed the macro-form of both functions requires__DECLARE_RCC_ATOMIC_ENVto be in scope — otherwise the caller fails to compile on IDF 6.The correct wrap is
PERIPH_RCC_ATOMIC() { … }fromesp_private/periph_ctrl.h. That's what ESP-IDF's owncomponents/esp_driver_i2s/i2s_platform.cuses when calling the same LL functions.IDF 6 confirmation status now
espressif/esp-idf@master:i2s_ll_enable_bus_clock(int i2s_id, bool enable)✓i2s_ll_reset_register(int i2s_id)✓i2s_platform.cPERIPH_RCC_ATOMIC()) in placeThis is the maximum "confirmed working on IDF 6" that can be established without physical IDF 6 silicon in the loop. The shim now matches ESP-IDF's own convention for calling these LL functions.