Setup the nRF5 SDK Development Environment¶
This section describes how to set up the nRF5 SDK development environment on your system.
Set up the toolchain¶
To build the nRF5 SDK applications, GNU ARM Embedded Toolchain is required. Follow one of the following guides for your host operating system:
macOS¶
Follow the steps below to set up the development environment on macOS:
-
GNU make is bundled with Xcode tools. Verify by running:
make --v -
Download and install the GNU ARM Embedded Toolchain. The
7-2018-q2-updateversion is recommended. Then ensure the path is added to your OS PATH environment variable.Type the following in your terminal to verify if the path is set correctly:echo 'export PATH="<path to install directory>/gcc-arm-none-eabi-7-2018-q2-update/bin:${PATH}"' >> ~/.bash_profile source ~/.bash_profilearm-none-eabi-gcc --version -
Download the nRF5x-Command-Line-Tools-OSX, then extract the
.tararchive anywhere on your filesystem. Ensure the extracted directory is added to your OS PATH environment variable.echo 'export PATH="<the path to the extracted directory>/mergehex:${PATH}"' >> ~/.bash_profile source ~/.bash_profileType the following in your terminal to verify if
mergehexworks:mergehex --version -
Install the latest stable version of pyOCD via
pipas follows. Skip this step if pyOCD already exists.pip install -U pyocdType the following in your terminal to verify if
pyocdworks:pyocd --version
Windows¶
The following instructions rely on Chocolatey. If Chocolatey isn’t an option, you can install dependencies from their respective websites and ensure the command line tools are on your PATH environment variable.
-
Open an Administrator
cmd.exewindow -
Disable global confirmation to avoid having to confirm installation of individual programs:
choco feature enable -n allowGlobalConfirmation -
Use
chocoto install dependencies:choco install git make python -
Open a new
cmd.exewindow as a regular user to continue -
Download and install the GNU ARM Embedded Toolchain. The
7-2018-q2-updateversion is recommended. Run the installer and follow the given instructions. Upon completion, check the Add path to environment variable option. Then verify if the compiler works:arm-none-eabi-gcc --version -
Download the nRF5x-Command-Line-Tools for Win32. Run the installer and follow the given instructions. Then verify if
mergehexworks:mergehex --version -
Install the latest stable version of pyOCD via
pipas follows. Skip this step if pyOCD already exists.Type the following in your terminal to verify ifpip install -U pyocdpyocdworks:pyocd --version
Linux¶
Here we describe how to set up the toolchain on Ubuntu version 18.04 LTS. The steps should be similar for other Linux distributions.
-
Ensure your host system is up to date before proceeding.
sudo apt update sudo apt upgrade -
Install the following packages using your system’s package manager.
sudo apt install build-essential checkinstall -
Download and install the GNU ARM Embedded Toolchain. The
7-2018-q2-updateversion is recommended. Then ensure the path is added to your OS PATH environment variable.Type the following in your terminal to verify if the path is set correctly:echo 'export PATH="<path to install directory>/gcc-arm-none-eabi-7-2018-q2-update/bin:${PATH}"' >> ~/.bashrc source ~/.bashrcarm-none-eabi-gcc --version -
Download the nRF5x-Command-Line-Tools-Linux-xxx, then extract the
.tararchive anywhere on your filesystem. Ensure the extracted directory is added to your OS PATH environment variable.echo 'export PATH="<the path to the extracted directory>/mergehex:${PATH}"' >> ~/.bashrc source ~/.bashrcType the following in your terminal to verify if
mergehexworks:mergehex --version -
Install the latest stable version of pyOCD via
pipas follows. Skip this step if pyOCD already exists.pip install -U pyocdType the following in your terminal to verify if
pyocdworks:pyocd --version
Clone the repository¶
Clone the nrf52840-m2-devkit repository from GitHub:
git clone https://github.com/makerdiary/nrf52840-m2-devkit
Install the nRF5 SDK¶
Download the SDK file nRF5_SDK_16.0.0_98a08e2 from www.nordicsemi.com. Note that the current version is 16.0.0.
Extract the zip file to the nrf52840-m2-devkit/nrf_sdks directory. This should give you the following folder structure:
./nrf52840-m2-devkit/
├── LICENSE
├── README.md
├── boards
├── config
├── docs
├── examples
├── firmware
├── mkdocs.yml
├── nrf_sdks
│ ├── README.md
│ └── nRF5_SDK_16.0.0_98a08e2
└── tools
To use the nRF5 SDK you first need to set the toolchain path in makefile.windows or makefile.posix depending on platform you are using. That is, the .posix should be edited if you are working on either Linux or macOS. These files are located in:
cd <nRF5 SDK>/components/toolchain/gcc
Open the file in a text editor (Visual Studio Code is recommended), and make sure that the GNU_INSTALL_ROOT variable is pointing to your GNU Arm Embedded Toolchain install directory.
GNU_INSTALL_ROOT ?= $(HOME)/gcc-arm-none-eabi/gcc-arm-none-eabi-7-2018-q2-update/bin/
GNU_VERSION ?= 7.3.1
GNU_PREFIX ?= arm-none-eabi
Next steps¶
If everything works as expected, it's ready to build and run the examples to verify the development environment setup.
The steps that are described in Build & Run a first example will walk you through verifying your setup with the simple Blinky example.
Create an Issue¶
Interested in contributing to this project? Want to report a bug? Feel free to click here: