Commit graph

69 commits

Author SHA1 Message Date
Joakim Andersson ea705116ed tfm: Print memory usage of TF-M built executables
Print the memory usage of TF-M built executables during build.
This is defaulting to OFF because we have CONFIG_TFM_BUILD_LOG_QUIET
set to ON.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2023-05-03 10:00:56 +02:00
Joakim Andersson 9ccd202a76 tfm: Use relative path to the runners.yaml hex file and move tfm_merged
Move tfm_merged.hex from <build>/tfm_merged.hex to
<build>/zephyr/tfm_merged.hex.
Use relative path to the runners.yaml hex file.

This makes it possible to move the build folder.
Example would be to copy out the runners.yaml and tfm_merged.hex file
and still be able to call west flash --skip-rebuild.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2023-03-31 09:20:04 +02:00
Joakim Andersson dd47f4c730 modules: trusted-firmware-m: Allow application to use qcbor TF-M
QCBOR cannot be shipped with Zephyr.
Allow the application to supply their own copy of QCBOR or let the TF-M
build system automatically download this dependency.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2023-02-11 07:59:06 +09:00
Kevin Townsend cd8d4ccad5 modules: tfm: Disable initial attestation service
Prevents Zephyr from enabling the initial attestation service in TF-M,
due to a dependency it has on an incompatibly-licensed library (QCBOR).

This update checks if either of the following config flags are
enabled at build time:

- `CONFIG_TFM_PARTITION_INITIAL_ATTESTATION`
- `CONFIG_TFM_PSA_TEST_INITIAL_ATTESTATION`

If either of these are set to true, a fatal error will be thrown at
build time, indicating the reason for the failure.

This change can be reverted once a longer term solution to the QCBOR
license issues has been resolved.

Signed-off-by: Kevin Townsend <kevin.townsend@linaro.org>
2023-02-11 07:59:06 +09:00
Joakim Andersson df12df354c modules: trusted-firmware-m: Remove setting of removed cmake option
Remove setting of the TFM_LIB_MODEL option for IPC and SFN models.
This option is removed together with the library model.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2023-02-07 14:27:03 +01:00
Joakim Andersson 5c97bb5ecd modules: trusted-firmware-m: Fix TF-M floating point options
Fix setting of TF-M floating point options when floating point is
enabled in the application.
FP design in Armv8.0-M architecture requires consistent FP ABI types
between SPE and NSPE.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2023-02-07 14:27:03 +01:00
Joakim Andersson d9b6e58eb3 modules: trusted-firmware-m: Add TF-M connection based NS API source
Add TF-M connection based NCS API source file to build.
This file is needed when a secure service is using connection
based method.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Signed-off-by: David Brown <david.brown@linaro.org>
2023-01-27 14:25:30 -05:00
Kevin Townsend 186cd65160 manifest: Update to TF-M 1.7.0 and MBedTLS 3.2.1
Update TF-M from 1.6.0 to 1.7.0
Update MBedTLS from 3.1.0 to 3.2.1.

Updates the cmake wrapper for changes introduced in TF-M 1.7.0.

Signed-off-by: Kevin Townsend <kevin.townsend@linaro.org>
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Signed-off-by: David Brown <david.brown@linaro.org>
2023-01-27 14:25:30 -05:00
Joakim Andersson 2572a53a45 tfm: Remove library model support
In TF-M 1.7.0 release the Library model has been removed.
Remove the library model support from zephyr before updating TF-M
version.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Signed-off-by: David Brown <david.brown@linaro.org>
2023-01-27 14:25:30 -05:00
Joakim Andersson b43dfa27e9 modules: trusted-firmware-m: Remove dependency on module file for tests
Remove the dependency on the test repositories having a zephyr module
file in their repositories.
With this change we can take the upstream test repositories direct
commit SHA or tag.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2023-01-25 11:23:23 +00:00
Joakim Andersson 3abcc19fd7 tfm: Add option to enable the SFN model
Add option to enable the SFN model when building TF-M.
The SFN model will eventually replace the Library model.

