summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorGravatar Matthew Wozniak <me@woz.blue> 2025-12-11 23:58:51 -0500
committerGravatar Matthew Wozniak <me@woz.blue> 2025-12-11 23:58:51 -0500
commit5356bc886d53291a9a812f2aba35e4e165d96fba (patch)
tree55fbe7e4f3cb54a5b8c43b40aba4771dc0465d8a /Makefile
downloadstm32_can_demo-5356bc886d53291a9a812f2aba35e4e165d96fba.tar.gz
stm32_can_demo-5356bc886d53291a9a812f2aba35e4e165d96fba.zip
initial commit
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile31
1 files changed, 31 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..6b5ce62
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,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