sandbox/blue-pill/blinky/Makefile

59 lines
923 B
Makefile
Raw Normal View History

# configurables
OBJS :=
TARGET := blinky
OBJS += $(TARGET).o
# targets
ELF := $(TARGET).elf
BIN := $(TARGET).bin
# toolchain setup
ARMTC := arm-none-eabi
ARMCC := $(ARMTC)-gcc
CC := $(ARMCC)
LD := $(ARMCC)
ARMSIZE := $(ARMTC)-size
OBJCOPY := $(ARMTC)-objcopy
# compiler options
2018-03-07 16:06:25 +00:00
CPUFLAGS := -mcpu=cortex-m3 -mthumb -std=c99
CFLAGS := -Wall -Wextra -Os -MD $(CPUFLAGS)
LDFLAGS := $(CPUFLAGS) -nostartfiles -Wl,-T,bluepill.ld
LDLIBS := -lc -lnosys
# programmer options
STARTMEM := 0x8000000
# targets
.PHONY: all
all: $(BIN)
$(ELF): $(OBJS)
$(ARMCC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)
2018-03-07 23:55:54 +00:00
$(ARMSIZE) $@
.PHONY: strip
strip: $(ELF)
$(ARMTC)-strip $(ELF)
2018-03-07 23:55:54 +00:00
$(ARMSIZE) $(ELF)
$(BIN): $(ELF)
$(OBJCOPY) -O binary $< $@
.PHONY: flash
flash: $(BIN)
st-flash write $(BIN) $(STARTMEM)
.PHONY: erase
erase:
st-flash erase
.PHONY: install
install: erase flash
.PHONY: clean
clean:
rm -f *.o *.bin *.elf *.d *.map