Skip to content

Commit 563f151

Browse files
committed
Add gdbflash target using BMP
1 parent c5c2039 commit 563f151

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ else
4141
NRFJPROG = nrfjprog
4242
endif
4343

44+
# auto-detect BMP on macOS, otherwise have to specify
45+
BMP_PORT ?= $(shell ls -1 /dev/cu.usbmodem????????1 | head -1)
46+
4447
ifeq ($(OS),Windows_NT)
4548
PROGFILES = C:/Program Files (x86)
4649
GNU_INSTALL_ROOT = $(PROGFILES)/GNU Tools ARM Embedded/7 2018-q2-update/bin/
@@ -67,6 +70,9 @@ NM := '$(GNU_INSTALL_ROOT)$(GNU_PREFIX)-nm'
6770
OBJDUMP := '$(GNU_INSTALL_ROOT)$(GNU_PREFIX)-objdump'
6871
OBJCOPY := '$(GNU_INSTALL_ROOT)$(GNU_PREFIX)-objcopy'
6972
SIZE := '$(GNU_INSTALL_ROOT)$(GNU_PREFIX)-size'
73+
GDB := '$(GNU_INSTALL_ROOT)$(GNU_PREFIX)-gdb'
74+
75+
GDB_BMP = arm-none-eabi-gdb -ex 'target extended-remote $(BMP_PORT)' -ex 'monitor swdp_scan' -ex 'attach 1'
7076

7177
#function for removing duplicates in a list
7278
remduplicates = $(strip $(if $1,$(firstword $1) $(call remduplicates,$(filter-out $(firstword $1),$1))))
@@ -341,6 +347,10 @@ erase:
341347
@echo Erasing chip
342348
$(NRFJPROG) --eraseall -f nrf52
343349

350+
gdbflash: $(BUILD)/$(MERGED_FNAME).hex
351+
@echo Flashing: $<
352+
@$(GDB_BMP) -nx --batch -ex 'load $<' -ex 'compare-sections' -ex 'kill'
353+
344354
#******************* Compile rules *******************
345355

346356
## Create build directories

0 commit comments

Comments
 (0)