STM32-Blink/makefile

36 lines
516 B
Makefile
Raw Normal View History

2024-04-03 17:47:08 +02:00
# Toolchain
CC = arm-none-eabi-gcc
OBJCOPY = arm-none-eabi-objcopy
STFLASH = st-flash
# Compiler flags
CFLAGS = -std=c99 -Wall -Wextra -Werror -g -mthumb -mcpu=cortex-m3
# Object files
OBJS = blink.o
# Output files
ELF = blink.elf
BIN = blink.bin
# Targets
.PHONY: all clean flash
all: $(BIN)
$(BIN): $(ELF)
$(OBJCOPY) -O binary $< $@
$(ELF): $(OBJS)
$(CC) $(CFLAGS) $^ -o $@
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
clean:
rm -f $(OBJS) $(ELF) $(BIN)
flash: $(BIN)
$(STFLASH) --reset write $< 0x8000000