Skip to content
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

imgtool.py file in mbed-os interferes with imgtool python package installed in system #14153

Closed
romanjoe opened this issue Jan 14, 2021 · 4 comments · Fixed by #14362
Closed

Comments

@romanjoe
Copy link
Contributor

Description of defect

imgtool files included in mbed-os in mbed-os/tools/psa/tfm/bin_utils and particularly imgtool.py file interferes with imgtool package installed in system.

For particular case, Cypress secure tools set called cysecuretools requires imgtool package from pip to operate. When user tries to compile a test or an example for Cypress target CY8C064B0S2_4343W he gets an error (log is provided below).

Target(s) affected by this defect ?

CY8C064B0S2_4343W
https://os.mbed.com/platforms/CY8CKIT-064B0S2-4343W/

Toolchain(s) (name and version) displaying this defect ?

gcc, arm, iar

What version of Mbed-os are you using (tag or sha) ?

latest master (at the time of opening 2e905a0)

What version(s) of tools are you using. List all that apply (E.g. mbed-cli)

Name: mbed-cli
Version: 1.10.4

How is this defect reproduced ?

Compile an example project for CY8CKIT064B0S2_4343W with mbed compile -m CY8CKIT064B0S2_4343W -t GCC_ARM -v

Get error:

Traceback (most recent call last): File "/Users/rnok/repos/mbed-os/tools/test_api.py", line 2091, in build_test_worker bin_file, _ = build_project(*args, **kwargs) File "/Users/rnok/repos/mbed-os/tools/build_api.py", line 621, in build_project res = toolchain.link_program(resources, build_path, name) File "/Users/rnok/repos/mbed-os/tools/toolchains/mbed_toolchain.py", line 804, in link_program post_build_hook(self, r, elf, full_path) File "/Users/rnok/repos/mbed-os/tools/targets/__init__.py", line 681, in sign_image psoc6_sign_image(t_self, resources, elf, binf, m0hexf) File "/Users/rnok/repos/mbed-os/tools/targets/PSOC6.py", line 180, in sign_image import cysecuretools File "/Users/rnok/.pyenv/versions/3.7.8/lib/python3.7/site-packages/cysecuretools/__init__.py", line 16, in <module> from cysecuretools.main import CySecureTools File "/Users/rnok/.pyenv/versions/3.7.8/lib/python3.7/site-packages/cysecuretools/main.py", line 47, in <module> from cysecuretools.execute.signtool import SignTool File "/Users/rnok/.pyenv/versions/3.7.8/lib/python3.7/site-packages/cysecuretools/execute/signtool.py", line 18, in <module> import imgtool.main as imgtool ModuleNotFoundError: No module named 'imgtool.main'; 'imgtool' is not a package

@ciarmcom
Copy link
Member

Thank you for raising this detailed GitHub issue. I am now notifying our internal issue triagers.
Internal Jira reference: https://jira.arm.com/browse/IOTOSM-3234

@0xc0170
Copy link
Contributor

0xc0170 commented Jan 19, 2021

cc @ARMmbed/mbed-os-tools

@saheerb
Copy link
Contributor

saheerb commented Feb 23, 2021

@romanjoe this doesn't seem to be happening with cysecuretools=2.0.0 (this is the version we currently have in CI)

LDong-Arm added a commit to LDong-Arm/mbed-os that referenced this issue Feb 23, 2021
Fixes: ARMmbed#14153

The target CYTFM_064B0S2_4343W is signed using `cysecuretools` which
depends on `imgtool` managed by `pip`. However, Arm Musca targets
requires a modified/wrapped version of the image tool copied from
trusted-firmware-m + MCUboot.

To avoid conflicts in the version of `imgtool` used, we should only
add the copied version of `imgtool` to python's system path for
Musca targets instead of doing it globally for all targets.
@LDong-Arm
Copy link
Contributor

@romanjoe Thanks for identifying the issue, that has been really helpful to us.

Here's a fix: LDong-Arm/mbed-os@e5901ec
We'll raise a pull request a few days later, as we are waiting for other work to be merged first, to avoid conflicts.

LDong-Arm added a commit to LDong-Arm/mbed-os that referenced this issue Mar 1, 2021
Fixes: ARMmbed#14153

The target CYTFM_064B0S2_4343W is signed using `cysecuretools` which
depends on `imgtool` managed by `pip`. However, Arm Musca targets
requires a modified/wrapped version of the image tool copied from
trusted-firmware-m + MCUboot.

To avoid conflicts in the version of `imgtool` used, we should only
add the copied version of `imgtool` to python's system path for
Musca targets instead of doing it globally for all targets.
LDong-Arm added a commit to LDong-Arm/mbed-os that referenced this issue Mar 3, 2021
Fixes: ARMmbed#14153

The target CYTFM_064B0S2_4343W is signed using `cysecuretools` which
depends on `imgtool` managed by `pip`. However, Arm Musca targets
requires a modified/wrapped version of the image tool copied from
trusted-firmware-m + MCUboot.

To avoid conflicts in the version of `imgtool` used, we should only
add the copied version of `imgtool` to python's system path for
Musca targets instead of doing it globally for all targets.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants