Skip to content

CLI Reference

openocd-python ships with a command-line tool for quick diagnostics and interactive debugging. It connects to an already-running OpenOCD instance over the TCL RPC protocol.

Terminal window
openocd-python [--host HOST] [--port PORT] COMMAND
OptionDefaultDescription
--hostlocalhostOpenOCD host address
--port6666OpenOCD TCL RPC port
--versionPrint the package version and exit
CommandDescription
infoShow target state, transport, adapter, and speed
replInteractive OpenOCD command shell
readRead memory and display as hexdump
scanScan and display the JTAG chain

Displays the current target state and adapter configuration in a single overview.

Terminal window
openocd-python info

Example output:

=== OpenOCD Target Info ===
Target: stm32f1x.cpu
State: halted
PC: 0x08001234
Transport: swd
Adapter: cmsis-dap
Speed: 4000 kHz

The info command queries four things:

  • Target name and state via the targets command
  • Program counter (only when halted) via reg pc
  • Transport (e.g. swd, jtag) via transport select
  • Adapter name and speed via adapter name and adapter speed

If any query fails (for example, no target is configured), that section is skipped rather than causing an error.

Opens an interactive prompt where you can type raw OpenOCD TCL commands and see the responses.

Terminal window
openocd-python repl
OpenOCD REPL (type 'quit' or Ctrl-D to exit)
ocd> targets
TargetName Type Endian TapName State
-- ------------------ ---------- ------ ------------------ -----
0* stm32f1x.cpu cortex_m little stm32f1x.cpu halted
ocd> reg pc
pc (/32): 0x08001234
ocd> adapter speed
4000
ocd> quit
OptionDefaultDescription
--timeout10.0Command timeout in seconds

Exit the REPL by typing quit, exit, q, or pressing Ctrl-D.

Reads a block of memory and displays it as a formatted hexdump with both hex and ASCII columns.

Terminal window
openocd-python read ADDRESS [SIZE]
ArgumentDefaultDescription
ADDRESS(required)Start address in hex (e.g. 0x08000000)
SIZE64Number of bytes to read

Example:

Terminal window
openocd-python read 0x08000000 64
08000000: 00 50 00 20 A1 01 00 08 AB 01 00 08 AD 01 00 08 |.P. ............|
08000010: AF 01 00 08 B1 01 00 08 B3 01 00 08 00 00 00 00 |................|
08000020: 00 00 00 00 00 00 00 00 00 00 00 00 B5 01 00 08 |................|
08000030: B7 01 00 08 00 00 00 00 B9 01 00 08 BB 01 00 08 |................|

The hexdump format shows 16 bytes per line with:

  • Address on the left
  • Two groups of 8 hex bytes separated by a gap
  • ASCII representation on the right (non-printable bytes shown as .)

Scans the JTAG chain and displays all discovered TAPs (Test Access Ports) with their IDCODEs and IR lengths.

Terminal window
openocd-python scan

Example output:

TAP Name IDCODE IR Enabled
--------------------------------------------------
stm32f1x.cpu 0x3BA00477 4 yes
stm32f1x.bs 0x06414041 5 yes

If no TAPs are found, the command prints:

No TAPs found on the JTAG chain.

All commands accept --host and --port to target a remote OpenOCD instance:

Terminal window
# OpenOCD running on a Raspberry Pi
openocd-python --host 192.168.1.50 --port 6666 info
# OpenOCD on a non-standard port
openocd-python --port 7777 repl

If you installed openocd-python in a project managed by uv, use uv run:

Terminal window
uv run openocd-python info
uv run openocd-python read 0x08000000 128

Or run it directly without installation using uvx:

Terminal window
uvx openocd-python info