sandbox/blue-pill/draugr/Makefile

74 lines
1.4 KiB
Makefile
Raw Permalink Normal View History

2018-03-07 16:06:25 +00:00
# configurables
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
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
2018-03-08 19:31:00 +00:00
PAGER ?= less
OPENOCD ?= /usr/share/openocd
2018-03-07 16:06:25 +00:00
# compiler options
CPUFLAGS := -mcpu=cortex-m3 -mthumb
CFLAGS := -Wall -Wextra -Os -MD $(CPUFLAGS)
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
2018-03-08 19:31:00 +00:00
### build targets ###
2018-03-07 16:06:25 +00:00
.PHONY: all
all: $(BIN)
$(ELF): $(OBJS)
$(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 $< $@
2018-03-08 19:31:00 +00:00
.PHONY: clean
clean:
rm -f *.o *.bin *.elf *.d *.map
### programming targets ###
2018-03-07 16:06:25 +00:00
.PHONY: flash
flash: $(BIN)
st-flash write $(BIN) $(STARTMEM)
.PHONY: erase
erase:
st-flash erase
2018-03-08 19:31:00 +00:00
.PHONY: reset
reset:
st-flash reset
2018-03-07 16:06:25 +00:00
.PHONY: install
2018-03-08 19:31:00 +00:00
install: erase flash reset
2018-03-07 16:06:25 +00:00
2018-03-08 19:31:00 +00:00
### miscellaneous targets ###
.PHONY: disass
disass: $(ELF)
$(ARMTC)-objdump -D $(ELF) | $(PAGER)
.PHONY: dump
dump: $(ELF)
$(ARMTC)-objdump -D $(ELF) > $(TARGET).dump
2018-03-07 16:06:25 +00:00
2018-03-08 19:31:00 +00:00
.PHONY: ocd
ocd:
openocd -f $(OPENOCD)/scripts/interface/stlink-v2.cfg -f $(OPENOCD)/scripts/target/stm32f1x.cfg