We have had issues getting the debugger to work.  I discovered that it wasn’t so much that the connections were wrong, as Eclipse being very finicky.

When it falls into a trap before getting to main, it can be because: the code is expecting SEMIHOSTING, but gdb is not ready to catch.  If semi-hosting libraries are used in the firmware, then semi-hosting must be enabled in gdb.

Put another way, code will simply fail to start (trap at 0x0) if semi-hosting apparatus is not physically set up.

The following has to be  setup exactly right for semi-hosting to work:

If it hits a trap at 0x0 then there is no trap handler for semi-hosting, or there is no code loaded.

If the code should hit a breakpoint, but simply starts automatically, then it is perhaps because debugging has not been specified to the compiler, and it is not generating the debug handles.  It ought to look like this:

If user-breakpoints are being skipped then it might be because the code has been optimized away.  Turn all optimization off like this:

If it hits the breakpoint at main, but the source doesn’t show up then it probably failed to load the symbols from the elf file.   The spec should look like this.

If there are incorrect load symbol files, or no load symbol files specified, or the file names don’t look like the above, then close this dialog, close the project, re-open it, and refresh the projects and then see if the right file names are turning up.

To remove semihosting the following has to be done:

  1. Remove the defined constants
    DEBUG_NRF_USER
    DEBUG
  2. Remove the other linker flags: -mabi=aapcs –specs=rdimon.specs -Wl,–start-group -lgcc -lc -lc -lm -lrdimon -Wl,–end-group
  3. Clear these check boxes
    and on the previous “debugger” tab: 

Leave a Reply