Debugging target firmware


Using OpenOCD

OpenOCD supports stepping, adding breakpoints watch points when you are debugging your firmware codes.

First, make sure you have the OpenOCD started. If you already done so in the “Flashing target firmware” section, you could skip this step now. Otherwise run the following command in a privileged terminal.

$ openocd.exe -f interface/cmsis-dap.cfg -f target/nrf51.cfg

Then open the second privileged terminal to set up a telnet debug session with your target device:

$ target remote localhost:3333

Now we need to set some breakpoints in the code:

> break main.c:25

Stop the currently running code using the following command:

> monitor reset halt

Reset the code back to start:

> monitor reset init

Now we can run the firmware program which will pause at the break point we just set:

> continue

Using Keil

Adding breakpoints, debugging and stepping in Keil is pretty straightforward, it’s all been setup on the IDE GUI, refer to the Keil documentation to details.