MCPInstall

memory-analysis

当需要解析 .map 文件或 ELF 获取固件内存使用报告、符号大小排名或版本对比时使用。

Installs
560
Last 24h
—
Trending rank
—
Security
Not audited

Install

Works with every agent the skills CLI supports.

npx skills add https://github.com/leokemp223/embed-ai-tool --skill memory-analysis
  1. 01

    Install

    Run the command in your project. The CLI asks which agents to install for.

  2. 02

    Describe the task

    Ask your agent for something this skill covers. It loads memory-analysis automatically when relevant.

  3. 03

    Review the result

    The agent follows the SKILL.md steps, scripts and references bundled with the skill.

SKILL.md

The instructions your agent reads when the skill is triggered.

固件内存分析

适用场景

  • 构建完成后需要了解固件的 Flash/RAM 使用情况。
  • 需要找出占用空间最大的函数或变量。
  • 需要对比两次构建的内存变化,追踪代码膨胀。
  • 需要确认固件是否即将超出芯片内存限制。
  • 需要解析链接脚本获取芯片 Flash/RAM 总容量。

必要输入

  • .map 文件路径(GCC/ARM 链接器生成),或 ELF 文件路径。
  • 可选的链接脚本路径(用于计算使用率百分比)。
  • 可选的告警阈值和 Top-N 符号数量。

自动探测

  • --scan 模式自动搜索构建目录中的 .map 和 ELF 文件。
  • 解析 .map 文件中的 Memory Configuration 块获取 FLASH/RAM 总容量。
  • 若提供链接脚本,从 MEMORY {} 块解析容量信息。
  • 自动检测 arm-none-eabi-size 和 arm-none-eabi-readelf 可用性。

执行步骤

  1. 先阅读 references/usage.md,确认本次是环境探测、构建目录扫描,还是执行分析。
  2. 若不确定工具是否可用,先运行 scripts/memory_analyzer.py 的 --detect 模式确认。
  3. 使用 --scan <build_dir> 自动查找可分析的文件。
  4. 使用 --map-file 或 --elf 执行内存分析。
  5. 可选使用 --linker-script 获取总容量并计算使用率。
  6. 使用 --top <N> 查看占用最大的符号。
  7. 使用 --compare 对比两个 .map 文件的差异。

失败分流

  • 当 arm-none-eabi-size 或 arm-none-eabi-readelf 不可用且需要 ELF 分析时,返回 environment-missing。
  • 当指定的 .map 或 ELF 文件不存在时,返回 artifact-missing。
  • 当 .map 文件格式无法识别或解析失败时,返回 project-config-error。
  • 当内存使用率超过告警阈值时,在成功结果中附带告警信息。

平台说明

  • .map 文件解析使用纯正则,无需外部工具,全平台可用。
  • ELF 分析需要 arm-none-eabi-size,通常随交叉编译工具链安装。
  • 链接脚本解析使用纯正则,支持 GCC LD 格式。

输出约定

  • 输出各 section(.text, .rodata, .data, .bss)的大小和地址。
  • 输出 Flash 使用量(.text + .rodata + .data)和 RAM 使用量(.data + .bss)。
  • 若有总容量信息,输出使用率百分比和告警状态。
  • 输出按大小排序的 Top-N 符号列表。
  • 对比模式输出各 section 和符号的增减变化。

交接关系

  • 当内存即将溢出需要优化时,建议用户审查 Top-N 大符号。
  • 当需要定位具体函数在代码中的位置时,可配合 IDE 或 grep 使用。

FAQ

What does the memory-analysis skill do?

当需要解析 .map 文件或 ELF 获取固件内存使用报告、符号大小排名或版本对比时使用。

How do I install memory-analysis?

Run npx skills add https://github.com/leokemp223/embed-ai-tool --skill memory-analysis in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/memory-analysis/ (personal) or .claude/skills/memory-analysis/ (project).

Which AI agents can use memory-analysis?

Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.

Is memory-analysis safe to install?

No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.

Who maintains memory-analysis?

It is published by leokemp223 in leokemp223/embed-ai-tool. It has 560 recorded installs.

More from leokemp223/embed-ai-tool

View all →

serial-monitor

leokemp223/embed-ai-tool

当需要识别正确串口、调用自带脚本抓取日志,并分析嵌入式固件运行状态时使用。

585 installs

build-keil

leokemp223/embed-ai-tool

当需要通过 Keil MDK 命令行编译嵌入式工程,调用自带脚本解析工程文件、执行构建并定位固件产物时使用。

572 installs

build-platformio

leokemp223/embed-ai-tool

当需要通过 PlatformIO 命令行编译嵌入式工程,调用自带脚本解析环境配置、执行构建并定位固件产物时使用。

568 installs

workflow

leokemp223/embed-ai-tool

当需要串联多个 skill 完成编译+烧录+监控或编译+烧录+调试等流水线任务时使用。

flash-keil

leokemp223/embed-ai-tool

当需要通过 Keil MDK 内置调试器烧录固件到目标板时使用,利用工程中已配置的调试器和 Flash 算法执行下载。

566 installs

build-cmake

leokemp223/embed-ai-tool

当需要配置或构建基于 CMake 的嵌入式固件工程,调用自带脚本执行构建并定位固件产物时使用。

564 installs

Popular other skills

View category →

hyperframes-cli

heygen-com/hyperframes

The HyperFrames CLI by job - scaffold, check, look at frames, edit the timeline, preview, render locally or in the cloud, publish, project history - plus reading its JSON and recovering from build or render failures.

1.3M installs

triage

mattpocock/skills

Move issues and external PRs through a state machine of triage roles, categorise, verify, grill if needed, and write agent-ready briefs.

1M installs

ask-matt

mattpocock/skills

Ask which skill or flow fits your situation. A router over the skills in this repo.

778.4K installs

to-questionnaire

mattpocock/skills

Turn a decision you can't fully answer into a questionnaire for someone else to fill in.

508.9K installs

wait-what

mattpocock/skills

Stop. That last message did not land: re-pitch it.

459.7K installs

loop-me

mattpocock/skills

Grill me about specs for the workflows I want to build, within this workspace.

447.9K installs