Browse Source

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 years ago
parent
commit
f5bb9d6139
2 changed files with 34 additions and 2 deletions
  1. 24
    0
      Makefile
  2. 10
    2
      README.md

+ 24
- 0
Makefile View File

227
 
227
 
228
 flash-openocd-stlink: $(BUILDDIR)/$(PROJECT).elf
228
 flash-openocd-stlink: $(BUILDDIR)/$(PROJECT).elf
229
 	openocd -f interface/stlink-v2.cfg -c "transport select hla_swd" -f target/stm32f0x.cfg -c "program $(BUILDDIR)/$(PROJECT).elf verify reset exit"
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 View File

57
 You will also need to install some program to flash the firmware.  The simplest
57
 You will also need to install some program to flash the firmware.  The simplest
58
 option is [dfu-util][], as it requires no extra hardware (though if upgrading
58
 option is [dfu-util][], as it requires no extra hardware (though if upgrading
59
 from versions older than 1.2.0, either the Boot switch must be installed or two
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
 [toolchain]: https://launchpad.net/gcc-arm-embedded
63
 [toolchain]: https://launchpad.net/gcc-arm-embedded
64
 [dfu-util]: http://dfu-util.sourceforge.net/
64
 [dfu-util]: http://dfu-util.sourceforge.net/
65
 [stlink]: https://github.com/texane/stlink
65
 [stlink]: https://github.com/texane/stlink
66
 [OpenOCD]: http://openocd.org/
66
 [OpenOCD]: http://openocd.org/
67
+[Black Magic Probe]: https://github.com/blacksphere/blackmagic/wiki
67
 
68
 
68
 ## Compiling
69
 ## Compiling
69
 
70
 
125
 
126
 
126
     $ make flash-openocd-stlink
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
 ## Usage
136
 ## Usage
129
 
137
 
130
 After first flashing the PD Buddy Sink, the device has no configuration.  To
138
 After first flashing the PD Buddy Sink, the device has no configuration.  To

Loading…
Cancel
Save