GDB and OpenOCD and DAP

I'm currently trying to get an overview of how GDB is able to remotely debug an Arm microcontroller.

From what I understand the following sequence takes place:

GDB client -> OpenOCD server -> JTAG converter -> Debug access port -> Coresight Debug Components (e.g. Breakpoint unit)

The Coresight TRM provides a good overview of how registers are exposed through the DAP - http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0314h/Cihbhhde.html

If a DAPLink is used as the JTAG/SW converter, it provides the CMSIS-DAP commands, a standard interface for accessing the DAP. I can see how this can be used to read the registers of coresight debug components.

I am unsure of how GDB and OpenOCD fit together. Does GDB receive the ROM table and send its commands to OpenOCD, such as set breakpoint? Or does GDB just have general knowledge of the Arm architecture, and OpenOCD deals with the low level details of accessing of debug registers?

Thanks

Posted Feb 11, 2019, 10:32 PM UTC

23
duskwuff•

Or does GDB just have general knowledge of the Arm architecture, and OpenOCD deals with the low level details of accessing of debug registers?

Correct. The GDB remote serial protocol -- which is what GDB uses to communicate with OpenOCD -- operates at a relatively high level. Implementing those commands in terms of DAP operations is the job of OpenOCD.

2
zydeco100•

I've recently been debugging by using Segger's GDB server directly over JLink in Linux (/opt/Segger/JLink/JLinkGDBServerCLExe). The target was a Cortex-A7.

Didn't need an OpenOCD server in the mix at all.

1
FreddieChopin•

JLinkGDBServer that you used fulfills the same role as OpenOCD does - works as a middleman between GDB and the hardware. The only difference is that your software works with JLink only, while OpenOCD works with many other adapters.

3