makerdiary / nrf52840-mdk-usb-dongle

An open-source, small and low-cost USB Dongle that supports Bluetooth 5.4, Bluetooth mesh, Thread, Zigbee, 802.15.4, ANT and 2.4 GHz proprietary protocols
https://wiki.makerdiary.com/nrf52840-mdk-usb-dongle/
Apache License 2.0
318 stars 82 forks source link

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

Open koush opened 3 years ago

koush commented 3 years ago

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.

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.