diff --git a/src/delta.c b/src/delta.c index f76d8e2a..6ab6aa6b 100644 --- a/src/delta.c +++ b/src/delta.c @@ -83,7 +83,7 @@ static inline uint8_t *patch_read_cache(WB_PATCH_CTX *ctx) if (ctx->p_off < ctx->patch_cache_start + (DELTA_PATCH_BLOCK_SIZE - BLOCK_HDR_SIZE)) - return ctx->patch_cache + ctx->p_off; + return ctx->patch_cache + ctx->p_off - ctx->patch_cache_start; } ctx->patch_cache_start = ctx->p_off; ext_flash_check_read( diff --git a/tools/test-delta.mk b/tools/test-delta.mk index 66f3556a..006c2d59 100644 --- a/tools/test-delta.mk +++ b/tools/test-delta.mk @@ -6,11 +6,12 @@ test-delta-update:EXPVER=tools/test-expect-version/test-expect-version /dev/ttyA test-delta-update-ext:SIGN_ARGS?=--ecc256 test-delta-update-ext:SIGN_DELTA_ARGS?=--ecc256 --encrypt /tmp/enc_key.der test-delta-update-ext:USBTTY?=/dev/ttyACM0 -test-delta-update-ext:TIMEOUT?=30 +test-delta-update-ext:TIMEOUT?=50 test-delta-update-ext:EXPVER=tools/test-expect-version/test-expect-version /dev/ttyACM0 test-delta-update: factory.bin test-app/image.bin tools/uart-flash-server/ufserver tools/delta/bmdiff tools/test-expect-version/test-expect-version @st-flash reset + @sleep 2 @st-flash erase || st-flash erase @diff .config config/examples/stm32wb-delta.config || (echo "\n\n*** Error: please copy config/examples/stm32wb-delta.config to .config to run this test\n\n" && exit 1) $(SIGN_TOOL) $(SIGN_ARGS) --delta test-app/image_v1_signed.bin test-app/image.bin \ @@ -19,28 +20,32 @@ test-delta-update: factory.bin test-app/image.bin tools/uart-flash-server/ufserv $(PRIVATE_KEY) 2 @st-flash write factory.bin 0x08000000 @echo Expecting version '1' - @(test `$(EXPVER)` -eq 1) + @(test `$(EXPVER)` -eq 1) || (st-flash reset && test `$(EXPVER)` -eq 1) @echo @sleep 2 @st-flash write test-app/image_v7_signed_diff.bin 0x0802C000 @sleep 2 @st-flash reset @echo Expecting version '7' - @(test `$(EXPVER)` -eq 7) + @(test `$(EXPVER)` -eq 7) || (st-flash reset && test `$(EXPVER)` -eq 7) @sleep 2 @st-flash reset @echo Expecting version '1' @(test `$(EXPVER)` -eq 1) + @sleep 2 + @st-flash reset + @sleep 2 @st-flash erase || st-flash erase @st-flash write factory.bin 0x08000000 @echo Expecting version '1' - @(test `$(EXPVER)` -eq 1) - @sleep 1 + @test `$(EXPVER)` -eq 1 + @sleep 2 @st-flash reset + @sleep 2 @st-flash write test-app/image_v2_signed_diff.bin 0x0802C000 @st-flash reset @echo Expecting version '2' - @(test `$(EXPVER)` -eq 2) + @(test `$(EXPVER)` -eq 2) || (st-flash reset && test `$(EXPVER)` -eq 2) @sleep 2 @st-flash reset @echo Expecting version '2' @@ -65,7 +70,9 @@ test-delta-update-ext: factory.bin test-app/image.bin tools/uart-flash-server/uf @sleep $(TIMEOUT) @killall ufserver @st-flash reset - @sleep 3 + @sleep 10 + @st-flash reset + @sleep 5 @st-flash read boot_full.bin 0x0800C000 0x8000 @SIZE=`wc -c test-app/image_v7_signed.bin | cut -d" " -f 1`; \ dd if=boot_full.bin of=boot.bin bs=1 count=$$SIZE @@ -78,6 +85,9 @@ test-delta-update-ext: factory.bin test-app/image.bin tools/uart-flash-server/uf @st-flash reset @(tools/uart-flash-server/ufserver test-app/image_v7_signed_diff.bin $(USBTTY))& @echo TEST INVERSE + @st-flash reset + @sleep 1 + @st-flash reset @sleep $(TIMEOUT) @st-flash reset @killall ufserver diff --git a/tools/uart-flash-server/Makefile b/tools/uart-flash-server/Makefile index 0fccf7d4..e744aab0 100644 --- a/tools/uart-flash-server/Makefile +++ b/tools/uart-flash-server/Makefile @@ -1,10 +1,21 @@ CC=$(CROSS_COMPILE)gcc CFLAGS=-Wall -DWOLFSSL_DEBUG -DTFM_TIMING_RESISTANT -DWOLFBOOT_SIGN_ECC256 -DWOLFBOOT_HASH_SHA256 -g -ggdb -I../../include -I../../hal -Wextra +Q?=@ +ifeq ($(V),1) + Q= +endif EXE=ufserver -$(EXE): $(EXE).o ../../src/libwolfboot.o - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) +$(EXE): $(EXE).o libwolfboot.o + $(Q)$(CC) -o $@ $^ $(CFLAGS) $(LIBS) + +%.o: %.c + $(Q)$(CC) $(CFLAGS) -c -o $(@) $(^) + +libwolfboot.o: ../../src/libwolfboot.c + $(Q)$(CC) $(CFLAGS) -c -o $(@) $(^) + clean: - rm -f *.o $(EXE) ../../src/libwolfboot.o + $(Q)rm -f *.o $(EXE)