wdekimpe gravatar image

Posted 2015-06-12 10:06:29 +0100


Debugging using QtCreator on Mac

This post started as a question, but got the suggestion to post this as a blog post. Here it is.

I have been trying to get QtCreator configured such that I can use it as my IDE for the nrf51822 on Mac OSX. I use the NRF51DK as hardware, but also had it working using my own board and a Jlink Lite.

As a starting point I have been reading this post: https://devzone.nordicsemi.com/questi...

Here's what I did in a nutshell:

  1. Installed latest version ofQtCreator (3.4.1) image description
  2. Enabled the Baremetal plugin and restarted QtCreator image description
  3. Configured the bare metal plugin (in preferences->baremetal) to point to the right gdb server on port 2331 (the default port on the jlink gdb server): Add>default, renamed it to Jlink GDB server, and added necessary commands for programming (load) and resetting, and also for redirecting stderr and stdout to the gdb terminal port - these commands will make sure that the software is uploaded to the flash before debugging image description
  4. Added a bare metal device (in preferences->Devices) and named it nrf51822, pointed to the gdb server provider added in previous step image description
  5. Added the compiler - installed the arm gcc toolchain ( https://launchpad.net/gcc-arm-embedded) and point to it in preferences>build&run>compilers: Add>GCC, renamed to ARM GCC, pointed compiler path to the arm-none-eabi-gcc executable, left everything else as default image description
  6. Added debugger (preferences>build&run>Debuggers), renamed it to gdb, pointed to executable arm-none-eabi-gdb-py image description
  7. Added a kit (preferences>build&run>kits), named it nrf51822 also, selected device type Bare Metal Device, selected the Device made in step 4, idem for Compiler (step 5) and Debugger (step6), left Sysroot empty, set Qt version to none, left Qt mkspec empty image description
  8. Changed default projects directory and default build director in preferences>build&run>General, the latter because I do not like the default location for the build files, but this is not really necessary, just personal preference image description
  9. Saved the content of the QBS file as found in answer of question in above mentioned link (https://devzone.nordicsemi.com/questi...) in myproject.qbs and opened that file in QtCreator
  10. In the projects view: add kit - nrf51822, and removed the default desktop kit which was created on opening of the qbs file image description
  11. Adapted the qbs file to my project's content
  12. Built my project
  13. From that I got a build error on Mac OSX. Apparently when compiling using a gcc based toolchain on MacOSX, it adds a build step automatically called dsymutil. Up till now I found no way to solve this other then this trick: copied /usr/bin/dsymutil to arm-gcc-none-eabi-dsymutil in the arm gcc bin directory (same directory as the xxx-gcc an xxx-gdb-py). Compilation goes fine then.
  14. Debug: I installed the jlink tools from segger and started the gdb server from a terminal window, using command JLinkGDBServer -device nrf51822 -if swd -speed 4000. GDB server then starts on localhost port 2331. Then add breakpoints and start debugging (with the green 'play' button) in Qt Creator. Joehoe! :-)

One note: in the qbs script, the output file has extension .out. In fact this an .elf file.

Addition: I used to do printf to a UART port, but got a tip (thanks mmulder) that this can also be redirected to the jlink interface. Here's what I needed to do for that:

  1. Added some commands in the bare metal gdb configuration: image description
  2. Add following to the linker options in the qbs script:


  3. Then I got a compile error, still not sure why: image description

  4. Solved my compilation problem, by defining a new compiler (see step 5 above), not pointing to gcc but to g++, everything else the same, image description and switch to that compiler in the kit definition image description With g++, compilation went fine.

To get the stdout, connect a telnet session to port 2333 after starting gdb.


hkn gravatar image

Posted June 23, 2015, 1:11 p.m.

Nice blog post! Links are not working here, but they are working in your initial post.

If running this guide on windows, be aware of this bug: https://bugreports.qt.io/browse/QBS-709

Cheers, Håkon

adfernandes gravatar image

Posted June 27, 2015, 5:08 p.m.

Awesome - thank you!

Ooch1 gravatar image

Posted July 5, 2015, 8:17 p.m.

That sounds nice, Qt Creator is a great IDE. But is it possible to use the nRF51 SDK in a convenient way with it? I am currently using the makefile setup with Eclipse which is kind of a pita...

skywavedesign gravatar image

Posted Aug. 2, 2015, 5:52 a.m.

Thanks for this article, it really helped me a lot!

I have released an template project based on this and other material:


bsiever gravatar image

Posted Aug. 4, 2015, 6:10 p.m.

Here's a workaround for the dsym hack in step 13:

  1. Qt Creator -> Preferences
  2. Select Qbs (at the bottom of the list)
  3. Select the profile for the nRF kit (created in step 7)
  4. Click the "Edit..." button.
  5. Add a new key/value pair. The key should be qbs.targetOS and I picked other as the value.

Thanks for sharing the info about QtCreator.

minjun gravatar image

Posted June 22, 2016, 9:37 a.m.

Hi, The link address mentioned in this post are all converted to https://devzone.nordicsemi.com/questi, is this one bug for Nordic Developer zone?

I am trying to get the QBS file mentioned in your post, but it is not easy.

Sign in to comment.

Related posts by tag