From cd9a8c174209c869bd590e8408503dc20863c291 Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Mon, 20 Apr 2020 16:22:28 +1000 Subject: [PATCH] nrf: Add openocd as a supported flasher. Tested with the Particle Debugger on a Xenon. --- ports/nrf/Makefile | 18 ++++++++++++++++++ .../nrf/boards/particle_xenon/mpconfigboard.mk | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index b6602de0b4..23d5cd20d0 100644 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -419,6 +419,24 @@ sd: $(BUILD)/$(OUTPUT_FILENAME).elf -ex 'quit' \ $< +else ifeq ($(FLASHER), openocd) + +OPENOCD ?= openocd + +ifeq ($(MCU_VARIANT), nrf51) +OPENOCD_TARGET ?= target/nrf52.cfg +else ifeq ($(MCU_VARIANT), nrf52) +OPENOCD_TARGET ?= target/nrf52.cfg +else +$(error Unsupported openocd target) +endif + +deploy: $(BUILD)/$(OUTPUT_FILENAME).hex + $(Q)$(OPENOCD) -f interface/cmsis-dap.cfg -f $(OPENOCD_TARGET) -c "init" -c "program $< verify reset" -c "exit" + +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" + endif flash: deploy diff --git a/ports/nrf/boards/particle_xenon/mpconfigboard.mk b/ports/nrf/boards/particle_xenon/mpconfigboard.mk index ca555d3932..34bead59ff 100644 --- a/ports/nrf/boards/particle_xenon/mpconfigboard.mk +++ b/ports/nrf/boards/particle_xenon/mpconfigboard.mk @@ -5,3 +5,7 @@ SOFTDEV_VERSION = 6.1.1 LD_FILES += boards/nrf52840_1M_256k.ld NRF_DEFINES += -DNRF52840_XXAA + +# The nrf52-particle.cfg is not included here, it can be found in the Particle Workbench +# Note: This requires openocd >0.10 +OPENOCD_TARGET ?= boards/$(BOARD)/nrf52-particle.cfg