Skip to content

Commit 5d95b22

Browse files
committed
musca: Improve missing python dependencies error
Previously, if intelhex, cbor, cryptography, or python3 weren't available, we'd see an error message like the following: [2/2] Running utility command for mbed-post-build-bin-ARM_MUSCA_B1 FAILED: mbed-os/targets/TARGET_ARM_SSG/TARGET_MUSCA_B1/CMakeFiles/mbed-post-build-bin-ARM_MUSCA_B1.util cd /Users/user/Code/mbed-os-example-blinky/cmake_build/ARM_MUSCA_B1/develop/GCC_ARM/mbed-os/targets/TARGET_ARM_SSG/TARGET_MUSCA_B1 && /usr/local/Frameworks/Python.framework/Versions/3.9/bin/python3.9 /Users/user/Code/mbed-os-example-blinky/mbed-os/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/scripts/generate_mbed_image.py --tfm-target musca_b1 --target-path /Users/user/Code/mbed-os-example-blinky/mbed-os/targets/TARGET_ARM_SSG/TARGET_MUSCA_B1 --secure-bin /Users/user/Code/mbed-os-example-blinky/mbed-os/targets/TARGET_ARM_SSG/TARGET_MUSCA_B1/tfm_s.bin --non-secure-bin /Users/user/Code/mbed-os-example-blinky/cmake_build/ARM_MUSCA_B1/develop/GCC_ARM/mbed-os-example-blinky.bin Traceback (most recent call last): File "/Users/user/Code/mbed-os-example-blinky/mbed-os/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 "/Users/user/Code/mbed-os-example-blinky/mbed-os/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 ninja: build stopped: subcommand failed. ERROR: CMake invocation failed! More information may be available by using the command line option '-v'. "Error code 1" is not very helpful. To provide a more helpful error message, detect the dependencies and panic if the dependencies aren't available when building for the target. The new error message looks like so: CMake Error at mbed-os/targets/TARGET_ARM_SSG/TARGET_MUSCA_B1/CMakeLists.txt:10 (message): Missing Python dependencies (python3, cbor, click, intelhex) so the binary cannot be signed. Please install requirements with: python3 -m pip install -r mbed-os/tools/cmake/requirements.txt This is better than before.
1 parent 937671a commit 5d95b22

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

targets/TARGET_ARM_SSG/TARGET_MUSCA_B1/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@
44
if("TFM" IN_LIST MBED_TARGET_LABELS)
55
include(mbed_set_post_build_tfm)
66

7+
# Check deps for image signing
8+
if(NOT(Python3_FOUND AND HAVE_PYTHON_INTELHEX AND HAVE_PYTHON_CBOR AND
9+
HAVE_PYTHON_CLICK AND HAVE_PYTHON_CRYPTOGRAPHY))
10+
message(FATAL_ERROR "Missing Python dependencies (python3, cbor, "
11+
"click, intelhex) so the binary cannot be signed. Please install "
12+
"requirements with:\n"
13+
"\tpython3 -m pip install -r mbed-os/requirements.txt")
14+
endif()
15+
716
mbed_post_build_tfm_sign_image(
817
ARM_MUSCA_B1
918
musca_b1

targets/TARGET_ARM_SSG/TARGET_MUSCA_S1/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@
44
if("TFM" IN_LIST MBED_TARGET_LABELS)
55
include(mbed_set_post_build_tfm)
66

7+
# Check deps for image signing
8+
if(NOT(Python3_FOUND AND HAVE_PYTHON_INTELHEX AND HAVE_PYTHON_CBOR AND
9+
HAVE_PYTHON_CLICK AND HAVE_PYTHON_CRYPTOGRAPHY))
10+
message(FATAL_ERROR "Missing Python dependencies (python3, cbor, "
11+
"click, intelhex) so the binary cannot be signed. Please install "
12+
"requirements with:\n"
13+
"\tpython3 -m pip install -r mbed-os/requirements.txt")
14+
endif()
15+
716
mbed_post_build_tfm_sign_image(
817
ARM_MUSCA_S1
918
musca_s1

0 commit comments

Comments
 (0)