Adafruit nRF52 Bootloader Common
Common Flashing Description for the Adafruit nRF52 Bootloader
Related Boards
Introduction
Section titled “Introduction”The Adafruit nRF52 Bootloader is used by many Adafruit and Seeedstudio boards
that are based on the Nordic Semiconductor nRF52 microcontroller family.
It features a Mass Storage Device emulation, so that UF2 files can be uploaded
via Drag and Drop. It is also backwards compatible to the BOSSA bootloader.
With the Adafruit nRF52 Bootloader, no external debugger such as a J-Link is
necessary for the normal usage. The tool used for flashing the board with
UF2 files via the Mass Storage Device is uf2conv from the Microsoft UF2
Reference Repository.
In some cases the bootloader may be too old to even mount on startup.
Enter the bootloader mode (usually by double tapping the reset button for
nRF52840 based boards) and check the INFO_UF2.TXT for bootloader information.
If the version is less than 0.4.0, please refer to Updating Old Bootloaders and Restoring the SoftDevice or
use the adafruit-nrfutil Script to
program your board.
Until and including RIOT Release 2025.01, the SoftDevice on
adafruit-feather-nrf52840-express
and adafruit-feather-nrf52840-sense
boards got erased when flashing RIOT. To restore the ability of using i.a.
Arduino and CircuitPython, the SoftDevice has to be flashed again.
Please also refer to Updating Old Bootloaders and Restoring the SoftDevice.
If the bootloader is not present on your board at all, an external debugger such as the J-Link has to be used. Please refer to (Re-)Flashing the UF2 Bootloader with an External Debugger.
Flashing the Board with RIOT
Section titled “Flashing the Board with RIOT”Using the default uf2conv Programmer
Section titled “Using the default uf2conv Programmer”The board is flashed using its on-board UF2 bootloader by default. The bootloader will present a mass storage device that has to be mounted so the RIOT buildsystem can find it. If you have an auto-mounter installed this will happen automatically.
The rest of the process is automated in the usual way with e.g.
BOARD=adafruit-feather-nrf52840-express.
Example with hello-world application:
make BOARD=adafruit-feather-nrf52840-express -C examples/basic/hello-world flash termIf RIOT is already running on the board, it will automatically reset the CPU and enter the bootloader. If some other firmware is running or RIOT crashed, you need to enter the bootloader manually by double-tapping the board’s reset button while the device is connected.
Set a Custom Mounting Point
Section titled “Set a Custom Mounting Point”If the UF2 mass storage device cannot be detected automatically or if multiple
UF2 devices are connected at the same time, you can explicitly specify the
mountpoint by setting UF2_MOUNTPOINT to the path that contains
INFO_UF2.TXT.
Example:
make UF2_MOUNTPOINT=/media/$USER/FEATHER52840 BOARD=adafruit-feather-nrf52840-express -C examples/basic/hello-world flashHandling the SoftDevice
Section titled “Handling the SoftDevice”The board definitions with RIOT retain the SoftDevice firmware blob shipped with
the original Adafruit nRF52 Bootloader that is used by i.a. Arduino and
CircuitPython but not used by RIOT. If you want to override the SoftDevice
to avoid having closed source software on your microcontroller or if you need
the additional space, you can specify the UF2_SOFTDEV=DROP option in your
make command. Be aware that you have to reflash the SoftDevice if you want
to use it in the future!
make UF2_SOFTDEV=DROP BOARD=adafruit-feather-nrf52840-express -C examples/basic/hello-world flash termIf your board features a non-standard SoftDevice version, you can specify it
with the UF2_SOFTDEV option as well. Currently supported are i.a. SD611
for SoftDevice Version 6.1.1 and SD730 for Version 7.3.0.
Setting the wrong SoftDevice version might corrupt the SoftDevice and
make a reflash of the SoftDevice necessary. Do not change it unless you know
what you’re doing!
Using the adafruit-nrfutil Programmer
Section titled “Using the adafruit-nrfutil Programmer”The adafruit-nrfutil is an adapted version of the original, discontinuied
nrfutil script from Nordic Semiconductor and programs the nRF52
microcontroller via DFU (Direct File Upload) via the serial port or via USB.
If you want to use the adafruit-nrfutil programming script, most of the
previous information about the uf2conv script applies as well.
Before using the script, you have to install it with the following command:
pip3 install --user adafruit-nrfutilTo select the adafruit-nrfutil, you can define the programmer in the
environment when you call make:
PROGRAMMER=adafruit-nrfutil BOARD=adafruit-feather-nrf52840-express -C examples/basic/hello-world flash termUpdating Old Bootloaders and Restoring the SoftDevice
Section titled “Updating Old Bootloaders and Restoring the SoftDevice”If the Adafruit nRF52 Bootloader is still present on the board but outdated
or the SoftDevice got erased (the INFO_UF2.TXT file will show
SoftDevice: not found), you can flash the bootloader via DFU.
As prerequisites, the arm-none-eabi-gcc compiler (which is usually already
present if you compiled something for your nRF52 board) and the
adafruit-nrfutil have to be installed.
Details on the installation process can be found in Adafruit’s GitHub repository.
With the following commands, the bootloader with SoftDevice will be compiled and flashed. For MacOS, you might have to select a different serial port.
git clone https://github.com/adafruit/Adafruit_nRF52_Bootloader.gitcd Adafruit_nRF52_Bootloadergit submodule update --initpip3 install --user adafruit-nrfutilmake BOARD=feather_nrf52840_sense SERIAL=/dev/ttyACM0 flash-dfuSometimes the process has to be done twice until the SoftDevice is successfully restored.
Further information about the update process can be found on the Adafruit Website.
(Re-)Flashing the UF2 Bootloader with an External Debugger
Section titled “(Re-)Flashing the UF2 Bootloader with an External Debugger”To flash the UF2 bootloader (if it is no longer present on your board),
you need to have the original nrfjprog installed and a compatible
debugger, such as a J-Link. Make sure to select the right board (see the note
in Updating Old Bootloaders and Restoring the SoftDevice).
git clone https://github.com/adafruit/Adafruit_nRF52_Bootloadercd Adafruit_nRF52_Bootloadergit submodule update --initnrfjprog --recovermake BOARD=adafruit-feather-nrf52840-express flashmake BOARD=adafruit-feather-nrf52840-express flash-sdMore information about how to flash nRF52 microcontrollers can be found in the Flashing section in nRF52 common. Some variants of the Adafruit Feather feature an SWD Connector, to which an external debugger can be connected. Other boards such as the Seeedstudio Xiao nRF52840 only have solder pads.