Skip to content

fix(stm32): guard fastspi <SPI.h> include on FASTLED_ALL_PINS_HARDWARE_SPI - #2596

Merged
zackees merged 1 commit into
masterfrom
fix/stm32-spi-h-guard
May 30, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/stm32-spi-h-guard

Conversation

@zackees

@zackees zackees commented May 30, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Every stm32h747xi_giga (Arduino Giga R1) build on master fails with fastspi_arm_stm32.h:11:14: fatal error: SPI.h: No such file or directory.
  • Root cause: the STM32H7 / Giga's stm32_hal_conf.h defines HAL_SPI_MODULE_ENABLED, so fastspi_arm_stm32.h does #include <SPI.h>. But the Arduino mbed-os core that drives the Giga doesn't auto-resolve <SPI.h> via PIO's lib finder — SPI must be listed in lib_deps, and it isn't.
  • Fix: same pattern as my earlier ESP8266 fix (fix(esp8266): guard SPI dispatch on FASTLED_ALL_PINS_HARDWARE_SPI #2570) — also require FASTLED_ALL_PINS_HARDWARE_SPI before pulling in the HAL path. Default builds get bitbang. Users who want STM32 hardware SPI define the macro AND add SPI to their lib_deps. One-line change in src/platforms/arm/stm32/fastspi_arm_stm32.h.

Fixes #2595

Test plan

  • bash lint clean.
  • CI: stm32h747xi_giga workflow should compile every example past the include error.
  • No regression on other STM32 boards (the default path that drops to bitbang is what end-users on stock STM32F* configs already get when SPI isn't in their lib_deps).

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

Summary by CodeRabbit

Bug Fixes

  • STM32 HAL builds now require explicit opt-in to use hardware SPI; default behavior is software SPI fallback.

Review Change Stack

…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
@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: 97672ad3-72c5-4e14-9cf1-6dec84c7cb0b

📥 Commits

Reviewing files that changed from the base of the PR and between 8d09b29 and be38288.

📒 Files selected for processing (1)
  • src/platforms/arm/stm32/fastspi_arm_stm32.h

📝 Walkthrough

Walkthrough

The PR tightens the conditional in fastspi_arm_stm32.h that controls HAL-based SPI initialization. Rather than unconditionally including SPI.h whenever HAL_SPI_MODULE_ENABLED is defined, the header now requires an explicit FASTLED_ALL_PINS_HARDWARE_SPI opt-in. This prevents build failures on STM32 boards (like the stm32h747xi_giga) where the SPI library is not automatically available.

Changes

STM32 HAL Hardware SPI Conditional Guard

Layer / File(s) Summary
STM32 HAL hardware SPI opt-in guard
src/platforms/arm/stm32/fastspi_arm_stm32.h
The HAL detection conditional now requires both HAL_SPI_MODULE_ENABLED and FASTLED_ALL_PINS_HARDWARE_SPI to enable hardware SPI and include SPI.h, with updated comments explaining the opt-in requirement. Default builds without the explicit opt-in fall back to software SPI.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related issues

Possibly related PRs

  • FastLED/FastLED#2570 — Implements the same gating pattern for ESP8266, protecting HAL/hardware SPI includes behind FASTLED_ALL_PINS_HARDWARE_SPI to avoid unconditional library dependencies.

Poem

🐰 A bunny hops through ifdef lands,
Where conditional guards take firm stands—
No more SPI.h when it's not there,
Just bitbang code, safe and fair!
Hardware SPI waits for opt-in blessing,
Solving our Giga R1 vexing.

🚥 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 and concisely summarizes the main change: guarding the SPI.h include behind the FASTLED_ALL_PINS_HARDWARE_SPI macro on STM32 platforms.
Linked Issues check ✅ Passed The code changes directly implement the fix specified in issue #2595: requiring both HAL_SPI_MODULE_ENABLED and FASTLED_ALL_PINS_HARDWARE_SPI before including SPI.h, enabling the bitbang fallback when hardware SPI is not explicitly opted into.
Out of Scope Changes check ✅ Passed The pull request modifies only the STM32 fastspi header file to add the macro guard, which is directly scoped to the stated objective of fixing the conditional SPI.h inclusion.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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-spi-h-guard

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 42700b5 into master May 30, 2026
5 of 7 checks passed
@zackees
zackees deleted the fix/stm32-spi-h-guard branch May 30, 2026 20:02
zackees added a commit that referenced this pull request May 30, 2026
) (#2615)

stm32h747xi_giga workflow has 44/0 fail/success on master, every recent
run dying at:

  src/platforms/arm/compile_test.hpp:78:6: error:
      #error "STM32 platforms should have FASTLED_ALLOW_INTERRUPTS set to 0"

Root cause: the gate at line 76 was

  #if defined(ARDUINO_ARCH_STM32) || defined(STM32F1)

— too broad. It fires for any platform that defines ARDUINO_ARCH_STM32,
which includes the Arduino Giga R1 (STM32H747XI). Giga runs on the
Arduino Mbed core at 480 MHz and deliberately sets

  #define FASTLED_ALLOW_INTERRUPTS 1

in its led_sysdef_arm_giga.h. That choice is correct for H7: a 480 MHz
clockless write has plenty of cycles to tolerate ISR latency, unlike
STM32F1 at 72 MHz where any interrupt mid-write disrupts WS28xx timing.

Fix: narrow the gate to exclude STM32H7 and Mbed-based STM32s:

  #if (defined(ARDUINO_ARCH_STM32) || defined(STM32F1)) \
      && !defined(STM32H7xx) \
      && !defined(FL_IS_STM32_MBED)

`FL_IS_STM32_MBED` is already defined in is_stm32.h for Mbed STM32
boards; `STM32H7xx` is a stock CMSIS define. Both are reliably present
at compile_test.hpp time.

STM32F1 / STM32F4 builds remain gated (neither exclusion macro is
defined for them) so the original safety net stays intact for the
families where the rule actually applies.

Local: bash test --cpp fl_gfx_rgbww passes.

Fixes #2614.

Refs #2596 (prior stm32h747xi_giga SPI.h fix — this is the next
compile error that surfaced once that was unblocked).
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.

stm32h747xi_giga: build fails — fastspi_arm_stm32.h pulls in <SPI.h> unconditionally on HAL detection

1 participant