Skip to content

feat(build): report flash and RAM footprint after a build - #71

Open
srpatcha wants to merge 1 commit into
masterfrom
feat/build-footprint-report
Open

feat(build): report flash and RAM footprint after a build#71
srpatcha wants to merge 1 commit into
masterfrom
feat/build-footprint-report

Conversation

@srpatcha

Copy link
Copy Markdown
Member

The MLP developer walk in the platform design document ends with a build that says how much of the board it used:

Flash: 384 KB
RAM:    72 KB
Ready to flash.

Nothing produced those numbers. A developer had to run size themselves and remember which columns to add — that is not being told, it is being left to find out.

$ ebuild build
[ok] Build completed successfully.

  Flash:     1.9 KB  of    1.00 MB  (0.2%)
  RAM  :   300.6 KB  of   192.0 KB  (156.6%)
[warn] RAM usage 300.6 KB exceeds the board's 192.0 KB -- this image will not fit.

Accounting

Matches scripts/measure_footprint.py in the eos repo, so the two tools cannot disagree about what a number means:

flash = text + data
ram   = data + bss

data is charged to both — it is stored in flash and copied to RAM at startup. Reading size's dec column instead understates RAM.

Where capacity comes from

The project's own board.yaml memory.flash_size / ram_size when it ships one — the convention the descriptions under hardware/board/ already use — otherwise a table of the reference part per board family.

Boards that boot from removable storage, and Linux-class parts with no fixed budget, are deliberately absent. A percentage against a guessed ceiling reads as authoritative; those report absolute sizes only.

Decisions worth reviewing

  • Over budget is a warning, not a failure. The image linked. It will not fit. That is better heard now than from a board that will not boot.
  • A cross build never falls back to the host size. Host size on an ARM ELF reports numbers for a different target and nothing in the output would say so. No tool → no report, rather than a wrong one.
  • A footprint that cannot be measured never fails the build. It is a missing convenience, not a defect in the user's code.

Also fixes .gitignore — found while committing this

Line 8 was a bare build/ from the Python-packaging block. It also matched ebuild/build/, the source package holding dispatch.py, ninja_backend.py and toolchain.py:

$ git check-ignore -v ebuild/build/footprint.py
.gitignore:8:build/	ebuild/build/footprint.py

Those four files predate the rule and stayed tracked, but every new module added there was silently ignored — including this one. Anchored to /build/, which keeps the setuptools artifact directory ignored and stops the pattern reaching nested source.

Verification

pytest: 235 passed, up from 202; 32 are new here. Built and measured three real projects — within budget, over budget, and a board with no known capacity — plus a gcc-compiled binary with a known 4 KB bss array to confirm the section accounting.

Branches off the master repair in #70, since master cannot currently run its own test suite.

🤖 Generated with Claude Code

"""

import subprocess
from pathlib import Path
The MLP developer walk in the platform design document ends with a build that
says how much of the board it used:

    Flash: 384 KB
    RAM:    72 KB
    Ready to flash.

Nothing produced those numbers. A developer had to run `size` themselves and
remember which columns to add, which is not being told — it is being left to
find out.

    $ ebuild build
    [ok] Build completed successfully.

      Flash:     1.9 KB  of    1.00 MB  (0.2%)
      RAM  :   300.6 KB  of   192.0 KB  (156.6%)
    [warn] RAM usage 300.6 KB exceeds the board's 192.0 KB -- this image
           will not fit.

The accounting matches scripts/measure_footprint.py in the eos repo so the two
tools cannot disagree about what a number means:

    flash = text + data
    ram   = data + bss

`data` is charged to both because it is stored in flash and copied to RAM at
startup; reading `size`'s "dec" column instead understates RAM.

Capacity comes from the project's own board.yaml `memory.flash_size` /
`ram_size` when it ships one — the convention the descriptions under
hardware/board/ already use — and otherwise from a table of the reference part
for each board family. Boards that boot from removable storage, and
Linux-class parts with no fixed budget, are deliberately absent: a percentage
against a guessed ceiling reads as authoritative, so those report absolute
sizes only.

An over-budget image is a warning, not a build failure. It linked; it will not
fit. The developer needs to hear that now rather than from a board that will
not boot.

A cross build is measured with its own `size` and never falls back to the host
one — host `size` on an ARM ELF reports numbers for a different target and
nothing in the output would say so. Where no suitable tool exists the report
is skipped rather than guessed, and never fails the build.

Also fixes .gitignore, found while committing this: line 8 was a bare `build/`
from the Python-packaging block, which also matched `ebuild/build/` — the
source package holding dispatch.py, ninja_backend.py and toolchain.py. Those
four files predate the rule and stayed tracked, but every new module added
there was silently ignored, including this one. Anchored to `/build/`, which
keeps the setuptools artifact directory ignored and stops the pattern reaching
nested source.

235 tests pass, up from 202; 32 are new here.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

1 participant