Skip to content

Commit e7341a9

Browse files
author
Michael Schwarcz
committed
tools: Add find_secure_image function
- Used by Non-secure targets post-build hooks to find the relevant secure image.
1 parent e03b3b6 commit e7341a9

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tools/psa/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from os.path import basename
2+
3+
4+
def find_secure_image(notify, resources, ns_image_path, configured_s_image_path, image_type):
5+
""" Find secure image. """
6+
image_files = resources.get_file_paths(image_type)
7+
secure_image = next((f for f in image_files if basename(f) == configured_s_image_path), None)
8+
secure_image = next((f for f in image_files if basename(f) == basename(ns_image_path)), secure_image)
9+
10+
if secure_image:
11+
notify.debug("Secure image file found: %s." % secure_image)
12+
else:
13+
notify.debug("Secure image file %s not found. Aborting." % configured_s_image_path)
14+
raise Exception("Required secure image not found.")
15+
16+
return secure_image

0 commit comments

Comments
 (0)