Skip to content

Commit 7d7ca42

Browse files
committed
Added test for encrypted update over UART on STM32WB55
1 parent eb2774e commit 7d7ca42

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

tools/test-enc.mk

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
ENC_TEST_UPDATE_VERSION=2
2+
SIGN_ARGS=
3+
KEYGEN_TOOL=python3 ./tools/keytools/keygen.py
4+
SIGN_TOOL=python3 ./tools/keytools/sign.py
5+
SIGN_ARGS+=--ecc256 --encrypt /tmp/enc_key.der
6+
SIGN_ENC_ARGS+=--ecc256 --encrypt /tmp/enc_key.der
7+
USBTTY=/dev/ttyACM0
8+
TIMEOUT=60
9+
10+
.config:
11+
@rm -f $@
12+
@echo [CONFIG]
13+
@cp config/examples/stm32wb-uart-flash-encryption.config $@
14+
15+
16+
tools/uart-flash-server/ufserver: FORCE
17+
@make -C `dirname $@`
18+
@rm -f src/libwolfboot.o
19+
20+
test-enc-update: factory.bin test-app/image.bin .config tools/uart-flash-server/ufserver FORCE
21+
@echo -n "0123456789abcdef0123456789abcdef" > /tmp/enc_key.der
22+
@$(SIGN_TOOL) $(SIGN_ARGS) test-app/image.bin $(PRIVATE_KEY) $(ENC_TEST_UPDATE_VERSION)
23+
@$(SIGN_TOOL) $(SIGN_ENC_ARGS) test-app/image.bin $(PRIVATE_KEY) $(ENC_TEST_UPDATE_VERSION)
24+
@st-flash write factory.bin 0x08000000
25+
@sleep 2
26+
@sudo true
27+
@(sudo tools/uart-flash-server/ufserver test-app/image_v$(ENC_TEST_UPDATE_VERSION)_signed_and_encrypted.bin $(USBTTY))&
28+
@sleep 5
29+
@st-flash reset
30+
@sleep $(TIMEOUT)
31+
@sudo killall ufserver
32+
@st-flash read boot.bin 0x08010000 0x1000
33+
@dd if=test-app/image_v$(ENC_TEST_UPDATE_VERSION)_signed.bin of=boot_compare.bin bs=4096 count=1
34+
@diff boot.bin boot_compare.bin || (echo "TEST FAILED" && exit 1)
35+
@rm boot.bin boot_compare.bin
36+
@echo "TEST SUCCESSFUL"
37+

0 commit comments

Comments
 (0)