aboutsummaryrefslogtreecommitdiff
path: root/examples/stm32/f1/Makefile.include
diff options
context:
space:
mode:
Diffstat (limited to 'examples/stm32/f1/Makefile.include')
-rw-r--r--examples/stm32/f1/Makefile.include21
1 files changed, 21 insertions, 0 deletions
diff --git a/examples/stm32/f1/Makefile.include b/examples/stm32/f1/Makefile.include
index 6b87b98..2ae9e27 100644
--- a/examples/stm32/f1/Makefile.include
+++ b/examples/stm32/f1/Makefile.include
@@ -45,6 +45,15 @@ LDFLAGS += --static -Wl,--start-group -lc -lgcc -lnosys -Wl,--end-group \
-L$(TOOLCHAIN_DIR)/lib \
-T$(LDSCRIPT) -nostartfiles -Wl,--gc-sections \
$(ARCH_FLAGS) -mfix-cortex-m3-ldrd
+
+ifneq ($(OPENCM3_DIR),)
+CFLAGS += -I$(OPENCM3_DIR)/include
+LDFLAGS += -L$(OPENCM3_DIR)/lib -L$(OPENCM3_DIR)/lib/stm32/f1
+SCRIPT_DIR = $(OPENCM3_DIR)/share
+else
+SCRIPT_DIR = $(shell dirname $(shell readlink -f $(shell which $(PREFIX)-gcc)))/../$(PREFIX)/share
+endif
+
OBJS += $(BINARY).o
OOCD ?= openocd
@@ -53,6 +62,9 @@ OOCD_BOARD ?= olimex_stm32_h103
# Black magic probe specific variables
# Set the BMP_PORT to a serial port and then BMP is used for flashing
BMP_PORT ?=
+# texane/stlink can be used by uncommenting this...
+# or defining it in your own makefiles
+#STLINK_PORT ?= :4242
# Be silent per default, but 'make V=1' will show all compiler calls.
ifneq ($(V),1)
@@ -107,6 +119,7 @@ clean:
$(Q)rm -f *.srec
$(Q)rm -f *.list
+ifeq ($(STLINK_PORT),)
ifeq ($(BMP_PORT),)
ifeq ($(OOCD_SERIAL),)
%.flash: %.hex
@@ -140,6 +153,14 @@ else
-x $(TOOLCHAIN_DIR)/scripts/black_magic_probe_flash.scr \
$(*).elf
endif
+else
+%.flash: %.elf
+ @echo " GDB $(*).elf (flash)"
+ $(Q)$(GDB) --batch \
+ -ex 'target extended-remote $(STLINK_PORT)' \
+ -x $(SCRIPT_DIR)/libopencm3/scripts/stlink_flash.scr \
+ $(*).elf
+endif
.PHONY: images clean