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
300 stars 79 forks source link

Operating bootloader using ONLY usb interface #46

Open rananna opened 3 years ago

rananna commented 3 years ago

Nordic provides utilities for DFU programming over USB, and I would like to provide a custom bootloader to users to load using usb. As far as I can tell the dongle’s existing bootloader can only be overwritten using an SWD compatible debugging probe such as Segger J-link. Is this the case? If not, how can I program a custom bootloader using only usb interface. I know I can change to open bootloader but so far I cannot get my custom bootloader to program. Any ideas?

caizelin commented 3 years ago

Hi, You can update your custom bootloader from UF2 Bootloader, as it does not need to sign your bootloader. Here is the steps you can follow: https://github.com/makerdiary/nrf52840-mdk-usb-dongle/tree/master/firmware/open_bootloader#change-to-open-bootloader-from-uf2-bootloader

You can find the source code of open bootloader here: https://github.com/makerdiary/nrf52840-mdk-usb-dongle/tree/master/examples/nrf5-sdk/open_bootloader

rananna commented 3 years ago

You have outlined the process to change to open bootloader from the uf2 bootloader. I want to replace the bootloader with a custom bootloader using only usb. Is this possible?

gbuzogany commented 3 years ago

Yes it is possible, but you will probably need to implement your own. https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/lib_bootloader_modules.html

Edit: I misunderstood your problem.

AFAIK the bootloader that comes with the MDK only allows you to install signed bootloaders. That means that to do what you want, you first need to flash another bootloader (yours) w/o signature enforcement (or enforcing different keys), so after that your users can do any updates you want from USB. This can be done through SWD, or, if you have the right keys, through USB.

Also keep in mind that you can do the SWD flashing through a raspberry pi or even cheap GPIO devices like the FT232H using OpenOCD.

chuckixia commented 3 years ago

Hi, You can update your custom bootloader from UF2 Bootloader, as it does not need to sign your bootloader. Here is the steps you can follow: https://github.com/makerdiary/nrf52840-mdk-usb-dongle/tree/master/firmware/open_bootloader#change-to-open-bootloader-from-uf2-bootloader

You can find the source code of open bootloader here: https://github.com/makerdiary/nrf52840-mdk-usb-dongle/tree/master/examples/nrf5-sdk/open_bootloader

this was exactly what I was looking for. Is it possible to put this on this website here: https://wiki.makerdiary.com/nrf52840-mdk-usb-dongle/programming/

also maybe make it clearer that the new dongles now ship with the new bootloader?