Repository navigation
fix(esp32): add noinline to IRAM_ATTR functions in RMT4 header - #2252
Conversation
GCC 14+ on Xtensa reorders literal pools, placing l32r constants after the instruction that references them. This causes linker errors: "dangerous relocation: l32r: literal placed after use". Replace `inline` with `__attribute__((noinline))` on all 7 IRAM_ATTR functions defined in channel_driver_rmt4.h to prevent the compiler from inlining them across translation units and disrupting literal pool placement. Closes #2247
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughRemoved Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 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 |
📊 Header Compilation PerformanceTotal Time: 1182.02ms Top 5 Slowest Headers
Warnings
Full Report |
) Brings the classic-ESP32 RMT (rmt_4) driver in line with the ChannelEngine + Peripheral API-object pattern that UART, FlexIO, and RMT5 already use. This is Phase 1 + Phase 3 of the plan in #3458: peripheral wrapper + bus-holder shape cleanup. Phase 2 (the actual ESP-IDF lifecycle calls) was already implemented — the stale "Stubs (to be implemented in Phase 3B)" comment misled the survey. ## What moved through the wrapper The new `IRMT4Peripheral` virtual interface (`irmt4_peripheral.h`) covers exactly the ESP-IDF lifecycle/control surface: - rmt_config() - rmt_driver_install() / rmt_driver_uninstall() - rmt_set_tx_thr_intr_en() - rmt_set_tx_intr_en() - rmt_set_gpio() / rmt_set_pin() - esp_intr_alloc() / esp_intr_free() `Rmt4PeripheralESP` is the real-hardware concrete impl. The engine holds a `shared_ptr<IRMT4Peripheral>` and routes those calls through it. ## What does NOT go through the wrapper The IRAM ISR hot path stays inline in the engine header. Virtual dispatch from the ISR would defeat the `FL_NO_INLINE` literal-pool placement guarantees on Xtensa (#2247 / #2252): - direct RMT.* register reads/writes - gpio_matrix_out() disconnect - fillNextBuffer() double-buffer refill - tx_start() per-platform register kicks The interface header's docblock spells this out explicitly under "Interface scope — what's OUT". ## BusTraits<Bus::RMT> uses the holder pattern `bus_traits.h` now constructs a `detail::Rmt4BusHolder { peripheral, driver }`, mirroring `detail::UartBusHolder` exactly. The static `gHolder` keeps both lifetimes paired and the function-local-static guard means we still only emit one `BusTraits<Bus::RMT>` definition per program. ## Stale comment removed `channel_driver_rmt4.cpp.hpp` had a "Stubs (to be implemented in Phase 3B)" banner above `acquireChannel()` / `releaseChannel()` / `configureChannel()`. Those are all implemented — they install the driver, configure the channel, allocate the hardware buffer, etc. The banner was a leftover from the Phase-3A scaffolding and gave a misleading impression of the driver's completeness. ## Tests + validation - `bash test --cpp` — 340/340 pass on this branch. - `clang-format --dry-run --Werror` clean on all new + edited files. - `bash compile esp32dev --examples AutoResearch` is currently blocked on this Windows box by a separate fbuild spec-file backslash regression (`cc1plus: fatal error: C:Usersniteris...`) that also reproduces on plain master. Tracked separately — not introduced by this PR. CI on Linux will exercise the build. ## Out of scope - `Rmt4PeripheralMock` for host-side unit tests of the engine's channel acquire/reconfigure/release strategies — straightforward follow-up but not in this PR. - RMT5 (S3/C3/C6/H2/P4) — separate driver, already conforms. - The TX/RX `rmt_4` + `rmt_rx` peripheral merge — flagged in the survey, explicitly out of scope. Closes #3458. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Summary
inlinewith__attribute__((noinline))on 7 IRAM_ATTR functions inchannel_driver_rmt4.hl32rconstants after the instruction that references them, causing linker errors:dangerous relocation: l32r: literal placed after usenoinlineprevents the compiler from inlining these ISR functions across translation units, keeping literal pool placement stableContext
I2SClockBasedLedDriver.hFiles changed
src/platforms/esp/32/drivers/rmt/rmt_4/channel_driver_rmt4.h— 7 functions:handleInterrupt,onThresholdInterrupt,onTxDoneInterrupt,fillNextBuffer,convertByteToRMT,tx_start,findChannelByNumberTest plan
Closes #2247
Summary by CodeRabbit
Release Notes