Hi Thomas,

 

In cmake, there are two ways to tell it to execute the file with python.

  1. Set it explicitly in the cmake file like:

COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/assemble.py

Cmake will call ${PYTHON_EXECUTABLE} to execute the .py file.

  1. Do not set the tool explicitly and the .py file starts with #! /usr/bin/env python3

In this way, the following command still works in linux:

COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/scripts/assemble.py

But it cannot work on windows as the python path set within the .py file is a linux path.

 

In the bl2/ext/mcuboot/CMakeLists.txt file, it set the tool explicitly with ${PYTHON_EXECUTABLE}. But the variable ${PYTHON_EXECUTABLE} is empty. The reason is that in this file, it searches the Python3 packge. So the Python3_EXECUTABLE is set with the python path after https://git.trustedfirmware.org/TF-M/trusted-firmware-m.git/tree/bl2/ext/mcuboot/CMakeLists.txt#n67.  Instead of ${PYTHON_EXECUTABLE}. So in fact, way 2 is used in this file. But as explains in way 2, the python path is a Linux path. So it works on Linux and does not work on Windows.

 

To solve this issue, the {PYTHON_EXECUTABLE should be replaced by Python3_EXECUTABLE in this file. I will create a patch to fix it later.

 

Regards,

Sherry Zhang

 

From: TF-M <tf-m-bounces@lists.trustedfirmware.org> On Behalf Of Thomas Törnblom via TF-M
Sent: Thursday, October 28, 2021 7:25 PM
To: tf-m@lists.trustedfirmware.org
Subject: [TF-M] BL2 builds, no "PYTHON_EXECUTABLE" defined

 

While attempting to build for the musca_s1, with mcuboot, on Windows, the build failed very late and brought up a Code Writer window on my screen.

I nailed it down to no "PYTHON_EXECUTABLE" being defined while processing bl2/ext/mcuboot/CMakeLists.txt, which caused the build line to just attempt to run wrapper.py, with no interpreter, and windows brought up the appropriate tools to write python code.

Adding "-DPYTHON_EXECUTABLE=python" to the cmake line fixed that, but it seems that this shouldn't be needed. The build tools should handle this, or?

There is a line:
#! /usr/bin/env python3

in wrapper.py, and I assume linux will handle this appropriately, but it doesn't seem windows does.

Cheers,
Thomas

--

Thomas Törnblom, Product Engineer
IAR Systems AB
Box 23051, Strandbodgatan 1
SE-750 23 Uppsala, SWEDEN
Mobile: +46 76 180 17 80 Fax: +46 18 16 78 01
E-mail:
thomas.tornblom@iar.com Website: www.iar.com
Twitter:
www.twitter.com/iarsystems