Skip to content

fix(esp32): pass PlatformIO's SDK defines on 2.x-layout frameworks - #1552

Merged
zackees merged 2 commits into
mainfrom
fix/esp32-pio-cppdefines
Sep 28, 2026
Merged

zackees merged 2 commits into
mainfrom
fix/esp32-pio-cppdefines

Conversation

@zackees

@zackees zackees commented Sep 28, 2026

Copy link
Copy Markdown
Member

Fixes #1549. Found while benchmarking #1537, whose pinned stack is exactly this layout.

Problem

arduino-esp32 2.x SDKs (tools/sdk/<mcu>/ with no flags/, e.g. espressif32@6.13.0) ship no flags/defines. get_sdk_defines therefore returned nothing, and every TU was compiled without the SDK CPPDEFINES PlatformIO passes: ESP_PLATFORM, IDF_VER, MBEDTLS_CONFIG_FILE, _GNU_SOURCE, HAVE_CONFIG_H, WITH_POSIX, UNITY_INCLUDE_CONFIG_H, _POSIX_READER_WRITER_LOCKS.

The visible symptom: FastLED does not compile. taskENTER_CRITICAL(&mux) only takes an argument #ifdef ESP_PLATFORM, so the build fails with macro "taskENTER_CRITICAL" passed 1 arguments, but takes just 0.

Fix

  • When flags/defines is absent, get_sdk_defines falls back to the CPPDEFINES block of tools/platformio-build-<mcu>.py, the same source parse_pio_cpppath already uses for include dirs.
  • It emits only literal, SDK-level entries, in the raw flags/defines form (-DIDF_VER=\"v4.4.7-dirty\").
  • It skips entries computed from the SCons env ($BOARD_F_CPU, %-formatted), and the Arduino/board-level names (ARDUINO*, ESP32, F_CPU) that fbuild already derives from the board. Duplicating those would trigger "redefined" warnings.
  • Fast path: Esp32FingerprintMetadata now includes the SDK defines. Before, the fingerprint ignored them (a user_flags vector was built and then dropped), so a build after this change, or after any framework change to defines, replayed the old firmware until a source file changed. That was reproduced locally before the fix.

Out of scope, noted: PlatformIO's script also sets ARDUINO=10812 (fbuild passes 10808) and ARDUINO_PARTITION_<name>. Those are board-level and unchanged here.

Verification

  • FastLED DemoReel100 on esp32s3 / espressif32@6.13.0 now builds with no build_flags workaround.
  • bench/blink: the first build after the change recompiles with all 8 SDK defines, and the next warm build is 51 ms (fast path).
  • Tests:
    • pio_cppdefines_yield_the_sdk_defines_in_flags_defines_form runs against the real block;
    • fallback-without-flags/defines and flags-file-wins cases;
    • sdk_defines_change_fast_path_metadata.

arduino-esp32 2.x SDKs ship no flags/defines, so get_sdk_defines returned
nothing and every compile lacked ESP_PLATFORM, IDF_VER,
MBEDTLS_CONFIG_FILE, _GNU_SOURCE and friends -- FastLED failed to build
(taskENTER_CRITICAL takes its argument only #ifdef ESP_PLATFORM). Fall
back to the CPPDEFINES block of the framework's platformio-build-<mcu>.py,
as include dirs already do, keeping only literal SDK-level entries.

The ESP32 fast-path fingerprint now includes the SDK defines; before, a
change to them replayed the previous firmware until a source changed.

Fixes #1549.
@coderabbitai

coderabbitai Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 7 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository: FastLED/fbuild/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 3d3871c7-9313-4dd2-af20-37955588192e

📥 Commits

Reviewing files that changed from the base of the PR and between 83dc147 and 0b8cf81.

📒 Files selected for processing (5)
  • crates/fbuild-build-esp/src/esp32/orchestrator/build.rs
  • crates/fbuild-build-esp/src/esp32/orchestrator/fingerprint.rs
  • crates/fbuild-library/src/library/esp32_framework/parsing.rs
  • crates/fbuild-library/src/library/esp32_framework/sdk_paths.rs
  • crates/fbuild-library/src/library/esp32_framework/tests.rs

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.

@zackees
zackees merged commit 3169dbc into main Sep 28, 2026
19 checks passed
@zackees
zackees deleted the fix/esp32-pio-cppdefines branch September 28, 2026 20:05
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Sep 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

fix(esp32): 2.x-layout frameworks get none of PlatformIO's CPPDEFINES (ESP_PLATFORM missing; FastLED fails on espressif32@6.13.0)

1 participant