NRF51 full-screen debugging


NetBeans Debugging

Introduction

This post is a quick tutorial on how to set up a GUI for debugging NRF51 code.

Currently, CLion does not support remote debugging, but they promised to consider it if enough votes were collected – so vote here! I am sure it’s going to be seamless once they implement it, so I’m awaiting eagerly.

Modifying XCode to use ARM tools is a big challenge and support documentation seems to stop at XCode 6. I have it in mind to try to write a plugin to support toolchain switching as well as code templates, so watch this space…

I also tried configuring CodeLite as there were romours that it was possible. Unfortunately it never worked for me (user error, I assume) but I intend to pursue this as I’d like to support this open source effort.

Conscious of my mental well-being, I am avoiding Eclipse and will not refer to it again in this post.

So which shall we use? NetBeans. While not the most modern and the least flexible of above-mentioned IDEs, it actually manages to debug cross-compiled code running on a remote device.

Here’s how

Step 1: Download the C/C++ enabled version of NetBeans from here.


Step 2: Create a new project


Follow the wizard’s path and select to open your project’s root directory.

Step 3: Create a new configuration for the ARM toolchain


Step 4: Set up the toolchain

Enter the path of your ARM toolchain, usually in /usr/local and fill in the rest of the form


You can access this form in the future by clicking on the “Services” tab on the left hand side of the project explorer


Then right click on the configuration name and select “Properties”


This will bring up a similar window as was shown the first time when you configued the toolchain


At this stage, you’ve set up a configuration to use the ARM toolchain.

Step 5: Connect the config to our project.

This is done by selecting “Set Project Configuration” from the Run menu


Step 6: Verify that the project is set to use the ARM config.

This is done by selecting “File/Project Properties” and making sure that “Tool Collection” is set to “ARM”


Step 7: Set up debugging session parameters


You should now be ready!

Let’s build the application by using your makefile


To debug, we must first launch the “jlinkgdbserver” executable, as described in my previous blog.
Unfortunately, I have not found a way to automatically do this from within NetBeans as it does not appear to have a pre-debugging hook where we would have been able to run the server. If anyone is aware of doing so, please alert me and I will update this post.

Open a terminal window and run the following command:

jlinkgdbserver -device nrf51822 -if swd -speed 4000 -noir -port 2331

The result should look something like this:


We can now start our debugger session by selecting “Debug/Attach Debugger” in NetBeans


This will open a dialog that you should fill in as shown here


If everything went well, you should be able to see the code in NetBeans and use their debugger fully!


I hope you found this tutorial helpful! See you next time, hopefully with a solution for CLion and XCode.
Happy hacking!

Some helpful links regarding the subject:

– ARM toolchain: GCC ARM Embedded in Launchpad

– Blog entry on setting up an NRF51 dev environment manually: Nordic NRF51 up and running | InContext, by Itamar Hassin

– Setting up an NRF51 dev environment on your mac: ihassin/fruitymesh-mac-osx · GitHub

– Setting up an NRF51 dev environment using Ansible (VirtualBox and Parallels): ihassin/fruitymesh-ubuntu-vm · GitHub

– Compiling an example using Make and CMake : ihassin/nrf51-blinky-cmake · GitHub

– FruityMesh example module: ihassin/fruitymesh-ping · GitHub

– FruityMesh example on official FruityMesh site: fruitymesh/Readme.md at master · mwaylabs/fruitymesh · GitHub

– Debugging NRF51 code using NetBeans GUI: NRF51 full-screen debugging | InContext, by Itamar Hassin

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s