Skip to content

fix(esp_extra_libs): clearDelayFunction guard + drop unused hal/mcpwm_ll.h - #2598

Merged
zackees merged 2 commits into
masterfrom
fix/esp-extra-libs-build
May 30, 2026
Merged

zackees merged 2 commits into
masterfrom
fix/esp-extra-libs-build

Conversation

@zackees

@zackees zackees commented May 30, 2026 •

Copy link
Copy Markdown
Member

Summary

esp_extra_libs (kitchensink against pioarduino IDF 5.x) was failing master with two independent errors. Both are fixable in FastLED with one-line edits; no fbuild or IDF changes needed.

1. stub_main.hpp:48 — clearDelayFunction undeclared

The call to clearDelayFunction() in ScopedEngineCleanup::~ScopedEngineCleanup fires unconditionally, but the include of its declaring header (platforms/stub/time_stub.h) is gated:

#if !defined(ARDUINO) || defined(FASTLED_USE_STUB_ARDUINO)
#include "platforms/stub/time_stub.h"
#endif

On a real Arduino build there's no stub delay override to clear. Wrap the call in the same guard.

2. mcpwm_timer.cpp.hpp:54 — hal/mcpwm_ll.h volatile-binding error

IDF 5.x's mcpwm_ll.h:1598 does mcpwm_timer_cfg0_reg_t cfg0 = mcpwm->timer[i].timer_cfg0; where the field is volatile. Under C++17+ the implicit copy ctor (const T&) can't bind to volatile T& — hard error.

FastLED does not actually use any mcpwm_ll_* function. The only IDF types referenced (mcpwm_dev_t, MCPWM0, cap_chn[].val) come from soc/mcpwm_struct.h on the line above. Drop the unused include; add a comment for posterity.

Test plan

  • bash lint clean (cpp_linting + others).
  • bash test fastled_core --cpp — host smoke test still passes.
  • CI: esp_extra_libs workflow should compile cleanly.

Note

A third concern (ESP_CACHE_MSYNC_FLAG_DIR_C2M at lcd_spi_peripheral_esp.cpp.hpp:364) surfaced in an earlier triage but does NOT appear in the current failure log. rmt5_peripheral_esp.cpp.hpp already has the #ifndef ESP_CACHE_MSYNC_FLAG_DIR_C2M / #define ... 0 fallback; if CI ever surfaces the same on lcd_spi, that's a one-line follow-up to copy the pattern.

Fixes #2597

Generated with Claude Code (https://claude.com/claude-code)

Summary by CodeRabbit

  • Bug Fixes
    • Improved STM32 hardware SPI configuration logic to prevent unnecessary library inclusion during HAL detection, reducing build conflicts in certain configurations
    • Resolved build compatibility issue on specific ESP-IDF 5.x toolchain versions that was causing compilation errors
    • Fixed cleanup behavior to properly support different platform build configurations

Review Change Stack

zackees added 2 commits May 30, 2026 09:21
…E_SPI

Every `stm32h747xi_giga` (Arduino Giga R1) build on master fails:

  platforms/arm/stm32/fastspi_arm_stm32.h:11:14: fatal error: SPI.h: No such file or directory

`fastspi_arm_stm32.h` pulls in Arduino's `<SPI.h>` whenever
`HAL_SPI_MODULE_ENABLED` is set, but the Arduino mbed-os core that
drives the Giga doesn't auto-resolve `<SPI.h>` from PlatformIO's lib
finder — `SPI` has to be listed in `lib_deps`, and it isn't.

Apply the same pattern as the ESP8266 fix (#2570): also require
`FASTLED_ALL_PINS_HARDWARE_SPI` before pulling in the HAL SPI path.
Default builds fall through to bitbang. Users who want STM32 hardware
SPI define the macro and add `SPI` to their `lib_deps`.

This is a one-line FastLED-side fix; no fbuild / lib_deps wrangling
needed. Matches the existing opt-in convention.

Fixes #2595
Two distinct errors block `esp_extra_libs` (kitchensink against
pioarduino/[email protected], esp32-s3-devkitc-1):

1) `stub_main.hpp:48`: `clearDelayFunction` was not declared in scope.

   The call site fires unconditionally, but the include of
   `platforms/stub/time_stub.h` (which declares it) is gated:

       #if !defined(ARDUINO) || defined(FASTLED_USE_STUB_ARDUINO)
       #include "platforms/stub/time_stub.h"
       #endif

   On a real Arduino build there's no stub delay override to clear in
   the first place. Wrap the call in the same guard.

2) `mcpwm_timer.cpp.hpp:54`: including `hal/mcpwm_ll.h` triggers a hard
   C++ error in IDF 5.x:

       hal/mcpwm_ll.h:1598: error: binding reference of type
       'const mcpwm_timer_cfg0_reg_t&' to
       'volatile mcpwm_timer_cfg0_reg_t' discards qualifiers

   `mcpwm_ll_timer_get_clock_prescale` does a copy from a volatile
   field; the implicit copy ctor (const T&) can't bind to volatile T&
   under C++17+.

   FastLED does not actually use any `mcpwm_ll_*` function — the only
   IDF types referenced here (`mcpwm_dev_t`, `MCPWM0`, `cap_chn[].val`)
   come from `soc/mcpwm_struct.h` on the line above. Drop the unused
   include; add a comment for posterity.

