-
Notifications
You must be signed in to change notification settings - Fork 3k
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
tfm-post-build: Don't capture subprocess stdout #14783
Conversation
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.
@rwalton-arm Thanks for the change.
Please also make the same change to the script for CLI 1:
mbed-os/tools/targets/ARM_MUSCA.py
Lines 161 to 171 in 3cf5f8e
def run_cmd(cmd, directory): | |
POPEN_INSTANCE = subprocess.Popen( | |
cmd, | |
stdout=subprocess.PIPE, | |
stderr=subprocess.STDOUT, | |
cwd=directory, | |
) | |
POPEN_INSTANCE.communicate() | |
return POPEN_INSTANCE.returncode |
@rwalton-arm, thank you for your changes. |
Thanks. I'll add it there, too. I didn't realise we had a different script for CLI 1. Good catch. |
38553db
to
b20ac90
Compare
No problem. Yea the scripts are slightly different but the CLI 2 script was derived from the CLI 1 one. The idea was to make the CLI 2 script + CMake hook general purpose enough for all TF-M (not just Musca), but Nuvoton told us our script took too few arguments so they ended up making their own for their TF-M target. A future improvement would be extending our generic TF-M signing script to support that too. (Slightly off topic here.) |
^ Speaking of this, actually Nuvoton's script dumps the stdout only when there's an error: mbed-os/targets/TARGET_NUVOTON/scripts/NUVOTON.py Lines 178 to 201 in 3cf5f8e
However, the signing script isn't particularly verbose - it doesn't print anything unless an error occurs. So I'm okay with not capturing stdout. |
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.
LGTM
Looks like travis failed due to an apt-get connection error.
|
This pull request has automatically been marked as stale because it has had no recent activity. @rwalton-arm, please carry out any necessary work to get the changes merged. Thank you for your contributions. |
Same failure when I manually reran Travis on this PR. I don't think the error is related to the change though. |
@rwalton-arm Let's rebase and that will retrigger the Travis, it should pass. |
subprocess.PIPE is used to enable the parent process to communicate with the subprocess via pipes, which mean all stdout and stderr messages are captured and returned as part of Popen.communicate's result tuple. In our case, we want to display the error messages on the console, so we don't need to capture the output from stdout. Example of a typical error message before this change: ``` Traceback (most recent call last): File "platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/scripts/generate_mbed_image.py", line 197, in <module> sign_and_merge_tfm_bin(args.tfm_target, args.target_path, args.non_secure_bin, args.secure_bin) File "platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/scripts/generate_mbed_image.py", line 81, in sign_and_merge_tfm_bin " secure binary, Error code: " + str(retcode)) Exception: Unable to sign musca_b1 secure binary, Error code: 1 ``` Example of the error message after this change: ``` Traceback (most recent call last): File "/mbed-os/tools/psa/tfm/bin_utils/wrapper.py", line 13, in <module> import click ModuleNotFoundError: No module named 'click' Traceback (most recent call last): File "platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/scripts/generate_mbed_image.py", line 194, in <module> sign_and_merge_tfm_bin(args.tfm_target, args.target_path, args.non_secure_bin, args.secure_bin) File "platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/scripts/generate_mbed_image.py", line 80, in sign_and_merge_tfm_bin raise Exception("Unable to sign " + target_name + Exception: Unable to sign musca_b1 secure binary, Error code: 1 ``` This is a significant improvement as now you can see what the reason for the failure was.
b20ac90
to
6d78f93
Compare
Pull request has been modified.
Frozen tools check is failing because I modified https://github.com/ARMmbed/mbed-os/blob/master/tools/targets/ARM_MUSCA.py @Patater can we ignore the frozen tools check for this? |
We should really wrap the TF-M post build scripts up into a python package; rather than a collection of similar scripts that spin up subprocesses to reuse some "common" python code, with hard coded file paths. If we make this a pypi package, we can reuse common code easily using the python import system, manage dependencies properly, and make the interface generic enough to handle the various use cases. Maybe we could then even add some unit tests to prove it all works as expected. |
Move script in targets/TARGET_ARM_SSG... |
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.
Tools changes only to files used by targets not supported in the online compiler.
CI started |
Jenkins CI Test : ✔️ SUCCESSBuild Number: 1 | 🔒 Jenkins CI Job | 🌐 Logs & ArtifactsCLICK for Detailed Summary
|
Summary of changes
subprocess.PIPE is used to enable the parent process to communicate with
the subprocess via pipes, which mean all stdout and stderr messages are
captured and returned as part of Popen.communicate's result tuple.
In our case, we want to display the error messages on the console, so we
don't need to capture the output from stdout.
Example of a typical error message before this change:
Example of the error message after this change:
Impact of changes
Migration actions required
Documentation
Pull request type
Test results
Reviewers