Repository navigation
fix(i2s-esp32dev): wrap IDF 6 LL calls in PERIPH_RCC_ATOMIC critical section - #3514
Merged
Merged
Conversation
…section 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]>
|
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 (1)
📝 WalkthroughWalkthroughThe ESP-IDF 6.x+ code path in i2s_periph_compat.h now includes esp_private/periph_ctrl.h and wraps I2S LL bus clock enable/disable and register reset calls inside PERIPH_RCC_ATOMIC() critical sections within fl_i2s_periph_enable and fl_i2s_periph_disable. ChangesI2S RCC atomic wrapping
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant Caller
participant fl_i2s_periph_enable
participant PERIPH_RCC_ATOMIC
participant i2s_ll
Caller->>fl_i2s_periph_enable: call enable(port)
fl_i2s_periph_enable->>PERIPH_RCC_ATOMIC: enter critical section
PERIPH_RCC_ATOMIC->>i2s_ll: i2s_ll_enable_bus_clock(port, true)
PERIPH_RCC_ATOMIC->>i2s_ll: i2s_ll_reset_register(port)
PERIPH_RCC_ATOMIC-->>fl_i2s_periph_enable: exit critical section
✨ 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 |
10 tasks
This was referenced Jul 1, 2026
zackees
added a commit
that referenced
this pull request
Jul 1, 2026
… Phase A) (#3518) Per #3516 meta / #3515 Phase A: enable a real IDF 6.0 CI target for the classic-ESP32 I2S clockless driver, and remove the compile-time `FASTLED_ESP32_I2S` selector so the driver is bound at runtime via the modern channel API instead of by preprocessor flag. ## Changes ### Runtime-selected I2S driver - **`src/FastLED.h`**: `FASTLED_ESP32_I2S` becomes a deprecation warning. Compat-shim message directs users to `FastLED.enableDriver<fl::Bus::FLEX_IO, 0>()` for runtime selection. - **`src/platforms/esp/32/core/fastled_esp32.h`**: driver header include is now gated on `FASTLED_ESP32_HAS_I2S` (feature flag — auto-enabled on classic ESP32) instead of the removed selector. The driver code always compiles on classic ESP32; `--gc-sections` elides it when unused. - **`src/platforms/esp/clockless.h`**: removed the `#if defined(FASTLED_ESP32_I2S)` branch of the `ClocklessController` alias. Legacy `addLeds<>` continues to route to the RMT / PARLIO / SPI default. The I2S path is reached through the modern channel API. ### IDF 6.0 CI target - **`ci/boards.py`**: new `ESP32_IDF_6_PIOARDUINO` platform URL pointing at `pioarduino/platform-espressif32#prep_IDF6` (commit `98230ad4aa`, 2026-05-25). That branch's `platform.json` pins `framework-arduinoespressif32` to `arduino-esp32/archive/master.zip` — arduino-esp32 master built on ESP-IDF v6.0.1+. - **`ci/boards.py`**: new `ESP32DEV_IDF6` board using the above, `platform_needs_install=True`, no driver-selector defines. - **`.github/workflows/build_esp32dev_idf6.yml`**: compile-smoke against Blink + SpecialDrivers/ESP/DriverTest. Fires on esp/ + i2s/ + ci/ changes, plus manual PR triggers. ## Why the flag removal matters - **gc-sections elision**: the driver code compiles unconditionally on classic ESP32 (via `FASTLED_ESP32_HAS_I2S`), and gc-sections drops it when the user's sketch doesn't reach into the I2S code path. This matches the FastLED convention documented in `src/fl/channels/README.md` — one binary, multiple drivers, linker keeps only what's referenced. - **User-facing selection**: users get I2S by explicitly asking for it at runtime, not by defining a compile-time symbol. This aligns with the modern channel-manager surface (`FastLED.enableDriver<>`, `Channel::create<>`) that the rest of the driver work in #3516 builds on. ## Verification - `bash test --cpp`: 344/344 pass on host (this is a pure gate change — no behavioral impact on the host code path). - `bash lint --cpp`: clean. - CI compile against IDF 6: exercised by the new `build_esp32dev_idf6.yml` workflow once this PR merges to master. The `i2s_periph_compat.h` `PERIPH_RCC_ATOMIC()` path (from #3514) will be hit end-to-end for the first time. ## What this does NOT do - Does NOT change legacy `addLeds<WS2812, PIN, GRB>()` behavior on IDF 4.x/5.x — that path continues to route through RMT / PARLIO / SPI as before. Users who previously set `-DFASTLED_ESP32_I2S=1` get a deprecation warning and must migrate to `FastLED.enableDriver<fl::Bus::FLEX_IO, 0>()` for the same behavior. - Does NOT touch the classic Yves driver ISR / DMA machinery. That's #3512 Phase 2 and follows the Phase B/C/D validation fence. Part of #3516 / #3515 Phase A. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
3 tasks done
zackees
added a commit
that referenced
this pull request
Jul 1, 2026
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Defect fix on the Phase 3 IDF 6 compat shim that landed in #3511. Verified against real ESP-IDF master source that the LL API calls need to be wrapped in
PERIPH_RCC_ATOMIC() { }— otherwise the caller fails to compile against IDF 6 because__DECLARE_RCC_ATOMIC_ENVisn't in scope.Verification against real ESP-IDF master (fa8039b5)
Fetched
components/esp_hal_i2s/esp32/include/hal/i2s_ll.hfromespressif/esp-idf@master:The macro-form of both functions requires
__DECLARE_RCC_ATOMIC_ENVto be declared in scope. My compat shim from #3511 called them raw, which would fail compile.Correct caller pattern (from
components/esp_driver_i2s/i2s_platform.cin the same tree):The
PERIPH_RCC_ATOMIC()macro (inesp_private/periph_ctrl.h) provides the__DECLARE_RCC_ATOMIC_ENVvariable and manages the critical section.Fix
Test plan
bash test --cpp: 344/344 pass (host suite unchanged — shim is IDF 6-only)bash lint --cpp: clean🤖 Generated with Claude Code
Summary by CodeRabbit