This blog post aims to describe how to setup a fully functional nRF51 development environment using Eclipse and the GCC toolchain. We are using a Segger JLink GDB server for the debugging portion, but there are OpenOCD plugins which should work (provided that it supports SWD).
The Nordic application note nAN-29 describes the setup using Sourcery CodeBench Lite and the nRF51822, but I will be using GNU Tools for ARM Embedded Processors with the nRF51422.
- Nordic Application Note nAN-29
- GNU Tools for ARM
- Nordic nRF51422 SDK (will need a product key to download)
- Eclipse IDE for C/C++ developers
- jLink GDB Server
- GNU Coreutils
The following plugins will need to be installed within eclipse. Please refer to this guide for the steps to take to install a new plugin (the Nordic Application note also covers it).
- EmbSysRegView: http://embsysregview.sourceforge.net/update
- GNU ARM Eclipse Plugin: http://gnuarmeclipse.sourceforge.net/updates
Current Versions as of this writing
- GNU Tools for ARM: 4.8-2014-q1
- Nordic nRF51422 SDK: 5.2.0
- jLink: 4.84f
- Core Utils: 5.3.0
- Make: 3.81
- EmbSysRegView: 0.2.4
- Gnu ARM Eclipse Plugin for JLink: 1.5.1
Setting Up Eclipse
Since the application note provides good information in many sections, we will be referring back to it as needed.
Section 1.1 in the application note provides a good overview for installing some necessary plugins. Use the same technique to add the GNU ARM Eclipse Plugin.
Import and Configure Existing Makefile Project
Section 1.2 in the application note describes the Code Sourcery setup, but since we are using GNU make, we can ignore most of the suggestions, except when it comes to Paths and Symbols.
Note that I have added the paths for not only gcc, but app_common and the s210 soft device. You may need to add other related directories if you want eclipse to not show errors in the UI.
The Symbols shown, BOARD_NRF6310 and NRF51, are necessary to include.
Adding Debugging Support for JLink
Since we have already installed the GNU ARM plugin for eclipse, we can add a new debug configuration for our device. Note you’ll need to successfully do a build to find the *.out file for the debug configuration. The corresponding section in the application note is Section 2.
For the debugger, add the path to the arm-non-eabi-gdb.exe binary:
C:\Program Files (x86)\GNU Tools ARM Embedded\4.8 2014q1\bin\arm-none-eabi-gdb.exe
For startup, you’ll need to add the same options provided in the application note (substituting NRF51422 as needed):
mon speed 10000
mon endian little
mon flash download = 1
mon flash device = NRF51422
mon reset 0
The application note’s recommendation of using nrfjprog.exe in section 3 is good, but I use ‘make flash’.
Enabling EmbSys Register Viewer
Following the application note’s (nAN-29 Section 4) recommendation will correctly setup the register viewer.
Notes on Folder Paths for Projects
GDB has some problems with spacese in the debugging path for the application source code, so to successfully debug your code on device, make sure that the path to your source directory has no spaces.
Another interesting note is that Segger JLink will breakpoint your processor at the hard fault handler if you have allocated too many breakpoints while using a Segger JLink lite (4 breakpoint limit).
With these recommendations combined with Nordic’s application note nAN-29, we can have an eclipse development environment with GDB debugging from within eclipse, using a full GCC toolchain. When I followed the original application note I ran into areas where GDB entered unknown territory (GDB couldn’t find the source code). With these modifications GDB works flawlessly.
nAN-29 is removed from Nordic site since Nordic thinks it is no longer valid. Anyway to repost it here? or make steps in details without reference to nAN-29. Thanks.
Since Nordic has removed the application note 29, I will need to update the post so that it stands alone from the application note. Thanks for posting a note about the application note removal, a tutorial isn’t very useful if the links it refers to is missing.
Have you tried using VisualGDB for Visual Studio. It has worked great for me on an embedded project using GDB and GCC.
I haven’t specifically tried VisualGDB for Visual Studio, but it looks good. It may be the subject of a followup blog post if I get some time to work on it. I generally like Eclipse since it is an open source project and with GNU ARM Eclipse plugins I can develop and test firmware changes quickly within Eclipse.
I had the same problem finding nAN-29. But I used archive.org with the bad link for it and it was there.
Thanks, Way Back Machine!
I am having the following error when start the debugging session.
No source available for “0xffffffff”
Do you have any idea?
Thanks in advance