nRF5 SDK
Offical Software Development Kit for nRF51 and nRF52 Series¶
Overview¶
The nRF5 SDK is your first stop for building fully featured, reliable and secure applications with the nRF52 and nRF51 Series. It offers developers a wealth of varied modules and examples right across the spectrum including numerous Bluetooth Low Energy profiles, Device Firmware Upgrade (DFU), GATT serializer and driver support for all peripherals on all nRF5 Series devices. The nRF5 SDK will almost certainly have something for your needs in developing exciting yet robust wireless products.
Follow this guide to set up a nRF5 SDK development environment on your system, and then build and run a sample application.
Set up the toolchain¶
To build the nRF5 SDK examples, GNU ARM Embedded Toolchain is required. Follow one of the following guides for your host operating system:
macOS¶
-
GNU make is bundled with Xcode tools. Verify by running:
make --v
-
Download and install the GNU ARM Embedded Toolchain. The
6-2017-q2-update
version 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:# in ~/.bash_profile, add the following script export PATH="<path to install directory>/gcc-arm-none-eabi-6-2017-q2-update/bin:${PATH}"
arm-none-eabi-gcc --version
-
Download the nRF5x-Command-Line-Tools-OSX, then extract the
.tar
archive anywhere on your filesystem. Ensure the extracted directory is added to your OS PATH environment variable.# in ~/.bash_profile, add the following script export PATH="<the path to the extracted directory>:${PATH}"
Type the following in your terminal to verify if
mergehex
works:mergehex --version
-
Install the latest stable version of pyOCD via
pip
as follows:pip install -U pyocd
Type the following in your terminal to verify if
pyocd
works:pyocd --version
Windows¶
On Windows the easiest way to install the dependencies is to use the MSYS2. You can do so by performing the following steps:
-
Download and run the installer - "x86_64" for 64-bit, "i686" for 32-bit Windows.
-
Start MSYS2. Update the package database and core system packages with:
pacman -Syu
-
If needed, close MSYS2, run it again from Start menu. Update the rest with:
pacman -Su
-
Install dependencies:
pacman -S git make python2
-
Download and install the GNU ARM Embedded Toolchain. The
6-2017-q2-update
version 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
mergehex
works:mergehex --version
-
Install the latest stable version of pyOCD via
pip
as follows:Type the following in your terminal to verify ifpip install -U pyocd
pyocd
works:pyocd --version
Linux¶
This section describes how to set up the development environment on Ubuntu. The steps should be similar for other Linux distributions.
-
Ensure your host system is up to date before proceeding.
sudo apt-get update
sudo apt-get upgrade
-
Install the following packages using your system’s package manager.
sudo apt-get install build-essential checkinstall
-
Download and install the GNU ARM Embedded Toolchain. The
6-2017-q2-update
version 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:# in ~/.bash_profile, add the following script export PATH="<path to install directory>/gcc-arm-none-eabi-6-2017-q2-update/bin:${PATH}"
arm-none-eabi-gcc --version
-
Download the nRF5x-Command-Line-Tools-Linux-xxx, then extract the
.tar
archive anywhere on your filesystem. Ensure the extracted directory is added to your OS PATH environment variable.# in ~/.bash_profile, add the following script export PATH="<the path to the extracted directory>:${PATH}"
Type the following in your terminal to verify if
mergehex
works:mergehex --version
-
Install the latest stable version of pyOCD via
pip
as follows:pip install -U pyocd
Type the following in your terminal to verify if
pyocd
works:pyocd --version
Clone the repository¶
Clone the grove-mesh-kit
repository from GitHub:
git clone --recursive https://github.com/makerdiary/grove-mesh-kit
Or if you have already cloned the project, you may update the submodule:
git submodule update --init
Install the nRF5 SDK¶
Download the SDK file nRF5_SDK_v15.2.0_9412b96
from www.nordicsemi.com.
Extract the zip file to the grove-mesh-kit
repository. This should give you the following folder structure:
./grove-mesh-kit/ ├── LICENSE ├── README.md ├── config ├── docs ├── examples ├── firmware ├── mkdocs.yml └── nrf_sdks ├── README.md ├── nRF5-SDK-for-Mesh └── nRF5_SDK_v15.2.0_9412b96
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 your are working on either Linux or macOS. These files are located in:
<nRF5 SDK>/components/toolchain/gcc
Open the file in a text editor (Sublime 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-6-2017-q2-update/bin/ GNU_VERSION ?= 6.3.1 GNU_PREFIX ?= arm-none-eabi
Building the Grove CLI example¶
Now you can try to build the Grove CLI example:
-
Open terminal and change directory to:
cd ./grove-mesh-kit/examples/grove_cli/armgcc/
-
Compile the example by running:
make
Running the Grove CLI example¶
After compiling the source code, run the example:
-
Connect the nRF52840-MDK board to your PC using the USB-C cable.
-
Program the application and Softdevice by running:
make flash_all
-
Grove CLI will start automatically after programming. In Terminal, run:
screen /dev/cu.usbmodem846fa1a9d0de1 115200
Type Enter and
grove
. Test functionality of each command. If you need a hint you can call commands with option-h
or–help
. -
Alternatively, Web Device CLI is a better choice. Just start the Web Device CLI by clicking the following link:
-
Click the Connect button and pair the Grove CLI device. Just do it as you did in the terminal.
Create an Issue¶
Interested in contributing to this project? Want to report a bug? Feel free to click here: