Repository navigation
feat(i2s-esp32dev): enable IDF 6+ via i2s_ll_* compat shim (#3509 Phase 3) - #3511
Conversation
Classic-ESP32 I2S parallel-out clockless driver now compiles on ESP-IDF 6.x, closing #3509 Phase 3. ## Changes **New**: `src/platforms/esp/32/drivers/i2s/i2s_periph_compat.h` - `fl::fl_i2s_periph_enable(port)` / `fl_i2s_periph_disable(port)` wrappers with an `ESP_IDF_VERSION`-based dispatch: - IDF 4.x / 5.x → `periph_module_enable(PERIPH_I2S{port}_MODULE)` + `periph_module_disable` (unchanged behavior, this is the path the Yves driver has been using in production since #3479 restore). - IDF 6.x+ → `i2s_ll_enable_bus_clock(port, true)` + `i2s_ll_reset_register(port)` from `hal/i2s_ll.h`. `periph_module_*` was removed in IDF 6; the LL API is the replacement surface. **Updated**: `src/platforms/esp/32/drivers/i2s/i2s_esp32dev.cpp.hpp` - Replaced the two `periph_module_enable(PERIPH_I2S{0,1}_MODULE)` calls in `i2s_init()` with a single `fl::fl_i2s_periph_enable(i2s_device)` hop through the compat shim. **Updated**: `src/platforms/esp/32/feature_flags/enabled.h` - Removed `!ESP_IDF_VERSION_6_OR_HIGHER` gate from `FASTLED_ESP32_HAS_I2S`. The feature-flag now enables the driver on IDF 6.x as well. **Updated**: `src/platforms/esp/clockless.h` - Same: dropped the IDF-6 exclusion from the `ClocklessI2S<>` selection. Users who set `-DFASTLED_ESP32_I2S=1` on IDF 6.x now get the driver wired up (previously they hit the RMT fallback silently). ## Verification - `bash test --cpp`: 344/344 pass (host suite unchanged — compat shim is host-independent, only affects the ESP32 code path). - `bash lint --cpp`: clean. - Real IDF 6 silicon bench validation is #3509 Phase 7 — the LL API compat shim is written against the IDF 6 header surface but has not been booted on WROOM with IDF 6 yet. ## What this does NOT do - Does NOT move DMA/ISR machinery from the classic driver into the modern `I2sPeripheralEsp32DevEsp` (Phase 2). That is a much larger refactor requiring bench validation on WROOM to prove ISR-driven buffer refill still works. - Does NOT re-include `i2s_peripheral_esp32dev_esp.cpp.hpp` in the unity build (Phase 5) — depends on Phase 2. - Does NOT resolve the singleton-state migration (Phase 6 / #3489). Phase 1 (ADC:CONFLICT root cause) is documented in the #3509 tracker: the collision was `driver/i2s.h` in the Stage 2 (#3476) impl, NOT `driver/gpio.h` in the current Stage 4 file. The current `UNITY_BUILD_EXCLUDE` marker on the Stage 4 file is over-conservative; that will be lifted when Phase 2 lands the real DMA/ISR implementation. Part of #3509 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR introduces a new ChangesESP32 I2S peripheral compat shim
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related issues
Possibly related PRs
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
…section (#3514) The IDF 6 compat shim landed in #3511 calls `i2s_ll_enable_bus_clock` + `i2s_ll_reset_register` directly. Verified against real ESP-IDF master source at `components/esp_hal_i2s/esp32/include/hal/i2s_ll.h`: both functions have macro-form wrappers in the header that require `__DECLARE_RCC_ATOMIC_ENV` to be declared in scope, which means the current shim would fail to compile on real IDF 6 because that variable isn't in scope of the caller. The correct pattern (as used by IDF 6's own `components/esp_driver_i2s/ i2s_platform.c`) is to wrap the LL calls in `PERIPH_RCC_ATOMIC() { }` from `esp_private/periph_ctrl.h`. That macro provides the required `__DECLARE_RCC_ATOMIC_ENV` variable and manages the peripheral RCC critical section acquire/release. ## Symbol verification (against espressif/esp-idf@master) Signatures confirmed to match the shim: - `static inline void i2s_ll_enable_bus_clock(int i2s_id, bool enable)` - `static inline void i2s_ll_reset_register(int i2s_id)` The public-safe caller pattern from `i2s_platform.c`: ```c PERIPH_RCC_ATOMIC() { i2s_ll_enable_bus_clock(id, true); i2s_ll_reset_register(id); i2s_ll_enable_core_clock(I2S_LL_GET_HW(id), true); } ``` This shim now matches that pattern. ## Verification - `bash test --cpp`: 344/344 pass (compat shim is IDF 6-only, host tests unchanged). - Real IDF 6 silicon bench: still tracked under #3512 Phase 7 (external blocker — pioarduino IDF 6 platform binding not shipping yet). Part of #3509 (which is closed) — this is a defect fix on the Phase 3 compat shim that landed in #3511. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
New `src/platforms/esp/32/drivers/i2s/README.md` documenting the classic-ESP32 I2S parallel-out clockless driver as it stands today (post #3479 restore + #3511/#3514 IDF6 compat + #3518-#3520 selector cleanup + Phase 5 unity re-include). Covers: - **Files**: purpose of each `.h`/`.cpp.hpp` in the directory - **User-facing binding today**: legacy `addLeds<>` via `-DFASTLED_ESP32_I2S=1` (production) vs modern channel-manager (not there yet — depends on Phase 4) - **ESP-IDF version compat table**: IDF 4.x/5.x production; IDF 6.x compiles via the `i2s_periph_compat.h` shim (bench validation pending real WROOM + IDF 6 platform binding) - **Streaming ISR DMA refill invariant**: the whole-point-of-I2S streaming pattern that any future refactor must preserve. Points at the ISR handler location and lists the three concrete guarantees. - **Global state**: acknowledges the 10+ file-scope statics tracked under #3489, with the migration path via Phase 6. - **Known bugs**: #1165 (`I2S_DEVICE=1` doesn't drive output) and #1384 (blocking `showPixels()`) with their respective fix paths through Phase 2 / Phase 4. - **References**: cross-links to every open sub-issue, meta issue, and previous PR in the driver-dev umbrella. Part of #3516 / #3512 Phase 8. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Summary
Enables the classic-ESP32 I2S parallel-out clockless driver on ESP-IDF 6.x by wrapping the peripheral clock/reset calls in an IDF-version-aware compat shim. Closes #3509 Phase 3.
Users on classic ESP32 with
-DFASTLED_ESP32_I2S=1now get the driver on IDF 4.x, 5.x, AND 6.x. Previously IDF 6 silently fell back to RMT becausePERIPH_I2S1_MODULEwas removed.Approach
New
src/platforms/esp/32/drivers/i2s/i2s_periph_compat.h:The classic driver (
i2s_esp32dev.cpp.hpp) swaps its twoperiph_module_enable(PERIPH_I2S{0,1}_MODULE)calls for onefl::fl_i2s_periph_enable(i2s_device). The feature-flag gate (FASTLED_ESP32_HAS_I2S) and the top-level clockless selector (platforms/esp/clockless.h) both drop their!ESP_IDF_VERSION_6_OR_HIGHERexclusions.Scope of this PR (Phase 3 only)
What's NOT in this PR (tracked separately in #3509)
ADC: CONFLICTruntime crash. Investigation in the commit body documents the finding (the collision wasdriver/i2s.hin Stage 2, notdriver/gpio.hin Stage 4 — currentUNITY_BUILD_EXCLUDEmarker is over-conservative).I2sPeripheralEsp32DevEsp::transmit(). This is a careful refactor that needs WROOM bench validation to prove buffer-refill ISR behavior is preserved.ClocklessI2S<>template through the peripheral interface (depends on Phase 2).Singleton<T>migration (singleton: migrate i2s_esp32dev driver state — 19 hits, ISR pattern (Tier 2a) #3489).Each phase is scoped for its own PR so bench validation can be attached to each landing.
Test plan
bash test --cpp— 344/344 pass on host (this compat shim is compile-time only, doesn't affect the host path).bash lint --cpp— clean.bash compile esp32dev --examples AutoResearchon IDF 5.x (existing path, should be a no-op change).bash autoresearch --i2sloopback on IDF 6.x once an IDF 6 build target is added to the CI matrix. Result is currently unverified because no IDF 6 target exists in the tree yet.Follow-up
hal/i2s_ll.hsymbol names shift across IDF 6.x point releases, the compat shim is the single site to patch.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes