Skip to main content
Use OpenOCD to debug with an ST-Link, a CMSIS-DAP probe, or another adapter that OpenOCD supports. Compatibility depends on the OpenOCD build, the exact MCU, and the board wiring.

What you need

Embedder looks for OpenOCD in this order:
  1. Embedder’s own copy, if it has already downloaded one.
  2. openocd on PATH, or in a common install folder:
  3. A new download of Embedder’s own copy. This starts in the background when you open a project and no OpenOCD is found, or when a debug session needs one.
Because Embedder’s copy comes first once it’s downloaded, an OpenOCD you install afterward isn’t used. To use your own build, install it before Embedder downloads its copy, and ask Embedder which OpenOCD it detected before you rely on it.

Prepare

  1. Connect and power the target and debug adapter. Install any drivers or USB permissions the adapter needs.
  2. Identify the OpenOCD interface and target configurations for the board (see the table below).
  3. Build the firmware ELF with symbols. To attach, use the ELF that matches the firmware on the board.
  4. Run /debug and ask Embedder to check OpenOCD and GDB readiness.
In EMBEDDER.md, set Debug Interface = st-link or Debug Interface = cmsis-dap, along with the exact MCU and verified debug command. Without an interface setting, Embedder assumes ST-Link. When the target can’t be detected reliably, give the target configuration explicitly.

Connect and inspect

Replace build/app.elf with your build output. Embedder asks you to approve before it connects, unless your approval settings already allow it. A normal connection programs the ELF and tries to stop at main. From there, ask for breakpoints, stepping, variables, registers, or memory, as described in GDB debugging.

Script the connection

For a repeatable check, a hardware script can open the connection itself. This example applies only to a board verified to use ST-Link and the stm32f4x target configuration:
Save the script under .embedder/hardware/, replace the artifact and configuration values, and ask Embedder to run it. This example programs the target. The debugger connection closes when the script ends.

Preserve an existing run

Ask for attach-only to load symbols without programming or running to main. Add no-halt when execution should continue. In a script, use attach=True and no_halt=True. These options don’t make every OpenOCD configuration nonintrusive. Startup commands in the configuration can still affect the target. No-halt without attach-only still programs the ELF, then resets and halts the target. Read the attachment precautions before investigating a live fault.

Observe output

Use ITM/SWO when the MCU, probe, wiring, and firmware support it. Supply the correct CPU and SWO frequencies. Ordinary GDB debugging doesn’t need SWO.

Flash a bridge board

OpenOCD also programs boards on a remote hardware bridge that have an OpenOCD target and interface but no chip name. Install OpenOCD on the bridge host, then see Flash through a bridge.

Troubleshoot

  • No target configuration matches: verify the MCU and check the target files in the OpenOCD installation in use. Don’t substitute a nearby family.
  • No target could be determined: add the platform to the project, or give the target configuration name.
  • Adapter or USB access fails: check drivers, device permissions, wiring, target power, and competing applications.
  • Transport mismatch: confirm whether the target needs SWD or JTAG and that the interface and target configurations support it.
  • Download of Embedder’s OpenOCD fails, or your host isn’t supported: use the reported error to fix the network or host setup, or install OpenOCD yourself, for example with brew install openocd or apt install openocd.
  • Port already in use: another debug server is running. Stop it, then retry.
  • Probe busy after switching tools: stop the previous debugger or monitor before retrying. Starting OpenOCD closes other OpenOCD processes that use the same executable.
Last modified on October 13, 2026