From 634f6df32485457dd1c236633cffd49177aaf826 Mon Sep 17 00:00:00 2001 From: Glenn Ruben Bakke Date: Thu, 16 Jul 2020 23:17:28 +0200 Subject: [PATCH] nrf/Makefile: Add support for flashing with nrfutil. An additional Makefile parameter NRFUTIL_PORT can be set in order to define the serial port to used for the DFU (Default: /dev/ttyACM0). The "nrfutil" that is used as flasher towards OpenBootloader is available for installation through Python "pip". In case of SD=s140, SoftDevice ID 0xB6 is passed to nrfutil's package generation which corresponds to SoftDevice s140 v6.1.1. --- ports/nrf/Makefile | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index 4ee9384ec2..8680950804 100644 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -446,6 +446,31 @@ deploy: $(BUILD)/$(OUTPUT_FILENAME).hex sd: $(BUILD)/$(OUTPUT_FILENAME).hex $(Q)$(OPENOCD) -f interface/cmsis-dap.cfg -f $(OPENOCD_TARGET) -c "init" -c "program $(SOFTDEV_HEX) verify reset" -c "exit" +else ifeq ($(FLASHER), nrfutil) + +NRFUTIL_PORT ?= /dev/ttyACM0 +NRFUTIL_SD_REQ ?= 0x00 + +ifeq ($(SD), s140) +NRFUTIL_SD_REQ = 0xB6 +endif + +.PHONY: nrfutil_dfu_sd nrfutil_dfu_deploy +.NOTPARALLEL: nrfutil_dfu_sd nrfutil_dfu_deploy + +# DFU both SD and app in case of target "sd" +sd: nrfutil_dfu_sd nrfutil_dfu_deploy + +nrfutil_dfu_sd: $(BUILD)/$(OUTPUT_FILENAME).hex + $(Q)hexmerge.py -o $(BUILD)/stripped_sd.hex --range=0x1000: $(SOFTDEV_HEX) + $(Q)nrfutil pkg generate --hw-version 52 --sd-req 0x00 --sd-id 0x00 --softdevice $(BUILD)/stripped_sd.hex $(BUILD)/stripped_sd.zip + $(Q)nrfutil dfu usb-serial -pkg $(BUILD)/stripped_sd.zip -p $(NRFUTIL_PORT) -t 0 + +nrfutil_dfu_deploy: $(BUILD)/$(OUTPUT_FILENAME).hex + $(Q)nrfutil pkg generate --hw-version 52 --sd-req $(NRFUTIL_SD_REQ) --application-version 1 --application $(BUILD)/$(OUTPUT_FILENAME).hex $(BUILD)/$(OUTPUT_FILENAME)_dfu.zip + $(Q)nrfutil dfu usb-serial -pkg $(BUILD)/$(OUTPUT_FILENAME)_dfu.zip -p $(NRFUTIL_PORT) -t 0 + +deploy: nrfutil_dfu_deploy endif flash: deploy