From f2e80bf28d8daf726376615c063f84f4799e863e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Sun, 5 Jun 2016 18:14:42 +0200 Subject: [PATCH] add support for black magic probe SWD adapter --- Makefile | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 2b03a3b..5a7daf6 100644 --- a/Makefile +++ b/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