Repository navigation
Description
Goal
Add CONFIG_NEWLIB_NANO_FORMAT=y to tools/sdkconfig_for_smallest_fastled.defaults. It's a missing entry on what's by far the biggest cluster of non-FastLED bytes in the post-#2911 ESP32-S3 NEOPIXEL Blink audit:
| Symbol | Size |
|---|---|
_vfprintf_r |
11,309 B |
_svfprintf_r |
11,118 B |
_svfiprintf_r |
7,337 B |
_vfiprintf_r |
7,265 B |
get_arg$isra$0 (×N copies) |
~4,924 B |
_dtoa_r |
3,219 B |
| Cluster total | ~45 KB |
Switching newlib to the nano variants typically drops this cluster by 50-70% — projected ~20-30 KB measured saving on ESP32-S3 NEOPIXEL Blink when the user opts into the Stage 3 overlay. That's larger than every other Stage in #2886 combined.
Parent: #2886 — Stage 3 follow-up (extends the existing overlay file shipped in #2896).
Why this is a huge missed lever
The Stage 3 overlay file shipped in #2896 currently sets:
CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH=n # libespcoredump (~8 KB)
CONFIG_LOG_DEFAULT_LEVEL=ESP_LOG_NONE # libesp_diagnostics (~3 KB)
CONFIG_BOOTLOADER_LOG_LEVEL_NONE=y # bootloader strings (~1 KB)
CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT=y # panic formatter (~1-2 KB)Each of those targets sub-1.5 KB symbol clusters. None of them touch the dominant ~45 KB libc printf cluster. This is the largest unattended lever in the entire #2886 plan.
What CONFIG_NEWLIB_NANO_FORMAT=y does
ESP-IDF ships two newlib build variants:
- Standard newlib (default): full ISO C printf / scanf — supports
%f,%lf,%lld, all the long-format specifiers, full IEEE-754 floating-point conversion. ~45 KB of symbols on ESP32-S3. - Nano newlib (
CONFIG_NEWLIB_NANO_FORMAT=y): stripped printf / scanf — no floating-point support, no%lld, no positional args, smaller_dtoa_r. ~10-20 KB.
Concretely:
_vfprintf_rcollapses to a ~3-4 KB nano variant (was 11.3 KB)._svfiprintf_r(the int-only printf, what almost all framework code actually uses) stays similar but the dual full+int implementations collapse to one._dtoa_r(double-to-ASCII) drops if no floating-point format is used.
Constraint: what nano newlib can't do
Sketches that print floating-point with printf("%.3f\n", value) will produce %.3f literal output instead of the formatted number. Same for %lld. This is a real semantic change.
Mitigation for sketches that need full printf: the user simply does not add the overlay file to board_build.sdkconfig_defaults, or they override CONFIG_NEWLIB_NANO_FORMAT=n in their own overlay layered after FastLED's.
The overlay is opt-in (it's a separate tools/sdkconfig_for_smallest_fastled.defaults file the user has to wire into board_build.sdkconfig_defaults themselves). Adding CONFIG_NEWLIB_NANO_FORMAT=y only affects users who already chose the overlay.
Deliverable
1. tools/sdkconfig_for_smallest_fastled.defaults — add the nano-newlib knob
Add to the "Conservative knobs" section (it qualifies because float printf is rare in LED installations):
# Switch newlib to nano printf/scanf variants. Drops the ~45 KB
# libc printf cluster (`_vfprintf_r`, `_svfprintf_r`, `_svfiprintf_r`,
# `_vfiprintf_r`, `_dtoa_r`, `get_arg$isra$0`) by 50-70%. Projected
# ~20-30 KB measured saving on ESP32-S3 NEOPIXEL Blink.
#
# Constraint: no `%f` / `%lf` / `%lld` printf format support. Sketches
# that print floating-point values via printf will see literal format
# specifiers in the output instead of the formatted number. Most LED
# installations don't print floats; if yours does, either drop this
# overlay or layer a `CONFIG_NEWLIB_NANO_FORMAT=n` override after it.
CONFIG_NEWLIB_NANO_FORMAT=y2. docs/SLIM_ESP32S3.md — update row 2 + add a per-stage note
Row 2's "Savings" column gets updated from ~10-15 KB to ~30-45 KB (the old per-knob breakdown + the new nano-newlib knob). The Stage 3 per-stage detail section adds the constraint sidebar.
3. agents/docs/binary-size-analysis.md — same priority-table update for the agent-facing copy
Acceptance
tools/sdkconfig_for_smallest_fastled.defaultscontains the newCONFIG_NEWLIB_NANO_FORMAT=yknob with the inline constraint comment.docs/SLIM_ESP32S3.mdrow 2 reflects the updated savings range and the per-stage detail section documents the nano constraint.agents/docs/binary-size-analysis.mdtable mirrors the SLIM update.bash lint --cpppasses (this PR doesn't touch C++).
Verification — what an opt-in measured build should show
Default-flag build (no overlay applied): no change.
Overlay-applied build (board_build.sdkconfig_defaults = tools/sdkconfig_for_smallest_fastled.defaults): the libc printf cluster shrinks by ~20-30 KB. Measured by:
uv run python tests/measure_esp32s3_opt_ins.py --config stage3(the multi-config driver shipped in #2906).
The measurement happens in a follow-up PR — this PR just adds the knob to the overlay.
Out of scope
- Re-measuring the post-overlay total flash. Follow-up PR.
- Flipping row 2 of the SLIM priority table from 📊 to ✅. Requires the measurement.
- Changing the default behavior (the overlay remains opt-in).
Related
- Meta: ESP32-S3 Blink bloat reduction (file:line concrete plan) — supersedes #2885 #2886 — parent meta + Meta: ESP32-S3 Blink bloat reduction (file:line concrete plan) — supersedes #2885 #2886#issuecomment-4641413123 / #issuecomment-4641488454 / #issuecomment-4641538602.
- docs(esp32): ship tools/sdkconfig_for_smallest_fastled.defaults overlay (#2886 Stage 3) #2896 — Stage 3 (the overlay file this PR extends).
- tools(bloat): ship tests/measure_esp32s3_opt_ins.py multi-config audit driver #2906 — multi-config measurement driver (the verification path).
- perf(esp32): gate SPI dispatch in Channel::showPixels behind FASTLED_DISABLE_SPI_CHIPSETS #2914 — most recent algorithmic-bloat PR (different angle — FastLED-side).
🤖 Generated with Claude Code
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
docs(esp32): add CONFIG_NEWLIB_NANO_FORMAT=y to Stage 3 sdkconfig ove…