liveBook · Manning

OpenOCD

As explained in Embedded Software with Rust

Open On-Chip Debugger is open-source software that provides debugging, in-system programming, and boundary-scan access through hardware probes.

OpenOCD (Open On-Chip Debugger) connects a host computer to a microcontroller through a hardware debug probe. It supports firmware flashing and interactive debugging over SWD or JTAG, including reset, halt, resume, single-stepping, breakpoints, and memory access. section 2.5.2 section 6.5.5

In a GDB session, OpenOCD acts as the GDB server. GDB communicates with it over a TCP socket using the remote serial protocol; OpenOCD communicates with the probe over USB, and the probe drives the target’s debug lines. section 6.5.5

To set up a basic session:

  • Install OpenOCD using your platform’s package manager. On Windows, use the official binaries or install it through WSL. section 2.5.2
  • Create an openocd.cfg file identifying both the probe interface and the target chip. Shipped configurations are in the installation’s scripts/interface and scripts/target directories; their location varies by platform. section 2.5.2 section 6.5.5
  • Run openocd from the configuration file’s directory. Its GDB server listens on port 3333; connect from GDB with target extended-remote :3333. section 6.5.5
source [find interface/stlink.cfg]
source [find target/stm32f1x.cfg]

This minimal configuration selects an ST-Link probe and an STM32F1 target. Older OpenOCD releases used separate ST-Link variant files; current versions use stlink.cfg with auto-detection. section 6.5.5

openocd -f openocd.cfg -c "program target/thumbv7m-none-eabi/release/
your_project verify reset exit"

This example programs a built firmware image, verifies it, resets the target, and exits. Replace the image path with the firmware to flash. section 2.5.2

GDB with OpenOCD offers detailed, hardware-specific investigation but involves more explicit setup and manual steps. A probe-rs and defmt workflow favors faster iterations and compact logging, with less emphasis on deep hardware analysis. section 2.6.5

How Embedded Software with Rust covers it

How deep it goes
Explains the debug pipeline, installation, configuration discovery, GDB connection, and a firmware-flashing command.
Examples
Uses an ST-Link probe and STM32F1 target configuration, plus a command to program and verify a firmware image.
What you can do after
Operate/configure OpenOCD to connect GDB to a target and flash a firmware image.
How it connects
Connects GDB, SWD, JTAG, debug probes, and firmware flashing; contrasts probe-rs and defmt workflows.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Embedded Software with Rust. The section links point to the parts of the book it draws on.