瀏覽代碼

Add flash-bmp target to Makefile

I have a Black Magic Probe now, so I'd like to be able to use that to
flash the PD Buddy Sink.  This commit adds a Makefile rule to automate
the very long command to do that.  I didn't bother with a GDB script as
the BMP wiki suggests, since it seems to add little advantage when the
command is already hidden away in a Makefile.
Clara Hobbs 6 年之前
父節點
當前提交
f5bb9d6139
共有 2 個文件被更改,包括 34 次插入2 次删除
  1. 24
    0
      Makefile
  2. 10
    2
      README.md

+ 24
- 0
Makefile 查看文件

@@ -227,3 +227,27 @@ include $(RULESPATH)/rules.mk
227 227
 
228 228
 flash-openocd-stlink: $(BUILDDIR)/$(PROJECT).elf
229 229
 	openocd -f interface/stlink-v2.cfg -c "transport select hla_swd" -f target/stm32f0x.cfg -c "program $(BUILDDIR)/$(PROJECT).elf verify reset exit"
230
+
231
+GDB ?= $(TRGT)gdb
232
+
233
+ifeq ($(BMP_PORT),)
234
+BMP_PORT_CANDIDATES := $(wildcard \
235
+/dev/serial/by-id/usb-Black_Sphere_Technologies_Black_Magic_Probe_*-if00 \
236
+/dev/cu.usbmodem*1)
237
+ifeq ($(words $(BMP_PORT_CANDIDATES)),1)
238
+BMP_PORT := $(BMP_PORT_CANDIDATES)
239
+else
240
+BMP_PORT = $(error Black Magic Probe gdb serial port not found, please provide the device name via the BMP_PORT variable parameter$(if \
241
+$(BMP_PORT_CANDIDATES), (found $(BMP_PORT_CANDIDATES))))
242
+endif
243
+endif
244
+
245
+flash-bmp: $(BUILDDIR)/$(PROJECT).elf
246
+	$(GDB) -nx --batch \
247
+		-ex 'target extended-remote $(BMP_PORT)' \
248
+		-ex 'monitor swdp_scan' \
249
+		-ex 'attach 1' \
250
+		-ex 'load' \
251
+		-ex 'compare-sections' \
252
+		-ex 'kill' \
253
+		$(BUILDDIR)/$(PROJECT).elf

+ 10
- 2
README.md 查看文件

@@ -57,13 +57,14 @@ submodule.
57 57
 You will also need to install some program to flash the firmware.  The simplest
58 58
 option is [dfu-util][], as it requires no extra hardware (though if upgrading
59 59
 from versions older than 1.2.0, either the Boot switch must be installed or two
60
-pads must be bridged).  If you prefer to use SWD, you could also use [stlink][]
61
-or [OpenOCD][].
60
+pads must be bridged).  If you prefer to use SWD, you could also use
61
+[stlink][], [OpenOCD][], or a [Black Magic Probe][].
62 62
 
63 63
 [toolchain]: https://launchpad.net/gcc-arm-embedded
64 64
 [dfu-util]: http://dfu-util.sourceforge.net/
65 65
 [stlink]: https://github.com/texane/stlink
66 66
 [OpenOCD]: http://openocd.org/
67
+[Black Magic Probe]: https://github.com/blacksphere/blackmagic/wiki
67 68
 
68 69
 ## Compiling
69 70
 
@@ -125,6 +126,13 @@ ST-LINK/V2, you can easily do this as follows:
125 126
 
126 127
     $ make flash-openocd-stlink
127 128
 
129
+### Black Magic Probe
130
+
131
+Black Magic Probe debuggers can be used to flash the firmware as well.  This
132
+can be easily done as follows:
133
+
134
+    $ make flash-bmp
135
+
128 136
 ## Usage
129 137
 
130 138
 After first flashing the PD Buddy Sink, the device has no configuration.  To

Loading…
取消
儲存