aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Rheinfels <t.rheinfels@gmail.com>2019-10-27 08:01:56 +0100
committerTim Rheinfels <t.rheinfels@gmail.com>2019-10-27 08:01:56 +0100
commitd2fa4a47957451f3e63e7bf012a06125d0415545 (patch)
tree5cd079c17c6a6c4b2a0e1f4707c1cf7528e40f13
parentdc72ea603311123964271f910f051fb2027351ef (diff)
downloadChibiOS-Contrib-d2fa4a47957451f3e63e7bf012a06125d0415545.tar.gz
ChibiOS-Contrib-d2fa4a47957451f3e63e7bf012a06125d0415545.tar.bz2
ChibiOS-Contrib-d2fa4a47957451f3e63e7bf012a06125d0415545.zip
+ Added make targets for flashing and debugging via Black Magic and gdb
-rw-r--r--os/various/bmp.mk57
1 files changed, 57 insertions, 0 deletions
diff --git a/os/various/bmp.mk b/os/various/bmp.mk
new file mode 100644
index 0000000..1e2e63e
--- /dev/null
+++ b/os/various/bmp.mk
@@ -0,0 +1,57 @@
+##
+## make targets for the Black Magic Probe
+## See: https://github.com/blacksphere/blackmagic (Black Magic)
+## See: https://github.com/blacksphere/blackmagic/wiki/Frequently-Asked-Questions (Black Magic udev rules)
+##
+## Provides the following targets:
+##
+## all: Wrapper for the elf binary
+## flash: Uses GDB to flash the target via Black Magic
+## debug: Flashes the target and allows for debugging using gdb and Black Magic
+## debug-tui: Flashes the target and allows for debugging using gdb's TUI and Black Magic
+##
+
+GDB ?= arm-none-eabi-gdb # Path to the arm-none-eabi-gdb binary
+GDB_PROGRAM ?= $(BUILDDIR)/$(PROJECT).elf # Path to the elf binary
+GDB_BREAK ?= main # Function to break at when starting the debugger
+
+BMP_GDB ?= /dev/ttyBmpGdb # Device file for the Black Magic GDB devic
+
+all: $(GDB_PROGRAM)
+
+flash: $(GDB_PROGRAM)
+ $(GDB) $(GDB_PROGRAM) -nx --batch \
+ -ex 'target extended-remote $(BMP_GDB)' \
+ -ex 'monitor swdp_scan' \
+ -ex 'attach 1' \
+ -ex 'load' \
+ -ex 'compare-sections' \
+ -ex 'kill'
+
+debug: $(GDB_PROGRAM)
+ $(GDB) $(GDB_PROGRAM) -nx \
+ -ex 'target extended-remote $(BMP_GDB)' \
+ -ex 'monitor swdp_scan' \
+ -ex 'attach 1' \
+ -ex 'load' \
+ -ex 'compare-sections' \
+ -ex 'set mem inaccessible-by-default off' \
+ -ex 'break $(GDB_BREAK)' \
+ -ex 'c'
+
+debug-tui: $(GDB_PROGRAM)
+ $(GDB) $(GDB_PROGRAM) -nx \
+ -ex 'target extended-remote $(BMP_GDB)' \
+ -ex 'monitor swdp_scan' \
+ -ex 'attach 1' \
+ -ex 'load' \
+ -ex 'compare-sections' \
+ -ex 'set mem inaccessible-by-default off' \
+ -ex 'set pagination off' \
+ -ex 'focus cmd' \
+ -ex 'layout src' \
+ -ex 'break $(GDB_BREAK)' \
+ -ex 'c' \
+ -ex 'set pagination on'
+
+.PHONY: all flash debug debug-tui