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