Custom Projects in nRF5-SDK : Segger Embedded Studio (Arch linux)
07 Sep 2019, 12:26am TZ +05:30
Developing custom projects with nRF5-SDK for nRF52 devices from Nordic Semiconductors.
Keeping the mess of files away !
Fig: Segger Embedded Studio
Source: Segger Embedded Studio
Its been some time since I worked on BLE. So pulled out my nRF52-DK to try to start again.
Fig: nRF52-DK Board
Source: Nordic Semiconductors
BLE was really rusted. Looked at my past projects like
etc. They were already covered in layer of dust growing on them.
And so was the firmware. Nothing seams to work with Keil.
Hence I started on another adventure. Finding out how to do development on nRF52 the new way.
This time working under Manjaro Linux my choice of distro,
based on Arch Linux under the hood 😎.
Segger Embedded Studio #
To my surprise, Nordic Semiconductors had Segger Embedded Studio as default development environment.
I would walk you through the steps I took. Understanding the new way of developing with nRF5-SDK.
The focus on Segger Embedded Studio as default development environment. Due to availability of tooling and debugging support in Out-of-The-Box fashion.
IMPORTANT! its free for Commercial use by Nordic Semiconductors nRF52 and nRF51 products.
This is great no more struggling with
makefiles and Keil.
Well we first need to download the SDK.
Here we would be looking at
That was the latest one at Sept,2019.
There were a few video series that helped me out:
Playlist from Nordic Semiconductors on how to get started on Segger Embedded Studio
Tutorial on how to make your own nRF5-SDK sample projects:
I followed some work published by the same author. The second video in the above list.
After a few trials and error I found the right way to do this.
Setting up your Workspace #
Let’s walk through the steps. It might seem long but you would like in and remember it well.
I do at least, since its more copy paste than hack this - hack that stuff.
Step 1 : Directory Setup #
Note that both the SDK and Project are in the same Directory.
Though we would not touch the SDK we still need it for actual code compile and to extract from the examples.
First Create the Directory Listing & extract the SDK as follows:
Where the environment variables are as follows:
export NRF_SDK_VERSION="nRF5_SDK_15.3.0_59ac345"is version of SDK
export PROJECT_NAME="MyBlinky"is the Name of your desired project
export BRD="nRF52DK"This is the Board being used possible values include
- etc from the nRF52xxx family or may be a custom board
- Note In case of custom Board One needs to add a Compiler Define to the common configuration in Segger Embedded Studio
The actual file would be
export CONFIG="blank"This is the memory and soft-device configuration
- “mbr” with Master Boot Record
- “s132” with S132 Soft-Device configuration
The Last line would create an empty file tagging the SDK version in which the given project was created.
configdirectory would store the respective configuration for SDK files
Note: We can create multiple of
$BRD-$CONFIGcombos as needed. The
srcfolder would remain the same.
Step 2 : Get the Files in Order #
Next, we would need to copy the specific files.
2.1 Source Files #
First among them would be source code placed in the
2.2 SDK Configuration #
The Configuration for SDK stored in
This needs to be copied to the
2.3 Segger Embedded Studio project files #
Next the Project Files
This would need the respective project files for Segger Embedded Studio
.emProject , e.g.
Typically this is located at
ses directory in each of the example’s
corresponding configuration folder.
directory contains the files:
We need to copy all these 3 to the
Note that in this case we are specifically talking about the
peripheral examples. We can also the the similar job in case
of a BLE example also.
Step 3: Modifying the Project Configuration #
.emProject file is a XML file storing the project config.
There are specific sections of this file that need to be modified:
3.1 Project Name #
The part of
"blinky_pca10040" would change the executable name.
3.2 Include Directories #
This might look as a mangled thing but its essentially path.
Hence we need to modify the configuration accordingly:
../../../configThis is for OS Configuration in case of FreeRTOS
Need to Change this to
../src/configwhere we might have the
../../../../../../componentsand many more are actually the Path to SDK Components.
Hence this also needs to be changed.
We would transform
And similarly we can transform all other Directory Paths as well.
../configThis is the Last one it points to
In Our present configuration we have this at
Note All paths are separated by
;and this needs to remain correct.
In the End add
../srcto include all header files in
The transformed Block would look like
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
c_user_include_directories="../src/config; ../../nRF5_SDK_15.3.0_59ac345/components; ../../nRF5_SDK_15.3.0_59ac345/components/boards; ../../nRF5_SDK_15.3.0_59ac345/components/drivers_nrf/nrf_soc_nosd; ../../nRF5_SDK_15.3.0_59ac345/components/libraries/atomic; ../../nRF5_SDK_15.3.0_59ac345/components/libraries/balloc; ../../nRF5_SDK_15.3.0_59ac345/components/libraries/bsp; ../../nRF5_SDK_15.3.0_59ac345/components/libraries/delay; ../../nRF5_SDK_15.3.0_59ac345/components/libraries/experimental_section_vars; ../../nRF5_SDK_15.3.0_59ac345/components/libraries/log; ../../nRF5_SDK_15.3.0_59ac345/components/libraries/log/src; ../../nRF5_SDK_15.3.0_59ac345/components/libraries/memobj; ../../nRF5_SDK_15.3.0_59ac345/components/libraries/ringbuf; ../../nRF5_SDK_15.3.0_59ac345/components/libraries/strerror; ../../nRF5_SDK_15.3.0_59ac345/components/libraries/util; ../../nRF5_SDK_15.3.0_59ac345/components/toolchain/cmsis/include; ../../..; ../../nRF5_SDK_15.3.0_59ac345/external/fprintf; ../../nRF5_SDK_15.3.0_59ac345/integration/nrfx; ../../nRF5_SDK_15.3.0_59ac345/modules/nrfx; ../../nRF5_SDK_15.3.0_59ac345/modules/nrfx/hal; ../../nRF5_SDK_15.3.0_59ac345/modules/nrfx/mdk;config;../src;"
3.3 Preprocessor Definition #
These are the Preprocessor Directives separated by
For Custom Board We would need to change
That would transform to
Final Block would become Only in case of Custom Board:
3.4 Other Paths #
Replace anywhere the
../../../../../../components pattern occurs
with the as explained
for all files and tools as well.
3.5 Source File Section #
Finally the Source file section
This would transform to :
Based on the Project configuration.
Now this modified
.emProject can be used in Segger Embedded Studio.
That’s all you begin your adventure with derived projects.