aboutsummaryrefslogtreecommitdiff
path: root/ports/nrf
diff options
context:
space:
mode:
authorGlenn Ruben Bakke2020-07-16 23:17:28 +0200
committerGlenn Ruben Bakke2020-12-07 20:04:50 +0100
commit634f6df32485457dd1c236633cffd49177aaf826 (patch)
tree5edfa9ba5231c84b156f2021920754348827f2f8 /ports/nrf
parent718397a37d7ec2071b5f5d3668c31e6b8f69f3b9 (diff)
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.
Diffstat (limited to 'ports/nrf')
-rw-r--r--ports/nrf/Makefile25
1 files changed, 25 insertions, 0 deletions
diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile
index 4ee9384ec..868095080 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