Ruuvilab
As seen on Kickstarter

Segger Embedded Studio

« Back to tutorials

Professional IDE free-to-use for Nordic Semiconductor products

firmware

Comments

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. While the firmware is not "ready" for really anything as of July 2018, 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
cd ruuvi.firmware.c
git submodule update --init --recursive
git checkout 3.0.3-alpha

Then you should download Nordic Semiconductor SDK15 and unzip on the same level as ruuvi.firmware.c project.

After you have installed the SES, simply open the project file from ruuvi.firmware.c/targets/ruuvitag_b/ses. 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. Author's shell script for creating package and flashing it is below. Please note that official bootloader is not yet available. 

#!/bin/bash
NAME="dev"
VERSION="0.0.1"
while getopts "n:v:" option;
do
case "${option}"
in
n) NAME=${OPTARG};;
v) VERSION=${OPTARG};;
esac
done

nrfutil settings generate --family NRF52 --application _build/nrf52832_xxaa.hex --application-version 1 --application-version-string "$VERSION" --bootloader-version 1 --bl-settings-version 1 settings.hex
mergehex -m ../../../../nRF5_SDK_15.0.0_a53641a/components/softdevice/s132/hex/s132_nrf52_6.0.0_softdevice.hex ./ruuvi_bootloader.hex settings.hex -o sbc.hex
mergehex -m sbc.hex _build/nrf52832_xxaa.hex -o packet.hex
nrfjprog --family nrf52 --eraseall
nrfjprog --family nrf52 --program packet.hex
nrfjprog --family nrf52 --reset


echo "preparing ruuvi_${NAME}_${VERSION}"
mv packet.hex ruuvi_${NAME}_${VERSION}_full.hex
cp _build/nrf52832_xxaa.hex ruuvi_${NAME}_${VERSION}_app.hex
nrfutil pkg generate --application _build/nrf52832_xxaa.hex --application-version 1 --application-version-string "$VERSION" --hw-version 0x00000b --sd-req 0xA8 --key-file ~/git/ruuvitag_fw/keys/ruuvi_open_private.pem ruuvi_${NAME}_${VERSION}_dfu.zip

 

 

Comments

Share your project

#ruuvitag / @ruuvicom

Ruuvi Innovations Ltd (Oy) / Finland

Web Design Niku Creative