Skip to content

Commit 883ca21

Browse files
committed
nrf: Fix flashing with pyocd
1 parent 75f48a5 commit 883ca21

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

ports/nrf/Makefile

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ SRC_C += \
132132
lib/tinyusb/src/class/msc/msc_device.c \
133133
lib/tinyusb/src/class/cdc/cdc_device.c \
134134
lib/tinyusb/src/tusb.c \
135-
135+
136136
endif
137137

138138
DRIVERS_SRC_C += $(addprefix modules/,\
@@ -275,16 +275,24 @@ sd: $(BUILD)/$(OUTPUT_FILENAME).hex
275275

276276
bootloader:
277277
nrfjprog --program $(BOOT_FILE).hex -f nrf52 --chiperase --reset
278-
278+
279279
else ifeq ($(FLASHER), pyocd)
280280

281281
flash: $(BUILD)/$(OUTPUT_FILENAME).hex
282-
pyocd-flashtool -t $(MCU_VARIANT) $<
282+
pyocd-flashtool -t $(MCU_SUB_VARIANT) $< --sector_erase
283+
pyocd-tool -t $(MCU_SUB_VARIANT) erase $(BOOT_SETTING_ADDR)
284+
pyocd-tool -t $(MCU_SUB_VARIANT) write32 $(BOOT_SETTING_ADDR) 0x00000001
285+
pyocd-tool -t $(MCU_SUB_VARIANT) reset
283286

284287
sd: $(BUILD)/$(OUTPUT_FILENAME).hex
285-
pyocd-flashtool -t $(MCU_VARIANT) --chip_erase
286-
pyocd-flashtool -t $(MCU_VARIANT) $(SOFTDEV_HEX)
287-
pyocd-flashtool -t $(MCU_VARIANT) $<
288+
pyocd-flashtool -t $(MCU_SUB_VARIANT) --chip_erase
289+
pyocd-flashtool -t $(MCU_SUB_VARIANT) $(SOFTDEV_HEX)
290+
pyocd-flashtool -t $(MCU_SUB_VARIANT) $< --sector_erase
291+
pyocd-tool -t $(MCU_SUB_VARIANT) reset $(BOOT_SETTING_ADDR)
292+
293+
bootloader:
294+
pyocd-flashtool -t $(MCU_SUB_VARIANT) $(BOOT_FILE).hex --chip_erase
295+
pyocd-tool -t $(MCU_SUB_VARIANT) reset
288296

289297
endif
290298

0 commit comments

Comments
 (0)