From a8b9d49cfa668e508e2764b22e7e4f6c25685f65 Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Mon, 22 Feb 2021 17:12:35 +0000 Subject: [PATCH] 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 --- targets/TARGET_Cypress/scripts/PSOC6.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/targets/TARGET_Cypress/scripts/PSOC6.py b/targets/TARGET_Cypress/scripts/PSOC6.py index 75cf003fd9..e20818dc19 100644 --- a/targets/TARGET_Cypress/scripts/PSOC6.py +++ b/targets/TARGET_Cypress/scripts/PSOC6.py @@ -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))