Setting up the environment¶
To start working with the nRF Connect SDK, you should set up your development environment. nRF Connect SDK is based on the Zephyr RTOS, which means most of the requirements for Zephyr are also suitable for the nRF Connect SDK. The only requirement that is not covered by the installation steps in Zephyr is the GN tool. This tool is needed only for Matter applications.
This guide shows you how to set up a command-line nRF Connect SDK development environment on Ubuntu, macOS, or Windows manually. For automatic installation, please refer to the Installing automatically page.
Select and Update OS¶
Install available updates for your operating system:
Select Start > Settings > Update & Security > Windows Update. Click Check for updates and install any that are available.
On macOS Mojave or later, select System Preferences... > Software Update. Click Update Now if necessary.
On other versions, see this Apple support topic.
Install dependencies¶
Next, you’ll install some host dependencies using your package manager.
The current minimum required version for the main dependencies are:
Tool | Min. Version |
---|---|
CMake | 3.20.0 |
Python | 3.8 |
Devicetree compiler | 1.4.6 |
We use Chocolatey to install dependencies here. If Chocolatey isn’t an option, you can install dependencies from their respective websites and ensure the command line tools added in your PATH
environment variable.
-
Open a
cmd.exe
window as Administrator. To do so, press the Windows key Win , typecmd.exe
, right-click the result, and choose Run as Administrator. -
Disable global confirmation to avoid having to confirm the installation of individual programs:
-
Use
choco
to install the required dependencies: -
Close the window and open a new
cmd.exe
window as a regular user to continue.
Tip
To check the list of installed packages and their versions, run the following command:
-
Install Homebrew:
-
Use
brew
to install the required dependencies:
Tip
To check the versions of these dependencies installed, run the following command:
-
If using an Ubuntu version older than 22.04, it is necessary to add extra repositories to meet the minimum required versions for the main dependencies listed above. In that case, 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: -
Use
apt
to install the required dependencies: -
Verify the versions of the main dependencies installed on your system by entering:
Install GN tool for Matter
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.
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. -
Ensure that the GN tool is added to your
PATH
environment variable.
To install the GN tool, complete the following steps:
-
Create the directory for the GN tool:
-
Download the GN binary archive and extract it by using the following commands:
-
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: -
Add the location of the GN tool to
.bash_profile
:
-
To install the GN tool, complete the following steps:
-
Create the directory for the GN tool:
-
Download the GN binary archive and extract it by using the following commands:
-
Add the location of the GN tool to the system
PATH
. For example, if you are usingbash
, run the following commands:
Install west¶
To manage the combination of repositories and versions, the nRF Connect SDK uses Zephyr’s west.
To install west, reopen the command prompt window as an administrator to ensure that Python is initialized, and complete the following step:
Enter the following command in a command-line window:
Note
Ensure the west location is added to the path in environmental variables.
Enter the following command in a terminal window:
Get the code¶
To help you quickly build and run the samples on nRF52840 MDK USB Dongle, we maintain a public repository named ncs-playground which consists of nRF Connect SDK manifest repositories, additional hardware drivers and tested samples, etc.
To clone the repositories, complete the following steps:
-
Initialize the workspace folder (
my-workspace
) where all the required repositories will be cloned:Tip
You can initialize west with the revision of ncs-playground that you want to check out. For example, to check out the
v2.4.0
release, enter the following command: -
Enter the following commands to clone the project repositories:
After all the repositories updated, your workspace folder now looks similar to this:
-
Export a Zephyr CMake package. This allows CMake to automatically load the boilerplate code required for building nRF Connect SDK applications:
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 my-workspace
folder:
Enter the following command in a terminal in the my-workspace
folder:
Install Zephyr SDK¶
The Zephyr Software Development Kit (SDK) contains toolchains for each of Zephyr’s supported architectures, which include a compiler, assembler, linker and other programs required to build Zephyr applications.
It also contains additional host tools, such as custom QEMU and OpenOCD builds that are used to emulate, flash and debug Zephyr applications.
- Open a
cmd.exe
window by pressing the Windows key typingcmd.exe
. -
Download the Zephyr SDK bundle:
-
Extract the Zephyr SDK bundle archive:
Note
It is recommended to extract the Zephyr SDK bundle at one of the following locations:
%HOMEPATH%
%PROGRAMFILES%
The Zephyr SDK bundle archive contains the
zephyr-sdk-0.16.1
directory and, when extracted under%HOMEPATH%
, the resulting installation path will be%HOMEPATH%\zephyr-sdk-0.16.1
. -
Run the Zephyr SDK bundle setup script:
Note
You only need to run the setup script once after extracting the Zephyr SDK bundle.
You must rerun the setup script if you relocate the Zephyr SDK bundle directory after the initial setup.
-
Download and verify the Zephyr SDK bundle:
If your host architecture is 64-bit ARM (Apple Silicon, also known as M1), replace
x86_64
withaarch64
in order to download the 64-bit ARM macOS SDK. -
Extract the Zephyr SDK bundle archive:
Note
It is recommended to extract the Zephyr SDK bundle at one of the following locations:
$HOME
$HOME/.local
$HOME/.local/opt
$HOME/bin
/opt
/usr/local
The Zephyr SDK bundle archive contains the
zephyr-sdk-0.16.1
directory and, when extracted under$HOME
, the resulting installation path will be$HOME/zephyr-sdk-0.16.1
. -
Run the Zephyr SDK bundle setup script:
Note
You only need to run the setup script once after extracting the Zephyr SDK bundle.
You must rerun the setup script if you relocate the Zephyr SDK bundle directory after the initial setup.
-
Download and verify the Zephyr SDK bundle:
If your host architecture is 64-bit ARM (for example, Raspberry Pi), replace
x86_64
withaarch64
in order to download the 64-bit ARM Linux SDK. -
Extract the Zephyr SDK bundle archive:
Note
It is recommended to extract the Zephyr SDK bundle at one of the following locations:
$HOME
$HOME/.local
$HOME/.local/opt
$HOME/bin
/opt
/usr/local
The Zephyr SDK bundle archive contains the
zephyr-sdk-0.16.1
directory and, when extracted under$HOME
, the resulting installation path will be$HOME/zephyr-sdk-0.16.1
. -
Run the Zephyr SDK bundle setup script:
Note
You only need to run the setup script once after extracting the Zephyr SDK bundle.
You must rerun the setup script if you relocate the Zephyr SDK bundle directory after the initial setup.
-
Install udev rules, which allow you to flash most Zephyr boards as a regular user: