Skip to content

docs(esp8266): correct the stale FASTLED_USE_PROGMEM claim (#743) - #3824

Merged
zackees merged 1 commit into
masterfrom
docs/issue-743-esp8266-progmem
Aug 1, 2026
Merged

zackees merged 1 commit into
masterfrom
docs/issue-743-esp8266-progmem

Conversation

@zackees

@zackees zackees commented Aug 1, 2026 •

Copy link
Copy Markdown
Member

Closes #743. Comment-only; no behavior change.

The report was right about the code, wrong about today

#743 says gradient palettes land in RAM on ESP8266, citing:

// Default to NOT using PROGMEM here
#define FASTLED_USE_PROGMEM 0

The reporter read that correctly. The comment is what's stale.

fastled_progmem.h dispatches on platform before it ever tests the flag:

#if defined(__EMSCRIPTEN__) || defined(FASTLED_TESTING) || defined(FASTLED_STUB_IMPL)
#include "platforms/null_progmem.h"
#elif defined(ESP8266)
#include "platforms/esp/8266/progmem_esp8266.h"   // <-- ESP8266 exits here
...
#else
    ...
    #if (FASTLED_USE_PROGMEM == 1)                // <-- never reached

progmem_esp8266.h maps FL_PROGMEM → real PROGMEM and FL_PGM_READ_* → real pgm_read_*. ESP8266 tables are flash-resident regardless of the 0.

Measured, not inferred

Symbols from a linked ESP8266 image:

4023ac68  T  hot_gp                    (DEFINE_GRADIENT_PALETTE, Fire2023)
40239ef0  T  myRedWhiteBluePalette_p   (TProgmemPalette16, ColorPalette)

against the section map:

section VMA region
.data 0x3ffe8000 DRAM
.rodata 0x3ffe8620 DRAM — 940 B total
.irom0.text 0x40201010 (242 KB) flash

Both palettes are in flash. RAM-resident .rodata across the entire image is under 1 KB.

Changes

Three files, comments and one #error string:

  • led_sysdefs_esp8266.h — replace the misleading one-liner with the dispatch explanation and the symbol evidence.
  • README.md — same, plus a pointer from the "Typical settings: FASTLED_USE_PROGMEM=0" line so it doesn't read as "constants in RAM".
  • compile_test.hpp — the assert stays (it's a useful drift guard), but its message now says the flag is inert instead of implying it controls placement.

I kept the assert rather than deleting it: pinning the declared value has value even when the value is inert, and flipping it to 1 would make the header claim something untrue without moving any data.

Verification

check result
bash compile esp8266 --examples ColorPalette 269475 B flash / 28012 B RAM — byte-identical to baseline
forced --defines FASTLED_USE_PROGMEM=1 still errors, with the new message
bash test --cpp --clean 359/359
bash lint clean

Note on the protected file

led_sysdefs_esp8266.h is guarded by ci/hooks/protect_platform_headers.py. I used the documented FL_AGENT_ALLOW_PROTECTED_WRITE override, deliberately and only because this is a comment-only edit to that file — flagging it so the override isn't invisible in review.

What this does not claim

The ISR flash-cache hazard, the 2019 alignment crash, and the origin of the 0 are all covered in the research writeup on the issue. Short version: the clockless output path reads zero PROGMEM and is FL_IRAM-placed; gradient palettes are 4-byte aligned via FL_ALIGN_PROGMEM; and the 0 arrived unexplained in the 2016 "ESP8266 first light" commit.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Clarified ESP8266 flash-memory behavior and platform-specific PROGMEM handling.
    • Documented that FASTLED_USE_PROGMEM is retained for compatibility and must remain set to 0.
    • Added details about flash-resident gradient palette placement.
    • Improved compile-time guidance when the setting is changed incorrectly.

#743 reported that gradient palettes land in RAM on ESP8266, citing the
comment "Default to NOT using PROGMEM here". The reporter read the code
correctly; the comment is what's wrong now.

fastled_progmem.h dispatches on platform before it tests the flag:

    #if defined(__EMSCRIPTEN__) || ...
    #include "platforms/null_progmem.h"
    #elif defined(ESP8266)
    #include "platforms/esp/8266/progmem_esp8266.h"   <-- exits here
    ...
    #else
        #if (FASTLED_USE_PROGMEM == 1)                <-- never reached

progmem_esp8266.h maps FL_PROGMEM to real PROGMEM and FL_PGM_READ_* to
real pgm_read_*, so ESP8266 tables are flash-resident regardless of the
0. Verified by symbol placement in a linked image:

    4023ac68  T  hot_gp                  (DEFINE_GRADIENT_PALETTE)
    40239ef0  T  myRedWhiteBluePalette_p (TProgmemPalette16)

both inside .irom0.text @ 0x40201010, while .data/.rodata/.bss sit at
0x3ffexxxx. RAM-resident .rodata in that whole image is 940 bytes.

So the flag is inert on ESP8266 and the header, the platform README and
the compile-time assert all implied otherwise. Comments and one #error
string only:

- led_sysdefs_esp8266.h: replace the misleading one-liner with the
  dispatch explanation and the symbol evidence.
- README.md: same, plus a pointer from the "typical settings" line so
  the FASTLED_USE_PROGMEM=0 there doesn't read as "constants in RAM".
- compile_test.hpp: the assert stays (drift guard), but its message now
  says the flag is inert rather than implying it controls placement.

No behavior change. esp8266 ColorPalette is byte-identical before and
after: 269475 B flash / 28012 B RAM. `bash test --cpp --clean` 359/359,
`bash lint` clean. Confirmed the assert still fires with the new text
when FASTLED_USE_PROGMEM=1 is forced.

Note: led_sysdefs_esp8266.h is guarded by ci/hooks/protect_platform_headers.py;
edited via the documented FL_AGENT_ALLOW_PROTECTED_WRITE override, as this
is a comment-only change to that file.

Closes #743

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: 53e805c5-7667-44ca-b746-fb951da45e9b

📥 Commits

Reviewing files that changed from the base of the PR and between 7af0c5a and 03b62e3.

📒 Files selected for processing (3)
  • src/platforms/esp/8266/README.md
  • src/platforms/esp/8266/led_sysdefs_esp8266.h
  • src/platforms/esp/compile_test.hpp

📝 Walkthrough

Walkthrough

The ESP8266 documentation now explains platform-selected PROGMEM support, flash placement, gradient palette linking, and the compatibility value of FASTLED_USE_PROGMEM. The compile-time diagnostic now explains why setting the flag to 1 fails.

Changes

ESP8266 PROGMEM behavior

Layer / File(s) Summary
Document PROGMEM dispatch and validation
src/platforms/esp/8266/README.md, src/platforms/esp/8266/led_sysdefs_esp8266.h, src/platforms/esp/compile_test.hpp
The documentation describes flash-backed PROGMEM support and .irom0.text placement. The compile-time assertion retains its existing condition and clarifies the error message for nonzero FASTLED_USE_PROGMEM values.

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

Possibly related PRs

  • FastLED/FastLED#3815: Documents related ESP8266 flash and PROGMEM behavior in different files and code paths.
✨ 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 docs/issue-743-esp8266-progmem

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 31516ff into master Aug 1, 2026
10 of 11 checks passed
@zackees
zackees deleted the docs/issue-743-esp8266-progmem branch August 1, 2026 20:52
@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.

Gradient palettes get stored in RAM on ESP8266

1 participant