Skip to content

Commit ba04692

Browse files
committed
Added test: enc-delta-update with extradata
1 parent 8d92547 commit ba04692

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

test-app/Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ ARCH?=ARM
88
MCUXPRESSO_CMSIS?=$(MCUXPRESSO)/CMSIS
99
CFLAGS+=-I.
1010
CFLAGS+=-I./wcs
11-
DEBUG=1
11+
DEBUG?=1
12+
DELTA_DATA_SIZE?=2000
1213

1314
ifeq ($(SIGN),RSA2048)
1415
IMAGE_HEADER_SIZE:=512
@@ -166,7 +167,7 @@ endif
166167
ifeq ($(TARGET),sim)
167168
APP_OBJS=app_$(TARGET).o ../test-app/libwolfboot.o ../hal/$(TARGET).o
168169
# Override linker flags
169-
LDFLAGS=
170+
LDFLAGS=-Wl,-Map=image.map
170171
endif
171172

172173
ifeq ($(EXT_FLASH),1)
@@ -327,6 +328,9 @@ CFLAGS+=-I../lib/wolfssl
327328
standalone:CFLAGS+=-D"TEST_APP_STANDALONE"
328329
standalone:LDFLAGS:=-T standalone.ld -Wl,-gc-sections -Wl,-Map=image.map
329330

331+
delta-extra-data:CFLAGS+=-D"TEST_DELTA_DATA=$(DELTA_DATA_SIZE)" -ffunction-sections -fdata-sections
332+
delta-extra-data:LDFLAGS=-Wl,-Map=image.map
333+
330334
image.bin: image.elf
331335
@echo "\t[BIN] $@"
332336
$(Q)$(OBJCOPY) --gap-fill $(FILL_BYTE) -O binary $^ $@
@@ -338,6 +342,8 @@ image.elf: $(APP_OBJS) $(LSCRIPT)
338342

339343
standalone: image.bin
340344

345+
delta-extra-data: image.bin
346+
341347
../test-app/libwolfboot.o: ../src/libwolfboot.c FORCE
342348
@echo "\t[CC-$(ARCH)] $@"
343349
$(Q)$(CC) $(CFLAGS) -c $(OUTPUT_FLAG) $@ ../src/libwolfboot.c

test-app/app_sim.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@
4040
char enc_key[] = "0123456789abcdef0123456789abcdef"
4141
"0123456789abcdef";
4242

43+
#ifdef TEST_DELTA_DATA
44+
static volatile char __attribute__((used)) garbage[TEST_DELTA_DATA] = {0x01, 0x02, 0x03, 0x04 };
45+
46+
#endif
47+
4348
void hal_init(void);
4449

4550
int do_cmd(const char *cmd)

tools/test.mk

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ SPI_CHIP=SST25VF080B
77
SPI_OPTIONS=SPI_FLASH=1 WOLFBOOT_PARTITION_SIZE=0x80000 WOLFBOOT_PARTITION_UPDATE_ADDRESS=0x00000 WOLFBOOT_PARTITION_SWAP_ADDRESS=0x80000
88
SIGN_ARGS=
99
SIGN_ENC_ARGS=
10+
DELTA_DATA_SIZE?=2000
1011

1112
# python version only supported using
1213
# 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
159160
$(Q)$(BINASSEMBLE) external_flash.dd 0 test-app/image_v$(TEST_UPDATE_VERSION)_signed.bin \
160161
$(WOLFBOOT_PARTITION_SIZE) erased_sec.dd
161162

163+
test-sim-external-flash-with-enc-delta-update-extradata:DELTA_UPDATE_OPTIONS=--delta test-app/image_v1_signed.bin
164+
test-sim-external-flash-with-enc-delta-update-extradata:SIGN_ENC_ARGS=--encrypt /tmp/enc_key.der --aes128
165+
test-sim-external-flash-with-enc-delta-update-extradata: wolfboot.bin test-app/image.elf FORCE
166+
@printf "0123456789abcdef0123456789abcdef0123456789abcdef" > /tmp/enc_key.der
167+
$(Q)$(SIGN_TOOL) $(SIGN_OPTIONS) test-app/image.elf $(PRIVATE_KEY) 1
168+
$(Q)cp test-app/image_v1_signed.bin test-app/image_v1_signed.bak
169+
$(Q)rm -f test-app/image.elf test-app/app_sim.o
170+
$(Q)make -C test-app delta-extra-data DELTA_DATA_SIZE=$(DELTA_DATA_SIZE)
171+
$(Q)cp test-app/image_v1_signed.bak test-app/image_v1_signed.bin
172+
$(Q)$(SIGN_TOOL) $(SIGN_OPTIONS) $(SIGN_ENC_ARGS) test-app/image.elf $(PRIVATE_KEY) $(TEST_UPDATE_VERSION)
173+
$(Q)$(SIGN_TOOL) $(SIGN_ARGS) $(DELTA_UPDATE_OPTIONS) $(SIGN_ENC_ARGS) \
174+
test-app/image.elf $(PRIVATE_KEY) $(TEST_UPDATE_VERSION)
175+
$(Q)dd if=/dev/zero bs=$$(($(WOLFBOOT_PARTITION_SIZE))) count=1 2>/dev/null | tr "\000" "\377" > v1_part.dd
176+
$(Q)dd if=test-app/image_v1_signed.bin bs=256 of=v1_part.dd conv=notrunc
177+
$(Q)$(BINASSEMBLE) internal_flash.dd \
178+
0 wolfboot.bin \
179+
$$(($(WOLFBOOT_PARTITION_BOOT_ADDRESS) - $(ARCH_FLASH_OFFSET))) v1_part.dd
180+
$(Q)dd if=/dev/zero bs=$$(($(WOLFBOOT_SECTOR_SIZE))) count=1 2>/dev/null | tr "\000" "\377" > erased_sec.dd
181+
$(Q)$(BINASSEMBLE) external_flash.dd 0 test-app/image_v$(TEST_UPDATE_VERSION)_signed_diff_encrypted.bin \
182+
$(WOLFBOOT_PARTITION_SIZE) erased_sec.dd
183+
$(Q)ls -l test-app/*.bin
184+
162185

163186
test-sim-external-flash-with-enc-update:SIGN_ENC_ARGS=--encrypt /tmp/enc_key.der --aes128
164187
test-sim-external-flash-with-enc-update: wolfboot.bin test-app/image.elf FORCE

0 commit comments

Comments
 (0)