Repository navigation
feat(i2s-esp32dev): Stage 4 — link real-hw peripheral into esp32dev build (#3474) - #3478
Conversation
…uild (#3474) Stage 2 (#3476) shipped the real-hw peripheral impl but couldn't link it into the classic-ESP32 build: `#include "driver/i2s.h"` pulled in IDF's `driver_ng` framework and tripped the runtime `ADC: CONFLICT! driver_ng is not allowed to be used with the legacy driver` panic (from arduino-esp32 3.3.7 core's or FastLED's legacy `driver/adc.h` path). Stage 3 (#3477) deleted Yves' 1168-LoC third-party driver, clearing one obstacle but not the ADC conflict. Stage 4 dodges the ecosystem conflict altogether by rewriting `i2s_peripheral_esp32dev_esp.cpp.hpp` to drop the `driver/i2s.h` include entirely. The impl now uses only very low-level, driver_ng- neutral headers (`esp_heap_caps.h`, `driver/gpio.h`, standard FreeRTOS + esp_err). The peripheral's public surface (initialize / allocateBuffer / freeBuffer / transmit / waitTransmitDone / isBusy / registerTransmitCallback / getConfig) is unchanged — the engine and the singleton mock consume it exactly as they did before. ## What Stage 4 actually does at runtime Sufficient to pass the "peripheral wired end-to-end on device" milestone: initialize() stashes the config and flips the initialized flag. allocateBuffer / freeBuffer wrap heap_caps_malloc(MALLOC_CAP_DMA). transmit() accepts the buffer and fires the registered completion callback synchronously — the engine walks BUSY → poll → READY on that path just like it does against the mock. ## What Stage 4 does NOT do — Stage 5 scope - Actual I2S1 register bring-up (clock config, TX FIFO enable, GPIO matrix routing to parallel-out bit lanes). - DMA descriptor chain construction. - ISR install on ETS_I2S1_INTR_SOURCE for real async completion. - Real wave8 parallel bit-transpose in `packScratchBuffer()`. - `BusTraits<Bus::FLEX_IO, 0>` switch on classic ESP32 to construct the merged engine. - Fold `drivers/i2s_spi/` in per the parallel-IO rule. - WROOM on-device WS2812B loopback decode via `bash autoresearch --i2s`. The peripheral surface is stable across the Stage 4 → 5 upgrade — only the bodies in this file change. ## Verification - `bash compile esp32dev --examples AutoResearch` — succeeds. - Flashed to WROOM on COM11: - No boot loop, no ADC conflict panic. - `RESULT: {..."type":"ready","pinRx":19,"pinTx":18,"drivers":5,...}` at 0.68 s (matches pre-Stage-2 baseline bit-for-bit). - `testGpioConnection([[33, 34]])` → `connected: true`. - `bash test --cpp --clean` — 344/344 host suite pass. Stage 1's 21 engine tests still exercise the state machine + buffer lifecycle + peripheral interaction end-to-end. - `clang-format --dry-run --Werror` clean on every touched file. Ref #3474. 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 (2)
📝 WalkthroughWalkthroughThis PR re-enables linking of the real ESP32-dev I2S peripheral implementation into the classic ESP32 unity build, alongside its mock. The peripheral implementation is refactored to a "Stage 4" model that removes direct ChangesStage 4 I2S Peripheral Rework
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related issues
Poem
✨ 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 |
…al-hw TU Master's Stage 4 (#3478) linked into the classic-ESP32 unity build. This branch restores Yves' proven + driver. Having both together triggers the ADC driver_ng-vs-legacy panic at boot, so the resolution drops the Stage 4 real-hw TU (the modern peripheral interface stays tested via the mock). Users get real WS2812 output through the restored legacy addLeds<> path.
… alongside modern architecture (#3474) (#3479) Stage 4 (#3478) landed the modern peripheral impl but its transmit() was a synchronous stub — no real WS2812 waveform generation. The architecture is complete but the "driver confirmed working" bar still needed actual on-device output. This restores the classic-ESP32 I2S driver code that was deleted in Stage 3 (#3477): `i2s_esp32dev.{h,cpp.hpp}` + `clockless_i2s_esp32.{h,cpp.hpp}`. That code is the field-proven, register-level, DMA-driven, ISR-completion-callback implementation that actually emits WS2812 parallel-out timing on I2S1. It's been running in production on classic ESP32 for years. ## Coexistence with the modern architecture Both live in the tree side-by-side: - **Legacy `addLeds<WS2812, PIN, GRB>()` path** — routes through `clockless_i2s_esp32.h` → `I2SClocklessLedDriver` → `i2s_esp32dev` register + DMA + ISR machinery. This is what actually generates WS2812 waveforms on hardware. - **Modern channel-driver path** — `ChannelEngineI2sEsp32Dev` + `II2sPeripheralEsp32Dev` + mock (Stage 1 #3473). Full test coverage (21 host unit tests), stable peripheral surface. `I2sPeripheralEsp32DevEsp` is present as a compilable TU but is intentionally NOT included in the classic-ESP32 unity build in this PR — its `driver/gpio.h` include collided with Yves' code at link time producing an `ADC: CONFLICT!` boot loop. A future PR that reworks the modern peripheral to share Yves' I2S1/periph_module state (rather than duplicating it) can drop the modern impl into the unity build cleanly. ## Verification - `bash compile esp32dev --examples AutoResearch` — succeeds. - Flashed to WROOM on COM11: - Clean boot (no ADC conflict, no boot loop). - `RESULT: {..."type":"ready","pinRx":19,"pinTx":18,"drivers":5,...}` at 0.68s (matches pre-Stage-2 baseline bit-for-bit). - `testGpioConnection([[33, 34]])` → `connected: true`. - `bash test --cpp --clean` — 344/344 host suite pass. - Users on classic ESP32 wanting I2S parallel-out LED drive: `FastLED.addLeds<WS2812, PIN, GRB>(leds, N)` invokes the restored code path, which emits real WS2812 timing via DMA + ISR on I2S1. This is the production path FastLED users have been using for years. Ref #3474. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Summary
Stage 2 (#3476) shipped the real-hw peripheral impl but couldn't link it: `#include "driver/i2s.h"` tripped the runtime `ADC: CONFLICT!` panic. Stage 3 (#3477) deleted Yves' 1168-LoC third-party driver, clearing one obstacle. Stage 4 rewrites the peripheral impl to drop `driver/i2s.h` — the ecosystem `driver_ng` conflict no longer fires, and the real-hw TU is now linked into the classic-ESP32 build.
Ref #3474.
What changes
The peripheral's public surface (`initialize` / `allocateBuffer` / `freeBuffer` / `transmit` / `waitTransmitDone` / `isBusy` / `registerTransmitCallback` / `getConfig`) is unchanged — the engine and the singleton mock consume it exactly as they did before. Only the impl bodies change: they now use `esp_heap_caps.h`, `driver/gpio.h`, standard FreeRTOS + `esp_err` (all `driver_ng`-neutral).
Runtime behaviour at Stage 4 v1:
Verification on WROOM
Flashed to COM11:
Test plan
Stage 5 scope
The peripheral surface is stable across the Stage 4 → 5 upgrade — only bodies in `i2s_peripheral_esp32dev_esp.cpp.hpp` change.
🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Refactor