NRF52 debugging with QtCreator on Windows

Hello I succeeded to configure QtCreator toolchain to compile and debug my NRF52 board. So I wanted to share.

I use my own Makefile to compile everything so I will focus here on how to run a debug session (with breakpoints and candies !) inside QtCreator (which is the best C++ IDE of course).

Even if you are not interested, can you try my tutorial and tell me where you have problems ? So I can detail my configuration. It will help other guys.

My computer

OS: Windows 8.1

Arch: x86-64 but I tried to install 32bits tools

Install QtCreator

Easy step, I have version Qt Creator 4.0.0, based on Qt 5.6.0 (MSVC 2013, 32 bit)

Install Python

  • Because QtCreator uses Python inside gdb.
  • Install version 2.7.11
  • Add to environnement these variables:
  • PYTHONHOME = C:\Python27
  • PYTHONPATH = C:\Python27\Lib

Install GUN ARM toolchain

Here: https://launchpad.net/gcc-arm-embedded/+download

Version 5.3-2016-q1

Install GDB Server

Install SEGGER J-Link GDB Server V5.10u

Install Terminal

To receive/send message via UART. Install RealTerm: Serial Capture Program 2.0.0.70

Install Haroopad

Because it's cool to write documents with!

Configure QtCreator

New GDB Server

  • Open Help > About Plugins...

  • In Device Support section, enable BareMetal (v 4.0.0)

  • Retart QtCreator

  • Open Tools > Options

  • In left pane, click BareMetal

  • Click Add > OpenOCD (even if we don't use OpenOCD)

  • My config:

  • Name = JLink GDB Server

  • Startup mode = No Startup

  • Host = localhost ; 2331

  • Init cmds =

  • set remote hardware-breakpoint-limit 6

  • set remote hardware-watchpoint-limit 6 #(Not sure about limit)

  • monitor semihosting enable

  • load

  • monitor reset 0

  • Reset cmds = monitor reset 0

New Device

  • In Options left pane, go to Devices
  • Click Add, select Bare Metal Device and Start Wizard
  • Name = nrf52 device
  • GDB Server provider = JLink GDB Server (It's our previous config !)

Config GDB

  • In Options left pane, goto Debugger
  • Options I enabled (it works with them, maybe some of them are useless):
  • General tab: Use tooltips ; Warn when debugging Release
  • GDB tab: Adjust bp locations ; Use dynamic object type ; Load .gdbinit ; Load pretty printers
  • GDB Extend: Use asynchronous mode to control the inferior (or QtCreator will crash when you pause execution or set breakpoints while it's running.) ; Use common location for debug information.

New Debugger

  • Options left pane, go to Build & Run

  • Go to Debugger tab

  • Add a new one

  • Name = arm-gdb-py

  • Path = C:\nrf\toolchain\gnu-arm\5.3-2016q1\bin\arm-none-eabi-gdb-py.exe (QtCreator needs python-enabled GDB)

  • Click Apply

New Kit

  • Go to Kits tab

  • Click Add

  • Name = NRF52

  • Device type = Bare Metal Device

  • Device = nrf52 device

  • Compiler = whatever, I use Makefile

  • Debugger = arm-gdb-py

  • Qt Version = None

  • Close and validate Options

Configure new project

  • Create a new project, and import an existing project. It will allow you to use Makefile.
  • In QtCreator left pane, click on Projects
  • Add a Kit NRF52
  • To Build (in Build tab), I use the command line
 make -rRj VERBOSE=0 nrf52
  • To Run (in Run tab), add a Run configuration Custom Executable (on GDB server or HW db). Actually, "run" means that QtCreator will load the firmware into the target via GDB.
  • In Executable, enter path to the ".out" file. If you have never compiled, it is not existent yet.

Profit !

You should be able to set breakpoints and run in debug mode. QtCreator will connect as a GDB client to the JLink GDB server (that you have to launch manually only once). Then QtCreator will send the ".out" file to JLink which will load it into the board.

Any suggestions or improvements are welcome !


Sources: http://lists.qt-project.org/pipermail/qt-creator/2014-June/003748.html https://devzone.nordicsemi.com/blogs/702/debugging-using-qtcreator-on-mac/ http://morf.lv/modules.php?name=tutorials&lasit=37