PSOC6: Fix post build script

Raise an exception in case of a failure to find an image to use
for the binary signature. This prevents the method from assuming
the image is always successfully retrieved and crash when
attempting to print a message
pull/14324/head
Hugues Kamba 2021-02-22 17:12:35 +00:00
parent 29cfcd6d5f
commit a8b9d49cfa
1 changed files with 5 additions and 0 deletions

View File

@ -249,6 +249,11 @@ def sign_application(message_func, tools, binary, image_id):
# UPGRADE image will be generated automatically by cysecuretools
address, size = tools.flash_map(image_id=image_id, image_type="BOOT")
if not address or not size:
raise AddSignatureError(
f"Cannot find image with id {image_id} and type BOOT in the policy file"
)
tools.sign_image(binary, image_id)
message_func("[PSOC6.sign_image] Slot start address and size for image ID " \
+ str(image_id) + " is " + hex(address) + ", " + hex(size))