
Openocd
Flash firmware, start GDB/Telnet debug sessions, and capture Semihosting or ITM output on ARM boards via OpenOCD from your agent.
Overview
openocd is an agent skill for the Build phase that runs OpenOCD for ARM probe bring-up, firmware flash, GDB/Telnet debugging, and Semihosting or ITM output capture.
Install
npx skills add https://github.com/zhinkgit/embeddedskills --skill openocdWhat is this skill?
- Probe connectivity, firmware program (.elf/.hex/.bin), and Flash erase (auto|mass|sector)
- GDB Server on configurable port plus Telnet halt/resume/step, registers, memory, hardware breakpoints, run-to
- GDB command sequences, backtrace and locals shortcuts via arm-none-eabi-gdb
- Semihosting printf capture and ITM/SWO output observation
- Supports ST-Link, CMSIS-DAP, DAPLink, FTDI with skill/config.json operation modes 1–3
- Default GDB port 3333 and Telnet port 4444 in config
- Flash erase modes: auto, mass, and sector
- Three operation_mode values: direct execute, risk summary, confirm before execute
Adoption & trust: 1 installs on skills.sh; 340 GitHub stars; 3/3 security scanners passed (skills.sh audits); trending (+100% hot-view momentum).
What problem does it solve?
You keep retyping OpenOCD, GDB, and Telnet steps to flash and debug embedded firmware instead of a repeatable agent-driven workflow.
Who is it for?
Indie embedded developers on STM32-class ARM boards using ST-Link, CMSIS-DAP, or DAPLink who want agent-assisted flash and debug.
Skip if: Pure web or mobile app builders with no on-target debugging, or teams forbidden from shell access to hardware tools.
When should I use this skill?
You need OpenOCD probe detection, firmware programming, flash erase, GDB server, target reset, Telnet or GDB interactive debug, or Semihosting/ITM output on ARM hardware.
What do I get? / Deliverables
Your agent executes configured OpenOCD operations—flash, erase, debug server, and trace capture—using paths and ports from config.json with optional safety confirmation modes.
- Programmed firmware image on target flash
- Running GDB/Telnet debug session or captured Semihosting/ITM log output
Recommended Skills
Journey fit
Embedded bring-up sits in Build when you integrate hardware debug probes with your firmware workflow—not a typical web launch phase. Integrations covers toolchains and debug bridges (OpenOCD, ST-Link, CMSIS-DAP) wired into the build-and-debug loop.
How it compares
Hardware debug orchestration skill—not a cloud deploy or mobile navigation pattern pack.
Common Questions / FAQ
Who is openocd for?
Solo builders and small teams doing ARM firmware who already use OpenOCD and want Claude Code or similar agents to run flash, GDB server, and Telnet debug steps from SKILL.md.
When should I use openocd?
During Build integrations while bringing up boards, after each firmware build that needs programming, or when you need GDB backtraces, Semihosting printf, or ITM/SWO traces without leaving the agent session.
Is openocd safe to install?
It can erase flash and reset hardware; review the Security Audits panel on this page, set operation_mode to confirm-before-run in config.json, and never point it at production equipment you cannot recover.
SKILL.md
READMESKILL.md - Openocd
{ "exe": "openocd", "scripts_dir": "", "gdb_port": 3333, "telnet_port": 4444, "gdb_exe": "", "operation_mode": 1 } # openocd Claude Code skill,通过 OpenOCD 进行探针探测、固件烧录、Flash 擦除、GDB Server 启动、目标复位、Telnet 在线调试、GDB 源码级调试以及 Semihosting/ITM 输出捕获。支持 ST-Link、CMSIS-DAP、DAPLink、FTDI 等开源调试器。 ## 功能 - 探针与目标连通性探测 - 固件烧录(.elf / .hex / .bin) - Flash 擦除(支持 `auto|mass|sector` 模式) - GDB Server 启动(供 GDB 连接进行源码级调试) - 目标复位(支持 halt/run 模式) - **Telnet 在线调试**:halt / resume / step / 寄存器查看 / 内存读写 / 硬件断点 / run-to - **GDB 调试交互**:执行自定义 GDB 命令序列、快捷调用栈查看、局部变量查看 - **Semihosting 输出捕获**:捕获目标 `printf` 输出(ARM Semihosting,类似 J-Link RTT) - **ITM/SWO 观测**:基于 TPIU/ITM 读取 SWO 输出 ## 环境要求 - [OpenOCD](https://openocd.org/) — 安装后确保 `openocd` 可执行或填写完整路径 - Python 3.x(仅标准库,无额外依赖) - 调试器驱动(ST-Link 需要 ST 官方驱动或 WinUSB/libusb,CMSIS-DAP 免驱) - [Arm GNU Toolchain](https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads)(GDB 调试子命令需要 `arm-none-eabi-gdb`) ## 配置 ### 环境级配置(skill/config.json) 复制 `config.example.json` 为 `config.json`,根据实际环境修改: ```json { "exe": "openocd", "scripts_dir": "", "gdb_port": 3333, "telnet_port": 4444, "gdb_exe": "", "operation_mode": 1 } ``` | 字段 | 必填 | 说明 | |------|------|------| | `exe` | 是 | openocd 路径或命令名 | | `scripts_dir` | 否 | OpenOCD 配置脚本目录,为空时使用内置路径 | | `gdb_port` | 否 | GDB Server 端口,默认 3333 | | `telnet_port` | 否 | Telnet 端口,默认 4444 | | `gdb_exe` | 否 | arm-none-eabi-gdb 路径,GDB 调试子命令需要 | | `operation_mode` | 否 | `1` 直接执行 / `2` 输出风险摘要 / `3` 执行前确认 | ### 工程级配置(.embeddedskills/config.json) board/interface/target 等工程参数统一在工作区的 `.embeddedskills/config.json` 中管理: ```json { "openocd": { "board": "", "interface": "interface/stlink.cfg", "target": "target/stm32f4x.cfg", "adapter_speed": "4000", "transport": "swd", "tpiu_name": "stm32f4x.tpiu", "traceclk": "168000000", "pin_freq": "2000000" } } ``` 参数解析优先级:**CLI 参数 > 工程配置 > state.json > 默认值** 成功执行后,确认过的参数会自动写回工程配置。 当前实现的基础命令还包括 `targets`、`flash-banks`、`adapter-info`、`raw` 和 `gdb-server`,观测命令除了 `semihosting` 还支持 `itm`。 ## 擦除行为 - `erase --mode auto`:优先使用 target 映射到的 mass erase,未命中时回退 sector erase - `erase --mode mass`:强制整片擦除;当前 target 没有映射时返回 `mass_erase_unsupported` - `erase --mode sector`:强制按 bank 执行 `flash erase_sector <bank> 0 last` - `.bin` 烧录必须显式提供地址,例如 `0x08000000` # OpenOCD 常见 Board / Interface / Target 配置速查表 OpenOCD 通过 `.cfg` 配置文件组合来描述调试链路。优先使用 `board` 配置(已包含 interface 和 target),否则手动组合 `interface + target`。 ## Interface(调试器) | 调试器类型 | 配置文件 | |-----------|---------| | ST-Link V2 | `interface/stlink.cfg` | | ST-Link V3 | `interface/stlink.cfg` | | CMSIS-DAP | `interface/cmsis-dap.cfg` | | DAPLink | `interface/cmsis-dap.cfg` | | J-Link | `interface/jlink.cfg` | | FTDI 系列 | `interface/ftdi/minimodule.cfg` 等 | ## Target(目标芯片) ### STMicroelectronics | 系列 | 配置文件 | |------|---------| | STM32F0 | `target/stm32f0x.cfg` | | STM32F1 | `target/stm32f1x.cfg` | | STM32F2 | `target/stm32f2x.cfg` | | STM32F3 | `target/stm32f3x.cfg` | | STM32F4 | `target/stm32f4x.cfg` | | STM32F7 | `target/stm32f7x.cfg` | | STM32G0 | `target/stm32g0x.cfg` | | STM32G4 | `target/stm32g4x.cfg` | | STM32H7 | `target/stm32h7x.cfg` | | STM32L0 | `target/stm32l0x.cfg` | | STM32L1 | `target/stm32l1x.cfg` | | STM32L4 | `target/stm32l4x.cfg` | | STM32U5 | `target/stm32u5x.cfg` | | STM32WB | `target/stm32wbx.cfg` | | STM32WL | `target/stm32wlx.cfg` | ### GigaDevice | 系列 | 配置文件 | |------|---------| | GD32F1x3 | `target/stm32f1x.cfg`(兼容) | | GD32F3x0 | `target/stm32f1x.cfg`(兼容) | | GD32F4xx | `target/stm32f4x.cfg`(兼容) | | GD32E103 | `target/stm32f1x.cfg`(兼容) | > GigaDevice 芯片通常兼容对应 STM32 系列的 target 配置。 ### Nordic Semiconductor | 系列 | 配置文件 | |------|---------| | nRF51 | `target/nrf51.cfg` | | nRF52 | `target/nrf52.cfg` | ### NXP | 系列 | 配置文件 | |------|---------| | LPC1768 | `target/lpc1768.cfg` | | LPC4088 | `target/lpc4088.cfg` | ### ESP32 | 系列 | 配置文件 | |------|---------| | ESP32 | `target/esp32.cfg` | | ESP32-S2 | `target/esp32s2.cfg` | | ESP32-S3 | `tar