nRF52840 Advanced Development With the nRF5 SDK
Installing the ARM Toolchain & Nordic Tools
All of the nRF5 SDK's examples, components, and libraries are written in C. To compile those source files you'll need a C compiler for the ARM architecture. There are a handful of ARM C compilers out there, but we'll be focusing on the open-source ARM GCC toolchain in this tutorial.
In addition to the compiler, you'll need software that can take that compiled code and upload it to a Nordic nRF5 chip via either the bootloader or the SWD interface. Nordic's nRF5x Command Line Tools include nrfjprog, which can be used to upload via the SWD debug interface. adafruit-nrfutil -- a modified version of Nordic's nrfutil is used to upload via DFU bootloader.
Compiler -- ARM GNU Tools
The GNU Arm Embedded Toolchain is a collection of open-source compilers, build, and debug-tools for ARM microcontrollers -- including the ARM Cortex-M4 that make up a major chunk of the nRF52840 SoC. These tools include:
- GNU C/C++ Compiler -- A C/C++ compiler that turns your C/C++ code into machine code that the ARM can understand.
- Binary tools -- Tools that can link your compiled code together, compile assembly code, and perform a variety of file-conversion operations.
- Debugging tools -- GDB, the GNU Project Debugger, can be used to step through your code and view memory contents in real-time.
The ARM GNU tools are free to download and use. To get the latest version, visit the Arm GNU download's page.
On Windows, for example, click the "Download" link next to "Windows 32-bit\File: gcc-arm-none-eabi-7-2018-q2-update-win32.exe (82.98 MB)".
Windows users can run through the install wizard. By default, the ARM GNU tools will be installed in a directory like "C:\Program Files (x86)\GNU Tools ARM Embedded\7 2018-q2-update" (the last bit will vary by version of the tools).
Mac and Linux users will need to download and extract the ARM GNU tools to a preferred location on your computer, for example
SWD Programming Tools -- nRF5x Command Line Tools
It appears that the Nordic links have changed. For additional assistance locating the resources on the Nordic website, users can try checking out the Nordic DevZone.
- Installing the nRF5x Command Line Tools (links):
- Getting started with nRF5 SDK and Keil > Setting up your toolchain (still includes broken link)
- nRF Tools > nRF Command Line Tools (click the Installing the nRF Command Line Tools link)
- Software Download Page
- nRF5x Information Page
In order to upload new, compiled applications to your nRF52840 you'll need to install a handful of Nordic command-line tools, including nrfjprog.
To download these tools, visit the Installing the nRF5x Command Line Tools page of Nordic's information center.
The software is available for Windows, Linux 32-bit, Linux 64-bit, and macOS. Select your appropriate flavor from the pulldown towards the bottom of the page.
On Windows, run the installer and follow the instructions in the wizard. On Linux and Mac, extract the .tar file somewhere on your computer -- you may need to add the Nordic tools directory to your
$PATH environment variable.
DFU Bootloader Tools -- adafruit-nrfutil
Nordic's nrftuil is a Python-based tool for packaging device firmware updates (DFU) and updating an nRF chip with that package over either serial or Bluetooth. adafruit-nrfutil is derived from Nordic's original version of the software. It updates nrfutil to be Python 3-based, and provides DFU support for a variety of boards equipped with their nRF52 bootloader.
adafruit-nrfutil is used to update code on your nRF52840 with the serial bootloader.
To install adafruit-nrfutil, you'll first need to download and install Python 3. (If you have Python 2.7 installed, you'll still need Python 3 to install adafruit-nrfutil.)
Once you have Python 3 installed, the easiest way to install adafruit-nrfutil is with PyPI:
language:python pip3 install --user adafruit-nrfutil
If you use a different method to install adafruit-nrfutil, don't forget to add adafruit-nrfutil too your PATH environment variable!