diff --git a/test-app/Makefile b/test-app/Makefile index 5cea7e1ef..e0bca642c 100644 --- a/test-app/Makefile +++ b/test-app/Makefile @@ -8,7 +8,8 @@ ARCH?=ARM MCUXPRESSO_CMSIS?=$(MCUXPRESSO)/CMSIS CFLAGS+=-I. CFLAGS+=-I./wcs -DEBUG=1 +DEBUG?=1 +DELTA_DATA_SIZE?=2000 ifeq ($(SIGN),RSA2048) IMAGE_HEADER_SIZE:=512 @@ -166,7 +167,7 @@ endif ifeq ($(TARGET),sim) APP_OBJS=app_$(TARGET).o ../test-app/libwolfboot.o ../hal/$(TARGET).o # Override linker flags - LDFLAGS= + LDFLAGS=-Wl,-Map=image.map endif ifeq ($(EXT_FLASH),1) @@ -327,6 +328,9 @@ CFLAGS+=-I../lib/wolfssl standalone:CFLAGS+=-D"TEST_APP_STANDALONE" standalone:LDFLAGS:=-T standalone.ld -Wl,-gc-sections -Wl,-Map=image.map +delta-extra-data:CFLAGS+=-D"TEST_DELTA_DATA=$(DELTA_DATA_SIZE)" -ffunction-sections -fdata-sections +delta-extra-data:LDFLAGS=-Wl,-Map=image.map + image.bin: image.elf @echo "\t[BIN] $@" $(Q)$(OBJCOPY) --gap-fill $(FILL_BYTE) -O binary $^ $@ @@ -338,6 +342,8 @@ image.elf: $(APP_OBJS) $(LSCRIPT) standalone: image.bin +delta-extra-data: image.bin + ../test-app/libwolfboot.o: ../src/libwolfboot.c FORCE @echo "\t[CC-$(ARCH)] $@" $(Q)$(CC) $(CFLAGS) -c $(OUTPUT_FLAG) $@ ../src/libwolfboot.c diff --git a/test-app/app_sim.c b/test-app/app_sim.c index b977daabd..e200db557 100644 --- a/test-app/app_sim.c +++ b/test-app/app_sim.c @@ -40,6 +40,11 @@ char enc_key[] = "0123456789abcdef0123456789abcdef" "0123456789abcdef"; +#ifdef TEST_DELTA_DATA +static volatile char __attribute__((used)) garbage[TEST_DELTA_DATA] = {0x01, 0x02, 0x03, 0x04 }; + +#endif + void hal_init(void); int do_cmd(const char *cmd) diff --git a/tools/test.mk b/tools/test.mk index eb5ecd7ec..fadf552f3 100644 --- a/tools/test.mk +++ b/tools/test.mk @@ -7,6 +7,7 @@ SPI_CHIP=SST25VF080B SPI_OPTIONS=SPI_FLASH=1 WOLFBOOT_PARTITION_SIZE=0x80000 WOLFBOOT_PARTITION_UPDATE_ADDRESS=0x00000 WOLFBOOT_PARTITION_SWAP_ADDRESS=0x80000 SIGN_ARGS= SIGN_ENC_ARGS= +DELTA_DATA_SIZE?=2000 # python version only supported using # KEYGEN_TOOL="python3 $(WOLFBOOT_ROOT)/tools/keytools/keygen.py" @@ -159,6 +160,28 @@ test-sim-external-flash-with-update: wolfboot.bin test-app/image.elf FORCE $(Q)$(BINASSEMBLE) external_flash.dd 0 test-app/image_v$(TEST_UPDATE_VERSION)_signed.bin \ $(WOLFBOOT_PARTITION_SIZE) erased_sec.dd +test-sim-external-flash-with-enc-delta-update-extradata:DELTA_UPDATE_OPTIONS=--delta test-app/image_v1_signed.bin +test-sim-external-flash-with-enc-delta-update-extradata:SIGN_ENC_ARGS=--encrypt /tmp/enc_key.der --aes128 +test-sim-external-flash-with-enc-delta-update-extradata: wolfboot.bin test-app/image.elf FORCE + @printf "0123456789abcdef0123456789abcdef0123456789abcdef" > /tmp/enc_key.der + $(Q)$(SIGN_TOOL) $(SIGN_OPTIONS) test-app/image.elf $(PRIVATE_KEY) 1 + $(Q)cp test-app/image_v1_signed.bin test-app/image_v1_signed.bak + $(Q)rm -f test-app/image.elf test-app/app_sim.o + $(Q)make -C test-app delta-extra-data DELTA_DATA_SIZE=$(DELTA_DATA_SIZE) + $(Q)cp test-app/image_v1_signed.bak test-app/image_v1_signed.bin + $(Q)$(SIGN_TOOL) $(SIGN_OPTIONS) $(SIGN_ENC_ARGS) test-app/image.elf $(PRIVATE_KEY) $(TEST_UPDATE_VERSION) + $(Q)$(SIGN_TOOL) $(SIGN_ARGS) $(DELTA_UPDATE_OPTIONS) $(SIGN_ENC_ARGS) \ + test-app/image.elf $(PRIVATE_KEY) $(TEST_UPDATE_VERSION) + $(Q)dd if=/dev/zero bs=$$(($(WOLFBOOT_PARTITION_SIZE))) count=1 2>/dev/null | tr "\000" "\377" > v1_part.dd + $(Q)dd if=test-app/image_v1_signed.bin bs=256 of=v1_part.dd conv=notrunc + $(Q)$(BINASSEMBLE) internal_flash.dd \ + 0 wolfboot.bin \ + $$(($(WOLFBOOT_PARTITION_BOOT_ADDRESS) - $(ARCH_FLASH_OFFSET))) v1_part.dd + $(Q)dd if=/dev/zero bs=$$(($(WOLFBOOT_SECTOR_SIZE))) count=1 2>/dev/null | tr "\000" "\377" > erased_sec.dd + $(Q)$(BINASSEMBLE) external_flash.dd 0 test-app/image_v$(TEST_UPDATE_VERSION)_signed_diff_encrypted.bin \ + $(WOLFBOOT_PARTITION_SIZE) erased_sec.dd + $(Q)ls -l test-app/*.bin + test-sim-external-flash-with-enc-update:SIGN_ENC_ARGS=--encrypt /tmp/enc_key.der --aes128 test-sim-external-flash-with-enc-update: wolfboot.bin test-app/image.elf FORCE