Adds support for TrustedFirmware-M
v4 cover Adds support for TrustedFirmware-M
This series adds support for TrustedFirmware-M (TF-M).
https://trustedfirmware-m.readthedocs.io
https://git.trustedfirmware.org/TF-M/trusted-firmware-m.git
Trusted Firmware-M implements the Secure Processing Environment (SPE) for Armv8-M, Armv8.1-M architectures (e.g. the Cortex-M33, Cortex-M23, Cortex-M55, Cortex-M85 processors) or dual-core platforms.
Patches 1-3: Address host Python package dependencies. Patch 4: Add support for TF-M.
Changes in v4:
- Fix a recursive dependency loop issue.
Changes in v3:
- Add select BR2_HOST_CMAKE_AT_LEAST_3_21 to avoid cmake configure error due to old cmake version.
- Fix a Kconfig warning.
Changes in v2:
- Add TF-M to DEVELOPERS file
- Fix few nit.
Kory Maincent (4):
package/python-intelhex: Add support for host package package/python-click: Add support for host package package/python-cbor2: Add support for host package
boot: Add support for TrustedFirmware-M package
DEVELOPERS | 1 + boot/Config.in | 1 + boot/trusted-firmware-m/Config.in | 102 +++++++++++++++ boot/trusted-firmware-m/tfm-3rdparty.mk | 7 + boot/trusted-firmware-m/tfm-cmsis/Config.in | 10 ++ .../tfm-cmsis/tfm-cmsis.hash | 3 + .../trusted-firmware-m/tfm-cmsis/tfm-cmsis.mk | 23 ++++ boot/trusted-firmware-m/tfm-mbedtls/Config.in | 10 ++ .../tfm-mbedtls/tfm-mbedtls.hash | 3 + .../tfm-mbedtls/tfm-mbedtls.mk | 24 ++++ boot/trusted-firmware-m/tfm-mcuboot/Config.in | 10 ++ .../tfm-mcuboot/tfm-mcuboot.hash | 3 + .../tfm-mcuboot/tfm-mcuboot.mk | 23 ++++ boot/trusted-firmware-m/tfm-qcbor/Config.in | 10 ++ .../tfm-qcbor/tfm-qcbor.hash | 3 + .../trusted-firmware-m/tfm-qcbor/tfm-qcbor.mk | 23 ++++ boot/trusted-firmware-m/tfm-tests/Config.in | 10 ++ .../tfm-tests/tfm-tests.hash | 3 + .../trusted-firmware-m/tfm-tests/tfm-tests.mk | 24 ++++ .../trusted-firmware-m.hash | 3 + boot/trusted-firmware-m/trusted-firmware-m.mk | 120 ++++++++++++++++++ package/python-cbor2/python-cbor2.mk | 3 + package/python-click/python-click.mk | 1 + package/python-intelhex/python-intelhex.mk | 1 + support/testing/tests/boot/test_tfm.py | 12 ++ 25 files changed, 433 insertions(+) create mode 100644 boot/trusted-firmware-m/Config.in create mode 100644 boot/trusted-firmware-m/tfm-3rdparty.mk create mode 100644 boot/trusted-firmware-m/tfm-cmsis/Config.in create mode 100644 boot/trusted-firmware-m/tfm-cmsis/tfm-cmsis.hash create mode 100644 boot/trusted-firmware-m/tfm-cmsis/tfm-cmsis.mk create mode 100644 boot/trusted-firmware-m/tfm-mbedtls/Config.in create mode 100644 boot/trusted-firmware-m/tfm-mbedtls/tfm-mbedtls.hash create mode 100644 boot/trusted-firmware-m/tfm-mbedtls/tfm-mbedtls.mk create mode 100644 boot/trusted-firmware-m/tfm-mcuboot/Config.in create mode 100644 boot/trusted-firmware-m/tfm-mcuboot/tfm-mcuboot.hash create mode 100644 boot/trusted-firmware-m/tfm-mcuboot/tfm-mcuboot.mk create mode 100644 boot/trusted-firmware-m/tfm-qcbor/Config.in create mode 100644 boot/trusted-firmware-m/tfm-qcbor/tfm-qcbor.hash create mode 100644 boot/trusted-firmware-m/tfm-qcbor/tfm-qcbor.mk create mode 100644 boot/trusted-firmware-m/tfm-tests/Config.in create mode 100644 boot/trusted-firmware-m/tfm-tests/tfm-tests.hash create mode 100644 boot/trusted-firmware-m/tfm-tests/tfm-tests.mk create mode 100644 boot/trusted-firmware-m/trusted-firmware-m.hash create mode 100644 boot/trusted-firmware-m/trusted-firmware-m.mk create mode 100644 support/testing/tests/boot/test_tfm.py
Signature · 6 lines
2.25.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH v4 1/4 package/python-intelhex: Add support for host package
Add support for the host package to enable future support for TrustedFirmware-M, which depends on it.
--- package/python-intelhex/python-intelhex.mk | 1 + 1 file changed, 1 insertion(+)
package/python-intelhex/python-intelhex.mk +1 -0
@@ -12,3 +12,4 @@ PYTHON_INTELHEX_LICENSE = BSD-3-Clause PYTHON_INTELHEX_LICENSE_FILES = LICENSE.txt $(eval $(python-package)) +$(eval $(host-python-package))
Signature · 6 lines
2.25.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH v4 2/4 package/python-click: Add support for host package
In reply to Kory Maincent via buildrootAdd support for the host package to enable future support for TrustedFirmware-M, which depends on it.
--- package/python-click/python-click.mk | 1 + 1 file changed, 1 insertion(+)
package/python-click/python-click.mk +1 -0
@@ -12,3 +12,4 @@ PYTHON_CLICK_LICENSE_FILES = LICENSE.rst PYTHON_CLICK_SETUP_TYPE = setuptools $(eval $(python-package)) +$(eval $(host-python-package))
Signature · 6 lines
2.25.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH v4 3/4 package/python-cbor2: Add support for host package
In reply to Kory Maincent via buildrootAdd support for the host package to enable future support for TrustedFirmware-M, which depends on it.
--- package/python-cbor2/python-cbor2.mk | 3 +++ 1 file changed, 3 insertions(+)
package/python-cbor2/python-cbor2.mk +3 -0
@@ -12,5 +12,8 @@ PYTHON_CBOR2_LICENSE = MIT PYTHON_CBOR2_LICENSE_FILES = LICENSE.txt PYTHON_CBOR2_DEPENDENCIES = host-python-setuptools-scm PYTHON_CBOR2_ENV = CBOR2_BUILD_C_EXTENSION=1 +HOST_PYTHON_CBOR2_SETUP_TYPE = pep517 +HOST_PYTHON_CBOR2_DEPENDENCIES += host-python-setuptools-scm $(eval $(python-package)) +$(eval $(host-python-package))
Signature · 6 lines
2.25.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH v4 3/4] package/python-cbor2: Add support for host package
Quoted 13 lines · Kory Maincent via buildroot
Add support for the host package to enable future support for TrustedFirmware-M, which depends on it.
Signed-off-by Kory Maincent <[email protected]>--- package/python-cbor2/python-cbor2.mk | 3 +++ 1 file changed, 3 insertions(+)package/python-cbor2/python-cbor2.mk +0
-0
package/python-cbor2/python-cbor2.mk PYTHON_CBOR2_LICENSE = MIT · line 15
Quoted 4 lines
package/python-cbor2/python-cbor2.mk +1
-0@@ -12,5 +12,8 @@ PYTHON_CBOR2_LICENSE = MIT PYTHON_CBOR2_LICENSE_FILES = LICENSE.txt PYTHON_CBOR2_DEPENDENCIES = host-python-setuptools-scm PYTHON_CBOR2_ENV = CBOR2_BUILD_C_EXTENSION=1 +HOST_PYTHON_CBOR2_SETUP_TYPE = pep517
The setup type is inherited from the target, and it would be weird that it
needs to be different... Of course, the only difference between setuptools and pep517 is that the former adds an additional dependency on host-python-setuptools.
Bottom line: this should be removed, and perhaps the target's setup type
should change to pep517.
Regards,
Arnout
package/python-cbor2/python-cbor2.mk PYTHON_CBOR2_LICENSE = MIT · line 19
Quoted 4 lines
package/python-cbor2/python-cbor2.mk +2
-0+HOST_PYTHON_CBOR2_DEPENDENCIES += host-python-setuptools-scm $(eval $(python-package)) +$(eval $(host-python-package))
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH v4 4/4 boot: Add support for TrustedFirmware-M package
In reply to Kory Maincent via buildrootAdd support for TrustedFirmware-M:
https://trustedfirmware-m.readthedocs.io
https://git.trustedfirmware.org/TF-M/trusted-firmware-m.git
Trusted Firmware-M (TF-M) implements the Secure Processing Environment (SPE) for Armv8-M, Armv8.1-M architectures (e.g. the Cortex-M33, Cortex-M23, Cortex-M55, Cortex-M85 processors) or dual-core platforms.
Use subpackages to download the third-party project sources to be able to apply patches located in the TF-M sources. This approach is also necessary because the tfm-tests git host produces non-reproducible tarballs.
---
Changes in v4:
- Fix a recursive dependency loop issue. TF-M was depend on 3rd parties which where was patch dependent on TF-M to have access to their patches. Instead patch the 3rd parties sources in the TF-M packages.
Changes in v3:
- Add select BR2_HOST_CMAKE_AT_LEAST_3_21 to avoid cmake configure error due to old cmake version.
- Fix a Kconfig check-package too long line warning.
Changes in v2:
- Add TF-M to DEVELOPERS file
- Fix few nit.
--- DEVELOPERS | 1 + boot/Config.in | 1 + boot/trusted-firmware-m/Config.in | 102 +++++++++++++++ boot/trusted-firmware-m/tfm-3rdparty.mk | 7 + boot/trusted-firmware-m/tfm-cmsis/Config.in | 10 ++ .../tfm-cmsis/tfm-cmsis.hash | 3 + .../trusted-firmware-m/tfm-cmsis/tfm-cmsis.mk | 23 ++++ boot/trusted-firmware-m/tfm-mbedtls/Config.in | 10 ++ .../tfm-mbedtls/tfm-mbedtls.hash | 3 + .../tfm-mbedtls/tfm-mbedtls.mk | 24 ++++ boot/trusted-firmware-m/tfm-mcuboot/Config.in | 10 ++ .../tfm-mcuboot/tfm-mcuboot.hash | 3 + .../tfm-mcuboot/tfm-mcuboot.mk | 23 ++++ boot/trusted-firmware-m/tfm-qcbor/Config.in | 10 ++ .../tfm-qcbor/tfm-qcbor.hash | 3 + .../trusted-firmware-m/tfm-qcbor/tfm-qcbor.mk | 23 ++++ boot/trusted-firmware-m/tfm-tests/Config.in | 10 ++ .../tfm-tests/tfm-tests.hash | 3 + .../trusted-firmware-m/tfm-tests/tfm-tests.mk | 24 ++++ .../trusted-firmware-m.hash | 3 + boot/trusted-firmware-m/trusted-firmware-m.mk | 120 ++++++++++++++++++ support/testing/tests/boot/test_tfm.py | 12 ++ 22 files changed, 428 insertions(+) create mode 100644 boot/trusted-firmware-m/Config.in create mode 100644 boot/trusted-firmware-m/tfm-3rdparty.mk create mode 100644 boot/trusted-firmware-m/tfm-cmsis/Config.in create mode 100644 boot/trusted-firmware-m/tfm-cmsis/tfm-cmsis.hash create mode 100644 boot/trusted-firmware-m/tfm-cmsis/tfm-cmsis.mk create mode 100644 boot/trusted-firmware-m/tfm-mbedtls/Config.in create mode 100644 boot/trusted-firmware-m/tfm-mbedtls/tfm-mbedtls.hash create mode 100644 boot/trusted-firmware-m/tfm-mbedtls/tfm-mbedtls.mk create mode 100644 boot/trusted-firmware-m/tfm-mcuboot/Config.in create mode 100644 boot/trusted-firmware-m/tfm-mcuboot/tfm-mcuboot.hash create mode 100644 boot/trusted-firmware-m/tfm-mcuboot/tfm-mcuboot.mk create mode 100644 boot/trusted-firmware-m/tfm-qcbor/Config.in create mode 100644 boot/trusted-firmware-m/tfm-qcbor/tfm-qcbor.hash create mode 100644 boot/trusted-firmware-m/tfm-qcbor/tfm-qcbor.mk create mode 100644 boot/trusted-firmware-m/tfm-tests/Config.in create mode 100644 boot/trusted-firmware-m/tfm-tests/tfm-tests.hash create mode 100644 boot/trusted-firmware-m/tfm-tests/tfm-tests.mk create mode 100644 boot/trusted-firmware-m/trusted-firmware-m.hash create mode 100644 boot/trusted-firmware-m/trusted-firmware-m.mk create mode 100644 support/testing/tests/boot/test_tfm.py
DEVELOPERS +1 -0
@@ -1976,6 +1976,7 @@ F: board/octavo/osd32mp1-brk/ F: board/octavo/osd32mp1-red/ F: configs/octavo_osd32mp1_brk_defconfig F: configs/octavo_osd32mp1_red_defconfig +F: boot/trusted-firmware-m/ N: Kris Bahnsen <[email protected]> F: package/wilc-firmware/
boot/Config.in +1 -0
@@ -19,6 +19,7 @@ source "boot/shim/Config.in" source "boot/syslinux/Config.in" source "boot/ti-k3-boot-firmware/Config.in" source "boot/ti-k3-r5-loader/Config.in" +source "boot/trusted-firmware-m/Config.in" source "boot/uboot/Config.in" source "boot/vexpress-firmware/Config.in" source "boot/xilinx-prebuilt/Config.in"
boot/trusted-firmware-m/Config.in new file +102 -0
102 lines not on this page · raw message
boot/trusted-firmware-m/tfm-3rdparty.mk new file +7 -0
@@ -0,0 +1,7 @@ +################################################################################ +# +# TrustedFirmware-M 3rd parties +# +################################################################################ + +include $(sort $(wildcard boot/trusted-firmware-m/*/*.mk))
boot/trusted-firmware-m/tfm-cmsis/Config.in new file +10 -0
@@ -0,0 +1,10 @@ +config BR2_TARGET_TFM_CMSIS + bool + +if BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_3RD_PARTY + +config BR2_TARGET_TFM_CMSIS_CUSTOM_TARBALL_LOCATION + string "URL of custom cmcis tarball" + default "$(call github,arm-software,cmsis_6)/d0c460c169.tar.gz" + +endif
boot/trusted-firmware-m/tfm-cmsis/tfm-cmsis.hash new file +3 -0
@@ -0,0 +1,3 @@ +# sha256 locally computed +sha256 d846342840831f9124157b69b8edcdfcacc5427691f5b3341f714f0235c3cc49 tfm-cmsis-d0c460c1697d210b49a4b90998195831c0cd325c.tar.gz +sha256 b40930bbcf80744c86c46a12bc9da056641d722716c378f5659b9e555ef833e1 LICENSE
boot/trusted-firmware-m/tfm-cmsis/tfm-cmsis.mk new file +23 -0
@@ -0,0 +1,23 @@ +################################################################################ +# +# cmcis +# +################################################################################ + +ifeq ($(BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_3RD_PARTY),y) +TFM_CMSIS_VERSION = custom +TFM_CMSIS_TARBALL = $(call qstrip,$(BR2_TARGET_TFM_CMSIS_CUSTOM_TARBALL_LOCATION)) +TFM_CMSIS_SITE = $(patsubst %/,%,$(dir $(TFM_CMSIS_TARBALL))) +TFM_CMSIS_SOURCE = $(notdir $(TFM_CMSIS_TARBALL)) +BR_NO_CHECK_HASH_FOR += $(TFM_CMSIS_SOURCE) +else +TFM_CMSIS_VERSION = d0c460c1697d210b49a4b90998195831c0cd325c +TFM_CMSIS_SITE = $(call github,arm-software,cmsis_6,$(TFM_CMSIS_VERSION)) +TFM_CMSIS_LICENSE = Apache-2.0 +TFM_CMSIS_LICENSE_FILES = LICENSE +endif + +# This components is not built and installed, because it is intended to +# be included as source in TrustedFirmware-M build. + +$(eval $(generic-package))
boot/trusted-firmware-m/tfm-mbedtls/Config.in new file +10 -0
@@ -0,0 +1,10 @@ +config BR2_TARGET_TFM_MBEDTLS + bool + +if BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_3RD_PARTY + +config BR2_TARGET_TFM_MBEDTLS_CUSTOM_TARBALL_LOCATION + string "URL of custom mbedtls tarball" + default "https://github.com/Mbed-TLS/mbedtls/releases/download/v3.6.0/mbedtls-3.6.0.tar.bz2" + +endif
boot/trusted-firmware-m/tfm-mbedtls/tfm-mbedtls.hash new file +3 -0
@@ -0,0 +1,3 @@ +# sha256 locally computed +sha256 3ecf94fcfdaacafb757786a01b7538a61750ebd85c4b024f56ff8ba1490fcd38 mbedtls-3.6.0.tar.bz2 +sha256 9b405ef4c89342f5eae1dd828882f931747f71001cfba7d114801039b52ad09b LICENSE
boot/trusted-firmware-m/tfm-mbedtls/tfm-mbedtls.mk new file +24 -0
@@ -0,0 +1,24 @@ +################################################################################ +# +# mbedtls +# +################################################################################ + +ifeq ($(BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_3RD_PARTY),y) +TFM_MBEDTLS_VERSION = custom +TFM_MBEDTLS_TARBALL = $(call qstrip,$(BR2_TARGET_TFM_MBEDTLS_CUSTOM_TARBALL_LOCATION)) +TFM_MBEDTLS_SITE = $(patsubst %/,%,$(dir $(TFM_MBEDTLS_TARBALL))) +TFM_MBEDTLS_SOURCE = $(notdir $(TFM_MBEDTLS_TARBALL)) +BR_NO_CHECK_HASH_FOR += $(TFM_MBEDTLS_SOURCE) +else +TFM_MBEDTLS_VERSION = 3.6.0 +TFM_MBEDTLS_SITE = https://github.com/Mbed-TLS/mbedtls/releases/download/v$(TFM_MBEDTLS_VERSION) +TFM_MBEDTLS_SOURCE = mbedtls-$(TFM_MBEDTLS_VERSION).tar.bz2 +TFM_MBEDTLS_LICENSE = Apache-2.0 or GPL-2.0-or-later +TFM_MBEDTLS_LICENSE_FILES = LICENSE +endif + +# This components is not built and installed, because it is intended to +# be included as source in TrustedFirmware-M build. + +$(eval $(generic-package))
boot/trusted-firmware-m/tfm-mcuboot/Config.in new file +10 -0
@@ -0,0 +1,10 @@ +config BR2_TARGET_TFM_MCUBOOT + bool + +if BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_3RD_PARTY + +config BR2_TARGET_TFM_MCUBOOT_CUSTOM_TARBALL_LOCATION + string "URL of custom mcuboot tarball" + default "$(call github,mcu-tools,mcuboot)/v2.1.0.tar.gz" + +endif
boot/trusted-firmware-m/tfm-mcuboot/tfm-mcuboot.hash new file +3 -0
@@ -0,0 +1,3 @@ +# sha256 locally computed +sha256 bcee8c4b5a51477b27c6c587d11f46388823626aba7bd5082c77864a89dcf1b7 tfm-mcuboot-v2.1.0.tar.gz +sha256 86438164119907debf649e2f9f18a43ad506d75421c9d9675700066b0456205d LICENSE
boot/trusted-firmware-m/tfm-mcuboot/tfm-mcuboot.mk new file +23 -0
@@ -0,0 +1,23 @@ +################################################################################ +# +# mcuboot +# +################################################################################ + +ifeq ($(BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_3RD_PARTY),y) +TFM_MCUBOOT_VERSION = custom +TFM_MCUBOOT_TARBALL = $(call qstrip,$(BR2_TARGET_TFM_MCUBOOT_CUSTOM_TARBALL_LOCATION)) +TFM_MCUBOOT_SITE = $(patsubst %/,%,$(dir $(TFM_MCUBOOT_TARBALL))) +TFM_MCUBOOT_SOURCE = $(notdir $(TFM_MCUBOOT_TARBALL)) +BR_NO_CHECK_HASH_FOR += $(TFM_MCUBOOT_SOURCE) +else +TFM_MCUBOOT_VERSION = v2.1.0 +TFM_MCUBOOT_SITE = $(call github,mcu-tools,mcuboot,$(TFM_MCUBOOT_VERSION)) +TFM_MCUBOOT_LICENSE = Apache-2.0 +TFM_MCUBOOT_LICENSE_FILES = LICENSE +endif + +# This components is not built and installed, because it is intended to +# be included as source in TrustedFirmware-M build. + +$(eval $(generic-package))
boot/trusted-firmware-m/tfm-qcbor/Config.in new file +10 -0
@@ -0,0 +1,10 @@ +config BR2_TARGET_TFM_QCBOR + bool + +if BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_3RD_PARTY + +config BR2_TARGET_TFM_QCBOR_CUSTOM_TARBALL_LOCATION + string "URL of custom qcbor tarball" + default "$(call github,laurencelundblade,qcbor)/v1.2.tar.gz" + +endif
boot/trusted-firmware-m/tfm-qcbor/tfm-qcbor.hash new file +3 -0
@@ -0,0 +1,3 @@ +# sha256 locally computed +sha256 0f706ad90ada600bd1ddbdf8dc6f2f5910e11de355bb4454b9b4123f0e4ff525 tfm-qcbor-v1.2.tar.gz +sha256 fc6db297a2751188d9c2ece6ee468a295f285b9a24f96eab954a1a823c71be3b README.md
boot/trusted-firmware-m/tfm-qcbor/tfm-qcbor.mk new file +23 -0
@@ -0,0 +1,23 @@ +################################################################################ +# +# qcbor +# +################################################################################ + +ifeq ($(BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_3RD_PARTY),y) +TFM_QCBOR_VERSION = custom +TFM_QCBOR_TARBALL = $(call qstrip,$(BR2_TARGET_TFM_QCBOR_CUSTOM_TARBALL_LOCATION)) +TFM_QCBOR_SITE = $(patsubst %/,%,$(dir $(TFM_QCBOR_TARBALL))) +TFM_QCBOR_SOURCE = $(notdir $(TFM_QCBOR_TARBALL)) +BR_NO_CHECK_HASH_FOR += $(TFM_QCBOR_SOURCE) +else +TFM_QCBOR_VERSION = v1.2 +TFM_QCBOR_SITE = $(call github,laurencelundblade,qcbor,$(TFM_QCBOR_VERSION)) +TFM_QCBOR_LICENSE = BSD-3-Clause +TFM_QCBOR_LICENSE_FILES = README.md +endif + +# This components is not built and installed, because it is intended to +# be included as source in TrustedFirmware-M build. + +$(eval $(generic-package))
boot/trusted-firmware-m/tfm-tests/Config.in new file +10 -0
@@ -0,0 +1,10 @@ +config BR2_TARGET_TFM_TESTS + bool + +if BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_3RD_PARTY + +config BR2_TARGET_TFM_TESTS_CUSTOM_TARBALL_LOCATION + string "URL of custom TF-M-tests tarball" + default "https://git.trustedfirmware.org/TF-M/tf-m-tests.git/+archive/TF-Mv2.1.0.tar.gz" + +endif
boot/trusted-firmware-m/tfm-tests/tfm-tests.hash new file +3 -0
@@ -0,0 +1,3 @@ +# sha256 locally computed +sha256 409dee3cbbceb3f1ea2543cfc9e06a9de23706f5ae798b866d0f12b0c21a7bd5 tfm-tests-TF-Mv2.1.0-br1.tar.gz +sha256 42195e7f4ae4655d000688af4d4b143048352461dff5849d24e5afe6d1d84808 license.rst
boot/trusted-firmware-m/tfm-tests/tfm-tests.mk new file +24 -0
@@ -0,0 +1,24 @@ +################################################################################ +# +# TF-M tests +# +################################################################################ + +ifeq ($(BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_3RD_PARTY),y) +TFM_TESTS_VERSION = custom +TFM_TESTS_TARBALL = $(call qstrip,$(BR2_TARGET_TFM_TESTS_CUSTOM_TARBALL_LOCATION)) +TFM_TESTS_SITE = $(patsubst %/,%,$(dir $(TFM_TESTS_TARBALL))) +TFM_TESTS_SOURCE = $(notdir $(TFM_TESTS_TARBALL)) +BR_NO_CHECK_HASH_FOR += $(TFM_TESTS_SOURCE) +else +TFM_TESTS_VERSION = TF-Mv2.1.0 +TFM_TESTS_SITE = https://git.trustedfirmware.org/TF-M/trusted-firmware-m.git +TFM_TESTS_SITE_METHOD = git +TFM_TESTS_LICENSE = BSD-3-Clause +TFM_TESTS_LICENSE_FILES = license.rst +endif + +# This components is not built and installed, because it is intended to +# be included as source in TrustedFirmware-M build. + +$(eval $(generic-package))
boot/trusted-firmware-m/trusted-firmware-m.hash new file +3 -0
@@ -0,0 +1,3 @@ +# Locally calculated +sha256 5da6aee3e3dffbde61ee061fed8fc0b693ce934a8a707c91b19916e9b1ade638 trusted-firmware-m-0c4c99ba33b3e66deea070e149279278dc7647f4-br1.tar.gz +sha256 c16df600171bfdae60d22a01f046d742f89ba1046e2e5ed135bbf091b21be34f license.rst
boot/trusted-firmware-m/trusted-firmware-m.mk new file +120 -0
120 lines not on this page · raw message
support/testing/tests/boot/test_tfm.py new file +12 -0
@@ -0,0 +1,12 @@ +import infra.basetest + + +class TestTFMBuild(infra.basetest.BRTest): + config = \ + """ + BR2_TARGET_TRUSTED_FIRMWARE_M=y + BR2_TARGET_TRUSTED_FIRMWARE_M_PLATFORM="arm/mps2/an521" + """ + + def test_run(self): + pass
Signature · 6 lines
2.25.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH v4 4/4] boot: Add support for TrustedFirmware-M package
Hi Kory, all,
Lot's of comments on this one! Joy! I'll mark the series as Changes Requested.
Quoted 27 lines · Kory Maincent via buildroot
Add support for TrustedFirmware-M:
https://trustedfirmware-m.readthedocs.io
https://git.trustedfirmware.org/TF-M/trusted-firmware-m.gitTrusted Firmware-M (TF-M) implements the Secure Processing Environment (SPE) for Armv8-M, Armv8.1-M architectures (e.g. the Cortex-M33, Cortex-M23, Cortex-M55, Cortex-M85 processors) or dual-core platforms.
Use subpackages to download the third-party project sources to be able to apply patches located in the TF-M sources. This approach is also necessary because the tfm-tests git host produces non-reproducible tarballs.
Signed-off-by Kory Maincent <[email protected]>---
Changes in v4:
- Fix a recursive dependency loop issue. TF-M was depend on 3rd parties which where was patch dependent on TF-M to have access to their patches. Instead patch the 3rd parties sources in the TF-M packages.Changes in v3:
- Add selectBR2_HOST_CMAKE_AT_LEAST_3_21to avoid cmake configure error due to old cmake version.
- Fix aKconfigcheck-package too long line warning.Changes in v2:
- Add TF-M to DEVELOPERS file
- Fix few nit.
[snip]
Quoted 7 lines
boot/trusted-firmware-m/Config.in new file +1
-0@@ -0,0 +1,102 @@ +config BR2_TARGET_TRUSTED_FIRMWARE_M
boot/trusted-firmware-m/Config.in line 11
Quoted 10 lines
boot/trusted-firmware-m/Config.in new file +10
-0+ bool "TrustedFirmware-M (TF-M)" + select BR2_TARGET_TFM_TESTS + select BR2_TARGET_TFM_MBEDTLS + select BR2_TARGET_TFM_MCUBOOT + select BR2_TARGET_TFM_QCBOR + select BR2_TARGET_TFM_CMSIS + select BR2_HOST_CMAKE_AT_LEAST_3_21 + help + Enable this option if you want to build the TF-M for your + ARMv8 microcontroller.
Shouldn't that be ARMv8-M? Kind of implied by the "microcontroller" part of
course.
boot/trusted-firmware-m/Config.in line 13
Quoted 2 lines
boot/trusted-firmware-m/Config.in new file +2
-0+ + https://git.trustedfirmware.org/TF-M/trusted-firmware-m.git
I think https://trustedfirmware-m.readthedocs.io is a better link.
boot/trusted-firmware-m/Config.in line 22
Quoted 9 lines
boot/trusted-firmware-m/Config.in new file +9
-0+ +if BR2_TARGET_TRUSTED_FIRMWARE_M +choice + prompt "TF-M Version" + help + Select the specific TF-M version you want to use + +config BR2_TARGET_TRUSTED_FIRMWARE_M_LATEST_VERSION + bool "TF-Mv2.1.0"
Just "v2.1.0" should be enough?
boot/trusted-firmware-m/Config.in line 28
Quoted 6 lines
boot/trusted-firmware-m/Config.in new file +6
-0+ +config BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_VERSION + bool "Custom version" + select BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_3RD_PARTY + help + This option allows to use a specific official versions
versions -> version
boot/trusted-firmware-m/Config.in line 40
Quoted 12 lines
boot/trusted-firmware-m/Config.in new file +12
-0+ +config BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_TARBALL + bool "Custom tarball" + select BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_3RD_PARTY + +config BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_GIT + bool "Custom Git repository" + select BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_3RD_PARTY + +endchoice + +if BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_TARBALL
This should be a 'depends on' rather than an 'if'.
Quoted 11 lines
boot/trusted-firmware-m/Config.in new file +11
-0+ +config BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_TARBALL_LOCATION + string "URL of custom TF-M tarball" + +endif + +config BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_VERSION_VALUE + string "TF-M version" + depends on BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_VERSION + +config BR2_TARGET_TRUSTED_FIRMWARE_M_VERSION
boot/trusted-firmware-m/Config.in line 61
Quoted 10 lines
boot/trusted-firmware-m/Config.in new file +10
-0+ string + default "0c4c99ba33b3e66deea070e149279278dc7647f4" \ + if BR2_TARGET_TRUSTED_FIRMWARE_M_LATEST_VERSION + default "custom" if BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_TARBALL + default BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_REPO_VERSION \ + if BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_GIT + default BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_VERSION_VALUE \ + if BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_VERSION + +if BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_GIT
This block should come before the BR2_TARGET_TRUSTED_FIRMWARE_M_VERSION
definition.
boot/trusted-firmware-m/Config.in line 74
Quoted 13 lines
boot/trusted-firmware-m/Config.in new file +13
-0+ +config BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_REPO_URL + string "URL of custom repository" + +config BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_REPO_VERSION + string "Custom repository version" + help + Revision to use in the typical format used by Git + E.G. a sha id, a tag, .. + +endif + +menu "TF-M 3rd party projects"
I wouldn't make a submenu for this. We decided that the cut-off point for
submenus is 5, and we do reach that level, but then the submenu should be at the top level under BR2_TARGET_TRUSTED_FIRMWARE_M, i.e. the version choice itself should also be in the submenu.
I don't remember if we usually use "menuconfig" or "if .... menu".
boot/trusted-firmware-m/Config.in line 76
Quoted 2 lines
boot/trusted-firmware-m/Config.in new file +2
-0+config BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_3RD_PARTY + bool "Use custom tarball for TF-M 3rd party projects"
I don't think this option needs to be user visible - is there ever any point
to have upstream TF-M but custom cmsis?
boot/trusted-firmware-m/Config.in
Quoted 5 lines
boot/trusted-firmware-m/Config.in new file +5
-0+ +source "boot/trusted-firmware-m/tfm-mbedtls/Config.in" +source "boot/trusted-firmware-m/tfm-mcuboot/Config.in" +source "boot/trusted-firmware-m/tfm-qcbor/Config.in" +source "boot/trusted-firmware-m/tfm-cmsis/Config.in
As explained below, I don't think we need sub-packages for these. Still, this
is the place where the sub-versions should be specified. So here we should have:
config BR2_TARGET_TFM_MBEDTLS_TARBALL_LOCATION
config BR2_TARGET_TFM_MCUBOOT_TARBALL_LOCATION
etc.
boot/trusted-firmware-m/Config.in line 82
Quoted 1 line
boot/trusted-firmware-m/Config.in new file +1
-0+source "boot/trusted-firmware-m/tfm-tests/Config.in"
This one unfortunately needs to stay as a sub-package.
boot/trusted-firmware-m/Config.in line 89
Quoted 7 lines
boot/trusted-firmware-m/Config.in new file +7
-0+ +endmenu + +config BR2_TARGET_TRUSTED_FIRMWARE_M_PLATFORM + string "TF-M platform path" + help + Target plaform path to build for.
This is not explained very well. Maybe an example?
boot/trusted-firmware-m/Config.in line 100
Quoted 11 lines
boot/trusted-firmware-m/Config.in new file +11
-0+ +config BR2_TARGET_TRUSTED_FIRMWARE_M_ADDITIONAL_VARIABLES + string "Additional TF-M build variables" + help + Additional parameters for the TF-M build + E.G. '-DTFM_ISOLATION_LEVEL=2 -DTFM_PROFILE=large' + +config BR2_TARGET_TRUSTED_FIRMWARE_M_DEBUG + bool "Build in debug mode" + help + Enable this option to build TF-M with -DCMAKE_BUILD_TYPE=Debug.
We don't normally have such options, why do we want it now? And anyway, if you
really need it, you can do that with _ADDITIONAL_VARIABLES, no?
Quoted 8 lines
boot/trusted-firmware-m/Config.in new file +2
-0+ +endifboot/trusted-firmware-m/tfm-3rdparty.mk new file +0
-0
boot/trusted-firmware-m/tfm-3rdparty.mk line 7
Quoted 7 lines
boot/trusted-firmware-m/tfm-3rdparty.mk new file +7
-0@@ -0,0 +1,7 @@ +################################################################################ +# +# TrustedFirmware-M 3rd parties +# +################################################################################ + +include $(sort $(wildcard boot/trusted-firmware-m/*/*.mk))
There's no need for an additional .mk file for this, you can do this directly
from trusted-firmware-m.mk.
Also I wouldn't use wildcard here, but that's more of a personal opinion.
boot/trusted-firmware-m/tfm-cmsis/Config.in line 7
Quoted 13 lines
boot/trusted-firmware-m/tfm-cmsis/Config.in new file +7
-0@@ -0,0 +1,10 @@ +config BR2_TARGET_TFM_CMSIS + bool + +if BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_3RD_PARTY + +config BR2_TARGET_TFM_CMSIS_CUSTOM_TARBALL_LOCATION + string "URL of custom cmcis tarball"
cmsis
boot/trusted-firmware-m/tfm-cmsis/Config.in line 8
Quoted 1 line
boot/trusted-firmware-m/tfm-cmsis/Config.in new file +1
-0+ default "$(call github,arm-software,cmsis_6)/d0c460c169.tar.gz"
I think we should always have the tarball location specified in Config.in (see
also below in the .mk file), so here I would put:
config BR2_TARGET_TRUSTED_FIRMWARE_M_CMSIS_TARBALL_LOCATION
string "URL of custom cmsis tarball" \ if BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_3RD_PARTY
default "$(call
github,arm-software,cmsis_6)/tfm_cmsis-d0c460c1697d210b49a4b90998195831c0cd325c.tar.gz"
Note:
- because it's no longer a subpackage, it becomes an option of trusted-firmware-m itself, so we need that as a prefix;
- we can drop the "custom" part because it's always used.
Now I think of it: although trusted-firmware-m is the upstream name of the
repository, it is _really_ long... Perhaps we can abbreviate to tf-m for once? OTOH arm-trusted-firmware is even longer...
Quoted 18 lines
boot/trusted-firmware-m/tfm-cmsis/Config.in new file +2
-0+ +endifboot/trusted-firmware-m/tfm-cmsis/tfm-cmsis.hash new file +3
-0@@ -0,0 +1,3 @@ +# sha256 locally computed +sha256 d846342840831f9124157b69b8edcdfcacc5427691f5b3341f714f0235c3cc49 tfm-cmsis-d0c460c1697d210b49a4b90998195831c0cd325c.tar.gz +sha256 b40930bbcf80744c86c46a12bc9da056641d722716c378f5659b9e555ef833e1 LICENSEboot/trusted-firmware-m/tfm-cmsis/tfm-cmsis.mk new file +1
-0@@ -0,0 +1,23 @@ +################################################################################
boot/trusted-firmware-m/tfm-cmsis/tfm-cmsis.mk line 11
Quoted 10 lines
boot/trusted-firmware-m/tfm-cmsis/tfm-cmsis.mk new file +10
-0+# +# cmcis +# +################################################################################ + +ifeq ($(BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_3RD_PARTY),y) +TFM_CMSIS_VERSION = custom +TFM_CMSIS_TARBALL = $(call qstrip,$(BR2_TARGET_TFM_CMSIS_CUSTOM_TARBALL_LOCATION)) +TFM_CMSIS_SITE = $(patsubst %/,%,$(dir $(TFM_CMSIS_TARBALL))) +TFM_CMSIS_SOURCE = $(notdir $(TFM_CMSIS_TARBALL))
We can use the above unconditionally if we just give the correct default in
Config.in.
Also, we don't need to do this in a separate package, it can be done in TF_M
additional downloads (I'm going to use the TF_M abbreviation in my review because I'm too lazy to type long names :-)).
TF_M_CMSIS_TARBALL = $(call qstrip,$(BR2_TARGET_TF_M_CMSIS_TARBALL_LOCATION)) TF_M_ADDITIONAL_DOWNLOADS += $(TF_M_CMSIS_TARBALL)
define TF_M_CMSIS_EXTRACT
... extract $(TF_M_DL_DIR)/$(notdir $(TF_M_CMSIS_TARBALL)) ...
endef
boot/trusted-firmware-m/tfm-cmsis/tfm-cmsis.mk line 12
Quoted 1 line
boot/trusted-firmware-m/tfm-cmsis/tfm-cmsis.mk new file +1
-0+BR_NO_CHECK_HASH_FOR += $(TFM_CMSIS_SOURCE)
This still needs to be in the BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_3RD_PARTY condition, of course.
boot/trusted-firmware-m/tfm-cmsis/tfm-cmsis.mk line 16
Quoted 4 lines
boot/trusted-firmware-m/tfm-cmsis/tfm-cmsis.mk new file +4
-0+else +TFM_CMSIS_VERSION = d0c460c1697d210b49a4b90998195831c0cd325c +TFM_CMSIS_SITE = $(call github,arm-software,cmsis_6,$(TFM_CMSIS_VERSION)) +TFM_CMSIS_LICENSE = Apache-2.0
Why was this in the BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_3RD_PARTY condition?
We can assume that the license is the same, no?
Anyway, if it's not a sub-package, it will need to be added to TF_M_LICENSE
instead.
Quoted 7 lines
boot/trusted-firmware-m/tfm-cmsis/tfm-cmsis.mk new file +7
-0+TFM_CMSIS_LICENSE_FILES = LICENSE +endif + +# This components is not built and installed, because it is intended to +# be included as source in TrustedFirmware-M build. + +$(eval $(generic-package))
[snip]
Quoted 6 lines
boot/trusted-firmware-m/tfm-tests/Config.in new file +0
-0
boot/trusted-firmware-m/tfm-tests/Config.in line 8
Quoted 8 lines
boot/trusted-firmware-m/tfm-tests/Config.in new file +8
-0@@ -0,0 +1,10 @@ +config BR2_TARGET_TFM_TESTS + bool + +if BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_3RD_PARTY + +config BR2_TARGET_TFM_TESTS_CUSTOM_TARBALL_LOCATION + string "URL of custom TF-M-tests tarball" + default "https://git.trustedfirmware.org/TF-M/tf-m-tests.git/+archive/TF-Mv2.1.0.tar.gz"
Since this is a non-reproducible tarball, I'd only offer the option of a
custom git here. Then we can apply the same principle of having a conditionally-blind Config.in option and just one way of handling in the .mk file.
Of course, you'll need two Config.in options then, separately for the git URL
and the revision.
Quoted 2 lines
boot/trusted-firmware-m/tfm-tests/Config.in new file +2
-0+ +endif
[snip]
Quoted 25 lines
boot/trusted-firmware-m/trusted-firmware-m.mk new file +19
-0@@ -0,0 +1,120 @@ +################################################################################ +# +# TrustedFirmware-M +# +################################################################################ + +TRUSTED_FIRMWARE_M_VERSION = $(call qstrip,$(BR2_TARGET_TRUSTED_FIRMWARE_M_VERSION)) + +ifeq ($(BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_TARBALL),y) +# Handle custom FT-M tarballs as specified by the configuration +TRUSTED_FIRMWARE_M_TARBALL = $(call qstrip,$(BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_TARBALL_LOCATION)) +TRUSTED_FIRMWARE_M_SITE = $(patsubst %/,%,$(dir $(TRUSTED_FIRMWARE_M_TARBALL))) +TRUSTED_FIRMWARE_M_SOURCE = $(notdir $(TRUSTED_FIRMWARE_M_TARBALL)) +else ifeq ($(BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_GIT),y) +TRUSTED_FIRMWARE_M_SITE = $(call qstrip,$(BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_REPO_URL)) +TRUSTED_FIRMWARE_M_SITE_METHOD = git +else +# Handle stable official TF-M versions +TRUSTED_FIRMWARE_M_SITE = https://git.trustedfirmware.org/TF-M/trusted-firmware-m.git
boot/trusted-firmware-m/trusted-firmware-m.mk line 29
Quoted 10 lines
boot/trusted-firmware-m/trusted-firmware-m.mk new file +10
-0+TRUSTED_FIRMWARE_M_SITE_METHOD = git +# The licensing of custom or from-git versions is unknown. +# This is valid only for the latest (i.e. known) version. +ifeq ($(BR2_TARGET_TRUSTED_FIRMWARE_M_LATEST_VERSION),y) +TRUSTED_FIRMWARE_M_LICENSE = BSD-3-Clause +TRUSTED_FIRMWARE_M_LICENSE_FILES = license.rst +endif +endif + +ifeq ($(BR2_TARGET_TRUSTED_FIRMWARE_M):$(BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_VERSION)$(BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_TARBALL)$(BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_GIT),y:y)
Maybe we should have a config.in condition for this one? Actually, can't we
reuse BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_3RD_PARTY?
Quoted 12 lines
boot/trusted-firmware-m/trusted-firmware-m.mk new file +12
-0+BR_NO_CHECK_HASH_FOR += $(TRUSTED_FIRMWARE_M_SOURCE) +endif + +TRUSTED_FIRMWARE_M_DEPENDENCIES += \ + $(BR2_CMAKE_HOST_DEPENDENCY) \ + host-arm-gnu-toolchain \ + host-python-cbor2 \ + host-python-click \ + host-python-cryptography \ + host-python-jinja2 \ + host-python-intelhex \ + host-python-pyyaml
boot/trusted-firmware-m/trusted-firmware-m.mk line 51
Quoted 10 lines
boot/trusted-firmware-m/trusted-firmware-m.mk new file +10
-0+ +TRUSTED_FIRMWARE_M_PATCH_DEPENDENCIES += \ + tfm-mbedtls \ + tfm-mcuboot \ + tfm-qcbor \ + tfm-cmsis \ + tfm-tests + +define TRUSTED_FIRMWARE_M_PATCH_3RD_PARTIES + if [ -d $(@D)/lib/ext/cmsis ]; then \
Shouldn't all of these have such a condition? We can't be sure that they'll
still exist in future versions, right?
boot/trusted-firmware-m/trusted-firmware-m.mk line 62
Quoted 11 lines
boot/trusted-firmware-m/trusted-firmware-m.mk new file +11
-0+ $(APPLY_PATCHES) $(TFM_CMSIS_SRCDIR) $(@D)/lib/ext/cmsis \*.patch; \ + fi + $(APPLY_PATCHES) $(TFM_MBEDTLS_SRCDIR) $(@D)/lib/ext/mbedcrypto \*.patch; \ + $(APPLY_PATCHES) $(TFM_MCUBOOT_SRCDIR) $(@D)/lib/ext/mcuboot \*.patch; \ + $(APPLY_PATCHES) $(TFM_QCBOR_SRCDIR) $(@D)/lib/ext/qcbor \*.patch; \ + $(APPLY_PATCHES) $(TFM_TESTS_SRCDIR) $(@D)/lib/ext/tf-m-tests \*.patch; +endef +TRUSTED_FIRMWARE_M_POST_PATCH_HOOKS += TRUSTED_FIRMWARE_M_PATCH_3RD_PARTIES + +TRUSTED_FIRMWARE_M_CONF_OPTS += \ + -DCMAKE_TOOLCHAIN_FILE="$(HOST_DIR)/share/buildroot/toolchainfile.cmake" \
That doesn't sound right... That toolchainfile is meant for cross-compilation
to the Linux host, it's going to be completely wrong for the Cortex-M. I think we have to explicitly set all the options here with -D.
In the future, we could consider adding a toolchainfile for the
host-arm-gnu-toolchain as a whole. I think now is still a bit too soon for that.
boot/trusted-firmware-m/trusted-firmware-m.mk line 65
Quoted 3 lines
boot/trusted-firmware-m/trusted-firmware-m.mk new file +3
-0+ -DFETCHCONTENT_FULLY_DISCONNECTED=ON \ + -DMBEDCRYPTO_PATH=$(TFM_MBEDTLS_SRCDIR) \ + -DTFM_TEST_REPO_PATH=$(TFM_TESTS_SRCDIR) \
Actually, CMakeLists.txt says the following:
if(IS_DIRECTORY ${CONFIG_TFM_TEST_DIR})
add_subdirectory(${CONFIG_TFM_TEST_DIR} ${CMAKE_CURRENT_BINARY_DIR}/tf-m-tests)endif()
So perhaps we can just point CONFIG_TFM_TEST_DIR to something invalid and drop
the whole thing?
Quoted 6 lines
boot/trusted-firmware-m/trusted-firmware-m.mk new file +6
-0+ -DMCUBOOT_PATH=$(TFM_MCUBOOT_SRCDIR) \ + -DQCBOR_PATH=$(TFM_QCBOR_SRCDIR) \ + -DCMSIS_PATH=$(TFM_CMSIS_SRCDIR) \ + -DTFM_PLATFORM=$(call qstrip,$(BR2_TARGET_TRUSTED_FIRMWARE_M_PLATFORM)) + +ifeq ($(BR2_TARGET_TRUSTED_FIRMWARE_M_DEBUG),y)
boot/trusted-firmware-m/trusted-firmware-m.mk line 81
Quoted 10 lines
boot/trusted-firmware-m/trusted-firmware-m.mk new file +10
-0+TRUSTED_FIRMWARE_M_CONF_OPTS += -DCMAKE_BUILD_TYPE=Debug +endif + +TRUSTED_FIRMWARE_M_CONF_ENV += \ + CROSS_COMPILE=$(HOST_DIR)/bin/arm-none-eabi- + +define TRUSTED_FIRMWARE_M_CONFIGURE_CMDS + rm -f $(@D)/CMakeCache.txt + PATH=$(BR_PATH) \ + $(TRUSTED_FIRMWARE_M_CONF_ENV) $(BR2_CMAKE) -S $(@D) -B $(@D) \
Can we use -GNinja?
boot/trusted-firmware-m/trusted-firmware-m.mk line 93
Quoted 12 lines
boot/trusted-firmware-m/trusted-firmware-m.mk new file +12
-0+ $(TRUSTED_FIRMWARE_M_CONF_OPTS) \ + $(call qstrip,$(BR2_TARGET_TRUSTED_FIRMWARE_M_ADDITIONAL_VARIABLES)) +endef + +define TRUSTED_FIRMWARE_M_BUILD_CMDS + PATH=$(BR_PATH) \ + $(TRUSTED_FIRMWARE_M_CONF_ENV) $(BR2_CMAKE) \ + --build $(@D) -- install +endef + +define TRUSTED_FIRMWARE_M_INSTALL_TARGET_CMDS + # Install path for old version of TF-M
Since this is a new package in Buildroot, is it really necessary to support
versions < 2.1?
boot/trusted-firmware-m/trusted-firmware-m.mk line 96
Quoted 3 lines
boot/trusted-firmware-m/trusted-firmware-m.mk new file +3
-0+ if [ -d $(@D)/install/outputs ]; then \ + $(INSTALL) -D -m 0755 $(@D)/install/outputs/*.bin $(BINARIES_DIR); \ + $(INSTALL) -D -m 0755 $(@D)/install/outputs/*.elf $(BINARIES_DIR); \
I don't know how many binaries there are, but perhaps it makes sense to put
them in a subdirectory? Or is it just a single binary?
Quoted 30 lines
boot/trusted-firmware-m/trusted-firmware-m.mk new file +24
-0+ else \ + $(INSTALL) -D -m 0755 $(@D)/api_ns/bin/*.bin $(BINARIES_DIR); \ + $(INSTALL) -D -m 0755 $(@D)/api_ns/bin/*.elf $(BINARIES_DIR); \ + fi +endef + +# Configuration check +ifeq ($(BR2_TARGET_TRUSTED_FIRMWARE_M)$(BR_BUILDING),yy) + +ifeq ($(BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_TARBALL),y) +ifeq ($(call qstrip,$(BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_TARBALL_LOCATION)),) +$(error No tarball location specified. Please check BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_TARBALL_LOCATION) +endif +endif + +ifeq ($(BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_GIT),y) +ifeq ($(call qstrip,$(BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_REPO_URL)),) +$(error No repository specified. Please check BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_REPO_URL) +endif +endif + +endif + +$(eval $(generic-package))support/testing/tests/boot/test_tfm.py new file +0
-0
support/testing/tests/boot/test_tfm.py line 8
Quoted 8 lines
support/testing/tests/boot/test_tfm.py new file +8
-0@@ -0,0 +1,12 @@ +import infra.basetest + + +class TestTFMBuild(infra.basetest.BRTest): + config = \ + """ + BR2_TARGET_TRUSTED_FIRMWARE_M=y + BR2_TARGET_TRUSTED_FIRMWARE_M_PLATFORM="arm/mps2/an521"
This is just a build test, it should be covered by the autobuilders.
Instead, genrandconfig should be adapted to add this string.
Regards,
Arnout
support/testing/tests/boot/test_tfm.py line 12
Quoted 4 lines
support/testing/tests/boot/test_tfm.py new file +4
-0+ """ + + def test_run(self): + pass
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH v4 4/4] boot: Add support for TrustedFirmware-M package
Hello Arnout,
Thanks for this review, and sorry for the late reply.
Quoted 10 lines · On Mon, 15 Jul 2024 13:55:50 +0200 Arnout Vandecappelle <[email protected]> wrote:
Quoted 10 lines
boot/trusted-firmware-m/Config.in new file +10
-0+ +config BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_REPO_URL + string "URL of custom repository" + +config BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_REPO_VERSION + string "Custom repository version" + help + Revision to use in the typical format used by Git + E.G. a sha id, a tag, .. +
Quoted 8 lines
boot/trusted-firmware-m/Config.in line 74
Quoted 3 lines
boot/trusted-firmware-m/Config.in new file +3
-0+endif + +menu "TF-M 3rd party projects"I wouldn't make a submenu for this. We decided that the cut-off point for
submenus is 5, and we do reach that level, but then the submenu should be at the top level underBR2_TARGET_TRUSTED_FIRMWARE_M, i.e. the version choice itself should also be in the submenu.
Ack didn't know this.
Quoted 7 lines
I don't remember if we usually use "menuconfig" or "if .... menu".
boot/trusted-firmware-m/Config.in line 76
Quoted 2 lines
boot/trusted-firmware-m/Config.in new file +2
-0+config BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_3RD_PARTY + bool "Use custom tarball for TF-M 3rd party projects"I don't think this option needs to be user visible - is there ever any
point to have upstream TF-M but custom cmsis?
Yes I will remove it.
Quoted 9 lines
+
boot/trusted-firmware-m/Config.in
Quoted 4 lines
boot/trusted-firmware-m/Config.in new file +4
-0+source "boot/trusted-firmware-m/tfm-mbedtls/Config.in" +source "boot/trusted-firmware-m/tfm-mcuboot/Config.in" +source "boot/trusted-firmware-m/tfm-qcbor/Config.in" +source "boot/trusted-firmware-m/tfm-cmsis/Config.inAs explained below, I don't think we need sub-packages for these. Still,
this is the place where the sub-versions should be specified. So here we should have:
Quoted 7 lines
config
BR2_TARGET_TFM_MBEDTLS_TARBALL_LOCATION
configBR2_TARGET_TFM_MCUBOOT_TARBALL_LOCATION
etc.Quoted 1 line
+source "boot/trusted-firmware-m/tfm-tests/Config.in"
This one unfortunately needs to stay as a sub-package.
Yes, I will use EXTRA_DOWNLOADS and remove the tfm-test sub package.
Quoted 5 lines
Quoted 5 lines
boot/trusted-firmware-m/Config.in new file +5
-0+config BR2_TARGET_TRUSTED_FIRMWARE_M_ADDITIONAL_VARIABLES + string "Additional TF-M build variables" + help + Additional parameters for the TF-M build + E.G. '-DTFM_ISOLATION_LEVEL=2 -DTFM_PROFILE=large'
Quoted 8 lines
boot/trusted-firmware-m/Config.in line 100
Quoted 5 lines
boot/trusted-firmware-m/Config.in new file +5
-0+ +config BR2_TARGET_TRUSTED_FIRMWARE_M_DEBUG + bool "Build in debug mode" + help + Enable this option to build TF-M with -DCMAKE_BUILD_TYPE=Debug.We don't normally have such options, why do we want it now? And anyway, if
you really need it, you can do that with_ADDITIONAL_VARIABLES, no?
Yes indeed.
Quoted 9 lines
I think we should always have the tarball location specified in Config.in
(see also below in the .mk file), so here I would put:config
BR2_TARGET_TRUSTED_FIRMWARE_M_CMSIS_TARBALL_LOCATIONstring "URL of custom cmsis tarball" \ if BR2_TARGET_TRUSTED_FIRMWARE_M_CUSTOM_3RD_PARTYdefault "$(call
github,arm-software,cmsis_6)/tfm_cmsis-d0c460c1697d210b49a4b90998195831c0cd325c.tar.gz"
Quoted 8 lines
Note:
- because it's no longer a subpackage, it becomes an option of trusted-firmware-m itself, so we need that as a prefix;
- we can drop the "custom" part because it's always used.Now I think of it: although trusted-firmware-m is the upstream name of the
repository, it is _really_ long... Perhaps we can abbreviate to tf-m for once? OTOH arm-trusted-firmware is even longer...
Yep, I will change it to TF-M.
Quoted 5 lines
boot/trusted-firmware-m/trusted-firmware-m.mk line 51
Quoted 2 lines
boot/trusted-firmware-m/trusted-firmware-m.mk new file +2
-0+define TRUSTED_FIRMWARE_M_PATCH_3RD_PARTIES + if [ -d $(@D)/lib/ext/cmsis ]; then \Shouldn't all of these have such a condition? We can't be sure that they'll
still exist in future versions, right?
Yes I will add them.
Quoted 22 lines
Quoted 12 lines
(quoted diff) +1
-0+ $(APPLY_PATCHES) $(TFM_CMSIS_SRCDIR) $(@D)/lib/ext/cmsis\*.patch; \
(quoted diff) +2
-0+ fi + $(APPLY_PATCHES) $(TFM_MBEDTLS_SRCDIR) $(@D)/lib/ext/mbedcrypto\*.patch; \
(quoted diff) +1
-0+ $(APPLY_PATCHES) $(TFM_MCUBOOT_SRCDIR) $(@D)/lib/ext/mcuboot\*.patch; \
(quoted diff) +1
-0+ $(APPLY_PATCHES) $(TFM_QCBOR_SRCDIR) $(@D)/lib/ext/qcbor \*.patch;\
(quoted diff) +1
-0+ $(APPLY_PATCHES) $(TFM_TESTS_SRCDIR) $(@D)/lib/ext/tf-m-tests\*.patch; +endef
boot/trusted-firmware-m/trusted-firmware-m.mk
Quoted 5 lines
boot/trusted-firmware-m/trusted-firmware-m.mk new file +4
-1+TRUSTED_FIRMWARE_M_POST_PATCH_HOOKS += TRUSTED_FIRMWARE_M_PATCH_3RD_PARTIES + +TRUSTED_FIRMWARE_M_CONF_OPTS += \ + -DCMAKE_TOOLCHAIN_FILE="$(HOST_DIR)/share/buildroot/toolchainfile.cmake" \That doesn't sound right... That toolchainfile is meant for
cross-compilation to the Linux host, it's going to be completely wrong for the Cortex-M. I think we have to explicitly set all the options here with -D.
Quoted 3 lines
In the future, we could consider adding a toolchainfile for the
host-arm-gnu-toolchain as a whole. I think now is still a bit too soon for that.
Ok.
Quoted 6 lines
boot/trusted-firmware-m/trusted-firmware-m.mk line 81
Quoted 4 lines
boot/trusted-firmware-m/trusted-firmware-m.mk new file +4
-0+define TRUSTED_FIRMWARE_M_CONFIGURE_CMDS + rm -f $(@D)/CMakeCache.txt + PATH=$(BR_PATH) \ + $(TRUSTED_FIRMWARE_M_CONF_ENV) $(BR2_CMAKE) -S $(@D) -B $(@D) \Can we use -GNinja?
Yes we can. Should we change something and the configure command?
Quoted 16 lines
boot/trusted-firmware-m/trusted-firmware-m.mk line 93
Quoted 13 lines
(quoted diff) +2
-0+ $(TRUSTED_FIRMWARE_M_CONF_OPTS) \ + $(callqstrip,$(BR2_TARGET_TRUSTED_FIRMWARE_M_ADDITIONAL_VARIABLES)) +endef
boot/trusted-firmware-m/trusted-firmware-m.mk new file +9
-0+ +define TRUSTED_FIRMWARE_M_BUILD_CMDS + PATH=$(BR_PATH) \ + $(TRUSTED_FIRMWARE_M_CONF_ENV) $(BR2_CMAKE) \ + --build $(@D) -- install +endef + +define TRUSTED_FIRMWARE_M_INSTALL_TARGET_CMDS + # Install path for old version of TF-MSince this is a new package in Buildroot, is it really necessary to support
versions < 2.1?
No indeed.
Quoted 9 lines
Quoted 6 lines
(quoted diff) +2
-0+ if [ -d $(@D)/install/outputs ]; then \ + $(INSTALL) -D -m 0755 $(@D)/install/outputs/*.bin$(BINARIES_DIR); \
(quoted diff) +1
-0+ $(INSTALL) -D -m 0755 $(@D)/install/outputs/*.elf$(BINARIES_DIR); \
I don't know how many binaries there are, but perhaps it makes sense to put
them in a subdirectory? Or is it just a single binary?
Only one .bin and one .elf.
Quoted 14 lines
support/testing/tests/boot/test_tfm.py line 8
Quoted 11 lines
support/testing/tests/boot/test_tfm.py new file +8
-0@@ -0,0 +1,12 @@ +import infra.basetest + + +class TestTFMBuild(infra.basetest.BRTest): + config = \ + """ + BR2_TARGET_TRUSTED_FIRMWARE_M=y + BR2_TARGET_TRUSTED_FIRMWARE_M_PLATFORM="arm/mps2/an521"This is just a build test, it should be covered by the autobuilders.
Quoted 1 line
Instead, genrandconfig should be adapted to add this string.
Ok.
Regards,
Signature · 7 lines
Köry Maincent, Bootlin Embedded Linux and kernel engineering https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot