Installing the nRF Connect SDK
There are different ways to install the nRF Connect SDK, depending on your preferred development environment and the toolchain management tool:
Using Visual Studio Code and the nRF Connect for VS Code extension (recommended)
Using command line and nRF Util
Regardless of which way you choose, the following steps install the nRF Connect SDK source code and the nRF Connect SDK toolchain. This includes everything that is required by Zephyr’s Getting Started Guide together with additional tools and Python dependencies that the nRF Connect SDK uses.
Note
Using Visual Studio Code and the nRF Connect for VS Code extension is also covered in the Installing nRF Connect SDK and VS Code exercise of the nRF Connect SDK Fundamentals course on Nordic Developer Academy.
Update operating system
Before you start setting up the toolchain, install available updates for your operating system.
Operating System |
x86 |
x64 |
ARM64 |
---|---|---|---|
Tier 3 |
Tier 3 |
Not supported |
|
Tier 3 |
Tier 1 |
Not supported |
|
Not supported |
Tier 1 |
Not supported |
|
Not supported |
Tier 2 |
Not supported |
|
Not applicable |
Tier 3 |
Tier 3 |
|
Not applicable |
Tier 1 |
Tier 1 |
|
Not applicable |
Tier 3 |
Tier 3 |
|
Not applicable |
Tier 2 |
Tier 2 |
|
Not applicable |
Tier 3 |
Not supported |
See Supported operating systems for more information about the tier definitions.
Install prerequisites
Depending on your preferred development environment, install the following required tools:
The latest version of the nRF Command Line Tools package. Download it from the nRF Command Line Tools page.
The latest version of Visual Studio Code for your operating system from the Visual Studio Code download page.
In Visual Studio Code, the latest version of the nRF Connect for VS Code Extension Pack.
Linux users: nrf-udev module with udev rules required to access USB ports on Nordic Semiconductor devices and program the firmware.
The latest version of nRF Util development tool, a unified command line utility for Nordic products.
Note
After downloading the nRF Util executable, move it to a directory that is in the system
PATH
. On macOS and Linux, the downloaded file also needs to be given execute permission by typing chmod +x nrfutil or by checking the checkbox in the file properties.The latest version of the nRF Command Line Tools package. Download it from the nRF Command Line Tools page.
Note
After downloading and installing the tools, add nrfjprog to the system
PATH
in the environment variables.Linux users: nrf-udev module with udev rules required to access USB ports on Nordic Semiconductor devices and program the firmware.
Install the nRF Connect SDK toolchain
The nRF Connect SDK toolchain includes the Zephyr SDK and then adds tools and modules required to build nRF Connect SDK samples and applications on top of it. These include the required tools, the Python dependencies, and the GN tool for creating Matter applications.
When you first install the nRF Connect SDK, it is recommended to install the latest released versions of the SDK and the toolchain.
Depending on your preferred development environment, complete the following steps:
Open the nRF Connect extension in Visual Studio Code by clicking its icon in the Activity Bar.
In the extension’s Welcome View, click on Manage toolchains. The list of actions appears in the Visual Studio Code’s quick pick.
Click Install Toolchain. The list of available toolchain versions appears in the Visual Studio Code’s quick pick.
Select the toolchain version to install. The toolchain version should match the nRF Connect SDK version you are going to work with. If you have received a custom URL for installing the toolchain, you can provide it using the Change Toolchain Index button in the quick pick’s header (wrench icon). The toolchain installation starts in the background, as can be seen in the notification that appears.
When you install the toolchain for the first time, the installed version is automatically selected for your project.
After installing the toolchain, you can access the Install Toolchain option by clicking on Manage toolchains.
Open a terminal window.
Run the following command to install the nRF Util
toolchain-manager
command:nrfutil install toolchain-manager
Run the following command to list the available installations:
nrfutil toolchain-manager search
The versions from this list correspond to the nRF Connect SDK versions and will be version in the following step.
Run the following command to install the toolchain version for the SDK version of your choice:
nrfutil toolchain-manager install --ncs-version version
For example:
nrfutil toolchain-manager install --ncs-version v2.0.0
This example command installs the toolchain required for the nRF Connect SDK v2.0.0.
The toolchain is installed by default at C:/ncs/toolchains
on Windows, ~/ncs/toolchains
on Linux, and /opt/nordic/ncs/toolchains
on macOS.
If you have received a custom URL for installing the toolchain, you can use the following command to set it as default, replacing the respective parameter:
nrfutil toolchain-manager config --set toolchain-index=custom_toolchain_URL
If you have received a custom bundle ID for installing a specific toolchain version, you can use the following commands to provide it, replacing the respective parameter:
nrfutil toolchain-manager install --bundle-id custom_bundle_ID
To check the current configuration setting, use the nrfutil toolchain-manager config --show
command.
To read more about these commands, use the nrfutil toolchain-manager --help
command.
You can check the versions of the required tools and Python dependencies on the Requirements reference page.
Get the nRF Connect SDK code
Every nRF Connect SDK release consists of a combination of Git repositories at different versions and revisions, managed together by West. The revision of each of those repositories is determined by the current revision of the main (or manifest) repository, sdk-nrf. Simply put, you can work with the following versions of the nRF Connect SDK:
nRF Connect SDK version |
Required identifier of the revision |
Where to find the identifier |
---|---|---|
Specific release (recommended) |
Release tag (for example, |
Release notes of the release |
Development tag (for example, |
Changelog of the tag |
|
Branch |
Branch name (for example, |
sdk-nrf repository |
Note
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 nRF Connect SDK code base page.
To clone the nRF Connect SDK code, complete the following steps:
Open the nRF Connect extension in Visual Studio Code by clicking its icon in the Activity Bar.
In the extension’s Welcome View, click on Manage SDKs. The list of actions appears in the Visual Studio Code’s quick pick.
Click Install SDK. The list of available SDK versions appears in the Visual Studio Code’s quick pick.
Select the SDK version to install. When you first install the nRF Connect SDK, it is recommended to install the latest released versions of the SDK and the toolchain.
The SDK installation starts and it can take several minutes.
To clone the repositories, complete the following steps:
On the command line, open the directory
ncs
. By default, this is one level up from the location where you installed the toolchain. This directory will hold all nRF Connect SDK repositories.Start the toolchain environment for your operating system using the following command:
nrfutil toolchain-manager launch --terminal
nrfutil toolchain-manager launch --shell
nrfutil toolchain-manager launch --shell
Determine the identifier of the revision of the nRF Connect SDK you want to work with. See the table above for more information. When you first install the nRF Connect SDK, it is recommended to install the latest released versions of the SDK and the toolchain.
Initialize west with the revision of the nRF Connect SDK that you want to check out, replacing nRFConnectSDK_revision with the identifier:
west init -m https://github.com/nrfconnect/sdk-nrf --mr nRFConnectSDK_revision
For example:
Specific release: To check out the v2.7.0 release, enter the following command:
west init -m https://github.com/nrfconnect/sdk-nrf --mr v2.7.0
Development tag: To check out the
v1.9.2-dev1
tag, enter the following command:west init -m https://github.com/nrfconnect/sdk-nrf --mr v1.9.2-dev1
Branch: To check out the
main
branch that includes the latest state of development, enter the following command:west init -m https://github.com/nrfconnect/sdk-nrf --mr main
This will clone the manifest repository sdk-nrf into
nrf
.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.Note
If you get an error message when running west, update west to the latest version. See Troubleshooting West in the Zephyr documentation for more information.
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
If you used the default locations (C:ncs
on Windows, <home>/ncs
on Linux and MacOS), your directory structure now looks similar to this:
ncs
├─── toolchains
│ └─── <toolchain-installation>
└─── <west-workspace>
├─── .west
├─── bootloader
├─── modules
├─── nrf
├─── nrfxlib
├─── zephyr
└─── ...
In this simplified structure preview, <home> corresponds to ncs/
and <toolchain-installation> and <west-workspace> correspond to the version names you installed.
There are also additional directories, and the structure might change over time, for example if you later change the state of development to a different revision.
The full set of repositories and directories is defined in the manifest file (see the file in the repository).
Set up the command-line build environment
Note
This step is only required when working on command line with freestanding applications.
In addition to the steps mentioned above, if you want to build and program your application from the command line, you have to set up your command-line build environment by defining the required environment variables every time you open a new command-line or terminal window. See Important Environment Variables in the Zephyr documentation for more information about the various relevant environment variables.
Define the required environment variables as follows, depending on your operating system:
Complete the following steps:
Navigate to the
ncs
directory.Open the directory for your nRF Connect SDK version.
Run the following command in a terminal window:
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 Zephyr documentation about using zephyrrc files for more information.
Complete the following steps:
Navigate to the
ncs
directory.Open the directory for your nRF Connect SDK version.
Run the following command in a terminal window:
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 Zephyr documentation about using zephyrrc files for more information.
Complete the following steps:
Navigate to the
ncs
directory.Open the directory for your nRF Connect SDK version.
Run the following command in a terminal window:
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 Zephyr documentation about using zephyrrc files for more information.
System-wide installation
System-wide installation is an alternative to the recommended installation methods using the nRF Connect for VS Code extension or nRF Util. It gives you more control over each of the required tools, but requires more familiarity with Zephyr and with each of the tools.
To install the nRF Connect SDK system-wide, complete the following steps:
Follow the steps in the following sections of Zephyr’s Getting Started Guide to update your operating system and install dependencies:
Install west. Expand the section below to see the commands.
Note
It is easy to run into Python package incompatibilities when installing dependencies at a system or user level. This situation can happen, for example, if working on multiple Zephyr versions or other projects using Python on the same machine.
For this reason, it is suggested to use Python virtual environments.
Create a new virtual environment:
cd %HOMEPATH% python -m venv ncs/.venv
Activate the virtual environment:
ncs\.venv\Scripts\activate.bat
Once activated your shell will be prefixed with
(.venv)
. The virtual environment can be deactivated at any time by runningdeactivate
.Note
Remember to activate the virtual environment every time you start working.
Install west:
pip3 install west
Install west:
pip3 install -U west
Use
apt
to install Pythonvenv
package:sudo apt install python3-venv
Create a new virtual environment:
python3 -m venv ~/ncs/.venv
Activate the virtual environment:
source ~/ncs/.venv/bin/activate
Once activated, your shell will be prefixed with
(.venv)
. The virtual environment can be deactivated at any time by runningdeactivate
.Note
Remember to activate the virtual environment every time you start working.
Install west:
pip3 install west
Install west and make sure
~/.local/bin
is on yourPATH
environment variable:pip3 install --user -U west echo 'export PATH=~/.local/bin:"$PATH"' >> ~/.bashrc source ~/.bashrc
Create a new virtual environment:
python3 -m venv ~/ncs/.venv
Activate the virtual environment:
source ~/ncs/.venv/bin/activate
Once activated, your shell will be prefixed with
(.venv)
. The virtual environment can be deactivated at any time by runningdeactivate
.Note
Remember to activate the virtual environment every time you start working.
Install west:
pip3 install west
Install west:
pip3 install -U west
Get the nRF Connect SDK code as described in Get the nRF Connect SDK code for the command line. (You can skip step 2.) When you first install the nRF Connect SDK, it is recommended to install the latest released version of the SDK.
Install the Python dependencies. Expand the section below to see the commands.
Note
You might run into Python package incompatibilities when installing dependencies at a system or user level. For this reason, it is suggested to use Python virtual environments.
Enter the following commands in a
cmd.exe
terminal window in thencs
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 commands 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
Enter the following commands 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
Follow the steps in the “Install the Zephyr SDK” section in Zephyr’s Getting Started Guide to install the Zephyr SDK.
Depending on your preferred development environment:
If you want to work with Visual Studio Code, install the nRF Connect for VS Code extension (the default IDE for the nRF Connect SDK).
If you want to work from command line, Set up the command-line build environment.
If you want to build Matter applications, additionally install the GN meta-build system. This system generates the Ninja files that the nRF Connect SDK uses for Matter. See GN tool for more information.
Installation with Toolchain Manager
Note
The Toolchain Manager installation is recommended only when using the nRF54H20 DK with the nRF Connect SDK v2.7.0. When using any other DK, the Toolchain Manager installation is recommended for the nRF Connect SDK v1.9.x and earlier versions.
Toolchain Manager is a tool available from nRF Connect for Desktop, a cross-platform tool that provides different applications that simplify installing the nRF Connect SDK. Both the tool and the application are available for Windows, Linux, and macOS.
To install the toolchain and the SDK using the Toolchain Manager app, complete the following steps:
Install Toolchain Manager:
Download nRF Connect for Desktop for your operating system.
Install and run the tool on your machine.
In the APPS section, click Install next to Toolchain Manager.
The app is installed on your machine, and the Install button changes to Open.
Install the nRF Connect SDK source code:
Open Toolchain Manager in nRF Connect for Desktop.
Click SETTINGS in the navigation bar to specify where you want to install the nRF Connect SDK.
In SDK ENVIRONMENTS, click the Install button next to the nRF Connect SDK version that you want to install. When you first install the nRF Connect SDK, it is recommended to install the latest released versions of the SDK and the toolchain.
The nRF Connect SDK version of your choice is installed on your machine. The Install button changes to Open VS Code.
Set up the preferred building method:
To build on the nRF Connect for VS Code extension, complete the following steps:
In Toolchain Manager, click the Open VS Code button.
A notification appears with a list of missing extensions that you need to install, including those from the nRF Connect for Visual Studio Code extension pack.
Click Install missing extensions.
Once the extensions are installed, click Open VS Code button again.
You can then follow the instructions in Creating application in the nRF Connect for VS Code extension.
To build on the command line, complete the following steps:
With admin permissions enabled, download and install the nRF Command Line Tools.
Restart the Toolchain Manager application.
Click the dropdown menu for the installed nRF Connect SDK version.
Select the option to open a terminal window:
Windows: Open command prompt
Linux and macOS: Open Terminal
You can then follow the instructions in Creating application for use with command line.
Note
You can use the Generate environment script button to create a script that lets you switch between different nRF Connect SDK versions. After you create the script, rename it and put it in a directory in your system
PATH
. This works the same way as the--as-script
flag for nRF Util’s Toolchain Manager command (nrfutil toolchain-manager env --as-script
).