blob: 9062df8c809ffbda225f3fb726f5e5da8b5dd87e [file] [log] [blame]
Andrew Geissler9347dd42023-03-03 12:38:41 -06001# SPDX-License-Identifier: MIT
2#
3# Copyright (c) 2020 Arm Limited
4#
5
6SUMMARY = "Trusted Firmware for Cortex-M"
7DESCRIPTION = "Trusted Firmware-M"
8HOMEPAGE = "https://git.trustedfirmware.org/trusted-firmware-m.git"
9PROVIDES = "virtual/trusted-firmware-m"
10
11SRC_URI += "file://rwx.patch"
12
13UPSTREAM_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
20inherit python3native deploy
21
22# Baremetal and we bring a compiler below
23INHIBIT_DEFAULT_DEPS = "1"
24
25PACKAGE_ARCH = "${MACHINE_ARCH}"
26
27# See tools/requirements.txt for Python dependencies
28DEPENDS += "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
43B = "${WORKDIR}/build"
44
45# Build for debug (set TFM_DEBUG to 1 to activate)
46TFM_DEBUG ?= "0"
47
48# Platform must be set, ideally in the machine configuration.
49TFM_PLATFORM ?= ""
50python() {
51 if not d.getVar("TFM_PLATFORM"):
52 raise bb.parse.SkipRecipe("TFM_PLATFORM needs to be set")
53}
54
55PACKAGECONFIG ??= ""
56# Whether to integrate the test suite
57PACKAGECONFIG[test-secure] = "-DTEST_S=ON,-DTEST_S=OFF"
58PACKAGECONFIG[test-nonsecure] = "-DTEST_NS=ON,-DTEST_NS=OFF"
59
60# Currently we only support using the Arm binary GCC
61EXTRA_OECMAKE += "-DTFM_TOOLCHAIN_FILE=${S}/toolchain_GNUARM.cmake"
62
63# Don't let FetchContent download more sources during do_configure
64EXTRA_OECMAKE += "-DFETCHCONTENT_FULLY_DISCONNECTED=ON"
65
66# Add platform parameters
67EXTRA_OECMAKE += "-DTFM_PLATFORM=${TFM_PLATFORM}"
68
69# Handle TFM_DEBUG parameter
70EXTRA_OECMAKE += "${@bb.utils.contains('TFM_DEBUG', '1', '-DCMAKE_BUILD_TYPE=Debug', '-DCMAKE_BUILD_TYPE=Release', d)}"
71
72# Verbose builds
73EXTRA_OECMAKE += "-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON"
74
75EXTRA_OECMAKE += "-DMBEDCRYPTO_PATH=${S}/../mbedtls -DTFM_TEST_REPO_PATH=${S}/../tf-m-tests -DMCUBOOT_PATH=${S}/../mcuboot -DQCBOR_PATH=${S}/../qcbor"
76
77export 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
80CFLAGS[unexport] = "1"
81LDFLAGS[unexport] = "1"
82AS[unexport] = "1"
83LD[unexport] = "1"
84
85# python3-cryptography needs the legacy provider, so set OPENSSL_MODULES to the
86# right path until this is relocated automatically.
87export OPENSSL_MODULES="${STAGING_LIBDIR_NATIVE}/ossl-modules"
88
89do_configure[cleandirs] = "${B}"
90do_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.
98do_compile() {
99 cmake --build ${B} -- install
100}
101do_compile[progress] = "outof:^\[(\d+)/(\d+)\]\s+"
102
103do_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
109FILES:${PN} = "/firmware"
110SYSROOT_DIRS += "/firmware"
111
112addtask deploy after do_install
113do_deploy() {
114 cp -rf ${D}/firmware/* ${DEPLOYDIR}/
115}
116
117# Build paths are currently embedded
118INSANE_SKIP:${PN} += "buildpaths"