Skip to content

feat(f051): build flag to compile out sine startup for flash savings (~1 KB+) #3

Description

@dakejahl

Summary

Sine startup is the single largest chunk of flash we could reclaim on the F051, but ARK boards use it, so we're keeping it enabled by default and tracking a build-flag opt-out here.

Context

Enabling LTO (#1) bought cross-TU inlining on the F051 hot path at a cost of ~2.7 KB flash. The worst-case ARK_4IN1_F051 now sits at ~92.6% of the 27 KB app region (~2 KB headroom), and we want more room for the active-phase demag work (#2).

Sine startup (use_sine_start) is a runtime setting whose code is always linked in regardless of configuration:

  • pwmSin[] table — 720 B
  • advanceincrement() — 344 B
  • plus scattered conditionals in the 20 kHz interrupt and the main loop

That's ~1 KB+ of flash. Removing the hot-loop branches would also hand a few cycles back to the commutation path, which directly helps the demag effort.

Proposal

Gate sine startup behind a target #define (e.g. DISABLE_SINE_START), defaulting to enabled so existing boards are unaffected, and turn the opt-out on only for flash-tight targets that don't need it. Measure the exact saving when implemented.

Related deferred flash levers

  • Audit the remaining signed divisions and make them unsigned to drop __divsi3 (~460 B).
  • BlueJay custom-startup-tune engine gated off on ARK F051 (~424 B) — handled alongside the F051 perf work, not part of this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions