diff --git a/meta-arm/recipes-bsp/trusted-firmware-m/trusted-firmware-m.inc 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 += "cmake-native \ B = "${WORKDIR}/build" +# 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=ON). +BUILD_REGRESSION_TESTS ?= "0" + # Build for debug (set TFM_DEBUG to 1 to activate) TFM_DEBUG ?= "${FIRMWARE_DEBUG_BUILD}" @@ -53,11 +58,6 @@ python() { raise bb.parse.SkipRecipe("TFM_PLATFORM needs to be set") } -PACKAGECONFIG ??= "" -# Whether to integrate the test suite -PACKAGECONFIG[test-secure] = "-DTEST_S=ON,-DTEST_S=OFF" -PACKAGECONFIG[test-nonsecure] = "-DTEST_NS=ON,-DTEST_NS=OFF" - # Currently we only support using the Arm binary GCC EXTRA_OECMAKE += "-DTFM_TOOLCHAIN_FILE=${S}/toolchain_GNUARM.cmake" @@ -77,9 +77,12 @@ EXTRA_OECMAKE += "\ -DQCBOR_PATH=${S}/external/qcbor \ -DT_COSE_PATH=${S}/external/t_cose \ -DTFM_EXTRAS_REPO_PATH=${S}/external/tfm-extras \ - -DTFM_TEST_REPO_PATH=${S}/external/tf-m-tests \ " +# tf-m-tests directory +# The directory can be overridden by local tf-m-tests folder path. +TFM_TESTS_DIR ?= "${S}/external/tf-m-tests" + export CMAKE_BUILD_PARALLEL_LEVEL = "${@oe.utils.parallel_make(d, False)}" AS[unexport] = "1" @@ -92,7 +95,13 @@ export OPENSSL_MODULES = "${STAGING_LIBDIR_NATIVE}/ossl-modules" do_configure[cleandirs] = "${B}" do_configure() { - cmake -GNinja -S ${S} -B ${B} ${EXTRA_OECMAKE} ${PACKAGECONFIG_CONFARGS} + # When regression tests are enabled, TF-M is built under regression test + # directory. + if [ "${BUILD_REGRESSION_TESTS}" = "1" ]; then + cmake -GNinja -S ${TFM_TESTS_DIR}/tests_reg/spe -B ${B} -DCONFIG_TFM_SOURCE_PATH=${S} ${EXTRA_OECMAKE} + else + cmake -GNinja -S ${S} -B ${B} ${EXTRA_OECMAKE} + fi } # Invoke install here as there's no point in splitting compile from install: the @@ -110,6 +119,15 @@ do_install() { find ${B}/bin \( -name '*.bin' -o -name '*.elf' \) -type f | while read -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 } # Build paths are currently embedded because it's impossible to pass -fdebug-prefix-map