Change the default model to be IPC, which follows the default
configuration of TF-M.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2022-10-03 10:17:45 +02:00
Joakim Andersson c51505f661 modules: tfm: Exclude non-secure TF-M application from build
Exclude the non-secure TF-M application from being built by TF-M.
This also stops the building of the tfm_ns_api library that we were
linking against.
This library is defined by the tf-m regression tests.
Add the installed interface source files exported by the TF-M build
system compile them in the zephyr build system.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2022-08-09 13:59:02 +02:00
Anas Nashif 72e7fa8176 scripts: move mergehex.py to scripts/build
Move scripts needed by the build system and not designed to be run
individually or standalone into the build subfolder.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-12 10:03:45 +02:00
Joakim Andersson 3ccf5d03ff tfm: Add option for implementation custom reset handler with TF-M
Zephyr adds a custom handler that overrides the weak function
sys_arch_reset when TF-M platform partition is enabled.

This takes away the option for the application to override the weak
definition for their platform or use-case.

Add an option that control whether this default reset handling is added
to the build.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2022-06-30 13:00:09 +00:00
Joakim Andersson cb32d8e8e9 modules: tfm: Allow enabling FPU in the application with TF-M enabled
Allow the application to enable the FPU when TF-M has been enabled.
Pass the correct compilation flags according to the TF-M integration
guide.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2022-06-29 14:45:39 +00:00
Rajkumar Kanagaraj 8920f43639 modules: trusted-firmware-m: update val, pal, test static lib path
Previously val_nspe.a, pal_nspe.a, test_combine.a created under tfm binary
directory (${TFM_BINARY_DIR}/app/psa_api_tests/) now from TFM 1.6 it is
generated to the respective tfm binary directory with parent directory
(${TFM_BINARY_DIR}/tf-m-tests/app/psa_api_tests), update the CMake
accordingly.

Signed-off-by: Rajkumar Kanagaraj <rajkumar.kanagaraj@linaro.org>
2022-05-12 10:33:52 +02:00
Jimmy Brisson 2e6cd2550c modules: Update dependencies for TFM 1.6 release
This includes updates for the tfm deps:
 * tf-m-tests
 * psa-arch-tests

Signed-off-by: Jimmy Brisson <jimmy.brisson@linaro.org>
2022-05-12 10:33:52 +02:00
Jimmy Brisson e7e78cba14 tfm: Kconfig: Configure MCUBOOT_DATA_SHARING explicitly
Previously, MCUBOOT_DATA_SHARING was enabled when BL2 was built
and when the firmware update partition was present. This is not
the only situation that you might be interested in this data
sharing. The data sharing now has it's own Kconfig.

Further, use of the firmware update partition requires data
sharing, so it selects it.

Signed-off-by: Jimmy Brisson <jimmy.brisson@linaro.org>
2022-04-08 15:52:01 -07:00
Jimmy Brisson 0dcd6bd58a modules-tfm: Configure image versions with KConfig
Previously, you were required to set the image versions through the
CMake variables TFM_IMAGE_VERSION_{S,NS}. For better integration with
the rest of the zephyr build system, these are now KConfig variables
with the same name.

Signed-off-by: Jimmy Brisson <jimmy.brisson@linaro.org>
2022-04-08 15:52:01 -07:00
Kevin Townsend eacae5e4e9 samples: tfm: PSA firmware update sample
This commit adds a sample application demonstrating how to use
the PSA Firmware Update API from TF-M. It also enables the
`FIRMWARE_UPDATE` partition to be included at build time.

Signed-off-by: Kevin Townsend <kevin.townsend@linaro.org>
Signed-off-by: Jimmy Brisson <jimmy.brisson@linaro.org>
2022-04-08 15:52:01 -07:00
Joakim Andersson 5ee41d8b4e scripts: size_report: Add support for TF-M and BL2 image size reports
Add support for TF-M and BL2 image size reports.
This adds the following targets when TF-M or BL2 is enabled:
tfm_rom_report, tfm_ram_report, tfm_footprint
bl2_rom_report, bl2_ram_report, bl2_footprint

