Development with Eclipse and GCC

Updated version here (21.04.15):

I have noticed that there have been several questions on development with Eclipse and GCC, and I have also been trying myself for quite some time to make it work properly. It finally seems like I have figured out an approach that works for me. I.e., successfully importing and debugging of example projects from the nRF51 SDK. So I thought I could make a blog post to share my setup and hopefully help others who are also new to Eclipse and GCC.

Inspired by other devzone users I found out that the easiest solution to setup Eclipse with debugging is probably by using the GNU ARM eclipse plug-in from Regardless, it still it took me some time to get it all working so I have described my approach for importing and debugging SDK 6.0 exampe projects below.

Required tools:

Setting up Eclipse with register view

  • Start Eclipse

  • Click Help and select Install new software

  • Install embsysreqview

  • To install the register view file for Nordic Semiconductor devices copy file nrf51.xml to the folder eclipse\plugins\org.eclipse.cdt.embsysregview_x.x.x\data\cortex-m0\Nordic. nrf51.xml is located in SDK v.x.x.x\SVD.

Configuration step-by-step:

  1. First step is to make sure that the GNU ARM toolchain and Jlink are installed correctly by building and downloading an example project from SDK to a target. This is done by opening the command line in the gcc directory in one of the projects and type the 'make' command with the -f option to specify which makefile to use. After a successful build you should be able to flash your device by typing "make flash -f filename". Remember to flash softdevice beforehand with nRFgo studio when using example projects located in sXXX(softdevice) folders. image description
  2. Open Eclipse and install the GNU ARM plug-in like shown below. See for more details. In my setup I chose to install the Cross compiler and J-link debugging support only, but the others can also be installed if needed.image description
  3. Import an example project from SDK by making a new "makefile project with existing code". The screenshot below does for instance show how to import the heart rate example. You can also choose the Cross ARM GNU toolchain if you wish to make a Nordic project from scratch with auto-generation of makefiles , just make sure to set the toolchain path is defined in your Eclipse environment. image description
  4. The project should now be visible in your workspace. Then right-click on the project folder and enter properties->C/C++ Build and change the build directory to the gcc folder. Unmark "Use default build command" and type "make" if it is not the default build command. image description
  5. Next we have to tell Eclipse what make option to use during build, which by default is set to 'all'. As defined in the Nordic makefile.common 'all' = 'clean' +'release'. We want to change that to 'debug' in order to enable debugging of the application. It is possible to set the make option by adding new targets to chose what you want to build, but I prefer to set the Build option like shown in screenshot below. This is to ensure that potential auto-build configurations does not suddenly start a build with an unexpected make option.

image description

  1. Next step is to rename the Makefile you want to use in the gcc folder. In my case "ble_app_hrs.Makefile" -> "Makefile". If it is preferred to keep the filename the "-f filename" option can be added to the build command instead. The compiler will otherwise not find the Makefile. Now you should be able to successfully build the project. However, despite the successful build you will see that there are several errors in the Eclipse project. This is because Eclipse is not able to automatically index the include files and symbols declared in the Makefile. I have not found an solution for this besides adding the paths and symbols manually. Debugging will still work without adding the paths and symbols manually as Eclipse is a pure IDE and gcc and gdb take care of the build and debug. However, I prefer to add the paths and symbols in Eclipse to better find declarations,references,etc. located outside main in the project. image description.

  2. Indexing or not, the application should be ready for a debugging now. First build the solution by right clicking on the project folder and press "Build project". Then enter tab Run-> Debug Configurations (Alternatively the bug icon in the toolbar) to set up the debug interface. Make sure that the C/C++ Application path is pointing to the .out file of the built.
    image description

Then set the correct device name in the debugger tab according to your target. See "Supported device name" if you are unsure. Next step is to edit the "jlink_path" variable. Change the path to your latest version of your Segger driver folder (../JLink_Vxx). Then set arm-none-eabi-gdb in the GDB client Setup. SWO can also be disabled under Startup tab as it is not supported by the nRF devices (will only give a warning).

image description

9.That is it. Here is the debug view of the heart rate example:image description

10.Flash downloading can be done with nrfjprog.exe directly from Eclipse. On the run menu, click 'External tools Configuration', select 'program', and then click 'new'. Then set the location of nrfjprog: C:\Program files (x86)\Nordic Semiconductor\nrf51\bin\nrfjprog.exe, and your current working directory: ${workspace_loc}//_build. Then the last step is to provide the nrjprog arguments for programming the hex file: --program{workspace_loc}//_build/.hex --reset. Clicking the 'run' button will then program application to the board.


Edit 8.4.2015 - Removed references to deprecated application note.

Parents Comment Children
No Data