Installing the nRF Connect SDK
There are different ways to install the nRF Connect SDK, depending on your preferred development environment:
Using Visual Studio Code and nRF Connect for Visual Studio Code (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 nRF Connect for VS Code 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 to make sure it supports the nRF Connect SDK firmware.
Operating System |
x64 |
ARM64 |
|---|---|---|
Built and tested with Twister. |
Not supported. |
|
Built and tested with Twister. Comprehensive testing with Nordic Semiconductor hardware. |
Not supported. |
|
Not supported. |
Built and tested with Twister. |
Install prerequisites
Depending on your preferred development environment, install the following software tools.
All operating systems:
The v9.24a of SEGGER J-Link. Download it from the J-Link Software and Documentation Pack page. On Windows, install it manually together with SEGGER USB Driver for J-Link.
Additionally, for Windows users: SEGGER USB Driver for J-Link, required for support of older Nordic Semiconductor devices. For information on how to install the USB Driver, see the nRF Util prerequisites documentation.
Additionally, for Linux users: the nrf-udev module with udev rules required to access USB ports on Nordic Semiconductor devices and program the firmware.
Additionally, install Visual Studio Code:
The latest version of Visual Studio Code for your operating system from the Visual Studio Code download page or using this direct link.
In Visual Studio Code, the latest version of the nRF Connect for VS Code Extension Pack. nRF Connect for VS Code comes with its own bundled version of some of the nRF Util commands.
Note
You can also use a different IDE compatible with the VSIX format and install the extensions that are part of the nRF Connect for VS Code Extension Pack from the Open VSX Registry. However, Nordic Semiconductor does not test editors other than Visual Studio Code for compatibility with nRF Connect for VS Code. While you are encouraged to report any issues you encounter on DevZone, issues discovered in editors other than Visual Studio Code and not reproducible in Visual Studio Code will not be prioritized.
All operating systems:
The v9.24a of SEGGER J-Link. Download it from the J-Link Software and Documentation Pack page. On Windows, install it manually together with SEGGER USB Driver for J-Link.
Additionally, for Windows users: SEGGER USB Driver for J-Link, required for support of older Nordic Semiconductor devices. For information on how to install the USB Driver, see the nRF Util prerequisites documentation.
Additionally, for Linux users: the nrf-udev module with udev rules required to access USB ports on Nordic Semiconductor devices and program the firmware.
Additionally, just for the development in command line, you need a separate nRF Util download to install the nRF Connect SDK toolchain:
Download the executable for the latest version of nRF Util.
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.
Install the nRF Connect SDK code and toolchain
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 |
For each version of the nRF Connect SDK, Nordic Semiconductor provides a dedicated 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 SDK tools, the Python dependencies, and the GN tool for creating Matter applications. You can check the versions of the required tools and Python dependencies on the Requirements reference page.
Note
Unless you are familiar with the development process, you should always work with a specific, stable release of the nRF Connect SDK.
For more information about the repository and development model, see the nRF Connect SDK code base page.
When you install nRF Connect SDK for the first time, you have neither the SDK code nor the toolchain installed. Depending on your preferred development environment, complete the following steps:
Note
If you prefer, you can now start VS Code walkthrough and install the toolchain and the SDK from there.
Open the nRF Connect extension in Visual Studio Code by clicking its icon in the Activity Bar. The extension loads and the Welcome View appears with two buttons: Install SDK and Install Toolchain.
Click on Install SDK.
Select the region for download.
You only need to select the region for downloads once. The selected region applies to all future SDK and toolchain downloads. You can later change it in the Visual Studio Code settings.
The list of available SDK types appears.
Select nRF Connect SDK. The list of available stable versions for the nRF Connect SDK appears in the Visual Studio Code’s quick pick, grouped into two categories:
Pre-packaged SDKs & Toolchains - Available on the Nordic Semiconductor server. The package downloads both the SDK and toolchain, but skips the toolchain if you have it already installed. Available mostly for stable releases and some Git tags. Recommended for faster and more reliable download and installation.
GitHub - Taken from the nRF Connect by Nordic Semiconductor GitHub organization. Available for stable releases, but also Git tags and branches.
Select an nRF Connect SDK version to install from the Pre-packaged SDKs & Toolchains category. 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 and toolchain installation starts and it can take several minutes. You can follow the progress in the notification that appears.
After the installation is complete, the extension’s Welcome View is updated to feature Manage toolchains and Manage SDKs menus. You can use these menus to install other versions of the nRF Connect SDK and toolchain, either together or separately. See the extension documentation for more information.
Open a terminal window.
Remove the lock on the nRF Util installation to be able to install other nRF Util commands. See Locking nRF Util home directory in the tool documentation for more information.
Run the following command to install the nRF Util’s
sdk-managercommand:nrfutil install sdk-managerRun the following command to list the available installations:
nrfutil sdk-manager searchThe 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 SDK and the toolchain for the SDK version of your choice:
nrfutil sdk-manager install version
For example:
nrfutil sdk-manager install v3.3.0
This example command installs both the SDK code and the toolchain for the nRF Connect SDK v3.3.0. When you first install the nRF Connect SDK, it is recommended to install the latest released versions of the SDK and the toolchain.
Note
If you plan to work with a specific branch, use the command for installing the latest nRF Connect SDK release (v3.3.0) to install the latest toolchain. Then, you must use the
west initcommand several steps below to get the code of the desired branch. This is because thesdk-managercommand only supports installing specific release versions.The
sdk-managercommand installs the SDK by default atC:/ncs/on Windows and at~/ncs/on Linux, and the toolchain in thetoolchainssubdirectory. The SDK installation location can be modified, as explained in the command documentation. On macOS,/opt/nordic/ncs/and/opt/nordic/ncs/toolchainsare used and no other locations are allowed. Thencsdirectory holds all nRF Connect SDK repositories.If you have received a custom URL or a toolchain bundle ID for installing the toolchain, you can use dedicated commands to provide it. Expand the section below to see the commands.
If you have received a custom URL for installing the toolchain, you can use the following commands to set it as default, replacing the respective parameters:
nrfutil sdk-manager config toolchain-index add index-name custom_toolchain_URL nrfutil sdk-manager config toolchain-index set index-name
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 sdk-manager toolchain install --toolchain-bundle-id custom_bundle_ID
To learn more about
sdk-managercommands, use thenrfutil sdk-manager --helpcommand, or see the command documentation.Start the toolchain environment for your operating system using the following command pattern, with
--ncs-versioncorresponding to the nRF Connect SDK version you have installed:nrfutil sdk-manager toolchain launch --ncs-version version --terminal
For example:
nrfutil sdk-manager toolchain launch --ncs-version v3.3.0 --terminal
This example command starts the toolchain environment for the nRF Connect SDK v3.3.0.
nrfutil sdk-manager toolchain launch --ncs-version version --shell
For example:
nrfutil sdk-manager toolchain launch --ncs-version v3.3.0 --shell
This example command starts the toolchain environment for the nRF Connect SDK v3.3.0.
nrfutil sdk-manager toolchain launch --ncs-version version --shell
For example:
nrfutil sdk-manager toolchain launch --ncs-version v3.3.0 --shell
This example command starts the toolchain environment for the nRF Connect SDK v3.3.0.
Note
You can also use other options instead of
--ncs-version. See the sdk-manager command documentation for more information.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 the required parameters:
west init -m https://github.com/nrfconnect/sdk-nrf --mr nRFConnectSDK_revision nRFConnectSDK_revision_workspace_dir
In this command:
The first nRFConnectSDK_revision identifies the revision of the nRF Connect SDK.
The second nRFConnectSDK_revision_workspace_dir is the name of the workspace directory that will be created by west. For this installation method, it should be the same as the nRFConnectSDK_revision.
The command creates the nRFConnectSDK_revision subdirectory and checks out the given revision of the nRF Connect SDK inside it. For example:
Specific release: To check out the v3.3.0 release, enter the following command:
west init -m https://github.com/nrfconnect/sdk-nrf --mr v3.3.0 v3.3.0
Git tag: To check out the
v2.8.0-rc1tag, enter the following command:west init -m https://github.com/nrfconnect/sdk-nrf --mr v2.8.0-rc1 v2.8.0-rc1Branch: To check out the
mainbranch that includes the latest state of development, enter the following command:west init -m https://github.com/nrfconnect/sdk-nrf --mr main 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 updatechanges 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 nRFConnectSDK_revision subdirectory and run the following command to clone the project repositories:
west updateDepending 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
With the default locations to install the SDK code (C:/ncs on Windows, ~/ncs/ on Linux, and /opt/nordic/ncs/ on macOS) and its toolchain (C:/ncs/toolchains on Windows, ~/ncs/toolchains/ on Linux, and the non-modifiable /opt/nordic/ncs/toolchains/ on 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, <toolchain-installation> corresponds to the toolchain version (most commonly, a SHA) and <west-workspace> corresponds to the SDK version name. 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
ncsdirectory.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
ncsdirectory.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
ncsdirectory.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.
Alternative method: System-wide installation
System-wide installation is an alternative to the recommended installation methods using nRF Connect for VS Code 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
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/binis on yourPATHenvironment 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
Enter the
ncsdirectory you created when setting up the virtual environment:cd %HOMEPATH%/ncscd ~/ncscd ~/ncsGet the nRF Connect SDK code. When you first install the nRF Connect SDK, it is recommended to install the latest released version of the SDK. Run the following command, where nRFConnectSDK_revision is the revision of the nRF Connect SDK you want to get the code of:
west init -m https://github.com/nrfconnect/sdk-nrf --mr *nRFConnectSDK_revision*The command initializes a west workspace in the
ncsdirectory and checks out the given revision of the nRF Connect SDK sdk-nrf in thenrfsubdirectory. For example:Specific release: To check out the v3.3.0 release, enter the following command:
west init -m https://github.com/nrfconnect/sdk-nrf --mr v3.3.0
Git tag: To check out the
v2.8.0-rc1tag, enter the following command:west init -m https://github.com/nrfconnect/sdk-nrf --mr v2.8.0-rc1Branch: To check out the
mainbranch that includes the latest state of development, enter the following command:west init -m https://github.com/nrfconnect/sdk-nrf --mr mainAlternatively, you can omit the
--mrparameter, in which case west usesmainas the default nRFConnectSDK_revision.
In the
ncsdirectory, run the following command to clone the project repositories:west updateInstall 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.
In the
ncsdirectory, enter the following commands in acmd.exeterminal window:pip3 install -r zephyr/scripts/requirements.txt pip3 install -r nrf/scripts/requirements.txt pip3 install -r bootloader/mcuboot/scripts/requirements.txt
In the
ncsdirectory, enter the following commands in a terminal window:pip3 install -r zephyr/scripts/requirements.txt pip3 install -r nrf/scripts/requirements.txt pip3 install -r bootloader/mcuboot/scripts/requirements.txt
In the
ncsdirectory, enter the following commands in a terminal window: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 nRF Connect for VS Code (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.