Skip to content

Commit f57a27d

Browse files
committed
Fixed sign tool to accommodate all the options. Fixed tests.
1 parent 827362d commit f57a27d

2 files changed

Lines changed: 30 additions & 25 deletions

File tree

tools/keytools/sign.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
argv = sys.argv
6262
hash_algo='sha256'
6363

64-
if (argc < 4) or (argc > 6):
64+
if (argc < 4) or (argc > 7):
6565
print("Usage: %s [--ed25519 | --ecc256 | --rsa2048 | --rsa4096 ] [--sha256 | --sha3] [--wolfboot-update] image key.der fw_version\n" % sys.argv[0])
6666
sys.exit(1)
6767
for i in range(1, len(argv)):

tools/test.mk

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ ifeq ($(SIGN),RSA2048)
1818
SIGN_TOOL=tools/keytools/sign.py --rsa2048
1919
endif
2020

21+
ifeq ($(SIGN),RSA4096)
22+
SIGN_TOOL=tools/keytools/sign.py --rsa4096
23+
endif
24+
2125
ifeq ($(HASH),SHA256)
2226
SIGN_TOOL+= --sha256
2327
endif
@@ -44,6 +48,9 @@ testbed-off: FORCE
4448
@echo "1" >/sys/class/gpio/gpio4/value || true
4549
@echo "Testbed off."
4650

