Build firmware and flash to embedded hardware. Automatically selects the correct probe when multiple ST-Links are connected.
Build and flash firmware to the connected board.
Arguments: $ARGUMENTS
stm32f4_os). Required.stm32f407vg, stm32h750xx). Optional — auto-detected from hardware.Prefer MCP tools over CLI commands when available. They provide structured JSON responses and automatic error handling.
Pre-flight — check probes and cleanup:
cleanup_processes and probe_listDetermine MCU — if not specified, read the target's xmake.lua for set_values("embedded.mcu", ...).
Build — use MCP build_target:
mode: "debug"Find binary — locate the .bin file:
find build/$0 -name "$0.bin" -type f
The binary may be in build/$0/debug/ or build/$0/release/ depending on build mode.
Flash — use MCP flash with the binary path and MCU.
Verify — use MCP target_status and read_registers:
When multiple ST-Links are connected, --mcu is required to select the correct probe.
MCU is auto-detected from hardware (no manual config needed).
| Problem | Solution |
|---|---|
| No available debug probes | Check USB connection |
| LTO thin error in release | Build with mode: "debug" instead |
| Target not responding | Use MCP reset |
| Flash fails | Erase first: pyocd erase -t <mcu> --chip |
| Wrong probe selected | Use MCP probe_list to check |