-
Notifications
You must be signed in to change notification settings - Fork 0
/
Debug.mk
70 lines (60 loc) · 1.48 KB
/
Debug.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
GDB := PYTHONHOME=/home/stefan/opt/python-3.8 arm-none-eabi-gdb
JLINK := JLinkExe
JLINKGDBSERVER := JLinkGDBServer
STFLASH := st-flash
STUTIL := st-util
OPENOCD := openocd-st
OPENOCDFLAGS := -f interface/stlink.cfg -f target/stm32f1x.cfg
JLINKFLAGS := -device STM32F103RB -if SWD -speed 4000
# Short targets can be configured
flash: flash_stlink
debug: debug_openocd
# Uses st-flash via stlink
flash_stflash: firmware.bin
$(STFLASH) write $< 0x8000000
# Uses openocd via stlink
flash_openocd: firmware.bin
$(OPENOCD) $(OPENOCDFLAGS) -c "program $< 0x08000000 verify reset exit"
# Uses JLink
define flash_jlink_script
$(JLINK) $(JLINKFLAGS) -autoconnect 1 <<EOF
LoadFile $< 0x08000000
Reset
Exit
EOF
endef
export flash_jlink_script
flash_jlink: firmware.bin
eval "$$flash_jlink_script"
# Debugserver is JLink
debug_jlink: firmware.elf
{ \
set -e ;\
$(JLINKGDBSERVER) $(JLINKFLAGS) &\
pid=$$! ;\
$(GDB) -x debug_jlink.gdb $< ;\
kill $$pid ;\
}
# Debugserver is st-util
debug_stutil: firmware.elf
{ \
set -e ;\
$(STUTIL) &\
pid=$$! ;\
$(GDB) -x debug_stutil.gdb $< ;\
kill $$pid ;\
}
# Debugserver is OpenOCD via stlink
debug_openocd: firmware.elf
{ \
set -e ;\
$(OPENOCD) $(OPENOCDFLAGS) &\
pid=$$! ;\
$(GDB) -x debug_openocd.gdb $< ;\
kill $$pid ;\
}
# Uses Black Magic Probe via serial port
debug_bmp: firmware.elf
$(GDB) -x debug_bmp.gdb $<
.PHONY: flash flash_jlink flash_openocd flash_stflash
.PHONY: debug debug_bmp debug_jlink debug_stutil debug_openocd