2018-03-07 16:06:25 +00:00
|
|
|
# configurables
|
2018-03-07 23:01:27 +00:00
|
|
|
OBJS := startup.o
|
2018-03-07 16:06:25 +00:00
|
|
|
TARGET := blink
|
|
|
|
OBJS += $(TARGET).o
|
|
|
|
|
|
|
|
# targets
|
|
|
|
ELF := $(TARGET).elf
|
|
|
|
BIN := $(TARGET).bin
|
|
|
|
|
|
|
|
# toolchain setup
|
|
|
|
ARMTC := arm-none-eabi
|
2018-03-07 23:01:27 +00:00
|
|
|
AS := $(ARMTC)-as
|
|
|
|
CC := $(ARMTC)-gcc
|
|
|
|
CXX := $(ARMTC)-g++
|
|
|
|
LD := $(ARMTC)-ld
|
2018-03-07 16:06:25 +00:00
|
|
|
ARMSIZE := $(ARMTC)-size
|
|
|
|
OBJCOPY := $(ARMTC)-objcopy
|
|
|
|
|
|
|
|
# compiler options
|
|
|
|
CPUFLAGS := -mcpu=cortex-m3 -mthumb
|
|
|
|
CFLAGS := -Wall -Wextra -Os -MD $(CPUFLAGS)
|
2018-03-07 23:01:27 +00:00
|
|
|
CXXFLAGS := $(CFLAGS) -std=c++14 -fno-rtti -fno-exceptions -ffunction-sections -fdata-sections -fno-builtin
|
2018-03-07 16:06:25 +00:00
|
|
|
LDFLAGS := $(CPUFLAGS) -nostartfiles -Wl,-T,stm32f103.ld
|
|
|
|
LDLIBS := -lc -lnosys
|
|
|
|
|
|
|
|
# programmer options
|
|
|
|
STARTMEM := 0x8000000
|
|
|
|
|
|
|
|
# targets
|
|
|
|
|
|
|
|
.PHONY: all
|
|
|
|
all: $(BIN)
|
|
|
|
|
|
|
|
$(ELF): $(OBJS)
|
2018-03-07 23:01:27 +00:00
|
|
|
$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)
|
2018-03-07 23:55:54 +00:00
|
|
|
$(ARMSIZE) $@
|
2018-03-07 16:06:25 +00:00
|
|
|
|
|
|
|
$(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
|
|
|
|
|