Pack: Update scripts for creating TF-M CMSIS-Packs on linux
Signed-off-by: Robert Rostohar <Robert.Rostohar@arm.com>
Change-Id: I5005af763c4c636a2086e1087a0e8a745a1df784
diff --git a/cmsis_pack/README.md b/cmsis_pack/README.md
index 28f68d2..d55c2f4 100644
--- a/cmsis_pack/README.md
+++ b/cmsis_pack/README.md
@@ -6,13 +6,14 @@
- bash compatible shell (under Windows, use for example [git bash](https://gitforwindows.org/))
- [Git](https://git-scm.com/downloads)
- [7-Zip](https://www.7-zip.org/download.html)
-- [Python](https://www.python.org/downloads/) v3.6 or later
+- [Python](https://www.python.org/downloads/) v3.6 or later with pip package manager
- [Doxygen](https://www.doxygen.nl/download.html) v1.8.0 or later (for building documentation)
- [Graphviz](https://graphviz.org/download/) v2.38.0 or later (for building documentation)
- [PlantUML](http://sourceforge.net/projects/plantuml/files/plantuml.jar/download) v1.2018.11 or later
in PLANTUML_JAR_PATH (for building documentation)
- Java runtime environment 1.8 or later (for running PlantUML)
- CMSIS Pack installed in CMSIS_PACK_ROOT (for PackChk utility)
+- xmllint in path (XML schema validation; available only for Linux)
## Create packs
diff --git a/cmsis_pack/gen_doc.sh b/cmsis_pack/gen_doc.sh
index 63bfdbf..66412ae 100755
--- a/cmsis_pack/gen_doc.sh
+++ b/cmsis_pack/gen_doc.sh
@@ -18,7 +18,7 @@
echo "cmake_env = None" > tfm_env.py
# Generate reference and user manual
-sphinx-build.exe . user_guide
+sphinx-build . user_guide
# Move generated documentation
mv reference_manual/html ../docs/reference_manual
diff --git a/cmsis_pack/setup.sh b/cmsis_pack/setup.sh
index 3c33c28..f103c2a 100755
--- a/cmsis_pack/setup.sh
+++ b/cmsis_pack/setup.sh
@@ -3,8 +3,20 @@
# SPDX-License-Identifier: BSD-3-Clause
# Setup TF-M for building CMSIS-Packs
+# Check Python installation
+PYTHON=$(which python3 2> /dev/null)
+if [ -z "${PYTHON}" ]; then
+ echo "No python3 executable found!"
+ echo "Fall-back to python ..."
+ PYTHON=$(which python 2> /dev/null)
+ if [ -z "${PYTHON}" ]; then
+ echo "No python executable found!"
+ exit
+ fi
+fi
+
# Install required Python packages
-pip install -r requirements.txt
+${PYTHON} -m pip install -r requirements.txt
# TF-M repositories
TFM_URL=https://git.trustedfirmware.org/TF-M/trusted-firmware-m.git
@@ -20,8 +32,7 @@
# Clone TF-M repository
git clone $TFM_URL --branch $TFM_TAG --single-branch
errorlevel=$?
-if [ $errorlevel -gt 0 ]
- then
+if [ $errorlevel -gt 0 ]; then
echo "Error: Cloning TF-M repository failed"
echo " "
exit
@@ -30,8 +41,7 @@
# Clone TF-M tests repository
git clone $TFM_TESTS_URL --branch $TFM_TAG --single-branch
errorlevel=$?
-if [ $errorlevel -gt 0 ]
- then
+if [ $errorlevel -gt 0 ]; then
echo "Error: Cloning TF-M tests repository failed"
echo " "
exit
@@ -40,8 +50,7 @@
# Clone MCUboot repository
git clone $MCUBOOT_URL --branch $MCUBOOT_TAG --single-branch
errorlevel=$?
-if [ $errorlevel -gt 0 ]
- then
+if [ $errorlevel -gt 0 ]; then
echo "Error: Cloning MCUboot repository failed"
echo " "
exit
@@ -55,9 +64,8 @@
pushd ./trusted-firmware-m/bl2/ext/mcuboot/include/mcuboot_config
cp -v mcuboot_config.h.in mcuboot_config.h
# Remove defines which are already defined in bl2_config.h
-sed -i 's/#cmakedefine/\/\/#define/' mcuboot_config.h
-sed -i 's/#define MCUBOOT_LOG_LEVEL/\/\/#define MCUBOOT_LOG_LEVEL/' mcuboot_config.h
-unix2dos -q mcuboot_config.h
+sed -b -i 's/#cmakedefine/\/\/#define/' mcuboot_config.h
+sed -b -i 's/#define MCUBOOT_LOG_LEVEL/\/\/#define MCUBOOT_LOG_LEVEL/' mcuboot_config.h
popd
# Create TF-M Mbed Crypto config file (from default config)
@@ -83,7 +91,7 @@
# Generate files from templates
export TFM_TEST_PATH="${PWD}/tf-m-tests/test"
-python ./trusted-firmware-m/tools/tfm_parse_manifest_list.py \
+${PYTHON} ./trusted-firmware-m/tools/tfm_parse_manifest_list.py \
-o ./trusted-firmware-m \
-m ./trusted-firmware-m/tools/tfm_manifest_list.yaml \
-f ./trusted-firmware-m/tools/tfm_generated_file_list.yaml \
@@ -96,9 +104,8 @@
pushd ./trusted-firmware-m/platform/ext/common/armclang
for f in tfm_common_s.sct tfm_isolation_l3.sct
do
- sed -i '/TFM_IRQ_TEST_1_ATTR_FN/i*(:gdef:tfm_enable_irq)' $f
- sed -i '/TFM_IRQ_TEST_1_ATTR_FN/i*(:gdef:tfm_disable_irq)' $f
- unix2dos -q $f
+ sed -b -i '/TFM_IRQ_TEST_1_ATTR_FN/i*(:gdef:tfm_enable_irq)\r' $f
+ sed -b -i '/TFM_IRQ_TEST_1_ATTR_FN/i*(:gdef:tfm_disable_irq)\r' $f
done
popd
diff --git a/cmsis_pack/setup_mps2.sh b/cmsis_pack/setup_mps2.sh
index 161a674..ea349e5 100755
--- a/cmsis_pack/setup_mps2.sh
+++ b/cmsis_pack/setup_mps2.sh
@@ -194,8 +194,7 @@
do
mkdir -p $d/RTE/TFM
cp -v ${TFM_ROOT}/bl2/ext/mcuboot/config/mcuboot-mbedtls-cfg.h $d/RTE/TFM/
- sed -i '/#define __MCUBOOT_MBEDTLS_CFG__/a\\n#include "bl2_config.h"' $d/RTE/TFM/mcuboot-mbedtls-cfg.h
- unix2dos -q $d/RTE/TFM/mcuboot-mbedtls-cfg.h
+ sed -b -i '/#define __MCUBOOT_MBEDTLS_CFG__/a\\r\n#include "bl2_config.h"\r' $d/RTE/TFM/mcuboot-mbedtls-cfg.h
mkdir -p $d/RTE/TFM_Platform/SMM-SSE-200
cp -v ${DST_ROOT}/boot_hal.c $d/RTE/TFM_Platform/SMM-SSE-200/
cp -v ${DST_ROOT}/partition/flash_layout.h $d/RTE/TFM_Platform/SMM-SSE-200/
@@ -253,9 +252,8 @@
# Adjust memory map of non-secure project when using bootloader
pushd ${DST_ROOT}/project/fvp/tfm_bl/tfm_ns/${DST_DIR}
-sed -i 's/NS_CODE_START (0x00100000)/NS_CODE_START (0x00100400)/' mps2_an521_ns.sct
-sed -i 's/NS_CODE_SIZE (0x00080000)/NS_CODE_SIZE (0x0007F800)/' mps2_an521_ns.sct
-unix2dos -q mps2_an521_ns.sct
+sed -b -i 's/NS_CODE_START (0x00100000)/NS_CODE_START (0x00100400)/' mps2_an521_ns.sct
+sed -b -i 's/NS_CODE_SIZE (0x00080000)/NS_CODE_SIZE (0x0007F800)/' mps2_an521_ns.sct
popd
# Remove temporary device files