blob: c10efd5a62dde4f298dffafa31c4819c9c0b9e74 [file] [log] [blame]
Brad Bishopbec4ebc2022-08-03 09:55:16 -04001# 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
11LICENSE = "BSD-3-Clause & Apache-2.0"
12
13LIC_FILES_CHKSUM = "file://license.rst;md5=07f368487da347f3c7bd0fc3085f3afa \
14 file://../tf-m-tests/license.rst;md5=02d06ffb8d9f099ff4961c0cb0183a18 \
15 file://../mbedtls/LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57 \
16 file://../mcuboot/LICENSE;md5=b6ee33f1d12a5e6ee3de1e82fb51eeb8"
17
18SRC_URI = "git://git.trustedfirmware.org/TF-M/trusted-firmware-m.git;protocol=https;branch=${SRCBRANCH_tfm};name=tfm;destsuffix=git/tfm \
Patrick Williams8dd68482022-10-04 07:57:18 -050019 git://git.trustedfirmware.org/TF-M/tf-m-tests.git;protocol=https;branch=${SRCBRANCH_tfm-tests};name=tfm-tests;destsuffix=git/tf-m-tests \
20 git://github.com/ARMmbed/mbedtls.git;protocol=https;branch=${SRCBRANCH_mbedtls};name=mbedtls;destsuffix=git/mbedtls \
21 git://github.com/mcu-tools/mcuboot.git;protocol=https;branch=${SRCBRANCH_mcuboot};name=mcuboot;destsuffix=git/mcuboot \
Brad Bishopbec4ebc2022-08-03 09:55:16 -040022 "
23
24# The required dependencies are documented in tf-m/config/config_default.cmake
25# TF-Mv1.6.0
Patrick Williams8dd68482022-10-04 07:57:18 -050026SRCBRANCH_tfm ?= "release/1.6.x"
Brad Bishopbec4ebc2022-08-03 09:55:16 -040027SRCREV_tfm = "7387d88158701a3c51ad51c90a05326ee12847a8"
28# mbedtls-3.1.0
Patrick Williams8dd68482022-10-04 07:57:18 -050029SRCBRANCH_mbedtls ?= "master"
Brad Bishopbec4ebc2022-08-03 09:55:16 -040030SRCREV_mbedtls = "d65aeb37349ad1a50e0f6c9b694d4b5290d60e49"
31# TF-Mv1.6.0
Patrick Williams8dd68482022-10-04 07:57:18 -050032SRCBRANCH_tfm-tests ?= "release/1.6.x"
Brad Bishopbec4ebc2022-08-03 09:55:16 -040033SRCREV_tfm-tests = "723905d46019596f3f2df66d79b5d6bff6f3f213"
34# v1.9.0
Patrick Williams8dd68482022-10-04 07:57:18 -050035SRCBRANCH_mcuboot ?= "main"
Brad Bishopbec4ebc2022-08-03 09:55:16 -040036SRCREV_mcuboot = "c657cbea75f2bb1faf1fceacf972a0537a8d26dd"
37
38UPSTREAM_CHECK_GITTAGREGEX = "^TF-Mv(?P<pver>\d+(\.\d+)+)$"
39
40# Note to future readers of this recipe: until the CMakeLists don't abuse
41# installation (see do_install) there is no point in trying to inherit
42# cmake here. You can easily short-circuit the toolchain but the install
43# is so convoluted there's no gain.
44
45inherit python3native deploy
46
47# Baremetal and we bring a compiler below
48INHIBIT_DEFAULT_DEPS = "1"
49
50PACKAGE_ARCH = "${MACHINE_ARCH}"
51
52DEPENDS += "cmake-native \
53 ninja-native \
54 gcc-arm-none-eabi-native \
55 python3-intelhex-native \
56 python3-jinja2-native \
57 python3-pyyaml-native \
58 python3-click-native \
59 python3-cryptography-native \
60 python3-cbor2-native"
61
62S = "${WORKDIR}/git/tfm"
63B = "${WORKDIR}/build"
64
65# Build for debug (set TFM_DEBUG to 1 to activate)
66TFM_DEBUG ?= "0"
67
68# Platform must be set, ideally in the machine configuration.
69TFM_PLATFORM ?= ""
70python() {
71 if not d.getVar("TFM_PLATFORM"):
72 raise bb.parse.SkipRecipe("TFM_PLATFORM needs to be set")
73}
74
75PACKAGECONFIG ??= ""
76# Whether to integrate the test suite
77PACKAGECONFIG[test-secure] = "-DTEST_S=ON,-DTEST_S=OFF"
78PACKAGECONFIG[test-nonsecure] = "-DTEST_NS=ON,-DTEST_NS=OFF"
79
80# Currently we only support using the Arm binary GCC
81EXTRA_OECMAKE += "-DTFM_TOOLCHAIN_FILE=${S}/toolchain_GNUARM.cmake"
82
83# Don't let FetchContent download more sources during do_configure
84EXTRA_OECMAKE += "-DFETCHCONTENT_FULLY_DISCONNECTED=ON"
85
86# Add platform parameters
87EXTRA_OECMAKE += "-DTFM_PLATFORM=${TFM_PLATFORM}"
88
89# Handle TFM_DEBUG parameter
90EXTRA_OECMAKE += "${@bb.utils.contains('TFM_DEBUG', '1', '-DCMAKE_BUILD_TYPE=Debug', '', d)}"
91
92# Verbose builds
93EXTRA_OECMAKE += "-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON"
94
95EXTRA_OECMAKE += "-DMBEDCRYPTO_PATH=${S}/../mbedtls -DTFM_TEST_REPO_PATH=${S}/../tf-m-tests -DMCUBOOT_PATH=${S}/../mcuboot"
96
97export CMAKE_BUILD_PARALLEL_LEVEL = "${@oe.utils.parallel_make(d, False)}"
98
99# Let the Makefile handle setting up the CFLAGS and LDFLAGS as it is a standalone application
100CFLAGS[unexport] = "1"
101LDFLAGS[unexport] = "1"
102AS[unexport] = "1"
103LD[unexport] = "1"
104
105# python3-cryptography needs the legacy provider, so set OPENSSL_MODULES to the
106# right path until this is relocated automatically.
107export OPENSSL_MODULES="${STAGING_LIBDIR_NATIVE}/ossl-modules"
108
109# TF-M ships patches that it needs applied to mbedcrypto, so apply them
110# as part of do_patch.
111apply_local_patches() {
112 cat ${S}/lib/ext/mbedcrypto/*.patch | patch -p1 -d ${S}/../mbedtls
113}
114do_patch[postfuncs] += "apply_local_patches"
115
116do_configure[cleandirs] = "${B}"
117do_configure() {
118 cmake -GNinja -S ${S} -B ${B} ${EXTRA_OECMAKE} ${PACKAGECONFIG_CONFARGS}
119}
120
121# Invoke install here as there's no point in splitting compile from install: the
122# first thing the build does is 'install' inside the build tree thus causing a
123# rebuild. It also overrides the install prefix to be in the build tree, so you
124# can't use the usual install prefix variables.
125do_compile() {
126 cmake --build ${B} -- install
127}
128do_compile[progress] = "outof:^\[(\d+)/(\d+)\]\s+"
129
130do_install() {
131 # TODO install headers and static libraries when we know how they're used
132 install -d -m 755 ${D}/firmware
133 install -m 0644 ${B}/bin/* ${D}/firmware/
134}
135
136FILES:${PN} = "/firmware"
137SYSROOT_DIRS += "/firmware"
138
139addtask deploy after do_install
140do_deploy() {
141 cp -rf ${D}/firmware/* ${DEPLOYDIR}/
142}
143
144# Build paths are currently embedded
145INSANE_SKIP:${PN} += "buildpaths"