PROJECT test BUILD_DIR bin CFILES main CFILES utils LDLIBS -lm DEVICE

 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
PROJECT = test
BUILD_DIR = bin
CFILES += main.c
CFILES += utils.c
LDLIBS += -lm
DEVICE=stm32f103xb
OOCD_FILE = board/stm32f1discovery.cfg
INCLUDES += $(patsubst %,-I%, .)
OPENCM3_DIR=libopencm3
include $(OPENCM3_DIR)/mk/genlink-config.mk
include rules.mk
include $(OPENCM3_DIR)/mk/genlink-rules.mk
ifeq ($(BMP_PORT),)
BMP_PORT_CANDIDATES := $(wildcard /dev/serial/by-id/usb-Black_Sphere_Technologies_Black_Magic_Probe_*-if00)
ifeq ($(words $(BMP_PORT_CANDIDATES)),1)
BMP_PORT := $(BMP_PORT_CANDIDATES)
else
BMP_PORT = $(error Black Magic Probe gdb serial port not found, please provide the device name via the BMP_PORT variable parameter$(if $(BMP_PORT_CANDIDATES), (found $(BMP_PORT_CANDIDATES))))
endif
endif
ifeq ($(SERIAL_PORT),)
SERIAL_PORT_CANDIDATES := $(wildcard /dev/serial/by-id/usb-Black_Sphere_Technologies_Black_Magic_Probe_*-if02)
ifeq ($(words $(SERIAL_PORT_CANDIDATES)),1)
SERIAL_PORT := $(SERIAL_PORT_CANDIDATES)
else
SERIAL_PORT = $(error Black Magic Probe UART serial port not found, please provide the device name via the SERIAL_PORT variable parameter$(if $(SERIAL_PORT_CANDIDATES), (found $(SERIAL_PORT_CANDIDATES))))
endif
endif
install:
@echo -n "RAM: "; size "$(PROJECT).elf" | tail -1 | awk '{print $$2 + $$3}'
@echo -n "ROM: "; size "$(PROJECT).elf" | tail -1 | awk '{print $$1}'
@printf "INSTALL $(BMP_PORT) $(PROJECT).elf (flash)\n"
$(PREFIX)gdb -nx --batch \
-ex 'target extended-remote $(BMP_PORT)' \
-x black_magic_probe_flash.scr \
$(PROJECT).elf
picocom:
picocom -b115200 "$(SERIAL_PORT)"