Skip to content

Commit d390873

Browse files
committed
Fix padding in test
1 parent 55396ed commit d390873

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

src/libwolfboot.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1483,7 +1483,7 @@ int RAMFUNCTION wolfBoot_erase_encrypt_key(void)
14831483
sel_sec = nvm_select_fresh_sector(PART_BOOT);
14841484
mem -= (sel_sec * WOLFBOOT_SECTOR_SIZE);
14851485
#endif
1486-
XMEMSET(ff, 0xFF, ENCRYPT_KEY_SIZE + ENCRYPT_NONCE_SIZE);
1486+
XMEMSET(ff, FLASH_BYTE_ERASED, ENCRYPT_KEY_SIZE + ENCRYPT_NONCE_SIZE);
14871487
if (XMEMCMP(mem, ff, ENCRYPT_KEY_SIZE + ENCRYPT_NONCE_SIZE) != 0)
14881488
hal_set_key(ff, ff + ENCRYPT_KEY_SIZE);
14891489
#endif

tools/scripts/sim-sunnyday-update.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/bin/bash
2-
32
V=`./wolfboot.elf update_trigger get_version 2>/dev/null`
43
if [ "x$V" != "x1" ]; then
54
echo "Failed first boot with update_trigger"

tools/test.mk

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ ifeq ($(HASH),SHA3)
6969
SIGN_ARGS+= --sha3
7070
endif
7171

72+
ifeq ($(FLAGS_INVERT),1)
73+
INVERSION=
74+
else
75+
INVERSION=| tr "\000" "\377"
76+
endif
77+
7278
$(EXPVER):
7379
$(MAKE) -C $(dir $@)
7480

@@ -136,7 +142,7 @@ test-spi-off: FORCE
136142
@make testbed-on
137143

138144
test-update: test-app/image.bin FORCE
139-
@dd if=/dev/zero bs=131067 count=1 2>/dev/null | tr "\000" "\377" > test-update.bin
145+
@dd if=/dev/zero bs=131067 count=1 2>/dev/null $(INVERSION) > test-update.bin
140146
@$(SIGN_TOOL) $(SIGN_ARGS) test-app/image.bin $(PRIVATE_KEY) $(TEST_UPDATE_VERSION)
141147
@dd if=test-app/image_v$(TEST_UPDATE_VERSION)_signed.bin of=test-update.bin bs=1 conv=notrunc
142148
@printf "pBOOT" >> test-update.bin
@@ -155,11 +161,11 @@ test-sim-external-flash-with-update: wolfboot.bin test-app/image.elf FORCE
155161
$(Q)$(SIGN_TOOL) $(SIGN_OPTIONS) test-app/image.elf $(PRIVATE_KEY) $(TEST_UPDATE_VERSION)
156162
# Assembling internal flash image
157163
#
158-
$(Q)dd if=/dev/zero bs=$$(($(WOLFBOOT_PARTITION_SIZE))) count=1 2>/dev/null | tr "\000" "\377" > v1_part.dd
164+
$(Q)dd if=/dev/zero bs=$$(($(WOLFBOOT_PARTITION_SIZE))) count=1 2>/dev/null $(INVERSION) > v1_part.dd
159165
$(Q)dd if=test-app/image_v1_signed.bin bs=256 of=v1_part.dd conv=notrunc
160166
$(Q)$(BINASSEMBLE) internal_flash.dd 0 wolfboot.bin \
161167
$$(($(WOLFBOOT_PARTITION_BOOT_ADDRESS) - $(ARCH_FLASH_OFFSET))) v1_part.dd
162-
$(Q)dd if=/dev/zero bs=$$(($(WOLFBOOT_SECTOR_SIZE))) count=1 2>/dev/null | tr "\000" "\377" > erased_sec.dd
168+
$(Q)dd if=/dev/zero bs=$$(($(WOLFBOOT_SECTOR_SIZE))) count=1 2>/dev/null $(INVERSION) > erased_sec.dd
163169
$(Q)$(BINASSEMBLE) external_flash.dd 0 test-app/image_v$(TEST_UPDATE_VERSION)_signed.bin \
164170
$(WOLFBOOT_PARTITION_SIZE) erased_sec.dd
165171

