fix(esp32): use SysV size format to separate flash .rodata from DRAM - #1297
Conversation
Fixes #1261 — ESP32-C6 RAM reported as 1.88MB / 320KB (602.5%). The Berkeley size format lumps .flash.rodata (flash-resident) into the data column alongside .dram0.data (RAM-resident). For ESP32-C6 this inflates the RAM figure by counting flash-rodata as if it were RAM. Switch to size -A (SysV format) which lists each section with its name and address. parse_esp32_size_output classifies by section prefix: - Flash: .flash.*, .rodata*, .iram0.*, .text - RAM: .dram0.*, .dram.* Falls back to None when no ESP32-prefixed sections are detected, so non-ESP32 targets sharing this path get the standard Berkeley parser. Co-Authored-By: Claude <noreply@anthropic.com>
📝 WalkthroughWalkthroughESP32 size reporting now runs ChangesESP32 size reporting
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant ESP32Linker
participant esp32_report_size
participant SizeTool
participant parse_esp32_size_sysv
ESP32Linker->>esp32_report_size: Report ELF size
esp32_report_size->>SizeTool: Run `size -A`
SizeTool-->>esp32_report_size: Return SysV output
esp32_report_size->>parse_esp32_size_sysv: Parse sections
parse_esp32_size_sysv-->>ESP32Linker: Return SizeInfo
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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 |
Move the SysV size parser and its tests to a new size_report.rs submodule so esp32_linker.rs stays under the 1000-line ceiling enforced by the LOC gate CI job. No behavioral change. Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
crates/fbuild-build-esp/src/esp32/esp32_linker.rs (1)
553-566: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winInvalidate the size cache when changing ESP32 size parsing.
SizeArtifactCacheonly storesversion,elf_stamp, andsize_info. Since ESP32 now reports SYSV sections instead of Berkeley column values,report_size()can return unchanged ELF RAM usage from the old format. Add a size-report format version to the cache identity or bump the build fingerprint version while changing the parser.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/fbuild-build-esp/src/esp32/esp32_linker.rs` around lines 553 - 566, Update the size-cache identity used by report_size and SizeArtifactCache to include a version for the ESP32 size-report format, and bump it for the SYSV section parsing change. Ensure load_cached_size rejects entries created with the previous format while preserving cache reuse for matching versions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@crates/fbuild-build-esp/src/esp32/esp32_linker.rs`:
- Around line 553-566: Update the size-cache identity used by report_size and
SizeArtifactCache to include a version for the ESP32 size-report format, and
bump it for the SYSV section parsing change. Ensure load_cached_size rejects
entries created with the previous format while preserving cache reuse for
matching versions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 6aed74c6-80c5-4d51-9189-c31dc84d2612
📒 Files selected for processing (3)
crates/fbuild-build-esp/src/esp32/esp32_linker.rscrates/fbuild-build-esp/src/esp32/mod.rscrates/fbuild-build-esp/src/esp32/size_report.rs
Fixes #1261 — ESP32-C6 RAM reported as 1.88MB / 320KB (602.5%).
Problem
The Berkeley
sizeformat lumps.flash.rodata(flash-resident) into thedatacolumn alongside.dram0.data(RAM-resident). For ESP32-C6 this inflates the RAM figure by counting flash-rodata as if it were RAM, producing impossible percentages.The Berkeley output for an ESP32-C6 build:
data = 456789includes both.flash.rodataand.dram0.datatotal_ram = data + bss = 465,981— but real DRAM is only~10KBmax_ram = 320KB:465,981 / 327,680 = 142%(or higher for larger builds)Fix
Switch to
size -A(SysV format) which lists each section individually with its name:parse_esp32_size_outputclassifies by section prefix:.flash.*,.rodata*,.iram0.*,.text.dram0.*,.dram.*Returns
Nonewhen no ESP32-prefixed sections are detected, preserving the standard Berkeley parser for non-ESP32 builds.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes