Skip to content

fix(memory): reduce stm32f103c8 default flash/RAM usage (#4737) #4744

Closed

Description

@zackees

Context

Platform sub-issue of #4737. +10,276 B flash / +240 B RAM versus 3.10.3.

Source measurements, flash / RAM in bytes, fbuild 2.5.37, per-version source/examples and constant per-board build configuration. Reference SHAs: 3.10.3 20667c3a64, 3.10.6 ebf8c2823c, master 0c2e9f7300.

example 3.10.3 3.10.6 master reference
Blink 16092 / 3248 26600 / 3672 26368 / 3488

Execution workflow

Work one checklist item and one platform sub-issue at a time across the entire #4737 project, in the existing repository checkout without git worktrees. Use a feature branch in that checkout and reuse .build/fbuild/stm32f103c8, toolchain/dependency caches and test caches. Run builds sequentially. Verify changed source/flags are reflected in the ELF; use the appropriate wrapper's --clean only when stale-output evidence requires it. Record each completed item's measurements, checks and commit/PR before moving on.

Checklist

  • Reproduce this platform's current starting measurements with recorded SHA, flags and framework versions, and verify cache validity.
  • Create matched symbol/link-map evidence using bash bloat stm32f103c8; retain both the published example and controlled RGB-workload measurements where applicable.
  • Attribute the flash gap to concrete controller/channel, dispatch, GPIO/PWM and optional-subsystem symbols.
  • Shrink unnecessary abstractions, initialization and global state while preserving required peripheral behavior.
  • Measure Blink and a controlled RGB workload; verify affected GPIO/PWM and LED APIs.
  • Land measured default flash and RAM reductions below the recorded master values for every example in this child, and quantify remaining gaps to 3.10.3.
  • Add a focused size regression check. For any implementation, capture a failing budget/reproduction before coding (RED) and the passing result afterward (GREEN); run relevant tests, lint and code review.
  • Ratchet applicable existing flash budgets and enforce RAM budgets through existing checks, preserving normal feature behavior and avoiding relaxed ceilings.
  • Publish final before/after bytes, remaining gaps, source SHA, commands, flags, framework versions and landed commit/PR links; update meta(memory): reduce default flash/RAM usage across all measured platforms #4737's platform scorecard.

Decisions

  • Default-build reductions are required; optional slim configurations supplement the work but do not satisfy this child.
  • Scope is this platform; shared fixes must be measured on affected siblings and tracked in the parent.
  • Any unmet reduction criterion needs an explicit maintainer-approved exception with exact bytes before closure.

Activity

  1. zackees commented on Oct 7, 2026

    @zackees
    MemberAuthor

    Summary

    • Reorder ColorProfileBinding and ChannelOptions members to remove padding without changing defaults, ownership or supported settings.
    • Guard compact binding storage with a focused size regression test and preserve the tiny-tier no-growth probe.
    • Add the default STM32F103C8 image-flash/attributed-RAM budget.

    Refs #4744 and #4737. Close the child after landed-master size verification and the cumulative parent comment; leave the meta open.

    Measured local evidence

    Starting master 8d6ed12ccbac48ccc9b3708b2d537ee3a2a6c921; historical 3.10.3 20667c3a6413ed46a828f78ec95fb57e58d753f8. fbuild 2.5.37, STM32duino 2.9.0, arm-none-eabi-gcc 15.2.1, identical board configuration and normal flags. Sequential builds in the existing .build/fbuild/stm32f103c8 project; no git worktrees, no CI Full.

    workload 3.10.3 flash / RAM starting master candidate savings
    published Blink 16092 / 3248 26368 / 3488 26356 / 3480 12 / 8
    controlled GPIO3, one NEOPIXEL RGB LED, no Serial 16092 / 3248 25536 / 3488 25524 / 3480 12 / 8

    Remaining historical gap: published +10264 B flash / +232 B RAM; controlled +9432 / +232. No claim of parity.

    Image flash 26368 → 26356, attributed RAM 1940 → 1932; here both reductions agree with board totals. The controller symbol shrinks 140 → 132 bytes. Host binding shrinks 80 → 72 bytes. The first binding-only candidate saved 4 attributed bytes but rounded board totals stayed flat, so it was not claimed as a completed platform reduction.

    Validation

    • 3.10.3/master fbuild bloat reports and matched symbol ledger, published and controlled examples, same framework/caches.

    • Focused binding-size test RED (80 > 72), immediately rerun with sanitizers before editing; all 52 color-profile sanitizer cases GREEN after final layout.

    • Starting master fails both new size ceilings; final candidate passes bash bloat stm32f103c8 --budget tests/data/stm32f103c8_bloat_budget.json.

    • Tiny-tier no-growth probe uses <= the frozen legacy layout; compact layouts may shrink. No thresholds raised.

    • Recompiled staged translation units with compile-only assertions to validate header changes after suspect incremental results; source/framework caches retained.

    • bash test --cpp: 319/319 unit targets and 95/95 examples passed.

    • bash lint passed; all changed files reviewed against repository code-review rules with no findings.

    All fields and source APIs remain available, including RGBW/RGBWW, emitter profiles, gamma, typed buses and bus instance selection. As usual for C++ member-layout changes, consuming code must be rebuilt together with the library; no binary-layout compatibility claim.

    Logging audit: STM32 clockless operational logging already uses categories; remaining warnings in peripheral implementations describe invalid configuration, unsupported hardware or failures. No fl::printf logging calls in STM32/channel implementation. Linked libc printf primarily remains for explicitly used Serial/framework behavior; no such features removed.

    Shared-change local verification

    already completed platform previous landed Blink flash / RAM this candidate additional savings
    C3 403232 / 68540 403210 / 68540 22 / 0
    C6 360494 / 18628 360474 / 18612 20 / 16

    Both platforms passed their existing default budgets. Image-flash ceilings are ratcheted down again (C3 385622 → 385596; C6 403818 → 403794), with no RAM ceiling raised. C6 singleton storage is not represented in attributed RAM; its board totals show the additional 16-byte saving. All platform builds run locally and sequentially.

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