Boot: Use the PyPI version of imgtool
Modifies the Python wrapper for imgtool in TF-M to use the PyPI
version instead of the one in the MCUBoot repository.
Signed-off-by: Balint Matyi <Balint.Matyi@arm.com>
Change-Id: I0b3fb9c802c59628cced0962241a1b4573a00cfc
diff --git a/bl2/ext/mcuboot/MCUBoot.cmake b/bl2/ext/mcuboot/MCUBoot.cmake
index 71ed6e9..28dd7fe 100644
--- a/bl2/ext/mcuboot/MCUBoot.cmake
+++ b/bl2/ext/mcuboot/MCUBoot.cmake
@@ -166,7 +166,7 @@
POST_BUILD
#Sign secure binary image with default public key in mcuboot folder
- COMMAND ${PYTHON_EXECUTABLE} ${MCUBOOT_DIR}/scripts/wrapper.py
+ COMMAND ${PYTHON_EXECUTABLE} ${MCUBOOT_DIR}/scripts/wrapper/wrapper.py
ARGS -k ${KEY_FILE_S}
--public-key-format ${PUBLIC_KEY_FORMAT}
--align 1
@@ -182,7 +182,7 @@
${CMAKE_BINARY_DIR}/${_MY_PARAMS_S_BIN}_signed.bin
#Sign non-secure binary image with default public key in mcuboot folder
- COMMAND ${PYTHON_EXECUTABLE} ${MCUBOOT_DIR}/scripts/wrapper.py
+ COMMAND ${PYTHON_EXECUTABLE} ${MCUBOOT_DIR}/scripts/wrapper/wrapper.py
ARGS -k ${KEY_FILE_NS}
--public-key-format ${PUBLIC_KEY_FORMAT}
--align 1
@@ -263,7 +263,7 @@
-o ${CMAKE_BINARY_DIR}/${_MY_PARAMS_FULL_BIN}.bin
#Sign concatenated binary image with default public key in mcuboot folder
- COMMAND ${PYTHON_EXECUTABLE} ${MCUBOOT_DIR}/scripts/wrapper.py
+ COMMAND ${PYTHON_EXECUTABLE} ${MCUBOOT_DIR}/scripts/wrapper/wrapper.py
ARGS -k ${KEY_FILE}
--public-key-format ${PUBLIC_KEY_FORMAT}
--align 1
diff --git a/bl2/ext/mcuboot/scripts/requirements.txt b/bl2/ext/mcuboot/scripts/requirements.txt
index d3c54b4..14bbb18 100644
--- a/bl2/ext/mcuboot/scripts/requirements.txt
+++ b/bl2/ext/mcuboot/scripts/requirements.txt
@@ -2,4 +2,5 @@
pyasn1
pyyaml
cbor>=1.0.0
+imgtool>=1.6.0
click
\ No newline at end of file
diff --git a/bl2/ext/mcuboot/scripts/wrapper.py b/bl2/ext/mcuboot/scripts/wrapper/wrapper.py
similarity index 95%
rename from bl2/ext/mcuboot/scripts/wrapper.py
rename to bl2/ext/mcuboot/scripts/wrapper/wrapper.py
index 14ad07a..0944336 100644
--- a/bl2/ext/mcuboot/scripts/wrapper.py
+++ b/bl2/ext/mcuboot/scripts/wrapper/wrapper.py
@@ -11,13 +11,12 @@
import os
import sys
import click
-import macro_parser
-# Import the external MCUBoot repo's imgtool script
-scripts_path = os.path.abspath(os.path.join(os.path.dirname(__file__),
- '../../../../../mcuboot/scripts'))
-sys.path.insert(0, scripts_path)
import imgtool
import imgtool.main
+# Import macro_parser script
+parser_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '../'))
+sys.path.append(parser_path)
+import macro_parser
sign_bin_size_re = re.compile(r"^\s*RE_SIGN_BIN_SIZE\s*=\s*(.*)")
load_addr_re = re.compile(r"^\s*RE_IMAGE_LOAD_ADDRESS\s*=\s*(.*)")
diff --git a/docs/getting_started/tfm_sw_requirement.rst b/docs/getting_started/tfm_sw_requirement.rst
index 9b3e09b..91869d2 100644
--- a/docs/getting_started/tfm_sw_requirement.rst
+++ b/docs/getting_started/tfm_sw_requirement.rst
@@ -170,11 +170,11 @@
- CMake (see the "Supported CMake versions" chapter)
- GNU Make (see the "Supported make versions" chapter)
- Python3 and the pip package manager (from Python 3.4 it's included)
-- Python3 packages: *cryptography, pyasn1, yaml, jinja2 v2.10, cbor v1.0.0, click*
+- Python3 packages: *cryptography, pyasn1, yaml, jinja2 v2.10, cbor v1.0.0, click, imgtool v1.6.0*
.. code-block:: bash
- pip3 install --user cryptography pyasn1 pyyaml jinja2 cbor click
+ pip3 install --user cryptography pyasn1 pyyaml jinja2 cbor click imgtool
- SRecord v1.58 (for Musca test chip boards)
@@ -230,11 +230,11 @@
installation.
- Python3 `(native Windows version) <https://www.python.org/downloads/>`__ and
the pip package manager (from Python 3.4 it's included)
-- Python3 packages: *cryptography, pyasn1, yaml, jinja2 v2.10, cbor v1.0.0, click*
+- Python3 packages: *cryptography, pyasn1, yaml, jinja2 v2.10, cbor v1.0.0, click imgtool v1.6.0*
.. code-block:: bash
- pip3 install --user cryptography pyasn1 pyyaml jinja2 cbor click
+ pip3 install --user cryptography pyasn1 pyyaml jinja2 cbor click imgtool
- `SRecord v1.63 <https://sourceforge.net/projects/srecord/>`__ (for Musca test
chip boards)
@@ -493,6 +493,7 @@
"cryptography",,"Firmware"
"cbor",,"Firmware"
"click",,"Firmware"
+ "imgtool",,"Firmware"
"Doxygen",">1.8","Reference manual"
"Sphinx",">1.4","User Guide"
"sphinxcontrib-plantuml",,"User Guide"
@@ -544,12 +545,14 @@
fw --> jinja2
fw --> cbor
fw --> click
+ fw --> imgtool
cryptography --> Python3
pyasn1 --> Python3
yaml --> Python3
jinja2 --> Python3
cbor --> Python3
click --> Python3
+ imgtool --> Python3
[*] --> u_guide
u_guide --> Sphinx