-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
44 lines (32 loc) · 866 Bytes
/
Makefile
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
# Cross-compiler for ARM
AS = arm-none-eabi-as
LD = arm-none-eabi-ld
OBJCOPY = arm-none-eabi-objcopy
# Compiler and linker flags
LDFLAGS = -T stm32f103c8t6.ld
# List of source files
SRCS = main.s ivt.s default_handler.s reset_handler.s
# List of object files
OBJS = $(SRCS:.s=.o)
# Main target
all: prog.bin
# Compile ARM assembly source files into object files
%.o: %.s
$(AS) -o $@ $<
# Link object files into an ELF executable
prog.elf: $(OBJS) stm32f103c8t6.ld
$(LD) $(LDFLAGS) -o $@ $(OBJS)
# Convert ELF executable into a binary image
prog.bin: prog.elf
$(OBJCOPY) -O binary $< $@
# Clean up object files and binary image
cleanwin:
Del /F $(OBJS) prog.elf prog.bin
# Clean up object files and binary image
clean:
rm -f $(OBJS) prog.elf prog.bin
unlink:
git remote rm origin
write:
st-flash write 'prog.bin' 0x8000000
.PHONY: all clean unlink