Update firmware using the UF2 Bootloader¶
Overview¶
nRF52840 MDK USB Dongle 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.
UF2 Bootloader Update Notification
The dongle manufactured after July 20 2023 is shipped with the latest UF2 Bootloader 0.7.1. You may get a dongle without the latest bootloader, and if you would like to explore new features of the latest bootloader, just follow the Updating the UF2 Bootloader section.
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 MDK USB Dongle:
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 dongle by following the steps above.
To update the application firmware, complete the following steps:
-
Push and hold the button and plug your dongle into the USB port of your computer. Release the button after your dongle 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.
-
Re-plug the dongle and the new application firmware is running.
Double-Reset to enter DFU mode
If the button has been programmed as RESET functionality, reset twice within 500 ms will enter DFU with UF2 and CDC support.
Updating the UF2 Bootloader¶
The UF2 Bootloader can be upgraded by using a newer UF2 Bootloader with the name update-uf2_bootloader-nrf52840_mdk_usb_dongle-<version>-nosd.uf2
. This is the fastest and safest way to update bootloader. However, it requires your existing bootloader is at least 0.4.0. If not, follow Flashing UF2 Bootloader using an external debugger section.
To update the bootloader using UF2, complete the following steps:
-
Push and hold the button and plug your dongle into the USB port of your computer. Release the button after your dongle 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. It should be 0.4.0 or newer. The figure below shows we are running the0.7.1
version. -
Check if newer updates are available in the
firmware/uf2_bootloader
folder. The update is released with the nameupdate-uf2_bootloader-nrf52840_mdk_usb_dongle-<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
.
Installing UF2 Bootloader using an external debugger¶
You can always install a fresh .hex
-format bootloader using an external debugger if your existing bootloader is out-of-date or gets corrupted somehow. The .hex
-format bootloader is located in the firmware/uf2_bootloader
folder. Follow the instructions below for programming: