fix(ci): report flash and static RAM usage separately - #28789
Conversation
Bloaty's VM total includes zero-initialized RAM and understates the combined cost of data and code copied from flash into RAM. Report the flash load image and static RAM allocations independently so the PR headline reflects each resource's actual change. Assisted-by: Codex
Assisted-by: Codex
|
Thanks for this PR @dakejahl! Claude review on behalf of @JonasPerolini Tools/ci/firmware_size.py:29 — the flash total is derived from PT_LOAD segments, which makes it depend on ld's page-size heuristic. When the first section leaves room in its page, ld puts the ELF header into the first LOAD segment, so the segment LMA starts below the flash origin. With binutils 2.34 (GCC 9 2020-q2) and the fmu-v5x flash-analysis scripts (origin 0x08008000, 64 KB max page size) the first LOAD is at 0x08000000, the region check raises "load image outside the configured flash region", and 5 of 7 tests fail. It passes on 2.42 (px4-dev container) only because the default max page size there is 4 KB; relinking on 2.34 with Tools/ci/test_firmware_size.py:117 — the CLI test runs |
|
Thanks! While we're at it:
|
The base branch tip is fetched when the job runs, so a PR merged while its job was queued was compared against itself and reported a near-zero change, and commits landed in the meantime showed up as reverted.
ld maps the ELF header into the first LOAD segment when its max page size exceeds the flash origin's alignment (binutils 2.34 defaults to 64 KiB), so segment-based accounting rejected valid firmware as outside the flash region.
Growth over 100 B and 1000 B gets yellow and red markers, savings over 100 B green, so reviewers can spot size regressions without reading the numbers.
The matrix duplicated each board's flash-analysis linker region, which would drift silently. Section headers alone distinguish code executing in place (VMA == LMA) from data copied to or reserved in RAM, and the image span matches objcopy -O binary.
Debug, symbol and string table rows only change the file size and made up most of the comment.
This would be cool. Deferring until we setup the infrastructure for automated AI reviews. |
A push that puts flash and static RAM back to zero was still rewriting the sticky comment, so a PR with no size change carried a zero report. Remove that comment instead. Fork tokens cannot delete it, so those PRs hand a delete artifact to the poster. Assisted-by: Grok:grok-4.7 Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
Existing reports can be updated when size deltas return to zero, avoiding a separate privileged deletion path. Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com> Assisted-by: Codex:gpt-6
Summary
Report separate flash and static RAM deltas while retaining Bloaty's section and symbol breakdown.
Problem
The current headline treats total VM growth as flash growth. For #28760, FMUv5x shows +7,608 B even though flash grows by +3,128 B and static RAM by +4,480 B.
Solution
Measure the flash load image and RAM allocations separately from ELF section headers, with no per-target constants: sections with VMA == LMA execute from flash, and everything else allocated counts as RAM. Initialized data and RAM code count in both totals, flash includes padding exactly as
objcopy -O binarydoes, and debug information is excluded. Program headers aren't used because, depending on ld's page size, the first LOAD segment can include the ELF header below the flash origin. Growth over 100 B is marked yellow and over 1000 B red; savings over 100 B are marked green. The Bloaty breakdown is limited to VM sizes, which drops the debug and symbol table rows. A new analysis comment is posted only when flash or static RAM changes on a target. Existing comments are updated even when every delta returns to zero.PRs are diffed against the first parent of the merge commit instead of the base branch tip. If the PR merged while the job was queued, the tip already contains it, which caused the near-zero diffs seen after merge.
Validated with eight ARM ELF tests, flash totals matching the
.binforark_fmu-v6x_defaultandpx4_fmu-v6x_flash-analysis, and the CI bloaty-action image with--domain=vm.Comment preview: #28760 linker totals; breakdown from a local fmu-v6x change adding a 4 KiB buffer
🔎 Flash and RAM Analysis
px4_fmu-v6x — Bloaty section/symbol breakdown