Skip to content

Stage 3 extension: add CONFIG_NEWLIB_NANO_FORMAT=y (~20-30 KB) (#2886) #2915

Closed

Description

@zackees

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:

  1. 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.
  2. 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_r collapses 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=y

2. 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

  1. tools/sdkconfig_for_smallest_fastled.defaults contains the new CONFIG_NEWLIB_NANO_FORMAT=y knob with the inline constraint comment.
  2. docs/SLIM_ESP32S3.md row 2 reflects the updated savings range and the per-stage detail section documents the nano constraint.
  3. agents/docs/binary-size-analysis.md table mirrors the SLIM update.
  4. bash lint --cpp passes (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

🤖 Generated with Claude Code

Activity

  1. added a commit that references this issue on Jun 7, 2026
    5ca722e
  2. moved this from Triage to Done in FastLED Trackeron Jun 7, 2026
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