Skip to content

Instantly share code, notes, and snippets.

@JayKickliter
Last active October 23, 2017 06:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JayKickliter/7503ccb93bf0e844af6ab942cbeb2e11 to your computer and use it in GitHub Desktop.
Save JayKickliter/7503ccb93bf0e844af6ab942cbeb2e11 to your computer and use it in GitHub Desktop.
Debugging MBed nRF52DK board with GDB

Debugging nRF52DK MBed applications with GDB

Step 1 (one time only): replace MBed bootloader with JLink bootloader

  1. Power down nRF52DK
  2. Power up nRF52DK while holding down IF BOOT/RESET button
  3. Drag JLink bootloader binary to BOOTLOADER volume
  4. Power-cycle

At this point, the MBed bootloader has been replaced with JLink's.

Step 2: run JLinkGdbserver

$ JLinkGDBServer -Device NRF52 -If SWD -Speed 4000

Step 3: build application with debug symbols

$ mbed compile -c --profile mbed-os/tools/profiles/debug.json

Step 4 (one time only): create GDB script

Create debug_jlink.gdb in project root:

set history save on
target extended-remote localhost:2331

break _exit
commands
up 3
end

define reload
  load
  start
end

reload

Step 5: launch application using GDB

You can debug using plain GDB, or CGDB, which is a wrapper around GDB and provides a better TUI.

GDB

$ arm-none-eabi-gdb BUILD/NRF52_DK/GCC_ARM/<APP>.elf -x debug_jlink.gdb

CGDB

$ cgdb -d arm-none-eabi-gdb -- BUILD/NRF52_DK/GCC_ARM/<APP>.elf -x debug_jlink.gdb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment