LinuxCommandLibrary

openocd

provides debugging and programming for embedded systems

TLDR

Start with config file

$ openocd -f [interface/stlink.cfg] -f [target/stm32f4x.cfg]
copy
Program flash
$ openocd -f [interface.cfg] -f [target.cfg] -c "program [firmware.elf] verify reset exit"
copy
Start with specific interface
$ openocd -f [interface/jlink.cfg] -f [board/stm32f4discovery.cfg]
copy
Start telnet server only
$ openocd -f [config.cfg] -c "init"
copy
Dump flash memory
$ openocd -f [config.cfg] -c "init" -c "dump_image [output.bin] 0x08000000 0x10000"
copy
Debug output
$ openocd -d3 -f [interface.cfg] -f [target.cfg]
copy

SYNOPSIS

openocd [-f config] [-c command] [-d level] [options]

DESCRIPTION

openocd (Open On-Chip Debugger) provides debugging and programming for embedded systems. It interfaces with JTAG and SWD debug adapters to access microcontrollers.
Configuration files define the debug adapter (interface) and target device. Many boards and adapters have predefined configurations in the installation.
Programming mode flashes firmware to microcontrollers. Verify confirms the write succeeded. Reset starts the new firmware.
When running as a server, OpenOCD provides GDB server (port 3333) and telnet interface (port 4444). GDB connects for source-level debugging.
The telnet interface allows direct commands: halt, resume, step, memory read/write, register access, and breakpoint management.
Multiple targets can be debugged simultaneously. JTAG chains with several devices are supported.

PARAMETERS

-f FILE

Configuration file.
-c CMD
Run command.
-s DIR
Search directory.
-d LEVEL
Debug level (0-3).
-l FILE
Log to file.
--version
Show version.
--help
Show help.

CAVEATS

Requires appropriate adapter hardware. Target configuration must match device. Some features are adapter-specific. Debug permissions may need udev rules.

HISTORY

OpenOCD was started by Dominic Rath as a university project in 2005. It became the standard open-source on-chip debugger, supporting hundreds of target devices and debug adapters. Development continues under community governance.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community