Update firmware using the UF2 Bootloader¶
Overview¶
nRF52840 Connect Kit is shipped with the UF2 Bootloader, which is an easy-to-use and self-upgradable bootloader that can be used to update the firmware by just copying the .uf2
-format images to the flash drive without using an external programmer.
This section details how to update firmware using the UF2 Bootloader.
Flash memory layout¶
When updating firmware using the UF2 Bootloader, you must be aware of where in the device memory the different firmware components are located.
The following figure shows the default flash memory layout of nRF52840 Connect Kit:
Usage | Memory location | Size |
---|---|---|
Bootloader settings | 0x000FF000 | 4 KB |
MBR parameter storage | 0x000FE000 | 4 KB |
Bootloader config | 0x000FD800 | 2 KB |
Bootloader | 0x000F4000 | 38 KB |
Application | 0x00001000 | 972 KB |
Master Boot Record (MBR) | 0x00000000 | 4 KB |
Installing UF2 Converter¶
uf2conv
is an open source Python based tool for packing and unpacking UF2 files.
Before you install uf2conv
, make sure that you have Python 3.6.0 or later installed.
Then open up a terminal and run the following command to install the latest prerelease version from the HEAD of the main branch:
You can run uf2conv --help
for a list of available options:
Generating the firmware in UF2¶
To generate the application firmware in UF2, simply use uf2conv
on a .bin
file or .hex
file, specifying the family as 0xADA52840
:
To generate a UF2 image for bootloader from a .hex
file, specifying the separated family of 0xD663823C
:
Updating the application firmware¶
Generate the correct UF2 application firmware for your board by following the steps above.
To update the application firmware, complete the following steps:
-
Push and hold the USER button and plug your board into the USB port of your computer. Release the USER button after your board is connected. The RGB LED turns green.
-
It will mount as a Mass Storage Device called UF2BOOT.
-
Drag and drop the UF2 file onto the UF2BOOT volume. The RGB LED blinks red fast during flashing.
-
Reset the board and the new application firmware is running.
Enter DFU mode after the board power-up
After the board power-up, you can still enter the DFU mode by pressing the RESET button twice within 500 ms.
Updating the UF2 Bootloader¶
The UF2 Bootloader is self-upgradable, so that you can update the UF2 bootloader without using an external programmer. The latest UF2 bootloader is located in the firmware/uf2_bootloader
folder.
To update the bootloader, complete the following steps:
-
Push and hold the USER button and plug your board into the USB port of your computer. Release the USER button after your board is connected. The RGB LED turns green.
-
Open
INFO_UF2.TXT
in the UF2BOOT volume with a text editor, and check the current version of bootloader. The figure below shows we are running the0.7.0-rtm
version. -
Check if newer updates are available in the
firmware/uf2_bootloader
folder. The update is released with the nameupdate-nrf52840_connectkit-uf2_bootloader-<version>-nosd.uf2
. -
Drag and drop the update file onto the UF2BOOT volume.
-
Enter DFU mode again and verify the version printed in
INFO_UF2.TXT
.
How to recovery when the UF2 bootloader is broken
The only method to recovery from a broken bootloader is using an external debugger to download a fresh .hex
-format bootloader. The .hex
-format bootloader is also located in the firmware/uf2_bootloader
folder. Follow the instructions below for programming: