nrf52840-mdk-usb-dongle icon indicating copy to clipboard operation
nrf52840-mdk-usb-dongle copied to clipboard

Can't flash? Here's what I've learned.

Open koush opened this issue 2 years ago • 0 comments

Bootloaders

Firstly, there are two boot loaders for this device. The UF2 Bootloader and the Open Bootloader. Your device most likely shipped with the UF2 Bootloader, if you bought it in 2021. Prior to that, it was the Open Bootloader.

The instructions are totally confusing as how to flash, because it mixes it all in one page. So first things first, you need to determine what Bootloader you have installed. Hold the reset button and plug the board into the USB port. If you see a drive pop up called "MDK-Dongle", you are using the UF2 Bootloader. This Bootloader does NOT work with the nRF5 official flashing tools. However, it is very easy to flash, easier than the nRF5 official flashing tools in my opinion. Let's use this one, since that's what it comes with now.

  • UF2 Bootloader
    • Flashed by copying a uf2 file onto the MDK-Dongle removable storage drive.
    • None of the official Nordik flashing tools work. The SDK build tools works fine and create hex files that can be converted to uf2 files.
  • Open Bootloader
    • Flashed by using nrfutil

Flashing the UF2 Bootloader from the Open Bootloader

You can skip this step if you're already on the UF2 Bootloader.

Install nrfutilL

pip install nrfutil

Download the UF2 Bootloader zip package from here:

https://github.com/makerdiary/nrf52840-mdk-usb-dongle/raw/master/firmware/open_bootloader/uf2_bootloader-0.2.13-44-gb2b4284-nosd_signed.zip

Flash it:

# Hold the reset button and plug the board into the USB port to enter programming mode first.
nrfutil dfu usb-serial -pkg uf2_bootloader-0.2.13-44-gb2b4284-nosd_signed.zip -p <your-serial-port-name>

Flashing a .hex file:

This assumes you know how to build a hex file. This is done using the nRF5 SDK. In any case, download this hex file:

https://raw.githubusercontent.com/makerdiary/nrf52840-mdk-usb-dongle/master/examples/nrf5-sdk/blinky/hex/blinky_app.hex

And check out this repository and go to this folder:

https://github.com/makerdiary/nrf52840-mdk-usb-dongle/tree/master/tools

You will use uf2conv.py to generate a uf2 file. The uf2 file is the file format used to flash the UF2 Bootloader.

Assuming you are on Mac, the following should work:

# Hold the reset button and plug the board into the USB port to enter programming mode first.
# this is the input hex to flash
HEX=blinky_app.hex
# this outputs flash.uf2 from the above hex
python uf2conv.py $HEX -c -f 0xADA52840
# copy the flash.uf2 to the dongle to flash it
cp flash.uf2 /Volumes/MDK-DONGLE

IDE Support

Unsure. Currently I am just using the command line.

koush avatar Jul 24 '21 08:07 koush