5 Commits

Author SHA1 Message Date
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
d17037f2a1 Add SWD/DAP subsystem with DP/AP register access and AP enumeration
10th subsystem: session.swd provides DAP discovery, DP/AP register
read/write, AP enumeration, and convenience methods (dpidr, target_id).
Includes SWDError, DAPInfo, APInfo types, input validation, ADIv5/v6
AP classification, and 24 mock-only tests covering happy and error paths.
2026-02-15 16:36:25 -07:00
7a893cb328 Apply ruff format to existing source and test files 2026-02-15 16:36:12 -07:00
bc7cb77ec4 Fix reliability issues from code review, add error-path tests
Critical fixes:
- Separate notification and command connections to eliminate dual-reader
  race condition on the TCL RPC stream (C-1)
- Fix _get_or_create_loop() swallowing its own RuntimeError, causing
  deadlock when sync API called from async context (C-2)
- Add bounds checking to config string parser (C-3)
- Clean up OpenOCD subprocess on connection failure in Session.start (H-1)

Defense in depth:
- Add MAX_RESPONSE_SIZE (10MB) guard against unbounded buffer growth
- Preserve bytes after separator in _read_until_separator remainder buffer
- Set notification_failed flag when listener crashes, warn on next send
- Standardize error detection to case-insensitive across all modules
- Escape TCL special characters in RTT channelwrite to prevent injection
- Redirect OpenOCD stdout to DEVNULL to prevent pipe buffer deadlock
- Run SVD XML parsing in asyncio.to_thread to avoid blocking event loop

Consistency:
- Cache SyncSession subsystem wrappers (match async Session pattern)
- Make DecodedRegister frozen (match all other dataclasses)
- Add py.typed marker for PEP 561 type checker support
- Accept list[str] config in OpenOCDProcess.start for paths with spaces

Tests:
- Add 50 error-path tests covering connection, target, memory, register,
  flash, breakpoint, session, process, and notification failure modes
2026-02-12 18:52:38 -07:00
7e1eac5e2d Add openocd-python: typed async-first Python bindings for OpenOCD
Standalone PyPI package providing structured access to the full OpenOCD
command surface via the TCL RPC protocol (port 6666). Async-first API
with sync wrappers for every method.

Subsystems: target control, memory read/write, CPU registers, flash
programming, JTAG chain/scan/boundary, breakpoints/watchpoints, SVD
peripheral decoding, RTT channels, transport/adapter config.

79 tests passing against a mock TCL RPC server.
2026-02-12 17:55:58 -07:00