@@ -175,12 +181,12 @@ test-sim-external-flash-with-enc-delta-update-extradata: wolfboot.bin test-app/i
175181
$(Q)$(SIGN_TOOL) $(SIGN_OPTIONS) $(SIGN_ENC_ARGS) test-app/image.elf $(PRIVATE_KEY) $(TEST_UPDATE_VERSION)
176182
$(Q)$(SIGN_TOOL) $(SIGN_ARGS) $(DELTA_UPDATE_OPTIONS) $(SIGN_ENC_ARGS) \
177183
test-app/image.elf $(PRIVATE_KEY) $(TEST_UPDATE_VERSION)
178-
$(Q)dd if=/dev/zero bs=$$(($(WOLFBOOT_PARTITION_SIZE))) count=1 2>/dev/null | tr "\000" "\377" > v1_part.dd
184+
$(Q)dd if=/dev/zero bs=$$(($(WOLFBOOT_PARTITION_SIZE))) count=1 2>/dev/null $(INVERSION) > v1_part.dd
179185
$(Q)dd if=test-app/image_v1_signed.bin bs=256 of=v1_part.dd conv=notrunc
180186
$(Q)$(BINASSEMBLE) internal_flash.dd \
181187
0 wolfboot.bin \
182188
$$(($(WOLFBOOT_PARTITION_BOOT_ADDRESS) - $(ARCH_FLASH_OFFSET))) v1_part.dd
183-
$(Q)dd if=/dev/zero bs=$$(($(WOLFBOOT_SECTOR_SIZE))) count=1 2>/dev/null | tr "\000" "\377" > erased_sec.dd
189+
$(Q)dd if=/dev/zero bs=$$(($(WOLFBOOT_SECTOR_SIZE))) count=1 2>/dev/null $(INVERSION) > erased_sec.dd
184190
$(Q)$(BINASSEMBLE) external_flash.dd 0 test-app/image_v$(TEST_UPDATE_VERSION)_signed_diff_encrypted.bin \
185191
$(WOLFBOOT_PARTITION_SIZE) erased_sec.dd
186192
$(Q)ls -l test-app/*.bin
@@ -199,12 +205,12 @@ test-sim-external-flash-with-enc-update: wolfboot.bin test-app/image.elf FORCE
199205
test-app/image.elf $(PRIVATE_KEY) $(TEST_UPDATE_VERSION)
200206
# Assembling internal flash image
201207
#
202-
$(Q)dd if=/dev/zero bs=$$(($(WOLFBOOT_PARTITION_SIZE))) count=1 2>/dev/null | tr "\000" "\377" > v1_part.dd
208+
$(Q)dd if=/dev/zero bs=$$(($(WOLFBOOT_PARTITION_SIZE))) count=1 2>/dev/null $(INVERSION) > v1_part.dd
203209
$(Q)dd if=test-app/image_v1_signed.bin bs=256 of=v1_part.dd conv=notrunc
204210
$(Q)$(BINASSEMBLE) internal_flash.dd \
205211
0 wolfboot.bin \
206212
$$(($(WOLFBOOT_PARTITION_BOOT_ADDRESS) - $(ARCH_FLASH_OFFSET))) v1_part.dd
207-
$(Q)dd if=/dev/zero bs=$$(($(WOLFBOOT_SECTOR_SIZE))) count=1 2>/dev/null | tr "\000" "\377" > erased_sec.dd
213+
$(Q)dd if=/dev/zero bs=$$(($(WOLFBOOT_SECTOR_SIZE))) count=1 2>/dev/null $(INVERSION) > erased_sec.dd
208214
$(Q)$(BINASSEMBLE) external_flash.dd 0 test-app/image_v$(TEST_UPDATE_VERSION)_signed_and_encrypted.bin \
209215
$(WOLFBOOT_PARTITION_SIZE) erased_sec.dd
210216

@@ -220,7 +226,7 @@ test-sim-internal-flash-with-update: wolfboot.bin test-app/image.elf FORCE
220226
$(Q)cp test-app/image.bak.elf test-app/image.elf
221227
$(Q)dd if=/dev/urandom of=test-app/image.elf bs=1k count=16 oflag=append conv=notrunc
222228
$(Q)$(SIGN_TOOL) $(SIGN_OPTIONS) test-app/image.elf $(PRIVATE_KEY) $(TEST_UPDATE_VERSION)
223-
$(Q)dd if=/dev/zero bs=$$(($(WOLFBOOT_SECTOR_SIZE))) count=1 2>/dev/null | tr "\000" "\377" > erased_sec.dd
229+
$(Q)dd if=/dev/zero bs=$$(($(WOLFBOOT_SECTOR_SIZE))) count=1 2>/dev/null $(INVERSION) > erased_sec.dd
224230
$(Q)$(SIGN_TOOL) $(SIGN_ARGS) $(DELTA_UPDATE_OPTIONS) \
225231
test-app/image.elf $(PRIVATE_KEY) $(TEST_UPDATE_VERSION)
226232
$(Q)$(BINASSEMBLE) internal_flash.dd \
@@ -263,7 +269,7 @@ test-self-update: FORCE
263269
@st-flash --reset write test-app/image_v2_signed.bin 0x08020000 || \
264270
(make test-reset && sleep 1 && st-flash --reset write test-app/image_v2_signed.bin 0x08020000) || \
265271
(make test-reset && sleep 1 && st-flash --reset write test-app/image_v2_signed.bin 0x08020000)
266-
@dd if=/dev/zero bs=131067 count=1 2>/dev/null | tr "\000" "\377" > test-self-update.bin
272+
@dd if=/dev/zero bs=131067 count=1 2>/dev/null $(INVERSION) > test-self-update.bin
267273
@$(SIGN_TOOL) $(SIGN_ARGS) --wolfboot-update wolfboot.bin private_key.old $(WOLFBOOT_VERSION)
268274
@dd if=wolfboot_v$(WOLFBOOT_VERSION)_signed.bin of=test-self-update.bin bs=1 conv=notrunc
269275
@printf "pBOOT" >> test-self-update.bin

0 commit comments

Comments
 (0)