summaryrefslogtreecommitdiff
path: root/Makefile
blob: 6b5ce62c34b91e7972a82bf04e911c386ca97af5 (plain) (blame)
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
CC = arm-none-eabi-gcc
CFLAGS = -mcpu=cortex-m3 -mthumb -ffreestanding -Os -nostartfiles -std=c23 \
	-DSTM32F103xB \
	-Wpedantic \
	-I3p/cmsis-device-f1/Include \
	-I3p/CMSIS_6/CMSIS/Core/Include

LINKER_FILE=linker_script.ld
LDFLAGS=-specs=nano.specs -specs=nosys.specs -T $(LINKER_FILE)

all: blink.elf

.PHONY: clean flash debug

clean:
	rm -v *.o blink.elf

blink.elf: main.o startup.o system_stm32f1xx.o 
	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $^ -o blink.elf

system_stm32f1xx.o: 3p/cmsis-device-f1/Source/Templates/system_stm32f1xx.c 
	$(CC) $(CFLAGS) 3p/cmsis-device-f1/Source/Templates/system_stm32f1xx.c -c

%.o: %.c
	$(CC) $(CFLAGS) $< -c -o $@

flash: blink.elf
	openocd -f interface/stlink.cfg -f target/stm32f1x.cfg -c "program blink.elf verify reset exit"

debug: blink.elf
	openocd -f interface/stlink.cfg -f target/stm32f1x.cfg