nRF52840 Advanced Development With the nRF5 SDK
Introduction
Are you an nRF52840 user ready to take a leap away from the comforts of the Arduino IDE? Feeling limited by CircuitPython's support? Maybe it's time to set up an armgcc-based development environment of your own and dive into Nordic's nRF5 Software Development Kit (SDK).
This tutorial will cover download and setup of every software tool -- armgcc, nrfutil, and the nRF5 SDK -- you need for nRF52 development. It focuses on developing for the SparkFun Pro nRF52840 Mini Breakout.
SparkFun's nRF52840 ships with a USB-Serial DFU bootloader. So this tutorial will put extra focus on modifying the SDK to seamlessly bootload code via USB.
Pros and Cons
As with any development approach, there are benefits and disadvantages to building a homebrew programming environment.
Pros
- Lots of example applications! The list of examples in Nordic's nRF5 SDK is exhaustive. Everything from blinky to BLE heart-rate monitors are are included in the SDK.
- Nordic's documentation is equally-comprehensive and well-organized. Just take a peek at the nRF5 SDK Documentation.
- Access to more advanced features that may not have Arduino or CircuitPython support built out: NFC, ANT, capacitive-touch sensing, FreeRTOS just to name a few
- Flexibility to use your favorite IDE/editor. Whether you'd prefer to use Eclipse, Sublime, Notepad++, or, as we'll demonstrate in this tutorial Visual Studio Code, your options are nearly endless!
Cons
- We won't lie. Setting up a from-scratch toolchain and IDE can be a daunting task. You'll encounter errors that may seem to be impossibly isolated to your setup and your computer. If you're stuck, feel free to reach out in this tutorial's comments section.
- We're not in Arduino- or Python-land anymore. Developing with the nRF5 SDK is hard if you've never done it before. Whether you want to blink an LED or set up your nRF52 board as a BLE central device, there are a lot of new functions, macros, and programming paradigms to familiarize yourself with. Luckily there are a lot of examples!
- The SDK isn't tailor-made for the SparkFun nRF52840 Mini Breakout. For most examples, you'll need to make some Makefile (and potentially linker-script) modifications to load it onto your nRF52840 using the pre-programmed bootloader.
Required Materials
This tutorial is primarily designed to support the SparkFun Pro nRF52840 Mini Breakout -- especially the section covering SDK modifications to enable programming-via-bootloader.
That said, the general setup parts of this tutorial can be made applicable to any nRF52840 -- or even nRF58232 or nRF51 -- board. Nordic's nRF52840 Development Kit (DK) or the nRF52840 Dongle are great boards that should work with most of this tutorial. Beyond an nRF52840 board, you shouldn't need anything else besides a micro-B USB cable to attach between the device and your computer.
Suggested Reading
If you haven't read through it already, we recommend following along with our SparkFun Pro nRF52840 Mini Hookup Guide before continuing on. This tutorial will familiarize you with the hardware features of the board as well as the intricacies of the DFU/UF2 bootloader.