sandbox/blue-pill/skeleton/Makefile

71 lines
1.1 KiB
Makefile
Raw Normal View History

# configurables
2018-03-08 03:50:01 +00:00
OBJS := startup.o
TARGET :=
2018-03-08 03:50:01 +00:00
OBJS += $(TARGET).o
# targets
ELF := $(TARGET).elf
BIN := $(TARGET).bin
# toolchain setup
ARMTC := arm-none-eabi
2018-03-08 03:50:01 +00:00
CC := $(ARMTC)-gcc
LD := $(ARMTC)-gcc
AS := $(ARMTC)-as
ARMSIZE := $(ARMTC)-size
OBJCOPY := $(ARMTC)-objcopy
2018-03-08 03:50:01 +00:00
PAGER ?= less
# compiler options
2018-03-08 03:50:01 +00:00
CPUFLAGS := -mcpu=cortex-m3 -mthumb -std=c99
CFLAGS := -Wall -Wextra -Os -MD $(CPUFLAGS) -g
LDFLAGS := $(CPUFLAGS) -nostartfiles -Wl,-T,bluepill.ld
LDLIBS := -lc -lnosys
# programmer options
STARTMEM := 0x8000000
# targets
.PHONY: all
all: $(BIN)
$(ELF): $(OBJS)
2018-03-08 03:50:01 +00:00
$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)
$(ARMSIZE) $@
.PHONY: strip
strip: $(ELF)
$(ARMTC)-strip $(ELF)
$(ARMSIZE) $(ELF)
$(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
.PHONY: install
2018-03-08 03:50:01 +00:00
install: erase flash reset
.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