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