stm32c0-mcp
stm32c0-mcp
MCP server + CLI for scaffolding, building, and flashing bare-metal STM32C011
firmware, driving the STM32CubeCLT command-line toolchain
(/opt/ST/STM32CubeCLT_1.22.0 by default — override with STM32CUBECLT_ROOT).
Targets the STM32C011 family (default part: STM32C011F6Ux, matching the
STM32C0116-DK Discovery kit). No HAL/CMSIS pack dependency — scaffolded
projects are genuinely bare-metal (hand-written vector table, linker script,
and a GPIO-register blinky).
Setup
pyenv local 3.10.0
python3 -m venv .venv
.venv/bin/pip install -e ".[dev]"CLI usage
.venv/bin/stm32c0 scaffold /path/to/project [--project-name NAME] [--part STM32C011F6Ux] [--force]
.venv/bin/stm32c0 build /path/to/project [--clean]
.venv/bin/stm32c0 flash /path/to/project/build/firmware.elf [--serial-number SN] [--shared]
.venv/bin/stm32c0 list-probes [--shared]Multiple probes
STM32_Programmer_CLI's direct USB path only ever sees a single ST-LINK: with
two connected it finds one and rejects the other with Error: Serial number not found, which looks like a hardware fault but isn't. Pass --shared to
route through ST-LINK server, which sees them all:
.venv/bin/stm32c0 list-probes --shared # every probe's serial
.venv/bin/stm32c0 flash fw.elf --serial-number SN --shared # target one of themST-LINK server is started automatically when --shared is used. It ships with
STM32CubeIDE rather than STM32CubeCLT (expected at /usr/local/bin/stlink-server,
override with STLINK_SERVER), so --shared is opt-in: shared connections fail
outright where that server isn't installed. --shared listings report serial
numbers only, without firmware versions.
MCP server
.venv/bin/stm32c0-mcpExposes scaffold_project, build, flash, and list_probes as MCP tools.
See docs/registration.md for wiring it into Claude Code.
Tests
.venv/bin/pytest -vtests/test_build_smoke.py requires no hardware. tests/test_flash_hardware.py
is skipped automatically unless an ST-LINK probe is connected.
Layout
src/stm32c0_mcp/— package:parts.py(device memory-map table),config.py(toolchain discovery),stlink_server.py(ST-LINK server discovery/startup for multi-probe access),scaffold.py/build.py/flash.py/probes.py(drivers),mcp_server.py/cli.py(thin wrappers),templates/bare_metal/(project skeleton templates).examples/blinky/— a committed, buildable instance of the scaffolded project; doubles as the smoke-test fixture.