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