Skip to content

AVR: remaining Nano sketch growth vs 3.10.3 (+1.5 KB flash, +137 B RAM) and the RGBW power-estimate opt-in #4735

Open

Description

@zackees

Context

A user on a Nano (PlatformIO nanoatmega328) reported a large size regression with a simple sketch: gist 52ded62f. It is one NEOPIXEL on pin 6, 8 LEDs, setDither(false), setCorrection(TypicalLEDStrip), setBrightness, setMaxPowerInVoltsAndMilliamps(5, 400), set_max_power_indicator_LED(13) and FastLED.delay.

Reproduced exactly with fbuild (the gist plus the two prototypes the .ino preprocessor generates):

version flash RAM
3.10.3 5,096 B 163 B
3.10.6 (as reported) 9,704 B 496 B
master after #4730 8,874 B 317 B
master after #4734 6,570 B 300 B

The reduction came from #4730 (Serial linked only when a sketch uses it) and #4734 (32-bit limiter math, RGBW conversion and colour-profile code no longer linked into RGB-only sketches).

Remaining gap vs 3.10.3: about +1.5 KB flash, +137 B RAM

Each item below needs a decision, because shrinking it changes behaviour or drops a feature on the small tier:

  1. Dither reserve in the power limiter, ~330 B flash. Dither is a runtime setting (setDither(false) here), so it can't be removed at compile time. Option: a compile-time opt-out for small tiers, or a cheaper reserve calculation.
  2. Fixed-baseline and step-down limiter logic (Meta: color-pipeline review findings burndown (R1–R10, D1) #4156), part of the remaining flash. These are correctness fixes. Measure the exact cost and whether a smaller equivalent form exists.
  3. set_max_power_indicator_LED pin path, ~160 B flash (fl::Pin::_init, isSelected, digitalWrite, vtable for fl::Pin). This is the new fl::Pin abstraction compared with 3.10.3's direct pin write. Option: a direct-write fast path on AVR with identical pin behaviour.
  4. Controller object, 89 B vs 24 B in 3.10.3 (+65 B RAM). It holds the white-channel, gamma and colour-profile settings (ChannelOptions mSettings). Option: on !FL_PLATFORM_HAS_LARGE_MEMORY, store only what the tier can use, or move rarely used settings out of line.
  5. Controller vtables, +60 B RAM (CLEDController, ClocklessController, NEOPIXEL). On AVR, vtables live in RAM. Check which virtuals were added since 3.10.3 and whether the small tier needs them.

Correctness follow-up from #4734

An RGBW power-estimate opt-in is now required. The limiter reaches the RGBW estimate only after fl::detail::enable_rgbw_power_estimate() runs, which setRgbw() and all in-tree Channel paths (applyWhiteCfg) do. A third-party CLEDController subclass that writes mSettings' RGBW config directly, without calling setRgbw, would be charged as plain RGB. That under-counts power, because the white channel isn't counted, so the limiter could allow more current than the supply budget. No in-tree controller does this, and it is documented in cled_controller.h. Options: make mSettings private behind setters, or have a debug-build check that flags an RGBW config when the estimate is disabled.

Not reproduced: "a lot of yellow warnings" with 3.10.6 on PlatformIO

The reporter saw many warnings compiling this sketch with 3.10.6 under PlatformIO. fbuild builds showed none at 3.10.3, 3.10.6 or master, but fbuild may filter or suppress warnings differently, and PlatformIO is banned in-repo so I couldn't compare directly. Next step: ask the reporter for a few of the warning lines, then check whether they come from FastLED headers (#pragma message / #warning / -W diagnostics) and whether master still emits them.

Acceptance

  • The reporter's sketch measured on nanoatmega328 per item, with each change behaviour-preserving or explicitly approved.
  • AVR size ceilings ratcheted down (never up) per docs/SIZE_THRESHOLD_HISTORY.md.
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