add support for black magic probe SWD adapter
This commit is contained in:
parent
02835fa72f
commit
f2e80bf28d
13
Makefile
13
Makefile
@ -109,18 +109,23 @@ FP_FLAGS ?= -msoft-float
|
||||
ARCH_FLAGS = -mthumb -mcpu=cortex-m3 $(FP_FLAGS) -mfix-cortex-m3-ldrd
|
||||
|
||||
# SWD adapter used
|
||||
# supported are : st-link v2 (STLINKV2)
|
||||
SWD_ADAPTER ?= STLINKV2
|
||||
# supported are : st-link v2 (STLINKV2), black magic probe (BMP)
|
||||
SWD_ADAPTER ?= BMP
|
||||
ifeq ($(SWD_ADAPTER),STLINKV2)
|
||||
# OpenOCD configuration
|
||||
OOCD ?= openocd
|
||||
OOCD_INTERFACE ?= stlink-v2
|
||||
OOCD_TARGET ?= stm32f1x
|
||||
else ifeq ($(SWD_ADAPTER),BMP)
|
||||
# the black magic probe has a SWD controller built in
|
||||
BMPPORT ?= /dev/ttyACM0
|
||||
endif
|
||||
|
||||
# which USB CDC ACM port is used bu the device, so we can reset it
|
||||
ifeq ($(SWD_ADAPTER),STLINKV2)
|
||||
ACMPORT = /dev/ttyACM0
|
||||
else ifeq ($(SWD_ADAPTER),BMP)
|
||||
ACMPORT = /dev/ttyACM2
|
||||
endif
|
||||
ACMPORT_EXISTS = $(shell [ -e $(ACMPORT) ] && echo 1 || echo 0 )
|
||||
|
||||
@ -172,6 +177,8 @@ flash: $(BINARY).hex
|
||||
$(info flashing $(<) using SWD)
|
||||
ifeq ($(SWD_ADAPTER),STLINKV2)
|
||||
$(Q)$(OOCD) --file interface/$(OOCD_INTERFACE).cfg --file target/$(OOCD_TARGET).cfg --command "init" --command "reset init" --command "flash write_image erase $(<)" --command "reset" --command "shutdown" $(NULL)
|
||||
else ifeq ($(SWD_ADAPTER),BMP)
|
||||
$(Q)$(GDB) --eval-command="target extended-remote $(BMPPORT)" --eval-command="monitor version" --eval-command="monitor swdp_scan" --eval-command="attach 1" --eval-command="load" --eval-command="detach" --eval-command="kill" --eval-command="quit" $(<)
|
||||
endif
|
||||
|
||||
# reset device by setting the data width to 5 bis on the USB CDC ACM port
|
||||
@ -185,6 +192,8 @@ endif
|
||||
debug: $(BINARY).elf
|
||||
ifeq ($(SWD_ADAPTER),STLINKV2)
|
||||
$(Q)$(GDB) --eval-command="target remote | $(OOCD) --file interface/$(OOCD_INTERFACE).cfg --file target/$(OOCD_TARGET).cfg --command \"gdb_port pipe; log_output /dev/null; init\"" --eval-command="monitor reset halt" --eval-command="load" --eval-command="monitor reset init" $(<)
|
||||
else ifeq ($(SWD_ADAPTER),BMP)
|
||||
$(Q)$(GDB) --eval-command="target extended-remote $(BMPPORT)" --eval-command="monitor version" --eval-command="monitor swdp_scan" --eval-command="attach 1" $(<)
|
||||
endif
|
||||
|
||||
.PHONY: clean elf bin hex srec list libraries flash reset
|
||||
|
Loading…
Reference in New Issue
Block a user