Skip to content

Stage 2: Suppress Arduino-ESP32 boot banner via shim — ~3 KB (#2886) #2893

Closed

Description

@zackees

Goal

Ship a single-include shim in FastLED that suppresses the Arduino-ESP32 boot-banner code path so the linker dead-strips printBeforeSetupInfo() and its ~1-2 KB of rodata strings.

Projected savings: ~3 KB on the ESP32-S3 NEOPIXEL Blink baseline (top-25 row #21 from #2886: 1,464 B for printBeforeSetupInfo() + ~1-2 KB of carrier strings).

Parent: #2886 — Stage 2 of the multi-stage bloat-reduction plan.

Why the symbol is currently kept alive

The vendor call sites in framework-arduinoespressif32/cores/esp32/main.cpp (verified against the locally installed PIO copy of the Arduino-ESP32 core, lines 43-63):

// main.cpp:43
__attribute__((weak)) bool shouldPrintChipDebugReport(void) {
  // default impl returns true under some conditions
  ...
}

// main.cpp:52-58
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG
  printBeforeSetupInfo();
#else
  if (shouldPrintChipDebugReport()) {
    printBeforeSetupInfo();
  }
#endif

// main.cpp:60-65
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG
  // ...
#else
  if (shouldPrintChipDebugReport()) {
    // ...
  }
#endif

Even when the user has ARDUHAL_LOG_LEVEL=0 (i.e. the release default), the else branch still references printBeforeSetupInfo() and shouldPrintChipDebugReport(), so the linker keeps both alive. The "default" weak impl of shouldPrintChipDebugReport() returns truthy under common conditions, so the path is also live at runtime.

The leverage point is that shouldPrintChipDebugReport() is weak. A strong override defined in user TU is preferred by the linker over the framework's weak default, and replacing the body with return false; lets the optimizer fold the two if (shouldPrintChipDebugReport()) branches at the else site to dead code, after which --gc-sections drops printBeforeSetupInfo() and its ~292 lines of formatted-stream code.

Deliverable

Ship a single FastLED-owned shim:

  • File: src/extras/suppress_arduino_chip_debug_report.cpp.hpp
  • Content:
    // Strong override of the Arduino-ESP32 weak default in cores/esp32/main.cpp:43.
    // Returning false unconditionally lets `--gc-sections` drop
    // printBeforeSetupInfo() and its ~1-2 KB of rodata strings, saving
    // ~3 KB on release builds. See FastLED #2886 Stage 2.
    #if defined(ESP32)
    extern "C" bool shouldPrintChipDebugReport(void) { return false; }
    #endif

User integration is one line in their sketch:

#include <FastLED/extras/suppress_arduino_chip_debug_report.cpp.hpp>

The include lives outside src/FastLED.h's default surface — opt-in only, because globally overriding a vendor weak symbol on every FastLED user's behalf would be surprising scope creep. The file name encodes the action.

Why not auto-include from FastLED.h?

  1. Some users intentionally rely on the boot-info banner (debugging brownouts / wakeup sources, validating PSRAM detection).
  2. Strong-overriding a vendor weak symbol changes user-observable behavior — that belongs in an explicit opt-in, not the default.
  3. The shim is a 4-line .cpp.hpp — the integration cost is zero for users who want it.

Documentation

Acceptance

A release build of examples/Blink/Blink.ino with #include <FastLED/extras/suppress_arduino_chip_debug_report.cpp.hpp> immediately after the FastLED include shows:

  1. printBeforeSetupInfo absent from bash bloat esp32s3 output.
  2. shouldPrintChipDebugReport resolved to the FastLED shim (not the vendor weak default) — verify via xtensa-esp32s3-elf-nm on the linked ELF.
  3. Total flash decreases by ≥ 2.5 KB (target ~3 KB) versus the same sketch without the shim include.

Measurement command:

bash bloat esp32s3 --build
jq '.total_flash' .build/symbols/esp32s3/report.json
# Should be ≥ 2,500 B lower than the pre-Stage-2 baseline (388,380 B
# - 55,000 B from Stage 1 = ~333,380 B target; this stage brings it
# down another ~3 KB to ~330,380 B).

Out of scope

  • Changes to existing examples (none of the in-tree .ino sketches add the shim).
  • The Stage 0 docs/SLIM_ESP32S3.md reference page — separately tracked.
  • Auto-include from FastLED.h — explicitly opt-in per "Why not auto-include?" above.

Related

🤖 Generated with Claude Code

Activity

  1. moved this from Triage to Done in FastLED Trackeron Jun 7, 2026
  2. added a commit that references this issue on Jun 7, 2026
    80c6d98
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions