Repository navigation
feat(ci): add bash bloat <board> wrapper for per-symbol flash analysis - #2883
Conversation
Codifies the lessons from the recent #2773 ESP32-S3 binary-size audit into a one-call tool so future agents don't re-discover the same gotchas (toolchain prefix per board, PIO output path layout, required `--nm` until fbuild#428 lands, map-derived synthesis requiring fbuild >= 2.2.19, etc.). ## What ships - **`bloat`** — bash entry-point matching the existing `bash test` / `bash lint` / `bash compile` convention. - **`ci/bloat.py`** — Python wrapper around `fbuild symbols`: - Resolves the cross-toolchain `nm` from the PIO packages directory based on a `BOARD_CHIP_MAP` (esp32, esp32s2, esp32s3, esp32c3, esp32c6, esp32h2 today; entries are mechanical). - Locates the firmware ELF under either the PIO output (`.build/pio/<board>/.pio/build/<board>/firmware.elf`) or fbuild's native output (`.build/<board>/firmware.elf`). - Writes BOTH `report.json` (machine) and `report.md` (human, GitHub-flavoured tables) to `.build/symbols/<board>/`. - Prints a top-N table to stdout collapsing all (section, source) rows per demangled symbol name. Use `--no-summary` to suppress. - `--build` flag chains `bash compile <board> --examples Blink` first, for a one-shot fresh-build + analyse workflow. - **Fails fast** when the installed fbuild lacks `symbols` (the released 2.2.18 wheel does not carry it) with the exact upgrade path to take. - **CLAUDE.md** — new "Binary Size Analysis" section that: 1. Documents `bash bloat <board>` as the canonical entry point. 2. Bakes in the 5 lessons learned: fbuild release lag, why map-derived synthesis matters, the `FASTLED_LOG_VERBOSITY=0` dominant lever, why `--nm` is still required, how to diff two builds via `.claude/symbolaudit/diff.py`. 3. Adds an explicit "don'ts" list to keep agents from re-implementing the wrapper or shelling out to nm directly. ## Test plan - [x] `bash bloat esp32s3 --top 5` end-to-end against the Blink build: writes both artifacts, prints the top-5 summary table, reports 388,380 B flash / 37,460 B RAM / 4,591 symbols. - [x] `bash lint` clean (python_pipeline + cpp + js all green). - [x] Verified the released fbuild 2.2.18 wheel rejects the `symbols` subcommand, and the wrapper's `assert_fbuild_has_symbols()` fails fast with the upgrade message.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughAdds a complete binary bloat analysis toolchain: Python module ci/bloat.py that integrates fbuild symbols and nm-based symbol sizing for ESP32 boards, Bash wrapper script for CLI access, and documentation guiding users through firmware bloat audits. ChangesBinary Bloat Analysis Tooling
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Summary
Codifies the lessons from the recent #2773 ESP32-S3 binary-size audit into a one-call tool so future agents don't re-discover the same gotchas (toolchain prefix per board, PIO output path layout, required
--nmuntil fbuild#428 lands,fbuild symbolsrequiring fbuild >= 2.2.19, etc.).Ships
bloat— bash entry-point matching the existingbash test/bash lint/bash compileconvention.ci/bloat.py— wrapper aroundfbuild symbols:nmfrom PIO packages based onBOARD_CHIP_MAP(esp32, esp32s2, esp32s3, esp32c3, esp32c6, esp32h2 today; entries are mechanical).firmware.elfunder.build/pio/<board>/.pio/build/<board>/or.build/<board>/.report.json+report.mdto.build/symbols/<board>/.--buildchainsbash compilefirst.symbols(the 2.2.18 wheel doesn't carry it) with the exact upgrade path.Lessons baked into CLAUDE.md
symbolsmerged after v2.2.18 wheel tag; rebuild from main until 2.2.19 ships..flash.rodataper-symbol; without it ~58 KB of NEOPIXEL FL_WARN strings bucket as anonymous against main.cpp.o.FASTLED_LOG_VERBOSITY=0is the single biggest flash-bloat lever on ESP32-S3 (~43-58 KB).--nmstill required until fbuild DWORD access must be aligned on ARM M0 #428 lands build-info-driven toolchain resolution..claude/symbolaudit/diff.py.Test plan
bash bloat esp32s3 --top 5end-to-end against the Blink build: writes both artifacts, prints the top-5 summary table, reports 388,380 B flash / 37,460 B RAM / 4,591 symbols.bash lintclean (python_pipeline + cpp + js all green).symbolssubcommand, and the wrapper'sassert_fbuild_has_symbols()fails fast with the upgrade message.Related
BuildInfoschema migration so--nmbecomes unnecessarysymbols→bloatand write reports to.fbuild/build/<env>/bloat-report/🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Documentation