SparkFun Pro nRF52840 Mini Hookup Guide

Pages
Contributors: jimblom
Favorited Favorite 1

Using the Bootloader

Hopefully (unless you really need a debug interface) you'll never have to touch those SWD pins on the bottom side of the nRF52840 Breakout. The pre-programmed USB bootloader should have all of your programming bases covered.

The USB bootloader programmed on this board should provide support for programming via either USB serial (CDC), DFU (device firmware upgrade) or mass-storage device (MSD). So you can either automate your programming via a serial-like interface or drag a pre-compiled application onto your nRF52840's removable drive.

Bootloader Credits

The bootloader that ships on this board is heavily based on Adafruit’s nRF52 Bootloader. This is an extremely well-designed UF2, CDC, and DFU bootloader that provides extensive bootloading support to Nordic’s nRF52 (nRF52840 and nRF52832) products.

Software Tools Required

After you've compiled your nRF52840 application, you'll need one of two software tools to upload it to the chip via the USB bootloader. Both applications are compatible across all platforms.

adafruit-nrfutil and Python 3

Nordic's nrftuil is a Python-based tool for packaging device firmware updates (DFU) and updating a 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:

pip3 install --user adafruit-nrfutil

uf2conv.py (and Python Too)

In addition to the USB serial bootloader, the nRF52840 also includes a UF2 bootloader. This bootloader turns the nRF52840 into a USB mass-storage device, and allows you to simply drag a compiled file onto the device to program it.

If you'd like to take advantage of the nRF52840's UF2 bootloader, you'll need another Python-based tool: uf2conv.py. This Python script transforms a compiled ".hex" binary file to a UF2-compatible ".uf2" file.

You can grab the uf2conv.py script by downloading or cloning the Microsoft UF2 GitHub Repository.

To convert a compiled hex file to uf2, a command like...

python uf2conv.py -f 0xADA52840 -c -o _build/nrf52840_xxaa.uf2 _build/nrf52840_xxaa.hex

...should do the trick.

Entering the Bootloader

To get into bootloader mode manually you'll need to use one or both of the reset and pin-13 buttons. You can either double-tap the reset button.

Reset via reset double-tap

Or reset while holding down the pin-13 button:

Resetting via pin 13 low on reset

Either reset method will work. Bootloader mode is indicated by a flashing blue pin 7 LED. You should also notice a removable drive and USB serial port enumerate on your computer.

Factory Resetting

If your nRF52840 application isn't quite working as expected, you can wipe it out and return safely to bootloader mode. To perform a factory reset ground pin 2 while resetting the board.

Warning: Because pin 2's state at reset is sampled by the bootloader, be careful using it with any component that may pull the pin low on startup.