From 7cefa6df82a92aba2f88a285f753fc20fe6b9fb1 Mon Sep 17 00:00:00 2001 From: chrysn Date: Tue, 6 May 2025 14:27:07 +0200 Subject: [PATCH 1/4] boards/nrf52840dongle: Add support for nrfdfu programmer --- boards/nrf52840dongle/Makefile.include | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/boards/nrf52840dongle/Makefile.include b/boards/nrf52840dongle/Makefile.include index 135045a7d2d5..48784c35f24f 100644 --- a/boards/nrf52840dongle/Makefile.include +++ b/boards/nrf52840dongle/Makefile.include @@ -3,8 +3,24 @@ PROGRAMMER ?= nrfutil ifeq (nrfutil,$(PROGRAMMER)) + USING_NRF_BOOTLOADER = 1 - # Using nrfutil implies using the Nordic bootloader described at + FLASHFILE = $(HEXFILE) + FLASHDEPS += $(HEXFILE).zip + FLASHER = nrfutil + FFLAGS = dfu usb-serial --port=${PORT} --package=$(HEXFILE).zip +endif + +ifeq (nrfdfu,$(PROGRAMMER)) + USING_NRF_BOOTLOADER = 1 + + FLASHFILE = $(ELFFILE) + FLASHER = nrfdfu + FFLAGS = $(FLASHFILE) +endif + +ifeq (1,$(USING_NRF_BOOTLOADER)) + # Using an nrfutil style flasher implies using the Nordic bootloader described at # . # # It has a static MBR at the first 4k, and an ample 128k Open USB Bootloader at @@ -14,15 +30,10 @@ ifeq (nrfutil,$(PROGRAMMER)) ROM_OFFSET = 0x1000 ROM_LEN = 0xdf000 - FLASHFILE = $(HEXFILE) - FLASHDEPS += $(HEXFILE).zip - FLASHER = nrfutil - FFLAGS = dfu usb-serial --port=${PORT} --package=$(HEXFILE).zip - include $(RIOTMAKE)/tools/usb_board_reset.mk endif -PROGRAMMERS_SUPPORTED += nrfutil +PROGRAMMERS_SUPPORTED += nrfutil nrfdfu %.hex.zip: %.hex $(call check_cmd,$(FLASHER),Flash program and preparation tool) From ad61b527e4f1deacfba6d9d6fd4ee0bfdaa2f768 Mon Sep 17 00:00:00 2001 From: chrysn Date: Wed, 7 May 2025 10:22:10 +0200 Subject: [PATCH 2/4] boards/nrf52840dongle: Use nrfdfu programmer by default --- boards/nrf52840dongle/Makefile.include | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boards/nrf52840dongle/Makefile.include b/boards/nrf52840dongle/Makefile.include index 48784c35f24f..65b672204c2d 100644 --- a/boards/nrf52840dongle/Makefile.include +++ b/boards/nrf52840dongle/Makefile.include @@ -1,6 +1,6 @@ # This board uses the vendor's serial bootloader -PROGRAMMER ?= nrfutil +PROGRAMMER ?= nrfdfu ifeq (nrfutil,$(PROGRAMMER)) USING_NRF_BOOTLOADER = 1 From 972e25ae0a4805f4c4014c604e469772f3f7cc1a Mon Sep 17 00:00:00 2001 From: chrysn Date: Tue, 6 May 2025 14:27:59 +0200 Subject: [PATCH 3/4] boards/nrf52840dongle: Document free programmer --- boards/nrf52840dongle/doc.md | 31 +++++++++++++++++++++++++------ doc/doxygen/src/flashing.md | 2 +- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/boards/nrf52840dongle/doc.md b/boards/nrf52840dongle/doc.md index 20d6e6747705..8b3121cabdc0 100644 --- a/boards/nrf52840dongle/doc.md +++ b/boards/nrf52840dongle/doc.md @@ -48,7 +48,27 @@ reset button as well as 15 configurable external pins. ### Flash the board {#nrf52840dongle_flash} -The board is flashed using its on-board boot loader; the proprietary +The board is flashed using its on-board boot loader +called [Open USB bootloader](https://devzone.nordicsemi.com/nordic/short-range-guides/b/getting-started/posts/nrf52840-dongle-programming-tutorial) +using either of two tools described below. + +If RIOT is already running on the board, flashing the device will automatically reset the CPU and enter +the bootloader. +If some other firmware is running or RIOT crashed, you need to enter the bootloader +manually by pressing the board's reset button. + +Readiness of the bootloader is indicated by LD2 pulsing in red. + +#### nrfdfu + +The tool [nrfdfu](https://github.com/knurling-rs/nrfdfu-rs/) +is RIOT's default way of flashing a program by sending it to the bootloader. + +It needs to be installed locally using `cargo install nrfdfu`. + +#### nrfutil + +The proprietary [nrfutil](https://www.nordicsemi.com/Products/Development-tools/nRF-Util) program needs to be installed, and `nrfutil install nrf5sdk-tools` needs to be executed. Note that nrfutil, even when not running the "install" command, will install itself @@ -58,12 +78,11 @@ maintained by Nordic, and has become dysfunctional on Python 3.11. The nrfutil can turn the binary into a suitable zip file and send it to the bootloader. The process is automated in the usual `make flash` target. -If RIOT is already running on the board, it will automatically reset the CPU and enter -the bootloader. -If some other firmware is running or RIOT crashed, you need to enter the bootloader -manually by pressing the board's reset button. +#### Other programming methods -Readiness of the bootloader is indicated by LD2 pulsing in red. +When building a program for this board to be flashed using other methods +(e.g. using the board's Tag-Connect footprint), +setting `USING_NRF_BOOTLOADER=1` in the makefiles aligns the program suitable to be flashed after the bootloader. ### Accessing STDIO diff --git a/doc/doxygen/src/flashing.md b/doc/doxygen/src/flashing.md index 32a402c2a546..99d09c06220b 100644 --- a/doc/doxygen/src/flashing.md +++ b/doc/doxygen/src/flashing.md @@ -110,7 +110,7 @@ support multiple platforms are given in section ### nRF52 - `adafruit-nrfutil`, `uf2conv` (requires Adafruit bootloader), see @ref boards_common_adafruit-nrf52-bootloader -- `nrfutil` (required nRF bootloader) +- `nrfdfu` or `nrfutil` (requires nRF bootloader) - `nrfjprog` (requires a separate J-Link debugger) ### RP2040 From 11e54b08aef9c82777b3901db5914eaf9382773f Mon Sep 17 00:00:00 2001 From: chrysn Date: Tue, 20 May 2025 15:28:48 +0200 Subject: [PATCH 4/4] boards/nrf52840dongle: Documentation precision for nrfutil --- boards/nrf52840dongle/doc.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boards/nrf52840dongle/doc.md b/boards/nrf52840dongle/doc.md index 8b3121cabdc0..b5eb811df44f 100644 --- a/boards/nrf52840dongle/doc.md +++ b/boards/nrf52840dongle/doc.md @@ -75,7 +75,7 @@ that nrfutil, even when not running the "install" command, will install itself into `~/.nrfutil`. The older Python based version of nrfutil is no longer maintained by Nordic, and has become dysfunctional on Python 3.11. -The nrfutil can turn the binary into a suitable zip file and send it to the +The nrfutil works in two steps by turning the binary into a zip file and then sending the content of that zip file to the bootloader. The process is automated in the usual `make flash` target. #### Other programming methods