Both fixes are one-line edits to FastLED code; no fbuild or IDF
changes needed. Host smoke test (`bash test fastled_core --cpp`) and
`bash lint` both pass.

Fixes #2597
@coderabbitai

coderabbitai Bot commented May 30, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 785b28b3-1435-4c5d-b7ca-f456211c3d02

📥 Commits

Reviewing files that changed from the base of the PR and between 42700b5 and 7acf584.

📒 Files selected for processing (3)
  • src/platforms/arm/stm32/fastspi_arm_stm32.h
  • src/platforms/esp/32/drivers/gpio_isr_rx/mcpwm_timer.cpp.hpp
  • src/platforms/stub_main.hpp

📝 Walkthrough

Walkthrough

This PR fixes three independent build configuration issues across platform-specific code: STM32 HAL SPI requires explicit hardware SPI opt-in, ESP32 MCPWM driver removes an IDF 5.x incompatible include, and stub engine cleanup guards a call that exists only in stub-enabled builds.

Changes

Platform-specific build configuration guards

Layer / File(s) Summary
STM32 HAL SPI inclusion guard
src/platforms/arm/stm32/fastspi_arm_stm32.h
HAL SPI enablement and <SPI.h> inclusion now require both HAL_SPI_MODULE_ENABLED and FASTLED_ALL_PINS_HARDWARE_SPI, preventing unconditional Arduino SPI header inclusion when hardware SPI is not opted into.
ESP32 MCPWM header cleanup
src/platforms/esp/32/drivers/gpio_isr_rx/mcpwm_timer.cpp.hpp
Unused hal/mcpwm_ll.h include is removed and replaced with a comment explaining it triggers C++17 qualifier-binding errors in ESP-IDF 5.x; required register types already come from soc/mcpwm_struct.h.
Stub engine cleanup conditional guard
src/platforms/stub_main.hpp
ScopedEngineCleanup destructor wraps clearDelayFunction() in a preprocessor guard matching its declaration context, ensuring the call only executes when stub delay facilities are available.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

  • #2597 — This PR directly addresses both errors documented in the issue: the clearDelayFunction undeclared error (fixed by guarding the call) and the mcpwm_ll.h volatile-reference error (fixed by removing the include).

Possibly related PRs

  • FastLED/FastLED#2596 — Implements the same STM32 HAL SPI guard fix in fastspi_arm_stm32.h to prevent unconditional <SPI.h> inclusion.
  • FastLED/FastLED#2509 — Also modifies the ESP32 MCPWM driver include setup at the same location to resolve IDF 5.x/6.x compatibility issues.

Poem

🐰 Three guards for steady light,
STM32 won't bite,
ESP32 compiles clean,
Stub code's serene,
Platform harmony takes flight! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the two main fixes: adding a guard to clearDelayFunction and removing unused hal/mcpwm_ll.h include.
Linked Issues check ✅ Passed All code changes directly address the two primary objectives from issue #2597: wrapping clearDelayFunction in preprocessor guard and removing unused mcpwm_ll.h include.
Out of Scope Changes check ✅ Passed All changes are scoped to the two specified fixes; no out-of-scope modifications to unrelated files or build systems are present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/esp-extra-libs-build

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@zackees
zackees merged commit 5d92645 into master May 30, 2026
6 of 8 checks passed
@zackees
zackees deleted the fix/esp-extra-libs-build branch May 30, 2026 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

esp_extra_libs (kitchensink) red on master: clearDelayFunction undeclared + mcpwm_ll.h volatile-reference error

1 participant