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).
- 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.