Example:
west build -t tfm_rom_report

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2022-03-09 14:03:52 -05:00
Joakim Andersson bfbee8c54f tfm: Add config to disable all TF-M output
Add config to disable all TF-M output. This configuration is needed
in order to exclude the UART driver through a select in Kconfig
when either the code size optimization or the UART instance requires it.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2022-02-21 21:02:25 -05:00
Joakim Andersson 17f8932f16 modules: trusted-firmware-m: Use TF-M install headers as interface
Use the set of headers that the TF-M build system places in the
install output. Not all public header files are available in the
interface/include directory and the TF-M build system uses the install
mechanism of cmake to include additional headers based on platform
or configuration.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2022-02-01 11:31:36 +01:00
Sebastian Bøe 7ea7eb05ae tfm: kconfig: Fix config regression from TF-M 1.5
In TF-M 1.5 some defaults changed. Some of our CMake code was
unfortunately making assumptions about the defaults.

This is now rectified. The TF-M CMake variables that had their
defaults changed are now always set dependent on the Kconfig values
and we no longer leave the CMake variables unset and with default
values.

A cleanup will be done later to not rely on default values for all
variables. This patch only fixes the defaults that have changed.

Also, TFM_PSA_API is removed as it is now an internal variable.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2022-01-04 12:33:23 +01:00
Damian Krolik 45307140ac tfm: kconfig: make ITS size configurable
Add two Kconfig variables for controlling the size and
the number of assets to be stored in Internal Trusted
Storage (ITS).

Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
2021-12-14 13:42:57 -06:00
Joakim Andersson faad102707 modules: tfm: Fix in SPM log level silence configuration
Fix copy-paste mistake in SPM log level silence configuration, PARTITION
should be SPM in order to correctly silence SPM log.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-12-13 16:36:06 +01:00
Joakim Andersson 3db41349f5 cmake: Add variable for the TFM build directory
The TFM build directory path is hardcoded in many places.
In order to support out-of-tree secure partitions the output path
has to be known in potentially out-of-tree build scripts.
This could potentially break out-of-tree build scripts if the
location of the build directory was changed.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-11-22 22:19:41 -05:00
Joakim Andersson 13230747e3 modules: trusted-firmware-m: Fix mcuboot imgtool not found on path
Fix issue with TFM signing of images not using the correct imgtool.
The wrapper command expects the mcuboot scripts folder to be the
current working directory when called in order to find its own
version of imgtool.
Since the command is using a different current working directory
this is not found and the system imgtool is used instead.
This causes the commands to be run with 2 different version of imgtool
if the system imgtool is found and does not have any issues.
The system imgtool could not be installed or have compatibility issues
as 1.7.2 version of imgtool is currently required by the wrapper script

Fixes: #40254

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-11-21 18:51:16 -05:00
Joakim Andersson 9b87d6f7fc modules: tfm: Fix cmake warnings for unused variables
Fix cmake warnings for TF-M build system when PSA tests are not enabled.
This produces the following warnings:
"
CMake Warning:
  Manually-specified variables were not used by the project:

    PSA_TOOLCHAIN_FILE
    TOOLCHAIN
"

These warnings can point to cache or config variables being updated in
the TF-M build system so keep this free of warnings.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-11-15 14:54:48 -05:00
Joakim Andersson aaa38bfcb6 modules: tfm: Split CRYPTO_ASYMMETRIC module into SIGN and ENCRYPT
The ASSYMETRIC crypto module has been split in two, for sign and
encrypt. Update Kconfig entries to match.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-11-13 07:58:50 -05:00
Joakim Andersson 81c5fb47a8 modules: tfm: Remove CRYPTO_GENERATOR_MODULE kconfig
Remove CRYPTO_GENERATOR_MODULE Kconfig which has been removed.
Its features are covered by TFM_CRYPTO_KEY_MODULE and
CRYPTO_KEY_DERIVATION_MODULE.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-11-13 07:58:50 -05:00
Joakim Andersson dda3a5ad0d modules: tfm: Split trusted-firmware-m repository
Split the zephyr project maintained repository trusted-firmware-m into
forks of the individual upstream repositories.

https://git.trustedfirmware.org/TF-M/trusted-firmware-m.git
Upstream: TF-Mv1.4.1
Additions:
zephyr: module: Add zephyr module file
trusted-firmware-m: platform: lpcxpresso55s69: Update SDK

https://git.trustedfirmware.org/TF-M/tf-m-tests.git
Upstream: 51ff2bdfae043f6dd0813b000d928c4bda172660
Additions:
zephyr: module: Add module file for tf-m-tests

https://github.com/ARM-software/psa-arch-tests.git
Upstream: 60faad2ead1b967ec8e73accd793d3ed0e5c56bd
Additions:
zephyr: module: Add module file for psa-arch-tests
psa-arch-tests: Allow overriding of toolchain file

The organization of folders remain the same with the following
exceptions:
Moved:
root folder moved from modules/tee/tfm to modules/tee/tf-m to avoid
problems with west update.
zephyr/module.yml to trusted-firmware-m/zephyr/module.yml and
${ZEPHYR_TRUSTED_FIRMWARE_M_MODULE_DIR} points to what was previously
${ZEPHYR_TRUSTED_FIRMWARE_M_MODULE_DIR}/trusted-firmware-m.
Added:
psa-arch-tests/zephyr/module.yml and ${ZEPHYR_PSA_ARCH_TESTS_MODULE_DIR}
tf-m-tests/zephyr/module/ and ${ZEPHYR_TF_M_TESTS_MODULE_DIR}
Removed:
init-git.sh
README.rst

Fixes: #39353

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-11-01 11:20:06 -04:00
Joakim Andersson 4748777126 modules: tfm: Fix not defined configuration for TF-M log options
Fix configuration options for TF-M log levels configured to an empty
string when not defined. This can happen when none of the options
have been selected due to dependencies not being met.
For example when TFM_MINIMAL=y then TFM_PARTITION_LOG_LEVEL will not be
defined.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-10-27 10:51:34 +02:00
David Brown 1491551ca6 modules: Allow for Mbed TLS module to match upstream
Use the Mbed TLS module, expecting the upstream directory layout rather
than the nested directory we've been using before.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-10-18 09:51:06 -05:00
Joakim Andersson 70a9bc0e57 modules: tfm: Add configuration for TF-M log options
Add Kconfig options for configuring TF-M log options.
 - Partition log level
 - SPM log level
 - Exception info dump

Set log level to "info" which is the default in upstream TF-M.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-10-17 11:50:53 -04:00
Joakim Andersson f26f416e74 modules: tfm: Remove duplicate tfm cmakecache config
Remove duplicated setting of TF-M CMakeCache.txt entry TFM_BOARD.
In addition it is also wrong since the CONFIG_ prefix is missing.

Leftover from: 583d5a6db3

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-10-17 11:50:53 -04:00
Sebastian Bøe 3a3e3c041b tfm: build: Build TF-M with 1 thread on Windows
Don't build TF-M in parallel on Windows as it has been reported to
expose dependency issues with the TF-M build system.

These issues will be investigated at a later time.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2021-10-13 10:12:57 -04:00
Joakim Andersson 0f53679859 modules: tfm: Use ZEPHYR_<MODULE>_MODULE_DIR instead of relative paths
Use ZEPHYR_<MODULE>_MODULE_DIR instead of relative paths. Moving the
module folder would otherwise break the build system.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-10-11 21:05:30 -04:00
Sebastian Bøe e3b3afa7a5 tfm: Fix zephyr-sdk toolchain variant integration
The psa-arch-tests project changed how third-party toolchains are
integrated. This broke the Zephyr sdk.

This patch aligns with the new mechanism.

https://github.com/ARM-software/psa-arch-tests/pull/276

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2021-10-07 14:02:40 -05:00
Frank Audun Kvamtrø c91efdf939 modules: tfm: Override the TF-M MBEDCRYPTO_PATH
The TF-M build is passed a path to the mbedtls project
directory, however, NCS has its own mbedtls variant. When
building with TF-M we use a generator expression to allow
setting the path to mbedtls from nrf_security.

Signed-off-by: Frank Audun Kvamtrø <frank.kvamtro@nordicsemi.no>
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-08-30 17:08:34 -04:00
Håkon Øye Amundsen 881b877eca modules: tfm: add configuration for disabling the RNG module
A new configuration is available in TF-M, for disabling RNG
independent from key derivation. Introduce a corresponding
Kconfig option to control the RNG API enabling/disabling from
Zephyr.

