1# Corstone1000 machines specific TFM support
2
3COMPATIBLE_MACHINE = "(corstone1000)"
4
5TFM_PLATFORM = "arm/corstone1000"
6
7TFM_DEBUG = "1"
8
9## Default is the MPS3 board
10TFM_PLATFORM_IS_FVP ?= "FALSE"
11EXTRA_OECMAKE += "-DPLATFORM_IS_FVP=${TFM_PLATFORM_IS_FVP}"
12EXTRA_OECMAKE += "-DCC312_LEGACY_DRIVER_API_ENABLED=OFF"
13
14# libmetal v2023.04.0
15LICENSE += "& BSD-3-Clause"
16LIC_FILES_CHKSUM += "file://../libmetal/LICENSE.md;md5=f4d5df0f12dcea1b1a0124219c0dbab4"
17SRC_URI += "git://github.com/OpenAMP/libmetal.git;protocol=https;branch=main;name=libmetal;destsuffix=git/libmetal \
18            file://0001-cmake-modify-path-to-libmetal-version-file.patch;patchdir=../libmetal \
19            file://0002-arm-trusted-firmware-m-disable-address-warnings-into.patch \
20           "
21SRCREV_libmetal = "28fa2351d6a8121ce6c1c2ac5ee43ce08d38dbae"
22EXTRA_OECMAKE += "-DLIBMETAL_SRC_PATH=${S}/../libmetal -DLIBMETAL_BIN_PATH=${B}/libmetal-build"
23# The configuration can fail if libmetal tries to generate the docs and the doxygen bin is found
24EXTRA_OECMAKE += "-DWITH_DOC=False"
25
26# OpenAMP v2023.04.0
27LICENSE += "& BSD-2-Clause & BSD-3-Clause"
28LIC_FILES_CHKSUM += "file://../openamp/LICENSE.md;md5=ab88daf995c0bd0071c2e1e55f3d3505"
29SRC_URI += "git://github.com/OpenAMP/open-amp.git;protocol=https;branch=main;name=openamp;destsuffix=git/openamp"
30SRCREV_openamp = "accac4d3610cbb268f3c3fe3c31dc45dd4c4dd17"
31EXTRA_OECMAKE += "-DLIBOPENAMP_SRC_PATH=${S}/../openamp -DLIBOPENAMP_BIN_PATH=${B}/libopenamp-build"
32
33
34FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
35SRC_URI:append:corstone1000 = " \
36    file://0001-platform-corstone1000-Update-MPU-configuration.patch \
37    file://0002-platform-corstone1000-Cover-S_DATA-with-MPU.patch \
38    file://0003-Platform-corstone1000-Fix-issues-due-to-adjustment-M.patch \
39    file://0004-platform-corstone1000-align-capsule-update-structs.patch \
40    file://0005-platform-corstone1000-fix-synchronization-issue-on-o.patch \
41    file://0006-Platform-Corstone1000-skip-the-first-nv-counter.patch \
42    file://0007-platform-corstone1000-add-unique-guid-for-mps3.patch \
43    "
44
45# TF-M ships patches for external dependencies that needs to be applied
46apply_tfm_patches() {
47    find ${S}/lib/ext/qcbor -type f -name '*.patch' -print0 | sort -z | xargs -r -t -0 -n 1 patch -p1 -d ${S}/../qcbor/ -i
48    find ${S}/lib/ext/mbedcrypto -type f -name '*.patch' -print0 | sort -z | xargs -r -t -0 -n 1 patch -p1 -d ${S}/../mbedtls/ -i
49    find ${S}/lib/ext/mcuboot -type f -name '*.patch' -print0 | sort -z | xargs -r -t -0 -n 1 patch -p1 -d ${S}/../mcuboot/ -i
50    find ${S}/lib/ext/tf-m-tests -type f -name '*.patch' -print0 | sort -z | xargs -r -t -0 -n 1 patch -p1 -d ${S}/../tf-m-tests/ -i
51}
52
53do_patch[postfuncs] += "apply_tfm_patches"
54
55do_install() {
56  install -D -p -m 0644 ${B}/bin/tfm_s_signed.bin ${D}/firmware/tfm_s_signed.bin
57  install -D -p -m 0644 ${B}/bin/bl2_signed.bin ${D}/firmware/bl2_signed.bin
58  install -D -p -m 0644 ${B}/bin/bl1_1.bin ${D}/firmware/bl1_1.bin
59  install -D -p -m 0644 ${B}/bin/bl1_provisioning_bundle.bin ${D}/firmware/bl1_provisioning_bundle.bin
60}
61
62create_bl1_image(){
63    dd conv=notrunc bs=1 if=${D}/firmware/bl1_1.bin of=${D}/firmware/bl1.bin seek=0
64    dd conv=notrunc bs=1 if=${D}/firmware/bl1_provisioning_bundle.bin of=${D}/firmware/bl1.bin seek=40960
65}
66do_install[postfuncs] += "create_bl1_image"
67