support multiple SWD adapter
This commit is contained in:
parent
c679a74ba7
commit
02835fa72f
13
Makefile
13
Makefile
@ -108,13 +108,20 @@ LDLIBS += -Wl,--start-group -lc -lgcc -lnosys -Wl,--end-group
|
||||
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
|
||||
ifeq ($(SWD_ADAPTER),STLINKV2)
|
||||
# OpenOCD configuration
|
||||
OOCD ?= openocd
|
||||
OOCD_INTERFACE ?= stlink-v2
|
||||
OOCD_TARGET ?= stm32f1x
|
||||
endif
|
||||
|
||||
# which USB CDC ACM port is used bu the device, so we can reset it
|
||||
ifeq ($(SWD_ADAPTER),STLINKV2)
|
||||
ACMPORT = /dev/ttyACM0
|
||||
endif
|
||||
ACMPORT_EXISTS = $(shell [ -e $(ACMPORT) ] && echo 1 || echo 0 )
|
||||
|
||||
# compile target rules
|
||||
@ -163,7 +170,9 @@ $(LIB_DIR)/lib$(LIBNAME).a:
|
||||
|
||||
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)
|
||||
endif
|
||||
|
||||
# reset device by setting the data width to 5 bis on the USB CDC ACM port
|
||||
reset:
|
||||
@ -172,8 +181,10 @@ ifeq ($(ACMPORT_EXISTS), 1)
|
||||
$(Q)sleep 0.5
|
||||
endif
|
||||
|
||||
# debug using jtag (openOCB+GDB)
|
||||
# debug using GDB
|
||||
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" $(<)
|
||||
endif
|
||||
|
||||
.PHONY: clean elf bin hex srec list libraries flash reset
|
||||
|
Loading…
Reference in New Issue
Block a user