Signed-off-by: Håkon Øye Amundsen <haakon.amundsen@nordicsemi.no>
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2021-07-28 20:09:58 +02:00
Ioannis Glaropoulos 138be0a080 modules: tf-m: allow DOWNLOAD option for mcuboot
Allow developers the option of using the DOWNLOAD option
for MCUboot in TF-M bulds with BL2. Using MCUboot from
Zephyr is still the default option.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2021-07-28 19:38:35 +02:00
Ioannis Glaropoulos 5e6503f6a7 manifest: remove mcuboot version for TF-M in Zephyr
We remove the tfm-mcuboot module in Zephyr (which hosts the
mcuboot version that is used for TF-M builds in Zephyr). We
will force TF-M builds in Zephyr to  use the MCUboot version
that any Zephyr builds are using. This will allow Zephyr to
maintain a single mcuboot module version in its default
manifest.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2021-07-28 19:38:35 +02:00
Ioannis Glaropoulos d42671737e modules: tf-m: supply NXP HAL directory path for builds for LPC
For TF-M builds on LPCXPRESSO55S69 we set the path to the
NXP HAL sources that are required for building TF-M for this
platform.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2021-07-28 19:38:35 +02:00
Øyvind Rønningstad 583d5a6db3 tfm: Refactor the TF-M Cmake code to simplify and remove the function
The current CMakeLists.txt contains a function that is called from
the same file.

This patch removes the abstraction, allowing to remove many
lines of parameter handling.

Additionally, with this patch, the Cmake argument handling is now
done via a list, which removes many more named variables.

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2021-06-22 08:45:20 -04:00
Devaraj Ranganna 29ca4aaba2 modules: trusted-firmware-m: Set TF-M isolation level
The CMake variable `TFM_ISOLATION_LEVEL_ARG` was not properly set when
application configures higher isolation level. This led to isolation
level always being to set 1.

Signed-off-by: Devaraj Ranganna <devaraj.ranganna@linaro.org>
2021-06-16 10:02:34 +02:00
Torsten Rasmussen 7cc52f88c3 cmake: tfm: moving CMake execution of tfm_cmake to a custom command
Fixes: #36101

The move of CMake invocation to a dedicated custom target, see #34868
results in tfm_cmake to always be considered out-of-date, causing CMake
to be reinvoked in the TF-M Binary dir, which again results in the
build command to rebuild.

This commit moves the invocation to a custom command with the
CMakeCache.txt as output. The custom target tfm_cmake is updated to
depend on CMakeCache.txt.

This mean that CMake for TF-M will only be invoked inside the Zephyr
build command if that file is missing.

If the CMakeCache.txt file is updated or TF-M CMake or source code is
modified, then the build command inside the TF-M build folder will
ensure correct re-run of CMake from within the TF-M build folder.

This ensures that TF-M will still rebuild if TF-M code is modified,
while at the same time avoid unnecessary rebuilds of TF-M code.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-06-11 16:37:22 -05:00
Ioannis Glaropoulos bf87f98fa4 modules: tf-m: fix NS image selection for regression tests
When running with TFM Regression option set, but without
BL2 (MCUboot) we need to use the TF-M's NS binary, and not
the Zephyr application. This was selected properly for the
case with MCUboot boot already, but not when running the
regression tests without MCUboot.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2021-06-04 16:21:42 -05:00
Håkon Øye Amundsen f8a9e0019c modules: tfm: add option for selecting crypto modules
These are needed to disable not needed crypto modules in
the trusted-firmware-m module.

Signed-off-by: Håkon Øye Amundsen <haakon.amundsen@nordicsemi.no>
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2021-06-04 16:21:24 -05:00
Devaraj Ranganna 7273603707 modules: tf-m: Add Crosstool-NG toolchain support
Zephyr SDK is not supported on OS X, however, Zephyr toolchain can be
built on OS X using Crosstool-NG.

Currently, trusted-firmware-m CMakeLists.txt only supports `zephyr` and
`gnuarmemb` toolchains which prohibits building TF-M on OS X using
Zephyr toolchain built with Crosstool-NG.

docs:
https://docs.zephyrproject.org/latest/getting_started/toolchain_3rd_party_x_compilers.html#crosstool-ng

Signed-off-by: Devaraj Ranganna <devaraj.ranganna@linaro.org>
2021-06-04 16:16:05 -05:00