Building and programming a sample application¶
The recommended way of building and programming an nRF Connect SDK sample is to use the Nordic Edition of the SEGGER Embedded Studio (SES) IDE.
SEGGER Embedded Studio is free of charge for use with Nordic Semiconductor devices. After downloading it, you can register and activate a free license.
If you prefer to build your applications from the command line, see Build and Run an Application.
Building with SES¶
You must install a special version of SEGGER Embedded Studio to be able to open and compile the projects in the nRF Connect SDK. You can download it from the following links:
- SEGGER Embedded Studio (Nordic Edition) - Windows x86
- SEGGER Embedded Studio (Nordic Edition) - Windows x64
- SEGGER Embedded Studio (Nordic Edition) - Mac OS x64
- SEGGER Embedded Studio (Nordic Edition) - Linux x86
- SEGGER Embedded Studio (Nordic Edition) - Linux x64
Extract the downloaded package and run the file
Select File -> Open nRF Connect SDK Project.
The first time you import an nRF Connect SDK project, SES will prompt you to set the paths to the Zephyr Base directory and the GNU ARM Embedded Toolchain. Set the Zephyr Base directory to the full path to
ncs\zephyr. The GNU ARM Embedded Toolchain directory is the directory where you installed the toolchain (for example,
If you want to change these settings later, click Tools -> Options and select the nRF Connect tab (see nRF Connect SDK options in SES).
To import a project into SES, you must specify the following information:
- CMakeLists.txt - the location of the
CMakeLists.txtproject file of the sample that you want to work with
- Board Directory - the location of the board description of the board for which to build the project
- Board Name - the board name (select from the list that is populated based on the board directory)
- Build Directory - the folder in which to run the build (automatically filled based on the board name, but you can specify a different directory)
- Delete Existing CMakeCache.txt - select this option to ensure that you are not building with an outdated build cache
The following figure shows an example configuration for the Asset Tracker application built for the
- CMakeLists.txt - the location of the
Click OK to import the project into SES. You can now work with the project in the IDE.
Build and flash your project. The required steps differ depending on if you build a single application or a multi-image project (such as the nRF9160 samples, which include SPM).
If you are working with an nRF9160 DK, make sure to select the correct controller before you flash the application to your board.
Put the SW5 switch (marked debug/prog) in the NRF91 position to program the main controller, or in the NRF52 position to program the board controller. See the Device programming section in the nRF9160 DK User Guide for more information.
To build and flash an application:
- Select your project in the Project Explorer.
- From the menu, select Build -> Build Solution.
- When the build completes, you can flash the sample to a connected board:
- For a single-image application, select Target -> Download zephyr/zephyr.elf.
- For a multi-image application, select Target -> Download zephyr/merged.hex.
Alternatively, choose the Build and Debug option. Build and Debug will build the application and flash it when the build completes.
To inspect the details of the flashed code and the memory usage, click Debug -> Go.
In a multi-image build, this allows you to debug the source code of your application only.
When using SES to build the nRF Connect SDK samples, it might return an error indicating a project load failure. For example:
Can't load project file The project file <filepath> is invalid. The reported error is 'solution load command failed (1)'
This issue might be caused by a variety of problems, such as incorrectly specified project file paths. SES helps you to identify the source of the issue by providing a text output with detailed information about the error. Make sure to click OK on the error pop-up message and then inspect the text output in SES.
On Windows and Linux, SES uses the PATH variable to find executables. If you get an error that a tool or command cannot be found, first make sure that the tool is installed. If it is installed, add its location to the PATH variable.
For some tools, you can explicitly specify the location under Tools -> Options (select the nRF Connect tab).
Setup on macOS¶
On macOS, the global PATH variable is used only if you start SES from the command line.
If you start SES by running the file
bin/emStudio, the global PATH is not used, and you must specify the path to all executables under Tools -> Options (select the nRF Connect tab, see nRF Connect SDK options in SES).
In addition, specify the path to the west tool as additional CMake option, replacing path_to_west with the path to the west executable (for example,