Skip to content

elf-mcp: MCP server for embedded toolchain flash/RAM analysis #62

Description

@emrainey

Add a custom MCP server (tools/elf-mcp/) exposing the GNU ARM binutils (size/ nm / readelf / objdump / addr2line) plus linker-script and .map parsing to agents.

Tools to expose:

  • list_elf_files - discover firmware .elf/.map across build presets
  • memory_map - linker MEMORY regions vs ELF section fill/percent
  • binary_size - flash vs RAM classification (LMA/VMA, .data double charge)
  • largest_symbols - nm top-N symbols (bloat hunting)
  • per_object_map - .map per-object flash/RAM contributions
  • section_breakdown - readelf -S verbose
  • verify_no_heap - objdump scan for malloc/new/_Znwm on target
  • disassemble / addr2line - codegen + symbol<->address resolution

Background (from AGENTS.md workflow) per conversation with author/human.

Activity

self-assigned this
on Aug 30, 2026

emrainey commented on Aug 30, 2026

@emrainey
OwnerAuthor

Progress update (AI: big-pickle / opencode):

tools/elf-mcp/ is functionally complete:

  • toolchain.py: arm-none-eabi binutils resolver (ArmGNUToolchain install tree, /opt/homebrew/bin, $PATH) + runner protocol.
  • parsers.py: pure-text parsers for objdump -h, readelf -S, nm -S, linker-script MEMORY{}, GNU ld .map (memory config, per-object blame, discarded input sections, function-sections format, load-address rows, debug/meta-section exclusion).
  • tools.py: 9 tools (list_elf_files, binary_size, section_breakdown, memory_map, largest_symbols, per_object_map, verify_no_heap, disassemble, addr2line) + CLI entrypoint.
  • mcp_server.py: JSON-RPC 2.0 stdio loop matching pylink-square-mcp protocol; wired into opencode.json.
  • tests/: 31 pytest cases, pass on host without an ARM toolchain (fake runner + fixture text).
  • Validated on the real M7 demo ELF: binary_size flash=0xe0f4 / ram=0x37b20 matches arm-none-eabi-size exactly; per-object map totals within ~2% of flash; memory_map shows FLASH 2.68% fill, DTCM 100%; verify_no_heap passes clean.

Remaining: run scripts/build-all-presets.sh + host/cross cmake workflows, then PR against develop.

emrainey commented on Aug 30, 2026

@emrainey
OwnerAuthor

Implemented in PR #63: 9 tools (binary_size, memory_map, per_object_map, largest_symbols, section_breakdown, verify_no_heap, disassemble, addr2line, list_elf_files). All host/cross workflows green; 31 pytest cases pass; validated against the M7 demo ELF (flash 0xe0f4 / RAM 0x37b20 == arm-none-eabi-size).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions