blob: 59fa27e73f27f4a6f5ca8f02684642cf236bca4d [file] [log] [blame]
Kevin Penga9ec66f2022-07-05 15:21:16 +08001######################
2TF-M Example Partition
3######################
4The TF-M example partition is a simple Secure Partition implementation provided
5to aid development of new Secure Partitions.
6
7It is an Application RoT, SFN model Secure Partition and implements an
8connection-based RoT Service.
9
10Please refer to `PSA Firmware Framework 1.0`_
11and `Firmware Framework for M 1.1 Extensions`_
12for details of the attributes of Secure Partitions.
13
Elena Uziunaite676a1462023-11-14 16:58:45 +000014Please refer to :doc:`Adding Secure Partition <TF-M:integration_guide/services/tfm_secure_partition_addition>`
Kevin Penga9ec66f2022-07-05 15:21:16 +080015for more details of adding a new Secure Partition to TF-M.
16
Elena Uziunaite676a1462023-11-14 16:58:45 +000017.. file-structure:
18
Kevin Penga9ec66f2022-07-05 15:21:16 +080019**************
20File structure
21**************
22
23.. code-block:: bash
24
25 .
26 ├── CMakeLists.txt
27 ├── README.rst
28 ├── tfm_example_manifest_list.yaml
29 ├── tfm_example_partition_api.c
30 ├── tfm_example_partition_api.h
31 ├── tfm_example_partition.c
32 └── tfm_example_partition.yaml
33
34- ``CMakeLists.txt``
35
36 The CMake file for building this example Secure Partitions.
37 It is specific to the TF-M build system.
38
39- ``README.rst``
40
41 This document.
42
43- ``tfm_example_partition.yaml``
44
45 The manifest of this Secure Partition.
46
47- ``tfm_example_manifest_list.yaml``
48
49 The manifest list that describes the Secure Partition manifest of this Secure
50 Partition. See `TF-M Manifest List`_ for details of manifest lists.
51
52- ``tfm_example_partition.c``
53
54 The core implementation of this Secure Partition.
55
56- ``tfm_example_partition_api.c``
57
58 The APIs for accessing the RoT Services provided by this Secure Partition.
59
60- ``tfm_example_partition_api.h``
61
62 The header file that declares the RoT Services APIs.
63
64************
65How to Build
66************
67It is recommended to build this example Secure Partition via out-of-tree build.
68It can minimize the changes to TF-M source code for building and testing the
69example.
70
71To build, append the following extra build configurations to the CMake build
72commands.
73
74- ``-DTFM_PARTITION_EXAMPLE``
75
76 This is the configuration switch to enable or disable building this example.
77 Set to ``ON`` to enable or ``OFF`` to disable.
78
79- ``-DTFM_EXTRA_PARTITION_PATHS``
80
81 Set it to the absolute path of this directory.
82
83- ``-DTFM_EXTRA_MANIFEST_LIST_FILES``
84
85 Set it to the absolute path of the manifest list mentioned above -
86 ``tfm_example_manifest_list.yaml``.
87
88Refer to `Out-of-tree Secure Partition build`_ for more details.
89
Gergely Korcsák60e1b1e2024-04-19 17:25:37 +020090**********************************************
91Build steps for mps4/corstone315 platform
92**********************************************
931. Build and install TF-M with the following command:
94
95.. code-block:: bash
96
97 $ cmake -S <TF-M Source Dir> \
98 -B build/spe_test \
99 -DTFM_PLATFORM=arm/mps4/corstone315 \
100 -DTFM_TOOLCHAIN_FILE=<TF-M Source Dir>/toolchain_<toolchain>.cmake \
101 -DTFM_PARTITION_INTERNAL_TRUSTED_STORAGE=ON \
102 -DTFM_PARTITION_CRYPTO=ON \
103 -DTEST_NS=ON
104 -DTEST_S=ON \
105 $ cmake --build build/spe_test -- -j$(nproc) install
106
1072. Then build the example with the following:
108
109.. code-block:: bash
110
111 $ cmake -S <this_example_path> \
112 -B build/nspe_test \
113 -DTFM_TOOLCHAIN=<toolchain> \
114 -DCONFIG_SPE_PATH=$(shell pwd)/<build_dir>/spe_test/api_ns
115 $ cmake --build build/nspe_test -- -j$(nproc)
116
Kevin Penga9ec66f2022-07-05 15:21:16 +0800117***********
118How to Test
119***********
120To test the RoT Services, you need to build the APIs and call the service APIs
121somewhere.
122
123If you want to add comprehensive tests using the TF-M test framework, please
Elena Uziunaite676a1462023-11-14 16:58:45 +0000124refer to :doc:`Adding TF-M Regression Test Suite <TF-M-Tests:tfm_test_suites_addition>`.
Kevin Penga9ec66f2022-07-05 15:21:16 +0800125
126Testing in NSPE
127===============
128Any NSPE can be used to test the example RoT services.
129If you are using the tf-m-tests repo as NSPE, you can:
130
131- Add the ``tfm_example_partition_api.c`` to ``tfm_ns_api`` CMake library.
132- Add the current directory in the include directory of ``tfm_ns_api``.
133- Call the services APIs in the ``test_app`` function.
134
135Testing in SPE
136==============
137
138Testing in SPE is to test requesting the RoT Services in any Secure Partition.
139
140- Add the example services to the ``dependencies`` attribute in the target
141 Secure Partition's manifest.
142- Call the services APIs somewhere in the Secure Partition, for example, in the
143 entry function.
144
145Note that the API source file has already been added in the ``CMakeLists.txt``.
146There are no extra steps to build the APIs for testing in SPE.
147
148**********
149References
150**********
151
152| `PSA Firmware Framework 1.0`_
153| `Firmware Framework for M 1.1 Extensions`_
Kevin Penga9ec66f2022-07-05 15:21:16 +0800154| `TF-M Manifest List`_
155| `Out-of-tree Secure Partition build`_
Kevin Penga9ec66f2022-07-05 15:21:16 +0800156
157.. _PSA Firmware Framework 1.0:
Elena Uziunaite676a1462023-11-14 16:58:45 +0000158 https://developer.arm.com/documentation/den0063/latest/
Kevin Penga9ec66f2022-07-05 15:21:16 +0800159
160.. _Firmware Framework for M 1.1 Extensions:
Elena Uziunaite676a1462023-11-14 16:58:45 +0000161 https://developer.arm.com/documentation/aes0039/latest/
Kevin Penga9ec66f2022-07-05 15:21:16 +0800162
163.. _TF-M Manifest List:
Elena Uziunaite3ad0ecc2023-10-27 15:15:35 +0100164 https://trustedfirmware-m.readthedocs.io/en/latest/integration_guide/services/tfm_manifest_tool_user_guide.html#manifest-list
Kevin Penga9ec66f2022-07-05 15:21:16 +0800165
166.. _Out-of-tree Secure Partition build:
Elena Uziunaite3ad0ecc2023-10-27 15:15:35 +0100167 https://trustedfirmware-m.readthedocs.io/en/latest/integration_guide/services/tfm_secure_partition_addition.html#out-of-tree-secure-partition-build
Kevin Penga9ec66f2022-07-05 15:21:16 +0800168
Kevin Penga9ec66f2022-07-05 15:21:16 +0800169--------------
170
Gergely Korcsák60e1b1e2024-04-19 17:25:37 +0200171*Copyright (c) 2020-2024, Arm Limited. All rights reserved.*