A year has passed since I wrote the first part of this guide. Now, I decided to finish it, but for this second part, I am using updated versions of development tools (Installation instructions from the first part are still valid with minor changes). Now, this is my current setup :
- OS: Gnome Ubuntu 16.04.3 LTS 64-bit
- GNU toolchain for ARM: gcc-arm-none-eabi-7-2017-q4-major (Download)
- GNU Make 4.1
- nRF5 SDK 14.2.0
- JLink v6.22g (Download)
- nrfjprog version: 9.7.2 (Download)
- Eclipse Oxygen.2
Assuming, that a basic example has been built and flashed to our board, we are going to continue with eclipse setup. In addition to previous tools, we need to install the GNU MCU Eclipse (formerly GNU ARM Eclipse) plug-in.
2.1 Installing GNU MCU Eclipse from Marketplace
You can install this plugin from the Eclipse Marketplace (Help > Eclipse Marketplace). Search ‘ARM’ and select “GNU MCU Eclipse” from the results. The required packages to install are:
- GNU MCU C/C++ ARM Cross Compiler
- GNU MCU C/C++ J-Link Debugging
- GNU MCU C/C++ Packs
After installation, open the “packs” perspective to download the packs corresponding to nRF Family. You can open it from menu window > perspective > Open perspective > Other. Then a window appears for selecting the perspective:
Also you can use the icon in the top bar to make packs perspective visible:
Within the packs view, click refresh icon in the top-left to populate the list of available packs. This could take some time and it gets stuck in some repositories, so click “ignore” in when a pop-up window appears. When download finishes, look for NordicSemiconductor and right-click on nRF_DeviceFamilyPack and Install it. At this time the latest version is 8.15.2
2.2 Creating a project in Eclipse (From an example in SDK)
For this guide, I will not use project templates provided in Devzone tutorial. Instead of this I will create a new project for an example from the SDK. I will use the ble_app_blinky example and the nRF52840PDK (PCA10056).
First, create a Makefile project from existing code vía File menu. In the window that appears, locate the ble_app_blinky folder and the folder corresponding to the board:
Now, we should see in Project Explorer the new project containing the Makefile, the linker file, and if we previously build the example from console, we should also see a _build folder:
The next step, following the recommendation from Nordic’s blog, is to create virtual folders and link source files to them. First, we will start with main.c. Right-click on project > New > Folder. In Advanced, select Virtual Folder and name it “Application”. After this, right-click on Application folder and select New > File. In the new window, click on Advanced and choose option “Link to file in the filesystem” and locate the main.c file at <SDK_PATH>/examples/ble_peripheral/ble_app_blinky/main.c
In the Project Explorer view now appears the folder Application and the main.c file in it.
2.3 Building from Eclipse
At this moment, we successfully open the main.c file of our application in Eclipse, but a lot of problems are highlighted, almost the entire file. This is because we are using our own Makefile, and Eclipse indexer does not know where files and symbols are located. This is our view at this moment (or something similar):
Not only the indexer is not configured but also the build tools, which is the next we are going to set up.
Go to menu window > preferences. Here, we are going to set the path for arm-gcc toolchain and SEGGER JLink selecting “Global ARM toolchain Path” and “Global SEGGER J-Link Path” items respectively.
Now, the following changes should be done in project properties window:
- Configure default build command to make “VERBOSE=1”
- Configure providers to feed the indexer with location of files and headers.
Finally, we need to modify the Makefile.common file contained in the SDK, it is located at:
We need to remove the quotes around toolchain commands, as stated in devzone tutorial, but for this version of SDK, this file changed, so line 116 should be:
After following the previous steps, you should be able to build the project from Eclipse (the hammer icon) and see the output in the console view. It should be something like:
22:49:55 **** Build of configuration Default for project ble_app_blinky **** make VERBOSE=1 all mkdir _build cd _build && mkdir nrf52840_xxaa Compiling file: nrf_log_backend_rtt.c ... (A lot of output of compiled files) '/home/gustavo/apps/gcc-arm-none-eabi-7-2017-q4-major/bin/arm-none-eabi-size' _build/nrf52840_xxaa.out'/home/gustavo/apps/gcc-arm-none-eabi-7-2017-q4-major/bin/arm-none-eabi-size' _build/nrf52840_xxaa.out text data bss dec hex filename 25304 628 2196 28128 6de0 _build/nrf52840_xxaa.outPreparing: _build/nrf52840_xxaa.hex'/home/gustavo/apps/gcc-arm-none-eabi-7-2017-q4-major/bin/arm-none-eabi-objcopy' -O ihex _build/nrf52840_xxaa.out _build/nrf52840_xxaa.hexPreparing: _build/nrf52840_xxaa.bin'/home/gustavo/apps/gcc-arm-none-eabi-7-2017-q4-major/bin/arm-none-eabi-objcopy' -O binary _build/nrf52840_xxaa.out _build/nrf52840_xxaa.binDONE nrf52840_xxaa 22:50:06 Build Finished (took 10s.997ms)
The next steps, as recommended in Nordic’s tutorial, is to create links to files used by the application and grouping them in virtual folders, as we did with the main.c file.
Any suggestion, comment or correction is well received.