Repository navigation
Add from-elf: draw a linked firmware image from its ELF - #3
Merged
Merged
Conversation
`memmap from-elf firmware.elf --region flash=0x08000000:64K ...` reads the allocated sections and loadable segments of a linked ELF and writes an ordinary config, then checks it like `check`. Each --region gets a column titled with its usage. Gaps of --min-size or more become Free blocks, and initialised data is drawn again where it is stored in flash, with a note naming the bank it is copied to. In a region of more than 8 blocks, runs of small sections fold into a group with a detail column. New warnings: W110 (section outside every --region) and W111 (section overlaps another, left out). memmap/elf.py reads the file header, section headers and program headers itself, for 32- and 64-bit files in either byte order, so there is no new dependency. It gives the same fields as pyelftools on every test image, and truncated or corrupt files raise ElfError, including 64-bit offsets too large for struct. Notes can now span several lines and wrap after 20 ems. A multi-line note gets a rule beside it, and its height counts toward W102. Tests: synthetic ELFs, one rule each, including five memory banks; firmware built by binutils in every class and byte order; and nine real firmware images from Renode, kept as header snapshots with golden configs and drawings. docs/elf-testing.md describes them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Its converted image imports to a single block, so it showed little in the snapshot tests or the docs. The synthetic test for an image converted to an object file still covers reading one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every job warned that actions/checkout@v4 and astral-sh/setup-uv@v6 target the deprecated Node.js 20. checkout v7 and setup-uv v10.3.3 run on Node.js 24. setup-uv no longer publishes major tags since v8, so it is pinned to the exact release. None of the breaking changes in between touch these workflows. Two change behaviour: setup-uv v9 no longer prunes the uv cache by default, and v10 leaves the cache off for release events, so release.yml installs its dependencies without one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
memmap from-elf ELF [-o OUT] [--region id=start:size[:name]] [--min-size N] [--force] [--json] [--strict]. It writes an ordinary config from a linked ELF's allocated sections, then checks it likecheck:--region, titled with its usage (TCM\n5.8 KB of 384 KB (2%))--min-sizeor more (default 64 B), rounded down and marked≈when not exactcopied to TCM at 0x1000 1000), orRAM init datawhen it holds several sections--min-size 0turns this off).debug_*and other non-allocated sections are skipped by theirSHF_ALLOCflag, as is.tbss--region) and W111 (section overlaps another, left out)memmap/elf.py: a ~150-line reader for the file header, section headers and program headers, for 32- and 64-bit files in either byte order. No new dependency. It handles extended section/segment counts,.heximages converted to object files, and rejects core dumps and unlinked.ofiles. Truncated or corrupt files raiseElfError, which--jsonreports as E090.\n) and wrap after 20 ems. A multi-line note gets a rule beside it, and its height counts toward W102.actions/checkoutv4 → v7 andastral-sh/setup-uvv6 → v10.3.3, which run on Node.js 24 and clear the Node.js 20 deprecation warning on every job.--jsoncontract) and a newdocs/elf-testing.md.Tests
tests/test_from_elf.py, built bytests/elf_builder.py): one rule per test, including a five-bank STM32H7-style layout.tests/fixtures/firmware*.elf): one firmware written by binutils in every class and byte order.tests/test_elf_snapshots.py): eight images from Renode, kept as 3–6 KB header snapshots with golden configs and drawings. Ambiq Apollo4 is the one with three memory banks.Test plan
uv run pytest: 489 passeduv run mypyanduv run ruff checkpass🤖 Generated with Claude Code