Skip to content

build: expand SIZE_OPTIMISED_SRC to cover init/config/telemetry paths - #1330

Draft
nerdCopter wants to merge 11 commits into
emuflight:masterfrom
nerdCopter:build/size-optimised-src-expand
Draft

build: expand SIZE_OPTIMISED_SRC to cover init/config/telemetry paths#1330
nerdCopter wants to merge 11 commits into
emuflight:masterfrom
nerdCopter:build/size-optimised-src-expand

Conversation

@nerdCopter

@nerdCopter nerdCopter commented Jul 24, 2026

Copy link
Copy Markdown
Member

AI Generated pull-request

Closes #1221

Change

Adds 41 files to SIZE_OPTIMISED_SRC in make/source.mk, forcing -Os instead of default
optimization on init/config/telemetry paths not on the gyro/PID control loop. Build-flag-only
change — no source logic modified in any listed file.

  • Flash drivers (5): drivers/flash.c, drivers/flash_m25p16.c, drivers/flash_w25m.c, drivers/flash_w25n.c, drivers/flash_w25q128fv.c
  • Telemetry (12): telemetry/telemetry.c, telemetry/crsf.c, telemetry/ghst.c, telemetry/srxl.c, telemetry/frsky_hub.c, telemetry/hott.c, telemetry/jetiexbus.c, telemetry/smartport.c, telemetry/ltm.c, telemetry/mavlink.c, telemetry/msp_shared.c, telemetry/ibus.c, telemetry/ibus_shared.c
  • GPS/navigation (3): io/gps.c, flight/gps_rescue.c, flight/position.c
  • Rangefinder (3): drivers/rangefinder/rangefinder_hcsr04.c, drivers/rangefinder/rangefinder_lidartf.c, sensors/rangefinder.c
  • Sensor init (3): sensors/initialisation.c, sensors/barometer.c, sensors/compass.c
  • Display/IO (10): io/ledstrip.c, io/pidaudio.c, io/rcdevice.c, io/rcdevice_cam.c, io/displayport_max7456.c, io/displayport_msp.c, io/displayport_hdzero_osd.c, io/displayport_oled.c, io/displayport_srxl.c, io/displayport_crsf.c
  • CMS menus (2): cms/cms_menu_failsafe.c, cms/cms_menu_gps_rescue.c
  • Other (3): sensors/esc_sensor.c, drivers/camera_control.c, io/vtx_beesign.c

All 41 paths verified present in upstream/master @ 7651c15373 by direct filesystem check —
not taken from the issue's original file list, since master may have moved files since filing.

Why these are safe for -Os

Task-rate check in fc/fc_tasks.c: TASK_GPS 100 Hz, TASK_ALTITUDE 40 Hz, TASK_TELEMETRY
250 Hz polling — all well below the gyro/PID hot loop (TASK_GYROPID/TASK_ACC up to 1000 Hz+).
GPS rescue only runs during an active rescue, not steady-state flight. None of the added files
are in SPEED_OPTIMISED_SRC (pid/gyro/imu/mixer/scheduler/rx hot paths, DMA/SPI/timer drivers)
and none overlap with the existing SIZE_OPTIMISED_SRC entries.

findstring-based compile-rule matching checked for accidental substring collisions (e.g.
drivers/flash.c cannot match drivers/flash_m25p16.c — the search requires .c immediately
after flash); none found.

Measured flash/RAM delta

arm-none-eabi-size (xpack GCC 9.3.1, pinned by make/tools.mk), before = upstream/master @
7651c15373, after = this branch. Flash = .text + .data; RAM = .data + .bss.

Target Flash before Flash after Flash Δ RAM before RAM after RAM Δ
HELIOSPRING 380340 372047 -8293 B 112812 112776 -36 B
TMOTORF7 404855 396987 -7868 B 98672 98640 -32 B
MATEKF411 371913 365221 -6692 B 80676 80680 +4 B
WORMFC 381470 374013 -7457 B 97700 97652 -48 B

Flash reduction ~6.7-8.3 KB per target — at/slightly above the issue's own 3-8 KB/512KB-target
estimate. RAM flat, as expected (-Os affects code gen, not data layout).

Build verification

make clean && CCACHE_DISABLE=1 make test: 39/39 unit test binaries PASS, 0 compiler warnings,
0 errors. (One pre-existing, unrelated /usr/bin/ld: ... LOAD segment with RWX permissions
warning appears on host test binaries — confirmed unrelated: src/test/Makefile uses clang
for host tests and does not reference SIZE_OPTIMISED_SRC at all.)

Bench targets (HELIOSPRING TUNERCF405 SKYSTARSF405AIO PYRODRONEF7 FOXEERF722V4 FOXEERF405 APEXF7 TMOTORF7): 8/8 succeeded, 0 warnings, 0 errors, CCACHE_DISABLE=1.

Compile-only targets (MATEKF411 NBDHMBF4PRO WORMFC ALIENWHOOPF7 CRAZYFLIE2): 5/5 succeeded,
0 warnings, 0 errors, CCACHE_DISABLE=1.

Scope note vs. BF 4.5-maintenance

BF 4.5-maintenance's own SIZE_OPTIMISED_SRC (mk/source.mk) is narrower — it does not force
-Os on telemetry, GPS, rangefinder, flash drivers, displayport drivers, ledstrip.c,
pidaudio.c, rcdevice*.c, camera_control.c, or vtx_beesign.c. This change is an
EF-original flash-budget optimization (issue #1221), not a BF-parity backport.

Review status

Local coderabbit review --agent --base upstream/master -c AGENTS.md hit an external rate
limit on first attempt; not re-run before opening this PR. Self-review performed (see above).

Summary by CodeRabbit

  • Performance
    • Expanded size-optimized builds to include additional hardware and communication support, including flash storage, telemetry protocols, GPS rescue, rangefinders, sensors, displays, LED and audio controls, camera interfaces, ESC monitoring, and video transmitters.
    • These capabilities are now more consistently available in compact firmware builds.

Adds 41 files to SIZE_OPTIMISED_SRC in make/source.mk, forcing -Os
instead of default optimization on cold paths not on the gyro/PID
control loop: flash drivers (5), telemetry protocols (12), GPS/
gps_rescue/position (3), rangefinder (3), sensor init (3), display/
IO drivers (10), CMS menus (2), esc_sensor/camera_control/vtx_beesign
(3). Build-flag-only change, no source logic modified.

Files verified present at listed paths in upstream/master @ 7651c15
(not the issue's original file list, since master may have moved
files since filing). Task-rate check in fc/fc_tasks.c confirms
TASK_GPS (100Hz), TASK_ALTITUDE (40Hz), TASK_TELEMETRY (250Hz
polling) are all below the gyro/PID hot loop.

Measured flash delta (arm-none-eabi-size, xpack GCC 9.3.1) vs
upstream/master:
- HELIOSPRING: -8293 B
- TMOTORF7: -7868 B
- MATEKF411: -6692 B
- WORMFC: -7457 B
RAM flat (+/-50 B).

make clean && CCACHE_DISABLE=1 make test: 39/39 unit test binaries
PASS, 0 warnings, 0 errors. Bench targets (HELIOSPRING TUNERCF405
SKYSTARSF405AIO PYRODRONEF7 FOXEERF722V4 FOXEERF405 APEXF7 TMOTORF7):
8/8 succeeded. Compile-only targets (MATEKF411 NBDHMBF4PRO WORMFC
ALIENWHOOPF7 CRAZYFLIE2): 5/5 succeeded. Zero warnings/errors across
both sets under CCACHE_DISABLE=1.

Closes emuflight#1221

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 729dbbc9-5cd3-40dd-867d-dcef8753ffba

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

make/source.mk expands SIZE_OPTIMISED_SRC with additional flash, telemetry, GPS, sensor initialization, display, CMS, ESC sensor, camera, and VTX modules.

Changes

Size-optimized source coverage

Layer / File(s) Summary
Add cold-path modules to size-optimized builds
make/source.mk
Adds flash drivers, telemetry implementations, GPS and rescue code, rangefinder and sensor initialization modules, display and device interfaces, CMS menus, ESC sensor support, camera control, and Beesign VTX sources to SIZE_OPTIMISED_SRC.

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the change to expand SIZE_OPTIMISED_SRC for init/config/telemetry paths.
Description check ✅ Passed The description is detailed and covers the change, rationale, measurements, validation, and issue linkage.
Linked Issues check ✅ Passed The PR adds the exact cold-path files requested in #1221 and avoids the hot-path categories called out as off-limits.
Out of Scope Changes check ✅ Passed No unrelated code changes are indicated beyond the requested SIZE_OPTIMISED_SRC build-flag expansion.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nerdCopter

Copy link
Copy Markdown
Member Author

AI generated comment

@coderabbitai review

Local coderabbit review --agent could not complete during implementation — hit persistent free-tier rate-limiting. Change is build-flag-only: 41 files added to SIZE_OPTIMISED_SRC in make/source.mk, no source logic touched. make test 39/39, bench targets 8/8, compile-only targets 5/5, all zero warnings under CCACHE_DISABLE=1. Measured flash savings 6.7-8.3KB across HELIOSPRING/TMOTORF7/MATEKF411/WORMFC, RAM flat. Requesting a full review since no automated review has run on this PR yet.

@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown

@nerdCopter: Starting a full review of #1330, including the SIZE_OPTIMISED_SRC changes and their build-rule interactions.

✅ Action performed

Full review finished.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

build: expand SIZE_OPTIMISED_SRC to cover init/config/telemetry paths not yet on -Os

1 participant