What is it and how to use it?
Segger Embedded Studio (SES) is an Integrated Development Environment (IDE) for Nordic Semiconductor products, such as nRF52832 which is at the heart of RuuviTag. IDE brings together almost all the steps required for developing C-code for RuuviTags, such as writing the code, compiling the code, flashing the code to RuuviTag and debugging the code as it is being run on RuuviTag. This is a very different approach from GNU-tools, which generally follow the principle of doing only one thing such as compiling, linking or debugging.
It’s possible to use SES without Ruuvi development shield, but using a wired JLINK connection of nRF52-DK is strongly recommended.
You can also follow Nordic Semiconductor’s video instructions to get started.
How to get it?
Head to the Segger website and select the version for your operating system. Be sure to have at least version 3.40.
Setting up the project
In this tutorial we use ruuvi.firmware.c as a base. The firmware implements the functionality of official Ruuvi Firmware as of July 2019, it is built on top of Nordic SDK15 which has official support for SES. Start by running
git clone https://github.com/ruuvi/ruuvi.firmware.c.git
git checkout 3.30.2
git submodule update --init --recursive
Then you should download Nordic Semiconductor SDK and unzip on the same level as ruuvi.firmware.c project. Version 3.30.2 of Ruuvi firmware uses Noridc SDK 15.3
After you have installed the SES, simply open the project file from
ruuvi.firmware.c/src. You can open the project by selecting “File” from the top bar and the “Open solution”.
Compiling the project
To verify that you have everything as needed, select “Build” from the top bar and click “Build ruuvi.firmware.c”. On first compilation you’re asked to register SES. Enter your details and you’ll receive activation key on your email.
After a short while you should see “Build Complete” and Flash + RAM usage report.
Flashing the project
Connect your RuuviTag to your JLINK and JLINK to your computer via USB. Author prefers to use a RuuviTag ziptied to ruuvi Development kit.
Select “Target” from the top bar and “Connect to JLINK”. To flash the project, select “Target”->”Download ruuvi.firmware.c”. This will erase the tag and flash the softdevice + application to the RuuviTag. It’s important to note that the download will not include the bootloader.
Debugging the project
Select “Target” and “Connect JLINK”. Then Select “Target” and “Attach debugger”. Now you should see the program running and printing log texts from PLATFORM_LOG_INFO to the debug terminal.
SES supports using the hardware breakpoints in case you need to step through your program. Click on the line number on the left and you should see a red ball appear in your program. Select “Debug” and “Restart”. The program will halt in the fist line of main. You can then step over or into function calls, or run until the program reaches the breakpoint.
Adding new files to the project
You can add new files by right clicking on the project explorer structure and selecting “Add new file”, “Add existing file” or “New folder”. However, included .h files are not seen outside their folder to files. To include .h files in your project, right click “Project ruuvi.firmware.c”, make sure project configuration “Common” is selected and click “Preprosessor” under “Code”. Select “User include directories” and include the directory with your header files.
Including bootloader in the binary
If you wish to include the bootloader in the binary, you’ll have to use same process as with the ARMGCC. Use nrfutil to create bootloader settings and and merge the softdevice 6.0.0, bootloader, application and settings into one hex. This hex can then be flashed to your target. The official packaging script for ARMGCC is available at GitHub, please note that scripts are board-specific.