Skip to main content
Glama
stm32-forge
by kcylp

STM32 Forge

ci license tests dsh mcp

一套引擎,四个入口。 把 STM32 从「探测工具链 → 建工程 → 改 .ioc(含时钟)→ 生成代码 → 编译 → 烧录 → 调试 → 回读寄存器」整条链交给模型执行,在 DeepSeek Harness 里是原生工具,在 Claude Code / Codex / Kun / WorkBuddy / Cursor 里通过 MCP 用同一套能力——因为两边吃的是同一份工具定义。

Fork 自三个上游的合并重构版,不是薄包装:源码级吸收后重写、去重、补断言。 出处与许可证逐项列在 NOTICE。主许可 Apache-2.0。

English · 架构 · MCP 接入 · 变更与"不做什么" · 迁移指南 · 路线图


为什么再做一个

现存的三个 STM32 插件各有绝活,也各有硬伤,而且互相装不到一起——DSH 的工具注册表重名直接抛错(dsh-tools/lib/index.js:385),stm32_build / stm32_flash / stm32_serial / stm32_watch / stm32_doctor / stm32_rtt 六个名字在两个上游里各写了一遍。

STM32 Forge 的处理方式:

来源

拿过来

丢掉

JingYu-er/dsh-stm32 (Apache-2.0)

21 族设备库、18 族时钟规划、.ioc 事务(计划→校验→备份→回滚)、CubeMX 无头生成、固件包安装、寄存器版工程、数据手册与器件检索、证据总线

12 MB 资源一刀切、Windows 盘符硬编码、单个 10 万行文件

Lylgj/dsh-stm32-toolkit (MIT)

GDB/MI 深度调试、J-Link 后端、Keil uvprojx + UV4、ELF 符号与体积(v0.3 吸收中)

与别人撞车的工具名、没有 .ioc 事务、假设环境已就绪

Airls-bubble/dsh-plugin-stm32-workbench (MIT)

工程卡 mcu.json、功能契约、结构化编译诊断、编码感知读写(GBK/UTF-8)、map 解析(v0.4 吸收中)

私有 backend 进程与端口、必须切「单片机模式」、随包分发 GPL 的 OpenOCD

Related MCP server: stm32cubemx-mcp

三条红线由代码保证

  • 只写自有区域:.ioc 走事务(计划 → 校验 → 备份 → 原子替换 → 失败回滚);源码只写 USER CODE BEGIN/END,块外逐字节保留。

  • 烧录不与调试抢探针:只烧录就不开会话,烧完 monitor reset run + detach;要调试才开,空闲自动关。

  • Serial Wire 不能关:.ioc 没有 SWD 时烧录前直接拒绝(会烧到失联)。

  • 每一步都带证据:计划编号、file:line:col、Verified OK、寄存器位域值、两次构建的体积差。

这些在代码里是断言 + 单测,不是 README 里的祈祷。

安装

DeepSeek Harness(原生工具 + 面板 + 命令 + SKILL)

dsh plugin --profile web add github:kcylp/dsh-stm32-forge
# 装完完全重启 DSH(插件层只在进程启动时加载)

任何 MCP 客户端(Claude Code / Codex / Kun / WorkBuddy / Cursor)

{
  "mcpServers": {
    "stm32-forge": {
      "command": "node",
      "args": ["<包目录>/lib/mcp/main.js"],
      "cwd": "D:/work/blink"
    }
  }
}

逐客户端的接法、验证方式与排错见 docs/MCP.md。

命令行

node lib/cli/main.js tools                        # 37 个工具一览
node lib/cli/main.js doctor --dir D:\work\blink   # 体检:缺什么、探针通不通
node lib/cli/main.js build  --dir D:\work\blink
node lib/cli/main.js flash  --dir D:\work\blink

工具面(DSH 与 MCP 同名同参)

组

工具

环境

stm32_doctor stm32_env_install stm32_route_plan

工程

stm32_project_create stm32_project_export

.ioc

stm32_ioc_inspect stm32_ioc_plan stm32_ioc_apply stm32_ioc_verify

生成

stm32_generate

代码

stm32_code_patch

构建

stm32_build

烧录

stm32_flash stm32_debug_run

调试

stm32_debug_session stm32_debug_eval stm32_debug_stop

寄存器

stm32_regs_read stm32_watch

运行时

stm32_serial stm32_rtt

设计

stm32_sch_read stm32_sch_pins stm32_sch_check stm32_sch_review stm32_sch_to_ioc

资料

stm32_pdf_read stm32_ds_fetch stm32_ds_lookup stm32_ds_list stm32_part_search

运维

stm32_assets stm32_cache stm32_download stm32_firmware_install stm32_layout_fix stm32_board_info

命令(DSH 壳):/stm32-doctor /stm32-env /stm32-setup /stm32-build /stm32-flash /stm32-debug /stm32-stop

状态

v0.2.0:三个入口已落地并各自验证过 —— DSH 原生(37 工具 / 7 命令 / SKILL / 调试台)、MCP stdio(initialize + tools/list + tools/call,与 DSH 同源同参)、CLI(tools / doctor / env / ioc / project / build / flash / call)。离线用例 1180 pass / 0 fail。

下一步:v0.3 吸收 Lylgj/dsh-stm32-toolkit 的 GDB/MI 深度调试、J-Link、Keil UV4 与 ELF 体积;v0.4 吸收 airls 的工程卡 / 功能契约 / 编码感知读写。见 docs/ROADMAP.md。

许可证

Apache-2.0。上游归属与随包第三方素材见 NOTICE。

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      A
      quality
      D
      maintenance
      MCP server for scaffolding, building, and flashing bare-metal STM32C011 firmware using the STM32CubeCLT toolchain. Exposes tools for project scaffold, build, flash, and probe listing.
      4
      -
    • A
      license
      A
      quality
      C
      maintenance
      An MCP server that enables AI agents to inspect, plan, validate, and apply STM32CubeMX .ioc configuration changes, and generate STM32CubeIDE projects, ensuring safe and testable embedded-system workflows.
      9
      8
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      An MCP server that lets AI coding agents drive the full STM32 development loop—code generation, build, flash, debug, serial monitoring, and fault diagnosis—end to end via CubeIDE, CubeMX, CubeProgrammer, OpenOCD, and GDB.
      1
      MIT
    • A
      license
      A
      quality
      Not graded
      maintenance
      MCP server for debugging STM32 microcontrollers over ST-LINK using STM32CubeCLT tools (GDB, ST-LINK_gdbserver, STM32_Programmer_CLI) with session management, flashing, breakpoints, memory/register access, and expression evaluation.
      19
      1
      GPL 3.0