Source code for the Trusted Boot Module.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tbm-mcu/Makefile

74 lines
1.6 KiB

BUILD ?= build
PREFIX ?= arm-none-eabi
all: $(BUILD)/tbm
LDSCRIPT = support/stm32f0-discovery.ld
CFLAGS += -Iinclude
CFLAGS += -Wall -Wundef -Wextra -Wshadow -Wimplicit-function-declaration
CFLAGS += -Wredundant-decls -Wmissing-prototypes -Wstrict-prototypes
CFLAGS += -fno-common --function-sections -fdata-sections
LDFLAGS += -static -nostartfiles
LDFLAGS += -Wl,--gc-sections
LIBS += -Wl,--start-group -lc -lgcc -lnosys -Wl,--end-group
# Set up libopencm3.
OPENCM3_DIR ?= libopencm3
OPENCM3_LIBNAME = opencm3_stm32f0
CFLAGS += -I$(OPENCM3_DIR)/include
CFLAGS += -DSTM32F0 -msoft-float -mthumb -mcpu=cortex-m0
LDFLAGS += -L$(OPENCM3_DIR)/lib
LIBS += -l$(OPENCM3_LIBNAME)
STLINK_PORT ?= :4242
obj-y += source/main.o
obj-y += source/shell.o
obj-y += source/spi_flash.o
obj-y += source/usart.o
obj = $(addprefix $(BUILD)/, $(obj-y))
# Include the dependencies.
-include $(obj:.o=.d)
# Set up the toolchain.
CC := $(PREFIX)-gcc
LD := $(PREFIX)-gcc
GDB := $(PREFIX)-gdb
MAKE := make
.SECONDARY:
clean:
@echo "CLEAN"
@rm -rf $(BUILD)
$(OPENCM3_DIR)/lib/lib$(OPENCM3_LIBNAME).a:
@if [ ! -e libopencm3/.git ]; then \
git submodule init; \
git submodule update; \
fi
@$(MAKE) -C $(OPENCM3_DIR)
# Rule to compile C source code.
$(BUILD)/%.o: %.c
@echo "CC $<"
@mkdir -p $(dir $@)
@$(CC) -c $< -o $@ $(CFLAGS) -MT $@ -MMD -MP -MF $(@:.o=.d)
$(BUILD)/tbm: $(obj) $(LDSCRIPT) $(OPENCM3_DIR)/lib/lib$(OPENCM3_LIBNAME).a
@echo "LD $@"
@mkdir -p $(dir $@)
@$(LD) -o $@ $(CFLAGS) $(LDFLAGS) -T $(LDSCRIPT) $(obj) $(LIBS)
run: $(BUILD)/tbm
@echo "GDB $<"
@$(GDB) --batch \
-ex 'target extended-remote $(STLINK_PORT)' \
-x flash.scr \
$<
.PHONY: clean run