[PATCH] arm/trusted-firmware-m: Enable regression test build
Gergely Kovacs <[email protected]> Mon, 11 May 2026 11:49:53 +0000
| Newsgroups | org.yoctoproject.lists.meta-arm |
|---|---|
| Message-ID | <[email protected]> |
From: David Hu <[email protected]> TF-M build system has introduced a ground-breaking change since v2.0.0. Enable TF-M regression test build, following build instructions in TF-M document [1]. Add the BUILD_REGRESSION_TESTS variable to enable regression test builds. Individual regression test suites can be selected by passing the appropriate TF-M CMake options through EXTRA_OECMAKE. If regression test is enabled, build TF-M and tests from tf-m-tests directory. The build files for Normal World build will be installed. [1]: https://trustedfirmware-m.readthedocs.io/en/latest/building/tests_bu= ild_instruction.html Signed-off-by: David Hu <[email protected]> Signed-off-by: Gergely Kovacs <[email protected]> --- .../trusted-firmware-m/trusted-firmware-m.inc | 32 +++++++++++++++---- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/meta-arm/recipes-bsp/trusted-firmware-m/trusted-firmware-m.i= nc b/meta-arm/recipes-bsp/trusted-firmware-m/trusted-firmware-m.inc index 4e3c5912..3b6dce22 100644 --- a/meta-arm/recipes-bsp/trusted-firmware-m/trusted-firmware-m.inc +++ b/meta-arm/recipes-bsp/trusted-firmware-m/trusted-firmware-m.inc @@ -43,6 +43,11 @@ DEPENDS +=3D "cmake-native \ =20 B =3D "${WORKDIR}/build" =20 +# Build TF-M regression tests instead of the default firmware. +# When enabled, the desired test suite options should be appended to +# EXTRA_OECMAKE (e.g. -DTEST_S=3DON). +BUILD_REGRESSION_TESTS ?=3D "0" + # Build for debug (set TFM_DEBUG to 1 to activate) TFM_DEBUG ?=3D "${FIRMWARE_DEBUG_BUILD}" =20 @@ -53,11 +58,6 @@ python() { raise bb.parse.SkipRecipe("TFM_PLATFORM needs to be set") } =20 -PACKAGECONFIG ??=3D "" -# Whether to integrate the test suite -PACKAGECONFIG[test-secure] =3D "-DTEST_S=3DON,-DTEST_S=3DOFF" -PACKAGECONFIG[test-nonsecure] =3D "-DTEST_NS=3DON,-DTEST_NS=3DOFF" - # Currently we only support using the Arm binary GCC EXTRA_OECMAKE +=3D "-DTFM_TOOLCHAIN_FILE=3D${S}/toolchain_GNUARM.cmake" =20 @@ -77,9 +77,12 @@ EXTRA_OECMAKE +=3D "\ -DQCBOR_PATH=3D${S}/external/qcbor \ -DT_COSE_PATH=3D${S}/external/t_cose \ -DTFM_EXTRAS_REPO_PATH=3D${S}/external/tfm-extras \ - -DTFM_TEST_REPO_PATH=3D${S}/external/tf-m-tests \ " =20 +# tf-m-tests directory +# The directory can be overridden by local tf-m-tests folder path. +TFM_TESTS_DIR ?=3D "${S}/external/tf-m-tests" + export CMAKE_BUILD_PARALLEL_LEVEL =3D "${@oe.utils.parallel_make(d, Fals= e)}" =20 AS[unexport] =3D "1" @@ -92,7 +95,13 @@ export OPENSSL_MODULES =3D "${STAGING_LIBDIR_NATIVE}/o= ssl-modules" =20 do_configure[cleandirs] =3D "${B}" do_configure() { - cmake -GNinja -S ${S} -B ${B} ${EXTRA_OECMAKE} ${PACKAGECONFIG_CONFA= RGS} + # When regression tests are enabled, TF-M is built under regression = test + # directory. + if [ "${BUILD_REGRESSION_TESTS}" =3D "1" ]; then + cmake -GNinja -S ${TFM_TESTS_DIR}/tests_reg/spe -B ${B} -DCONFIG= _TFM_SOURCE_PATH=3D${S} ${EXTRA_OECMAKE} + else + cmake -GNinja -S ${S} -B ${B} ${EXTRA_OECMAKE} + fi } =20 # Invoke install here as there's no point in splitting compile from inst= all: the @@ -110,6 +119,15 @@ do_install() { find ${B}/bin \( -name '*.bin' -o -name '*.elf' \) -type f | while r= ead -r file; do install -m 0644 "$file" "${D}${FIRMWARE_DIR}" done + + # Install for NS build + if [ -d "${B}/api_ns" ]; then + install -d -m 0755 ${D}/sysroot-only/api_ns + + cd ${B}/api_ns + find . -type d -exec install -d -m 0755 ${D}/sysroot-only/api_ns= /{} \; + find . -type f -exec install -m 0644 {} ${D}/sysroot-only/api_ns= /{} \; + fi } =20 # Build paths are currently embedded because it's impossible to pass -fd= ebug-prefix-map