diff --git a/conf/Makefile.stm32 b/conf/Makefile.stm32 index 7556762013..737e44467d 100644 --- a/conf/Makefile.stm32 +++ b/conf/Makefile.stm32 @@ -52,6 +52,7 @@ CP = $(GCC_BIN_PREFIX)-objcopy DMP = $(GCC_BIN_PREFIX)-objdump NM = $(GCC_BIN_PREFIX)-nm SIZE = $(GCC_BIN_PREFIX)-size +GDB = $(GCC_BIN_PREFIX)-gdb RM = rm # If we can't find the toolchain then try picking up the compilers from the path @@ -62,8 +63,10 @@ CP = $(shell which arm-none-eabi-objcopy) DMP = $(shell which arm-none-eabi-objdump) NM = $(shell which arm-none-eabi-nm) SIZE = $(shell which arm-none-eabi-size) +GDB = $(shell which arm-none-eabi-gdb) RM = rm -GCC_LIB_DIR=$(shell dirname `which arm-none-eabi-gcc`)/../arm-none-eabi/lib +TOOLCHAIN_DIR=$(shell dirname `which arm-none-eabi-gcc`) +GCC_LIB_DIR=$(TOOLCHAIN_DIR)/../arm-none-eabi/lib endif # Detect if we are using the new libopencm3 or the old libopenstm32 @@ -250,7 +253,8 @@ ifeq ($(FLASH_MODE),SERIAL) upload: $(OBJDIR)/$(TARGET).bin $(LOADER) -p /dev/ttyUSB0 -b 115200 -e -w -v $^ else ifeq ($(FLASH_MODE),JTAG) -upload: $(OBJDIR)/$(TARGET).elf +ifeq ($(BMP_PORT),) +upload: $(OBJDIR)/$(TARGET).elf @echo "Using OOCD = $(OOCD)" @echo " OOCD\t$<" $(Q)$(OOCD) -f interface/$(OOCD_INTERFACE).cfg \ @@ -263,6 +267,16 @@ upload: $(OBJDIR)/$(TARGET).elf -c reset \ -c shutdown else +upload: $(OBJDIR)/$(TARGET).elf + @echo "Using Black Magic Probe" + @echo "Using GDB = $(GDB)" + @echo " BMP\t$<" + $(Q)$(GDB) --batch \ + -ex 'target extended-remote $(BMP_PORT)' \ + -x $(TOOLCHAIN_DIR)/arm-none-eabi/share/libopencm3/scripts/black_magic_probe_flash.scr \ + $< +endif +else upload: @echo unknown flash_mode $(FLASH_MODE) endif