Andrew Geissler | 9347dd4 | 2023-03-03 12:38:41 -0600 | [diff] [blame^] | 1 | # SPDX-License-Identifier: MIT |
| 2 | # |
| 3 | # Copyright (c) 2020 Arm Limited |
| 4 | # |
| 5 | |
| 6 | SUMMARY = "Trusted Firmware for Cortex-M" |
| 7 | DESCRIPTION = "Trusted Firmware-M" |
| 8 | HOMEPAGE = "https://git.trustedfirmware.org/trusted-firmware-m.git" |
| 9 | PROVIDES = "virtual/trusted-firmware-m" |
| 10 | |
| 11 | SRC_URI += "file://rwx.patch" |
| 12 | |
| 13 | UPSTREAM_CHECK_GITTAGREGEX = "^TF-Mv(?P<pver>\d+(\.\d+)+)$" |
| 14 | |
| 15 | # Note to future readers of this recipe: until the CMakeLists don't abuse |
| 16 | # installation (see do_install) there is no point in trying to inherit |
| 17 | # cmake here. You can easily short-circuit the toolchain but the install |
| 18 | # is so convoluted there's no gain. |
| 19 | |
| 20 | inherit python3native deploy |
| 21 | |
| 22 | # Baremetal and we bring a compiler below |
| 23 | INHIBIT_DEFAULT_DEPS = "1" |
| 24 | |
| 25 | PACKAGE_ARCH = "${MACHINE_ARCH}" |
| 26 | |
| 27 | # See tools/requirements.txt for Python dependencies |
| 28 | DEPENDS += "cmake-native \ |
| 29 | ninja-native \ |
| 30 | gcc-arm-none-eabi-native \ |
| 31 | python3-cbor2-native \ |
| 32 | python3-click-native \ |
| 33 | python3-cryptography-native \ |
| 34 | python3-pyasn1-native \ |
| 35 | python3-imgtool-native \ |
| 36 | python3-jinja2-native \ |
| 37 | python3-pyyaml-native \ |
| 38 | python3-pyhsslms-native \ |
| 39 | python3-ecdsa-native \ |
| 40 | python3-kconfiglib-native \ |
| 41 | " |
| 42 | |
| 43 | B = "${WORKDIR}/build" |
| 44 | |
| 45 | # Build for debug (set TFM_DEBUG to 1 to activate) |
| 46 | TFM_DEBUG ?= "0" |
| 47 | |
| 48 | # Platform must be set, ideally in the machine configuration. |
| 49 | TFM_PLATFORM ?= "" |
| 50 | python() { |
| 51 | if not d.getVar("TFM_PLATFORM"): |
| 52 | raise bb.parse.SkipRecipe("TFM_PLATFORM needs to be set") |
| 53 | } |
| 54 | |
| 55 | PACKAGECONFIG ??= "" |
| 56 | # Whether to integrate the test suite |
| 57 | PACKAGECONFIG[test-secure] = "-DTEST_S=ON,-DTEST_S=OFF" |
| 58 | PACKAGECONFIG[test-nonsecure] = "-DTEST_NS=ON,-DTEST_NS=OFF" |
| 59 | |
| 60 | # Currently we only support using the Arm binary GCC |
| 61 | EXTRA_OECMAKE += "-DTFM_TOOLCHAIN_FILE=${S}/toolchain_GNUARM.cmake" |
| 62 | |
| 63 | # Don't let FetchContent download more sources during do_configure |
| 64 | EXTRA_OECMAKE += "-DFETCHCONTENT_FULLY_DISCONNECTED=ON" |
| 65 | |
| 66 | # Add platform parameters |
| 67 | EXTRA_OECMAKE += "-DTFM_PLATFORM=${TFM_PLATFORM}" |
| 68 | |
| 69 | # Handle TFM_DEBUG parameter |
| 70 | EXTRA_OECMAKE += "${@bb.utils.contains('TFM_DEBUG', '1', '-DCMAKE_BUILD_TYPE=Debug', '-DCMAKE_BUILD_TYPE=Release', d)}" |
| 71 | |
| 72 | # Verbose builds |
| 73 | EXTRA_OECMAKE += "-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON" |
| 74 | |
| 75 | EXTRA_OECMAKE += "-DMBEDCRYPTO_PATH=${S}/../mbedtls -DTFM_TEST_REPO_PATH=${S}/../tf-m-tests -DMCUBOOT_PATH=${S}/../mcuboot -DQCBOR_PATH=${S}/../qcbor" |
| 76 | |
| 77 | export CMAKE_BUILD_PARALLEL_LEVEL = "${@oe.utils.parallel_make(d, False)}" |
| 78 | |
| 79 | # Let the Makefile handle setting up the CFLAGS and LDFLAGS as it is a standalone application |
| 80 | CFLAGS[unexport] = "1" |
| 81 | LDFLAGS[unexport] = "1" |
| 82 | AS[unexport] = "1" |
| 83 | LD[unexport] = "1" |
| 84 | |
| 85 | # python3-cryptography needs the legacy provider, so set OPENSSL_MODULES to the |
| 86 | # right path until this is relocated automatically. |
| 87 | export OPENSSL_MODULES="${STAGING_LIBDIR_NATIVE}/ossl-modules" |
| 88 | |
| 89 | do_configure[cleandirs] = "${B}" |
| 90 | do_configure() { |
| 91 | cmake -GNinja -S ${S} -B ${B} ${EXTRA_OECMAKE} ${PACKAGECONFIG_CONFARGS} |
| 92 | } |
| 93 | |
| 94 | # Invoke install here as there's no point in splitting compile from install: the |
| 95 | # first thing the build does is 'install' inside the build tree thus causing a |
| 96 | # rebuild. It also overrides the install prefix to be in the build tree, so you |
| 97 | # can't use the usual install prefix variables. |
| 98 | do_compile() { |
| 99 | cmake --build ${B} -- install |
| 100 | } |
| 101 | do_compile[progress] = "outof:^\[(\d+)/(\d+)\]\s+" |
| 102 | |
| 103 | do_install() { |
| 104 | # TODO install headers and static libraries when we know how they're used |
| 105 | install -d -m 755 ${D}/firmware |
| 106 | install -m 0644 ${B}/bin/* ${D}/firmware/ |
| 107 | } |
| 108 | |
| 109 | FILES:${PN} = "/firmware" |
| 110 | SYSROOT_DIRS += "/firmware" |
| 111 | |
| 112 | addtask deploy after do_install |
| 113 | do_deploy() { |
| 114 | cp -rf ${D}/firmware/* ${DEPLOYDIR}/ |
| 115 | } |
| 116 | |
| 117 | # Build paths are currently embedded |
| 118 | INSANE_SKIP:${PN} += "buildpaths" |