51+
test-reset: FORCE
52+
@(sleep 1 && make testbed-off && sleep 1 && make testbed-on) &
53+
4754
test-spi-on: FORCE
4855
@make testbed-off
4956
@echo "7" >/sys/class/gpio/unexport || true
@@ -93,7 +100,7 @@ test-self-update: wolfboot.bin test-app/image.bin FORCE
93100
@make clean
94101
@rm src/*_pub_key.c
95102
@make factory.bin RAM_CODE=1 WOLFBOOT_VERSION=$(WOLFBOOT_VERSION) SIGN=$(SIGN)
96-
@$(SIGN_TOOL) test-app/image.bin $(PRIVATE_KEY) $(TEST_UPDATE_VERSION)
103+
@python3 $(SIGN_TOOL) test-app/image.bin $(PRIVATE_KEY) $(TEST_UPDATE_VERSION)
97104
@st-flash --reset write test-app/image_v2_signed.bin 0x08020000 || \
98105
(make test-reset && sleep 1 && st-flash --reset write test-app/image_v2_signed.bin 0x08020000) || \
99106
(make test-reset && sleep 1 && st-flash --reset write test-app/image_v2_signed.bin 0x08020000)
@@ -107,7 +114,7 @@ test-self-update: wolfboot.bin test-app/image.bin FORCE
107114

108115
test-update-ext: test-app/image.bin FORCE
109116
@python3 $(SIGN_TOOL) test-app/image.bin $(PRIVATE_KEY) $(TEST_UPDATE_VERSION)
110-
@$$(dd if=/dev/zero bs=1M count=1 | tr '\000' '\377' > test-update.rom)
117+
@(dd if=/dev/zero bs=1M count=1 | tr '\000' '\377' > test-update.rom)
111118
@dd if=test-app/image_v$(TEST_UPDATE_VERSION)_signed.bin of=test-update.rom bs=1 count=524283 conv=notrunc
112119
@printf "pBOOT" | dd of=test-update.rom obs=1 seek=524283 count=5 conv=notrunc
113120
@make test-spi-on
@@ -139,10 +146,8 @@ test-factory: factory.bin
139146
(make test-reset && sleep 1 && st-flash --reset write factory.bin 0x08000000))&
140147

141148
test-resetold: FORCE
142-
@$$(sleep 1 && st-info --reset) &
149+
@(sleep 1 && st-info --reset) &
143150

144-
test-reset: FORCE
145-
@$$(sleep 1 && make testbed-off && sleep 1 && make testbed-on) &
146151

147152

148153

@@ -153,17 +158,17 @@ test-01-forward-update-no-downgrade: $(EXPVER) FORCE
153158
@echo Creating and uploading factory image...
154159
@make test-factory
155160
@echo Expecting version '1'
156-
@$$(test `$(EXPVER)` -eq 1)
161+
@(test `$(EXPVER)` -eq 1)
157162
@echo
158163
@echo Creating and uploading update image...
159164
@make test-update TEST_UPDATE_VERSION=4
160165
@echo Expecting version '4'
161-
@$$(test `$(EXPVER)` -eq 4)
166+
@(test `$(EXPVER)` -eq 4)
162167
@echo
163168
@echo Creating and uploading update image...
164169
@make test-update TEST_UPDATE_VERSION=1
165170
@echo Expecting version '4'
166-
@$$(test `$(EXPVER)` -eq 4)
171+
@(test `$(EXPVER)` -eq 4)
167172
@make clean
168173
@echo TEST PASSED
169174

@@ -172,17 +177,17 @@ test-02-forward-update-allow-downgrade: $(EXPVER) FORCE
172177
@echo Creating and uploading factory image...
173178
@make test-factory ALLOW_DOWNGRADE=1
174179
@echo Expecting version '1'
175-
@$$(test `$(EXPVER)` -eq 1)
180+
@(test `$(EXPVER)` -eq 1)
176181
@echo
177182
@echo Creating and uploading update image...
178183
@make test-update TEST_UPDATE_VERSION=4
179184
@echo Expecting version '4'
180-
@$$(test `$(EXPVER)` -eq 4)
185+
@(test `$(EXPVER)` -eq 4)
181186
@echo
182187
@echo Creating and uploading update image...
183188
@make test-update TEST_UPDATE_VERSION=2
184189
@echo Expecting version '4'
185-
@$$(test `$(EXPVER)` -eq 2)
190+
@(test `$(EXPVER)` -eq 2)
186191
@make clean
187192
@echo TEST PASSED
188193

@@ -191,21 +196,21 @@ test-03-rollback: $(EXPVER) FORCE
191196
@echo Creating and uploading factory image...
192197
@make test-factory
193198
@echo Expecting version '1'
194-
@$$(test `$(EXPVER)` -eq 1)
199+
@(test `$(EXPVER)` -eq 1)
195200
@echo
196201
@echo Creating and uploading update image...
197202
@make test-update TEST_UPDATE_VERSION=4
198203
@echo Expecting version '4'
199-
@$$(test `$(EXPVER)` -eq 4)
204+
@(test `$(EXPVER)` -eq 4)
200205
@echo
201206
@echo Creating and uploading update image...
202207
@make test-update TEST_UPDATE_VERSION=5
203208
@echo Expecting version '5'
204-
@$$(test `$(EXPVER)` -eq 5)
209+
@(test `$(EXPVER)` -eq 5)
205210
@echo
206211
@echo Resetting to trigger rollback...
207212
@make test-reset
208-
@$$(test `$(EXPVER)` -eq 4)
213+
@(test `$(EXPVER)` -eq 4)
209214
@make clean
210215
@echo TEST PASSED
211216

@@ -220,17 +225,17 @@ test-21-forward-update-no-downgrade-SPI: $(EXPVER) FORCE
220225
@echo Creating and uploading factory image...
221226
@make test-factory $(SPI_OPTIONS)
222227
@echo Expecting version '1'
223-
@$$(test `$(EXPVER)` -eq 1)
228+
@(test `$(EXPVER)` -eq 1)
224229
@echo
225230
@echo Creating and uploading update image...
226231
@make test-update-ext TEST_UPDATE_VERSION=4 $(SPI_OPTIONS)
227232
@echo Expecting version '4'
228-
@$$(test `$(EXPVER)` -eq 4)
233+
@(test `$(EXPVER)` -eq 4)
229234
@echo
230235
@echo Creating and uploading update image...
231236
@make test-update-ext TEST_UPDATE_VERSION=1 $(SPI_OPTIONS)
232237
@echo Expecting version '4'
233-
@$$(test `$(EXPVER)` -eq 4)
238+
@(test `$(EXPVER)` -eq 4)
234239
@make clean
235240
@echo TEST PASSED
236241

@@ -239,22 +244,22 @@ test-23-rollback-SPI: $(EXPVER) FORCE
239244
@echo Creating and uploading factory image...
240245
@make test-factory $(SPI_OPTIONS)
241246
@echo Expecting version '1'
242-
@$$(test `$(EXPVER)` -eq 1)
247+
@(test `$(EXPVER)` -eq 1)
243248
@echo
244249
@echo Creating and uploading update image...
245250
@make test-update-ext TEST_UPDATE_VERSION=4 $(SPI_OPTIONS)
246251
@echo Expecting version '4'
247-
@$$(test `$(EXPVER)` -eq 4)
252+
@(test `$(EXPVER)` -eq 4)
248253
@echo
249254
@echo Creating and uploading update image...
250255
@make test-update-ext TEST_UPDATE_VERSION=5 $(SPI_OPTIONS)
251256
@echo Expecting version '5'
252-
@$$(test `$(EXPVER)` -eq 5)
257+
@(test `$(EXPVER)` -eq 5)
253258
@echo
254259
@echo Resetting to trigger rollback...
255260
@make test-reset
256261
@sleep 2
257-
@$$(test `$(EXPVER)` -eq 4)
262+
@(test `$(EXPVER)` -eq 4)
258263
@make clean
259264
@echo TEST PASSED
260265

@@ -264,12 +269,12 @@ test-34-forward-self-update: $(EXPVER) FORCE
264269
@make distclean
265270
@make test-factory RAM_CODE=1 SIGN=$(SIGN)
266271
@echo Expecting version '1'
267-
@$$(test `$(EXPVER)` -eq 1)
272+
@(test `$(EXPVER)` -eq 1)
268273
@echo
269274
@echo Updating keys, firmware, bootloader
270275
@make test-self-update WOLFBOOT_VERSION=4 RAM_CODE=1 SIGN=$(SIGN)
271276
@sleep 2
272-
@$$(test `$(EXPVER)` -eq 2)
277+
@(test `$(EXPVER)` -eq 2)
273278
@make clean
274279
@echo TEST PASSED
275280

0 commit comments

Comments
 (0)