Datasheet
Can I use GDB to debug my nRF52?
You can, yes, but it will require a Segger J-Link (that's what we've tested against anyway, other options exist), and it's
an advanced operation. But if you're asking about it, you probably know that.
Assuming you have the Segger J-Link drivers installed, you can start Segger's GDB Server from the command line
as follows (OSX/Linux used here):
$ JLinkGDBServer -device nrf52832_xxaa -if swd -speed auto
Then open a new terminal window, making sure that you have access to gcc-arm-none-eabi-gdb from the
command line, and enter the following command:
$ ./arm-none-eabi-gdb something.ino.elf
` something.ino.elf ` is the name of the .elf file generated when you built your sketch. You can find this by enabling
'Show verbose output during: [x] compilation' in the Arduino IDE preferences. You CAN run GDB without the .elf file,
but pointing to the .elf file will give you all of the meta data like displaying the actual source code at a specific
address, etc.
Once you have the (gdb) prompt, enter the following command to connect to the Segger GDB server (updating
your IP address accordingly, since the HW isn't necessarily local!):
(gdb) target remote 127.0.0.1:2331
If everything went well, you should see the current line of code where the device is halted (normally execution on
the nRF52 will halt as soon as you start the Segger GDB Server).
At this point, you can send GDB debug commands, which is a tutorial in itself! As a crash course, though:
To continue execution, type ' monitor go ' then ' continue '
To stop execution (to read register values, for example.), type ' monitor halt '
To display the current stack trace (when halted) enter ' bt '
To get information on the current stack frame (normally the currently executing function), try these:
info frame : Display info on the current stack frame
info args : Display info on the arguments passed into the stack frame
info locals : Display local variables in the stack frame
info registers : Dump the core ARM register values, which can be useful for debugging specific fault
conditions
© Adafruit Industries https://learn.adafruit.com/adafruit-itsybitsy-nrf52840-express Page 27 of 179










