Installing manually
The recommended way to get started with the nRF Connect SDK is to use nRF Connect for Desktop. See the Installing automatically page for information about how to install automatically.
Note
If you use nRF Connect for Desktop to install the nRF Connect SDK, you can skip this section of the documentation. If you prefer to install the toolchain manually, see the following documentation for instructions.
To manually install the nRF Connect SDK, you must install all required tools and clone the nRF Connect SDK repositories. See the following sections for detailed instructions.
If you already have your system set up to work with Zephyr OS based on Zephyr’s Getting Started Guide, you already have some of the requirements for the nRF Connect SDK installed. The only requirement not covered by the installation steps in Zephyr is the GN tool. This tool is needed only for Matter (Project CHIP) applications. You can also skip the Install the GNU Arm Embedded Toolchain section.
Before you start setting up the toolchain, install available updates for your operating system. See Requirements for information on the supported operating systems and Zephyr features.
Install the required tools
The installation process is different depending on your operating system.
Note
You will be asked to reboot after installing some of the tools. You can skip these notifications and reboot only once after you complete the installation of all tools.
The recommended way for installing the required tools on Windows is to use Chocolatey, a package manager for Windows. Chocolatey installs the tools so that you can use them from a Windows command-line window.
To install the required tools, complete the following steps:
Open a
cmd.exe
window as Administrator. To do so, press the Windows key, type “cmd.exe”, right-click the result, and choose Run as Administrator.Disable global confirmation to avoid having to confirm the installation of individual programs:
choco feature enable -n allowGlobalConfirmation
Use
choco
to install the required dependencies:choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System' choco install ninja gperf python git dtc-msys2
Ensure that these dependencies are installed with their versions as specified in the Required tools table.
To install the required tools on Ubuntu, complete the following steps:
Download, inspect and execute the Kitware archive script to add the Kitware APT repository to your sources list. A detailed explanation of
kitware-archive.sh
can be found here kitware third-party apt repository:wget https://apt.kitware.com/kitware-archive.sh sudo bash kitware-archive.sh
Use
apt
to install the required dependencies:sudo apt install --no-install-recommends git cmake ninja-build gperf \ ccache dfu-util device-tree-compiler wget \ python3-dev python3-pip python3-setuptools python3-tk python3-wheel xz-utils file \ make gcc gcc-multilib g++-multilib libsdl2-dev
Verify the versions of the main dependencies installed on your system by entering:
cmake --version python3 --version dtc --version
Ensure that these dependencies are installed with their versions as specified in the Required tools table. Refer to the Install Linux Host Dependencies page for additional information on updating the dependencies manually. If you are using other Linux-based operating systems, see the Install Requirements and Dependencies section in the Zephyr documentation.
Note
You do not need to install the Zephyr SDK. We recommend to install the compiler toolchain separately, as detailed in Install the GNU Arm Embedded Toolchain.
To install the required tools, complete the following steps:
Install Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Use
brew
to install the required dependencies:brew install cmake ninja gperf python3 ccache qemu dtc
Ensure that these dependencies are installed with their versions as specified in the Required tools table. Also see macOS alternative setup instructions in the Zephyr documentation for additional information.
In addition to these required tools, install the GN meta-build system if you are interested in building Matter (formerly Project Connected Home over IP, Project CHIP) applications. This system generates the Ninja files that the nRF Connect SDK uses.
To install the GN tool, complete the following steps:
Download the latest version of the GN binary archive for Windows from the GN website.
Extract the
zip
archive.Check that the GN tool is added to your
PATH
environment variable. See Environment Variables for instructions if needed.
To install the GN tool, complete the following steps:
Create the directory for the GN tool:
mkdir ${HOME}/gn && cd ${HOME}/gn
Download the GN binary archive and extract it by using the following commands:
wget -O gn.zip https://chrome-infra-packages.appspot.com/dl/gn/gn/linux-amd64/+/latest unzip gn.zip rm gn.zip
The wget tool is installed when installing the required tools on Linux.
Add the location of the GN tool to the system
PATH
. For example, if you are usingbash
, run the following commands:echo 'export PATH=${HOME}/gn:"$PATH"' >> ${HOME}/.bashrc source ${HOME}/.bashrc
To install the GN tool, complete the following steps:
Create the directory for the GN tool:
mkdir ${HOME}/gn && cd ${HOME}/gn
Install the wget tool:
brew install wget
Download the GN binary archive and extract it by using the following commands:
wget -O gn.zip https://chrome-infra-packages.appspot.com/dl/gn/gn/mac-amd64/+/latest unzip gn.zip rm gn.zip
Add the location of the GN tool to the system
PATH
. For example, if you are usingbash
, run the following commands:Create the
.bash_profile
file if you do not have it already:touch ${HOME}/.bash_profile
Add the location of the GN tool to
.bash_profile
:echo 'export PATH=${HOME}/gn:"$PATH"' >> ${HOME}/.bash_profile source ${HOME}/.bash_profile
Install west
To manage the combination of repositories and versions, the nRF Connect SDK uses Zephyr’s west.
To install west, complete the following step:
Enter the following command in a command-line window:
pip3 install west
Enter the following command in a terminal window:
pip3 install --user west
Enter the following command in a terminal window:
pip3 install west
You only need to do this once.
Get the nRF Connect SDK code
Every nRF Connect SDK release consists of a combination of Git repositories at different revisions. The revision of each of those repositories is determined by the current revision of the main (or manifest) repository, sdk-nrf.
Note
The latest state of development is on the main
branch of the sdk-nrf repository.
To ensure a usable state, the sdk-nrf repository defines the compatible states of the other repositories.
However, this state is not necessarily tested.
For a higher degree of quality assurance, check out a tagged release.
Unless you are familiar with the development process, you should always work with a specific release of the nRF Connect SDK.
For more information about the repository and development model, see the development model section.
To clone the repositories, complete the following steps:
Create a folder named
ncs
. This folder will hold all nRF Connect SDK repositories.Determine the identifier of the revision of the nRF Connect SDK you want to work with. The recommended way is to work with a specific release.
To work with a specific release, the identifier is the corresponding tag (for example,
v1.9.1
). You can find the tag in the Release notes of the release.To work with a development tag, the identifier is the corresponding tag (for example,
v1.2.99-dev1
)To work with a branch, the identifier is the branch name (for example,
main
to work with the latest state of development).To work with a specific state, the identifier is the SHA (for example,
224bee9055d986fe2677149b8cbda0ff10650a6e
).
From the command line, initialize west with the revision of the nRF Connect SDK that you want to check out, replacing NCS_revision with the identifier:
west init -m https://github.com/nrfconnect/sdk-nrf --mr NCS_revision
For example, to check out the v1.9.1 release, enter the following command:
west init -m https://github.com/nrfconnect/sdk-nrf --mr v1.9.1
To check out the latest state of development, enter the following command:
west init -m https://github.com/nrfconnect/sdk-nrf --mr main
Note
If you get an error message when running west, update west to the latest version. See Troubleshooting West if you need more information.
Initializing west with a specific revision of the manifest file does not lock your repositories to this version. Checking out a different branch or tag in the sdk-nrf repository and running
west update
changes the version of the nRF Connect SDK that you work with.This will clone the manifest repository sdk-nrf into
nrf
.Enter the following command to clone the project repositories:
west update
Depending on your connection, this might take some time.
Export a Zephyr CMake package. This allows CMake to automatically load the boilerplate code required for building nRF Connect SDK applications:
west zephyr-export
Your directory structure now looks similar to this:
ncs
|___ .west
|___ bootloader
|___ modules
|___ nrf
|___ nrfxlib
|___ zephyr
|___ ...
Note that there are additional folders, and that the structure might change. The full set of repositories and folders is defined in the manifest file.
Install additional Python dependencies
The nRF Connect SDK requires additional Python packages to be installed.
Use the following commands to install the requirements for each repository.
Enter the following command in a command-line window in the ncs
folder:
pip3 install -r zephyr/scripts/requirements.txt pip3 install -r nrf/scripts/requirements.txt pip3 install -r bootloader/mcuboot/scripts/requirements.txt
Enter the following command in a terminal window in the ncs
folder:
pip3 install --user -r zephyr/scripts/requirements.txt pip3 install --user -r nrf/scripts/requirements.txt pip3 install --user -r bootloader/mcuboot/scripts/requirements.txt
Enter the following command in a terminal window in the ncs
folder:
pip3 install -r zephyr/scripts/requirements.txt pip3 install -r nrf/scripts/requirements.txt pip3 install -r bootloader/mcuboot/scripts/requirements.txt
Install the GNU Arm Embedded Toolchain
To be able to cross-compile your applications for Arm targets, you must install version 9-2019-q4-major of the GNU Arm Embedded Toolchain.
Important
Make sure to install the toolchain version that is mentioned above. Other toolchain versions might not work with this version of the nRF Connect SDK. Similarly, other versions of the nRF Connect SDK might require a different toolchain version.
Do not use GNU Arm Embedded Toolchain versions 9-2020-q2-update and 10-2020-q4-major due to TF-M sample incompatibility issue. These versions do not work correctly when compiling binaries for Cortex-M Secure Extensions.
To set up the toolchain, complete the following steps:
Download the GNU Arm Embedded Toolchain for your operating system.
Extract the contents of the root folder of the toolchain into a directory of your choice. The recommended folder is
c:\gnuarmemb
on Windows and~/gnuarmemb
on Linux or macOS. Make sure that the folder name does not contain any spaces or special characters. By default, the contents are extracted to another folder that corresponds to the GNU Arm Embedded Toolchain version (version-folder in the following step). For example,c:\gccarmemb\9_2019-q4-major
, where9_2019-q4-major
is the version-folder name edited to contain no empty spaces.If you want to build and program applications from the command line, define the environment variables for the GNU Arm Embedded Toolchain. Depending on your operating system:
Open a command-line window and enter the commands below.
If you did not install the toolchain in the recommended folder, change the value of
GNUARMEMB_TOOLCHAIN_PATH
to the folder you used and make sure to provide the name of the version-folder.set ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb set GNUARMEMB_TOOLCHAIN_PATH=c:\gnuarmemb\version-folder
Open a terminal window and enter the commands below.
If you did not install the toolchain in the recommended folder, change the value of
GNUARMEMB_TOOLCHAIN_PATH
to the folder you used and make sure to provide the name of the version-folder.export ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb export GNUARMEMB_TOOLCHAIN_PATH="~/gnuarmemb/version-folder"
Open a terminal window and enter the commands below.
If you did not install the toolchain in the recommended folder, change the value of
GNUARMEMB_TOOLCHAIN_PATH
to the folder you used and make sure to provide the name of the version-folder.export ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb export GNUARMEMB_TOOLCHAIN_PATH="~/gnuarmemb/version-folder"
Set the environment variables persistently. Depending on your operating system:
Add the environment variables as system environment variables or define them in the
%userprofile%zephyrrc.cmd
file as described in Set up the command-line build environment. This lets you avoid setting them every time you open a command-line window.Define the environment variables in the
~/.zephyrrc
file as described in Set up the command-line build environment. This lets you avoid setting them every time you open a terminal window.Define the environment variables in the
~/.zephyrrc
file as described in Set up the command-line build environment. This lets you avoid setting them every time you open a terminal window.
Install a build IDE
You can install either the nRF Connect for Visual Studio Code extension or the SEGGER Embedded Studio (SES) Nordic Edition to open and compile projects in the nRF Connect SDK:
Visual Studio Code extension
The nRF Connect for Visual Studio Code extension is a complete IDE for developing applications for nRF91, nRF53 and nRF52 Series devices. This includes an interface to the compiler and linker, an RTOS-aware debugger, a seamless interface to the nRF Connect SDK, and a serial terminal. For detailed instructions, see the nRF Connect for Visual Studio Code documentation site.
SEGGER Embedded Studio Nordic Edition
You can install the SEGGER Embedded Studio (SES) Nordic Edition to open and compile projects in the nRF Connect SDK. SES is free of charge for use with Nordic Semiconductor devices.
To install the Nordic Edition, download the package for your operating system:
Extract the downloaded package in the directory of your choice.
Note
Notifications about newer versions of SES are disabled in the SES Nordic Edition. This is because of the custom nRF Connect SDK options that are available only in the Nordic Edition. You will not be able to use SES with the nRF Connect SDK if you install the latest standard version of SES.
When you move to a newer release of the nRF Connect SDK, check the Requirements page for the given release to see if you are using the minimum required version of SES Nordic Edition. If you need to install the latest version of the SES Nordic Edition, follow the steps described above and make sure to set up the build environment in SES once more.
Set up the build environment in SES
If you chose to use SEGGER Embedded Studio for building and programming a sample application, you must first set up your build environment.
Set up the SES environment. If you plan to build with SEGGER Embedded Studio, the first time you import an nRF Connect SDK project, SES might prompt you to set the paths to the Zephyr Base directory and the GNU ARM Embedded Toolchain. You only need to do this once. Complete the following steps:
Navigate to the
bin
directory.Run the
emStudio
executable file.Click OK on the pop-up window that opens.
Set the GNU ARM Embedded Toolchain directory path to the location where it was downloaded (for example,
c:\gnuarmemb
).Close the nRF Connect options window.
Navigate to Tools > Options and select the nRF Connect tab.
Set the full path of the Zephyr Base directory to
ncs/zephyr
.
Set up executables. The process is different depending on your operating system.
Make sure the locations of executable tools are added to the
PATH
variable, including Python, CMake, Ninja, and DTC. On Windows, SES uses thePATH
variable to find executables if they are not set in SES.Make sure the locations of executable tools are added to the
PATH
variable, including Python, CMake, Ninja, and DTC. On Linux, SES uses thePATH
variable to find executables if they are not set in SES.If you start SES on macOS by running the
emStudio
executable file, make sure to complete the following steps:Specify the path to all executables under Tools > Options (in the nRF Connect tab).
Use this section to change the SES environment settings later as well.
Specify the path to the west tool as an additional CMake option, replacing path_to_west with the path to the west executable (for example,
/usr/local/bin/west
):-DWEST=path_to_west
If you start SES from the command line, it uses the global
PATH
variable to find the executables. You do not need to explicitly configure the executables in SES.Regardless of how you start SES, 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, verify that its path is configured correctly in the SES settings or in the
PATH
variable.
If you want to change the SES environment settings after the initial setup, click Tools > Options and select the nRF Connect tab, as shown on the following screenshot from the Windows installation.
If you want to configure tools that are not listed in the SES options, add them to the PATH
variable.
Set up the command-line build environment
In addition to nRF Connect for Visual Studio Code and SEGGER Embedded Studio, you can also build and program your application from the command line. You have to set up your build environment by defining the required environment variables every time you open a new command-line or terminal window.
See Important Build System Variables for more information about the various relevant environment variables.
Define the required environment variables as follows, depending on your operating system:
Navigate to the ncs
folder and enter the following command: zephyr\zephyr-env.cmd
If you need to define additional environment variables, create the file %userprofile%zephyrrc.cmd
and add the variables there.
This file is loaded automatically when you run the above command.
See Option 3: Using zephyrrc files for more information.
Navigate to the ncs
folder and enter the following command: source zephyr/zephyr-env.sh
If you need to define additional environment variables, create the file ~/.zephyrrc
and add the variables there.
This file is loaded automatically when you run the above command.
See Option 3: Using zephyrrc files for more information.
Navigate to the ncs
folder and enter the following command: source zephyr/zephyr-env.sh
If you need to define additional environment variables, create the file ~/.zephyrrc
and add the variables there.
This file is loaded automatically when you run the above command.
See Option 3: Using zephyrrc files for more information.
You must also make sure that nrfjprog (part of the nRF Command Line Tools) is installed and its path is added to the environment variables. The west command programs the development kit by using nrfjprog by default. For more information on nrfjprog, see Programming SoCs with nrfjprog.