FastLED 3.9.15
Loading...
Searching...
No Matches
suppress_arduino_chip_debug_report.cpp.hpp
Go to the documentation of this file.
1#pragma once
2
3// =============================================================================
4// Suppress the Arduino-ESP32 boot-banner code path. (#2886 Stage 2 / #2893)
5//
6// On ESP32 targets, the Arduino-ESP32 core's `cores/esp32/main.cpp:43`
7// declares:
8//
9// __attribute__((weak)) bool shouldPrintChipDebugReport(void);
10//
11// and unconditionally references `printBeforeSetupInfo()` from the
12// `if (shouldPrintChipDebugReport())` branches at main.cpp:55 and :63.
13// Even at `ARDUHAL_LOG_LEVEL=0` (release default), the linker keeps
14// `printBeforeSetupInfo()` and its ~1-2 KB of formatted-stream rodata
15// alive because those call sites are reachable.
16//
17// Setting `-DFASTLED_SUPPRESS_ARDUINO_CHIP_DEBUG_REPORT=1` in build
18// flags emits a strong override of the weak vendor symbol below. The
19// optimizer folds both `if (shouldPrintChipDebugReport())` branches to
20// dead code, and `--gc-sections` drops `printBeforeSetupInfo()`
21// (~1,464 B at top-25 row #21 of #2886) plus its rodata carrier
22// strings — ~3 KB of flash on a typical ESP32-S3 NEOPIXEL build.
23//
24// USAGE (one option):
25//
26// 1. PlatformIO — in platformio.ini:
27// build_flags = -DFASTLED_SUPPRESS_ARDUINO_CHIP_DEBUG_REPORT=1
28//
29// 2. Arduino IDE — in a `build_opt.h` or compiler.cpp.extra_flags
30// override:
31// -DFASTLED_SUPPRESS_ARDUINO_CHIP_DEBUG_REPORT=1
32//
33// This is opt-in: globally overriding a vendor weak symbol on every
34// FastLED user's behalf would be surprising scope creep, and some
35// users rely on the boot banner for debugging brownouts / wake-up
36// sources / PSRAM detection.
37//
38// On non-ESP32 targets, or with the flag undefined / set to 0, this
39// file expands to nothing.
40// =============================================================================
41
42#include "platforms/esp/is_esp.h" // ok platform headers - for FL_IS_ESP32
43
44#if defined(FL_IS_ESP32) && defined(FASTLED_SUPPRESS_ARDUINO_CHIP_DEBUG_REPORT) \
45 && (FASTLED_SUPPRESS_ARDUINO_CHIP_DEBUG_REPORT)
46
47extern "C" bool shouldPrintChipDebugReport(void) { return false; }
48
49#endif // FL_IS_ESP32 && FASTLED_SUPPRESS_ARDUINO_CHIP_DEBUG_REPORT