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