Debugging with Lazarus (J Link) - michael-ring/mbf GitHub Wiki

To be able to debug from within Lazarus you need to use a debug Probe.

For this example we use Segger J-Link, a very affordable Debug Probe for Hobbists when bought as a standalone solution, but there is also a big number of boards available that either already bring an on-board J-Link debugger for free or can be re-flashed to be J-Link compatible.

J-Link can be flashed on nearly all Nucleo or Discovery boards from ST.com and is also available as a flash update for a huge number of NXP Boards.

The debugging experience highly depends on your workflow. Using breakpoints to navigate to the relevant code works a lot better than using single stepping/step over a lot, in my experience it does not take long until a step gets misinterpreted and the app continues to run.

So I try to get close to the root cause of an issue and then use Breakpoints and a very limited number of stepping.

Configuration inside of Lazarus is staightforward:

First Step:

Open Lazarus Options and navigate to Debugger and activate the Debugger backend settings.

Now fill in the options as seen on this screenshot, most values can stay with their default values:

images/IDE-Options.png

Second Step:

Now install J-Link Package for your platform from Segger's website:

[https://www.segger.com/downloads/jlink/#J-LinkSoftwareAndDocumentationPack](J-Link Software Pack)

and install the software.

When done start the J-Link GDBServer and configure it for your Controller:

images/J-LinkConfig.png

Hit OK and you are ready to debug your code from within Lazarus.

One Hint: Debugging works OK for small projects but for low-level Debugging and a more stable interface there are alternatives which are described in other articles in this Wiki