aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rw-r--r--examples/stm32/Makefile.include13
-rw-r--r--scripts/black_magic_probe_debug.scr4
-rw-r--r--scripts/black_magic_probe_flash.scr4
4 files changed, 25 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index fe8db6a..766073d 100644
--- a/Makefile
+++ b/Makefile
@@ -22,6 +22,7 @@ PREFIX ?= arm-elf
DESTDIR ?= /usr/local
INCDIR = $(DESTDIR)/$(PREFIX)/include
LIBDIR = $(DESTDIR)/$(PREFIX)/lib
+SHAREDIR = $(DESTDIR)/$(PREFIX)/share/libopencm3/scripts
INSTALL = install
TARGETS = stm32 lpc13xx lm3s
@@ -57,11 +58,14 @@ install: lib
@printf " INSTALL headers\n"
$(Q)$(INSTALL) -d $(INCDIR)/libopencm3
$(Q)$(INSTALL) -d $(LIBDIR)
+ $(Q)$(INSTALL) -d $(SHAREDIR)
$(Q)cp -r include/libopencm3/* $(INCDIR)/libopencm3
@printf " INSTALL libs\n"
$(Q)$(INSTALL) -m 0644 lib/*/*.a $(LIBDIR)
@printf " INSTALL ldscripts\n"
$(Q)$(INSTALL) -m 0644 lib/*/*.ld $(LIBDIR)
+ @printf " INSTALL scripts\n"
+ $(Q)$(INSTALL) -m 0644 scripts/* $(SHAREDIR)
clean:
$(Q)for i in $(addprefix lib/,$(TARGETS)) \
diff --git a/examples/stm32/Makefile.include b/examples/stm32/Makefile.include
index f370f45..a4512e9 100644
--- a/examples/stm32/Makefile.include
+++ b/examples/stm32/Makefile.include
@@ -24,6 +24,7 @@ CC = $(PREFIX)-gcc
LD = $(PREFIX)-gcc
OBJCOPY = $(PREFIX)-objcopy
OBJDUMP = $(PREFIX)-objdump
+GDB = $(PREFIX)-gdb
# Uncomment this line if you want to use the installed (not local) library.
# TOOLCHAIN_DIR = `dirname \`which $(CC)\``/../$(PREFIX)
TOOLCHAIN_DIR = ../../../..
@@ -38,6 +39,9 @@ OBJS += $(BINARY).o
OOCD ?= openocd
OOCD_INTERFACE ?= flossjtag
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 ?=
# Be silent per default, but 'make V=1' will show all compiler calls.
ifneq ($(V),1)
@@ -92,6 +96,7 @@ clean:
$(Q)rm -f *.srec
$(Q)rm -f *.list
+ifeq ($(BMP_PORT),)
ifeq ($(OOCD_SERIAL),)
%.flash: %.hex
@printf " FLASH $<\n"
@@ -116,6 +121,14 @@ else
-c "reset" \
-c "shutdown" $(NULL)
endif
+else
+%.flash: %.elf
+ @echo " GDB $(*).elf (flash)"
+ $(Q)$(GDB) --batch \
+ -ex 'target extended-remote $(BMP_PORT)' \
+ -x $(TOOLCHAIN_DIR)/scripts/black_magic_probe_flash.scr \
+ $(*).elf
+endif
.PHONY: images clean
diff --git a/scripts/black_magic_probe_debug.scr b/scripts/black_magic_probe_debug.scr
new file mode 100644
index 0000000..0bf774c
--- /dev/null
+++ b/scripts/black_magic_probe_debug.scr
@@ -0,0 +1,4 @@
+monitor version
+monitor swdp_scan
+attach 1
+run
diff --git a/scripts/black_magic_probe_flash.scr b/scripts/black_magic_probe_flash.scr
new file mode 100644
index 0000000..27663c8
--- /dev/null
+++ b/scripts/black_magic_probe_flash.scr
@@ -0,0 +1,4 @@
+monitor version
+monitor swdp_scan
+attach 1
+load