gadget-securevault/Makefile

74 lines
2.1 KiB
Makefile

CROSS_COMPILE:=arm-none-eabi-
CC:=$(CROSS_COMPILE)gcc
LD:=$(CROSS_COMPILE)gcc
WOLFSSL:=$(HOME)/wolfssl
VERSION?=1
OBJS:=startup.o main.o system.o usecfs_dev_spi.o usecfs.o mem.o led.o \
i2c.o display.o font_twisted.o spi.o spi_flash.o button.o systick.o newlib.o uart.o ui.o \
sdcard.o random.o usb.o mutex.o fw_update.o
OBJS+= \
$(WOLFSSL)/wolfcrypt/src/sha256.o \
$(WOLFSSL)/wolfcrypt/src/chacha.o \
$(WOLFSSL)/wolfcrypt/src/aes.o \
$(WOLFSSL)/wolfcrypt/src/pwdbased.o \
$(WOLFSSL)/wolfcrypt/src/hash.o \
$(WOLFSSL)/wolfcrypt/src/hmac.o \
$(WOLFSSL)/wolfcrypt/src/sp_int.o \
$(WOLFSSL)/wolfcrypt/src/sp_cortexm.o \
$(WOLFSSL)/wolfcrypt/src/wolfmath.o \
$(WOLFSSL)/wolfcrypt/src/memory.o \
$(WOLFSSL)/wolfcrypt/src/random.o \
$(WOLFSSL)/wolfcrypt/src/wc_port.o
UMX:=lib/unicore-mx/lib/libucmx_stm32f4.a
UMXFLAGS:=-Ilib/unicore-mx/include/ -DSTM32F4
LIBS+=$(UMX)
LSCRIPT:=target.ld
OBJCOPY:=$(CROSS_COMPILE)objcopy
CFLAGS:=-mcpu=cortex-m3 -mthumb -Wall -Wno-main -Wstack-usage=320 \
-ffreestanding -Wno-unused -DBLOCK_SIZE=4096 -I. -I$(WOLFSSL) -Ilib/unicore-mx/include \
-Iwolfboot/src -Iwolfboot/hal -Iwolfboot/include/wolfboot
CFLAGS+=-specs=nano.specs -lc -lg
CFLAGS+=$(UMXFLAGS)
CFLAGS+=-O2
#CFLAGS+=-g -ggdb3
CFLAGS+=-DWOLFSSL_USER_SETTINGS -DCRYPTO
ASFLAGS:=$(CFLAGS)
LDFLAGS:=-T $(LSCRIPT) -Wl,-gc-sections -Wl,-Map=image.map -mcpu=cortex-m3 -mthumb -nostartfiles
#all: image.bin
image.bin: image.elf
$(OBJCOPY) -O binary $^ $@
image.elf: $(LIBS) $(OBJS) $(LSCRIPT)
$(LD) $(LDFLAGS) $(OBJS) $(LIBS) -o $@
wolfboot: wolfboot-align.bin
wolfboot-align.bin:
@rm -f wolfboot/.config
@rm -f $(WOLFSSL)/wolfcrypt/src/*.o
cp wolfboot.config wolfboot/.config
make -C wolfboot $@
$(UMX):
make -C lib/unicore-mx FP_FLAGS="-O3 -mfloat-abi=soft" TARGETS=stm32/f4
sign: image.bin
python3 wolfboot/tools/keytools/sign.py image.bin wolfboot/ecc256.der $(VERSION)
clean:
@rm -f image.bin image.elf *.o image.map $(WOLFSSL)/wolfcrypt/src/*.o $(USECFS)/src/*.o
make -C lib/unicore-mx clean
make -C wolfboot clean
.PHONY: wolfboot