-
Notifications
You must be signed in to change notification settings - Fork 3k
PSA tools: Find secure image at post-build #9894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@mikisch81, thank you for your changes. |
tools/psa/__init__.py
Outdated
secure_image = next((f for f in image_files if basename(f) == basename(ns_image_path)), secure_image) | ||
|
||
if secure_image: | ||
toolchain.notify.debug("Secure image file found: %s." % secure_image) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resources has a notifier too, and if you're only using the notifier from the toolchain, pass in the notifier please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well it didn't work for resources notifier:
Traceback (most recent call last):
File "C:\miki_dev\mbed-os_backup\tools\test_api.py", line 2210, in build_test_worker
bin_file, _ = build_project(*args, **kwargs)
File "C:\miki_dev\mbed-os_backup\tools\build_api.py", line 584, in build_project
res, _ = toolchain.link_program(resources, build_path, name)
File "C:\miki_dev\mbed-os_backup\tools\toolchains\__init__.py", line 654, in link_program
self.binary(r, elf, bin)
File "C:\miki_dev\mbed-os_backup\tools\hooks.py", line 54, in wrapper
post_res = tooldesc["post"](t_self, *args, **kwargs)
File "C:\miki_dev\mbed-os_backup\tools\targets\__init__.py", line 604, in binary_hook
secure_bin = find_secure_image(t_self, resources, binf, configured_secure_image_filename, FileType.BIN)
File "C:\miki_dev\mbed-os_backup\tools\psa\__init__.py", line 12, in find_secure_image
resources.notify.debug("Secure image file found: %s." % secure_image)
AttributeError: 'Resources' object has no attribute 'notify'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably private then. Pass in a notifier instead.
tools/psa/__init__.py
Outdated
if secure_image: | ||
toolchain.notify.debug("Secure image file found: %s." % secure_image) | ||
else: | ||
toolchain.notify.debug("Secure image file %s not found. Aborting." % configured_s_image_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resources has a notifier too, and if you're only using the notifier from the toolchain, pass in the notifier please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
@mikisch81 I'm not seeing a change that calls this new function. How does this get invoked? |
By the musca post-build hook This is currently in a branch and will be added to #9221 |
@mikisch81 That code is not on master or in the diff, so this looks like you're adding dead code, because from the perspective of this branch you are adding dead code. Could you include the modification to the post-build hook too? |
Do you suggest adding the musca post build hook here? |
@mikisch81 That could work, and I would be alright with that. but:
So why is the PSOC6 post-build hook not refactored to use this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notifier changes requested offline.
tools/psa/__init__.py
Outdated
secure_image = next((f for f in image_files if basename(f) == basename(ns_image_path)), secure_image) | ||
|
||
if secure_image: | ||
toolchain.notify.debug("Secure image file found: %s." % secure_image) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
toolchain.notify.debug("Secure image file found: %s." % secure_image) | |
notify.debug("Secure image file found: %s." % secure_image) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
tools/psa/__init__.py
Outdated
if secure_image: | ||
toolchain.notify.debug("Secure image file found: %s." % secure_image) | ||
else: | ||
toolchain.notify.debug("Secure image file %s not found. Aborting." % configured_s_image_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
toolchain.notify.debug("Secure image file %s not found. Aborting." % configured_s_image_path) | |
notify.debug("Secure image file %s not found. Aborting." % configured_s_image_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
tools/psa/__init__.py
Outdated
|
||
|
||
# Find secure image. | ||
def find_secure_image(toolchain, resources, ns_image_path, configured_s_image_path, image_type): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def find_secure_image(toolchain, resources, ns_image_path, configured_s_image_path, image_type): | |
def find_secure_image(notify, resources, ns_image_path, configured_s_image_path, image_type): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
tools/psa/__init__.py
Outdated
from os.path import basename | ||
|
||
|
||
# Find secure image. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you change this into a doc comment? You would place this in a string as the first statement inside the body of the function.
E.G.
def find_secure_image(toolchain, resources, ns_image_path, configured_s_image_path, image_type):
""" Find secure image. """
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@theotherjimmy |
@orenc17 That does not make sense. If the PSOC6 has the same logic within it, then replacing that logic with this logic works regardless of PSA or any other three letter acronym you care to use. |
My tone on my comments has been rather harsh. My apologies, I'll be editing my comments better in the future. I had a discussion with the authors outside of this thread, and we will be working to wire this new method into the tools in the next few days so that it's tested and verified in this PR, or the PR that contains it. |
- Used by Non-secure targets post-build hooks to find the relevant secure image.
starting CI |
@ARMmbed/mbed-os-maintainers This PR needs to be for 5.12.0, #9910 will need this. |
@theotherjimmy , please re-review this PR |
Test run: SUCCESSSummary: 13 of 13 test jobs passed |
This PR is required for #9910 |
@theotherjimmy see this comment to see the proposed usage of this function in #9910 |
@0xc0170 is it possible to merge, and if any new comments from @theotherjimmy come up a new PR will be opened? |
@theotherjimmy I added tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have test. Looks great
@0xc0170 Is it possible to start CI? @theotherjimmy approved |
@cmonr Your timezone starts soon. running CI appreciated. (this passed travis, so it should be the same result as current master) |
We are now focusing on rc1 PRs and nightly job has some failures we are investigating. We will start when able. |
Adding @maclobdell |
I'll run one job here (exporters will fail as master has one bug) but at least to get the rest tested now |
CI started |
Test run: FAILEDSummary: 1 of 13 test jobs failed Failed test jobs:
|
Failure in the exporters will be fixed, tracked here #9938 |
@ARMmbed/mbed-os-maintainers Can we re-run the exporter job? |
restarted exporter to check if issue is resolved |
tools/psa/__init__.py
Outdated
@@ -0,0 +1,23 @@ | |||
from os.path import basename |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing license header here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
license addition needed
@0xc0170 Added missing license header |
- For cases where non-secure image is HEX and secure image is BIN
CI started |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meets post freeze criteria, PSA related. Approved.
Test run: SUCCESSSummary: 13 of 13 test jobs passed |
Description
Add a common function which finds the relevant secure image of a non-secure target.
This function will be called during the post-build hook which merges the secure and non-secure images together.
The logic was taken from the PSOC6 post-build hook
Tested with Musca_a1.
Pull request type
Reviewers
@theotherjimmy @orenc17
Release Notes