Skip to content

fix(stm32): priority-gate core detection so Mbed-on-STM32H7 (GIGA R1) builds (Closes #2784) - #2785

Merged
zackees merged 1 commit into
masterfrom
fix/stm32-giga-core-detection-priority
Jun 5, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/stm32-giga-core-detection-priority

Conversation

@zackees

@zackees zackees commented Jun 5, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes the `build_giga_r1.yml` workflow (Arduino GIGA R1 / `stm32h747xi`) by making STM32 core detection priority-aware. Closes #2784.

What's broken

`platforms/arm/stm32/core_detection.h` defines five per-core flags (STM32duino, Zephyr, Mbed, LibMaple, Particle) and asserts `_FL_STM32_CORE_COUNT <= 1`. Each flag was set unconditionally from its identifier macros — but Arduino frameworks define each other's compat identifiers:

  • Mbed-on-STM32H7 (Arduino GIGA R1) defines both `ARDUINO_ARCH_MBED` AND `ARDUINO_ARCH_STM32`, and its CMSIS layer pulls in `STM32_MCU_SERIES` for HAL register configuration.

Count went to ≥2 → hard `#error` → CI red.

The elif chain in the same file already resolves the ambiguity correctly (Zephyr > Mbed > STM32duino > LibMaple > Particle) — only the validation count was wrong.

What this PR changes

Each per-core flag now mirrors the elif priority: each lower-priority core counts only when no higher-priority core is also detected. Same change drops the redundant `F_CPU` redefinition warning from `led_sysdef_arm_giga.h` by guarding with `#ifndef`.

The validation's intent — catch genuine misconfigurations (two unrelated cores' libraries linked into one image with neither winning by priority) — is preserved. Legitimate single-core builds where the framework supplies compat identifiers now compile cleanly.

Test plan

Verified locally with `bash compile`:

```
PASS stm32h747xi (Arduino GIGA R1 / Mbed-on-STM32H7 — previously broken)
PASS stm32f103c8 (bluepill / STM32duino — regression guard)
PASS stm32f103cb (maple mini / STM32duino — regression guard)
PASS stm32f103tb (tinystm / STM32duino — regression guard)
PASS stm32f411ce (blackpill / STM32duino — regression guard)
PASS nucleo_f429zi (Nucleo F429 / STM32duino — regression guard)
PASS nucleo_f439zi (Nucleo F439 / STM32duino — regression guard)
```

`bash lint` clean.

Scope

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Fixed ARM Giga board configuration to respect external CPU frequency settings from the build environment
    • Improved STM32 board framework detection with proper priority handling to prevent conflicts when multiple frameworks are detected

… builds

`platforms/arm/stm32/core_detection.h` validates `_FL_STM32_CORE_COUNT <= 1`
across five per-core flags (STM32duino, Zephyr, Mbed, LibMaple, Particle).
Each flag was set unconditionally from its identifier macros, but Arduino
frameworks define each other's compat identifiers — Mbed-on-STM32H7 (the
Arduino GIGA R1 toolchain) defines BOTH `ARDUINO_ARCH_MBED` AND
`ARDUINO_ARCH_STM32`, and its CMSIS layer pulls in `STM32_MCU_SERIES` for
HAL register configuration. The count went to ≥2 and the hard `#error`
fired, breaking `bash compile stm32h747xi` and the `build_giga_r1.yml`
GitHub Actions workflow.

The elif chain in the same file already resolved the ambiguity correctly
by priority (Zephyr > Mbed > STM32duino > LibMaple > Particle) — only the
validation count was wrong.

Make each per-core flag mirror the elif priority: each lower-priority core
counts only when no higher-priority core is detected. This preserves the
validation's ability to catch genuine misconfigurations (two unrelated
cores' libraries linked into one image) while letting legitimate Mbed,
Zephyr, etc. builds compile cleanly.

Same change drops the redundant `F_CPU` redefinition warning from
`platforms/arm/giga/led_sysdef_arm_giga.h:39` by guarding with `#ifndef`.

Verified locally with `bash compile`:

  PASS  stm32h747xi     (Arduino GIGA R1 / Mbed-on-STM32H7 — previously broken)
  PASS  stm32f103c8     (bluepill / STM32duino — regression guard)
  PASS  stm32f103cb     (maple mini / STM32duino — regression guard)
  PASS  stm32f103tb     (tinystm / STM32duino — regression guard)
  PASS  stm32f411ce     (blackpill / STM32duino — regression guard)
  PASS  nucleo_f429zi   (Nucleo F429 / STM32duino — regression guard)
  PASS  nucleo_f439zi   (Nucleo F439 / STM32duino — regression guard)

`bash lint` clean.

Closes #2784

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Jun 5, 2026 •

Copy link
Copy Markdown

Review Change Stack

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: e2ae79ba-f038-429e-998b-07ef8a9ea33c

📥 Commits

Reviewing files that changed from the base of the PR and between 8c87cbf and ef21c5a.

📒 Files selected for processing (2)
  • src/platforms/arm/giga/led_sysdef_arm_giga.h
  • src/platforms/arm/stm32/core_detection.h

📝 Walkthrough

Walkthrough

This PR updates ARM platform macro definitions to enforce cleaner build-environment integration. The Giga header now uses #ifndef to guard F_CPU so external definitions take precedence, and the STM32 core detection refactors framework-selection logic to be mutually exclusive via priority ordering, preventing legacy identifiers from interfering when multiple framework macros coexist.

Changes

Platform Macro Guarding and STM32 Core Priority

Layer / File(s) Summary
Giga F_CPU conditional definition
src/platforms/arm/giga/led_sysdef_arm_giga.h
F_CPU is now conditionally defined only when not already provided by the build environment, allowing toolchain-supplied values to take precedence over the default 480000000.
STM32 core detection priority ordering
src/platforms/arm/stm32/core_detection.h
Per-core detection macros are refactored to apply a fixed priority (Zephyr > Mbed > STM32duino > LibMaple > Particle), ensuring only one core is detected even when multiple framework-related macros are defined, and tightening legacy identifier handling to not interfere with modern frameworks.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Possibly related PRs

  • FastLED/FastLED#2678: Both PRs modify src/platforms/arm/stm32/core_detection.h's STM32 framework/core selection macros at the same code level (main PR adds mutually exclusive priority-gating; retrieved PR adds ArduinoCore-zephyr/UNO Q routing).
  • FastLED/FastLED#2615: Both PRs adjust STM32/Mbed/Giga-related compile-time macro selection used downstream for gating (main PR changes STM32 core detection and Giga sysdef behavior; retrieved PR narrows interrupt-off gating using STM32H7/Mbed/Giga identifiers).

Poem

🐰 A rabbit hops through macro maze,
Untangling frameworks in a haze.
With priorities clear as spring morning dew,
One core selected—conflict-free and true! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: priority-gating STM32 core detection to fix a Mbed-on-STM32H7 (GIGA R1) build failure, with a clear reference to the issue being resolved.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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/stm32-giga-core-detection-priority

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 5d27167 into master Jun 5, 2026
7 checks passed
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 5, 2026
@zackees
zackees deleted the fix/stm32-giga-core-detection-priority branch August 21, 2026 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

broken build: stm32h747xi_giga — multiple STM32 cores detected (Mbed + CMSIS-imported STM32_MCU_SERIES)

1 participant