Ryan Malloy 2fa4aca286 Fix breakpoint_list parser for OpenOCD 0.12.0 dual-format output
OpenOCD uses two different output formats for breakpoint listing within
the same session: Breakpoint(IVA) for hardware (FPB) and IVA breakpoint
for software (patched). The old regex only matched the first format,
causing breakpoint_list() to always return empty when software
breakpoints were present. The third field is a comparator index or bp
number, not a hw/sw type flag — the format variant itself indicates the
breakpoint type.

Verified against live STM32F103C6T6 hardware: 8/9 lifecycle tests pass,
154/154 mock tests pass.
2026-02-17 22:13:50 -07:00
2026-02-15 18:12:24 -07:00

openocd-python

Typed, async-first Python bindings for the full OpenOCD command surface.

Install

pip install openocd-python

Quick Start

from openocd import Session

# Connect to a running OpenOCD instance
async with Session.connect() as ocd:
    state = await ocd.target.halt()
    pc = await ocd.registers.pc()
    mem = await ocd.memory.read_u32(0x08000000, 4)
    print(f"PC: {pc:#x}")

# Or spawn OpenOCD and connect
async with Session.start("interface/cmsis-dap.cfg -f target/stm32f1x.cfg") as ocd:
    await ocd.target.halt()
    regs = await ocd.registers.read_all()

# Synchronous API available too
with Session.start_sync("interface/cmsis-dap.cfg") as ocd:
    ocd.target.halt()
    print(f"PC: {ocd.registers.pc():#x}")

Features

  • Async-first with sync wrappers for every method
  • Typed returns — dataclasses, not raw strings
  • Full OpenOCD surface: target control, memory, registers, flash, JTAG, breakpoints, RTT
  • SVD decoding — read a peripheral register and get named bitfields
  • Process management — spawn and manage OpenOCD subprocesses
  • Dual transport — TCL RPC (primary) and telnet (fallback)

Requirements

  • Python 3.11+
  • OpenOCD installed and on PATH (or pass openocd_bin=)
Description
Typed, async-first Python bindings for the full OpenOCD command surface
Readme MIT 214 KiB
Languages
Python 100%