Skip to content

fix(esp8266): probe <SPI.h> in the guard that admits the Arduino SD backend - #3815

Merged
zackees merged 1 commit into
masterfrom
fix/esp8266-sd-spi-guard
Aug 1, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/esp8266-sd-spi-guard

Conversation

@zackees

@zackees zackees commented Aug 1, 2026 •

Copy link
Copy Markdown
Member

ESP8266 does not build at all on master. Found while trying to compile an example to investigate #743.

fs_sdcard_arduino.cpp.hpp:12:10: fatal error: SPI.h: No such file or directory

Cause

src/fl/system/sd/fs_sdcard_arduino.cpp.hpp:9 guarded the Arduino SD backend on two headers, then included a third unconditionally:

#if !defined(FL_IS_TEENSY) && FL_HAS_INCLUDE(<SD.h>) && FL_HAS_INCLUDE(<fs.h>)

// IWYU pragma: begin_keep
#include <SPI.h>

ESP8266 satisfies both probed terms — and <fs.h> for a reason that has nothing to do with SD cards, since the ESP8266 core ships its own unrelated <fs.h> for the flash filesystem. So the block was admitted, and then failed on the one header the guard never checked.

Adding <SPI.h> to the condition is the whole fix. Every header a block includes has to be in the condition that admits it.

Blast radius is one-directional. This only adds a term that is already true on platforms that have SPI.h, so they are unaffected. Platforms that lack it lose a block that could not compile there anyway.

Validation (local, per the skip-GHA-for-src workflow)

check result
bash compile esp8266 --examples ColorPalette on master fails — fatal error: SPI.h
bash compile esp8266 --examples ColorPalette here succeeds (4m50s)
bash test --cpp 359/359 unit + examples
bash lint no blocking violations

Context: this was found investigating #743

#743 (2019) reports gradient palettes landing in RAM on ESP8266 because FASTLED_USE_PROGMEM defaults to 0. While set up to check that, I confirmed the platform simply didn't compile.

For the record, since it settles #743 — objdump on the linked ESP8266 image from this branch:

40239f70 g  O .irom0.text  00000040 PartyColors_p
4023a030 g  O .irom0.text  00000040 CloudColors_p

.irom0.text is flash. The palettes are not in RAM.

The reason the setting says otherwise is that it is not consulted on ESP8266 at all. src/fastled_progmem.h:8 dispatches on defined(ESP8266) before it ever tests FASTLED_USE_PROGMEM, so progmem_esp8266.h is included unconditionally and maps FL_PROGMEM / FL_PGM_READ_* onto the real pgm_read_* accessors regardless of the value. Setting it to 0 or 1 does not move a byte. The reporter read # define FASTLED_USE_PROGMEM 0 and drew the only reasonable conclusion from it.

I did not correct that value here: led_sysdefs_esp8266.h is behind the protect_platform_headers hook, and overriding a deliberate guardrail for a documentation-grade change wants explicit sign-off rather than my judgement. Left as a note on #743 instead.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Prevented compilation issues when the required SPI header is unavailable in Arduino SD-card builds.

…ackend

ESP8266 did not build at all:

  fs_sdcard_arduino.cpp.hpp:12:10: fatal error: SPI.h: No such file or
  directory

The guard admitting this block tested <SD.h> and <fs.h>, then included
<SPI.h> unconditionally a few lines later. ESP8266 satisfies the first
two -- its core ships an unrelated <fs.h> for the flash filesystem, so
the probe passes for a reason that has nothing to do with SD cards --
while SPI was not on the include path. The block was admitted and then
failed on the one header the guard never checked.

Add <SPI.h> to the condition. Every header a block includes has to be in
the condition that admits it.

Platforms that do have SPI.h are unaffected: this only adds a term that
is already true for them. Platforms that lack it lose a block that could
not compile there anyway.

Verified locally: `bash compile esp8266 --examples ColorPalette` fails on
master and succeeds here; `bash test --cpp` 359/359; `bash lint` clean.

Co-Authored-By: Claude <[email protected]>
@coderabbitai

coderabbitai Bot commented Aug 1, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 1ddaf5d4-b3d5-41da-94f7-f1d5778394c0

📥 Commits

Reviewing files that changed from the base of the PR and between c435187 and 4ce82e9.

📒 Files selected for processing (1)
  • src/fl/system/sd/fs_sdcard_arduino.cpp.hpp

📝 Walkthrough

Walkthrough

The Arduino SD-card implementation guard now checks for <SPI.h> in addition to <SD.h> and <fs.h> before compiling the implementation.

Changes

Arduino SD-card compatibility

Layer / File(s) Summary
Require SPI header availability
src/fl/system/sd/fs_sdcard_arduino.cpp.hpp
The inclusion guard now requires <SPI.h> as well as <SD.h> and <fs.h>.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Possibly related PRs

✨ 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/esp8266-sd-spi-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.

@zackees
zackees merged commit 8e550aa into master Aug 1, 2026
10 of 12 checks passed
@zackees
zackees deleted the fix/esp8266-sd-spi-guard branch August 1, 2026 18:12
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Aug 1, 2026
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Aug 1, 2026
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.

1 participant