blob: c3f8a6b2a8c2328f5d4f5cd6ae0addc75036f607 [file] [log] [blame]
Galanakis, Minos41f85972019-09-30 15:56:40 +01001#################
2Integration guide
3#################
Gyorgy Szingdb9783c2019-04-17 21:08:48 +02004The purpose of this document is to provide a guide on how to integrate TF-M
5with other hardware platforms and operating systems.
6
7*****************
8How to build TF-M
9*****************
Summer Qinab1dd992021-05-25 13:58:55 +080010Follow the :doc:`Build instructions </docs/technical_references/instructions/tfm_build_instruction>`.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020011
12********************************************************
13How to export files for building non-secure applications
14********************************************************
Summer Qinab1dd992021-05-25 13:58:55 +080015Explained in the :doc:`Build instructions </docs/technical_references/instructions/tfm_build_instruction>`.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020016
17*************************
18How to add a new platform
19*************************
Robert Wakim12018a12021-06-29 11:47:03 +010020
21:doc:`Porting TF-M to a New Hardware </docs/integration_guide/porting_TFM_to_a_new_hardware>`
22contains guidance on how to add a new platform.
23
24*******************
25Supported Platforms
26*******************
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020027The hardware platforms currently supported are:
28
29- Soft Macro Model (SMM) Cortex-M33 SSE-200 subsystem for MPS2+ (AN521)
30- Cortex-M23 IoT Kit subsystem for MPS2+ (AN519)
Marton Berke8c2f5242020-07-28 14:52:29 +020031- Corstone-300 Ethos-U55 FVP (Cortex-M55 plus Ethos-U55 SSE-300 MPS3)
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020032- Musca-B1 test chip board (Cortex-M33 SSE-200 subsystem)
Marton Berke8aae06f2019-11-25 16:46:12 +010033- Musca-S1 test chip board (Cortex-M33 SSE-200 subsystem)
Kevin Peng0a142112018-09-21 10:42:22 +080034- CoreLink SSE-200 Subsystem for MPS3 (AN524)
Gabor Tothf07e92e2020-11-20 13:55:06 +010035- Corstone SSE-300 with Ethos-U55 Example Subsystem for MPS3 (AN547)
Ludovic Barre8a77bdd2020-03-26 19:53:07 +010036- STM32L5xx: Cortex-M33 based platform (STM32L562 and STM32L552 socs)
Øyvind Rønningstadba9aac02020-09-14 15:19:28 +020037- nRF9160 DK (Cortex-M33)
Andrzej Głąbekaa74ab62021-04-20 11:46:27 +020038- nRF5340 DK (Cortex-M33 Application MCU)
Jamie McCrae13ff4572021-04-06 10:47:12 +010039- BL5340 DVK (Cortex-M33 Application MCU)
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020040
41The files related to the supported platforms are contained under the
42``platform`` subfolder. The platform specific files are under
43``platform/ext/target``, which is organised by boards
44(e.g. ``platform/ext/target/mps2``), while the folder ``platform/ext/common``
45is used to store source and header files which are platform generic.
46
47More information about subsystems supported by the MPS2+ board can be found in:
48`MPS2+ homepage <https://developer.arm.com/products/system-design/development-boards/fpga-prototyping-boards/mps2>`__
49
Gabor Tothf07e92e2020-11-20 13:55:06 +010050More information about subsystems supported by the MPS3 board can be found in:
51`MPS3 homepage <https://developer.arm.com/products/system-design/development-boards/fpga-prototyping-boards/mps3>`__
52
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020053More information about the Musca-B1 test chip board can be found in:
54`Musca-B1 homepage <https://www.arm.com/products/development-tools/development-boards/musca-b1-iot>`__
55
Marton Berke8aae06f2019-11-25 16:46:12 +010056More information about the Musca-S1 test chip board can be found in:
57`Musca-S1 homepage <https://www.arm.com/company/news/2019/05/arm-demonstrates-new-iot-test-chip-and-board>`__
58
Kevin Peng0a142112018-09-21 10:42:22 +080059More information about subsystems supported by the MPS3 board can be found in:
60`MPS3 homepage <https://www.arm.com/products/development-tools/development-boards/mps3>`__
61
Marton Berke8c2f5242020-07-28 14:52:29 +020062More information about the Corstone-300 FVPs can be found in:
63`Arm Ecosystem FVPs homepage <https://developer.arm.com/tools-and-software/open-source-software/arm-platforms-software/arm-ecosystem-fvps>`__
64
Ludovic Barre8a77bdd2020-03-26 19:53:07 +010065More information about the STM32L5xx platform can be found in:
66`STM32L5 series product page <https://www.st.com/content/st_com/en/products/microcontrollers-microprocessors/stm32-32-bit-arm-cortex-mcus/stm32-ultra-low-power-mcus/stm32l5-series.html>`__
67
Andrzej Głąbekaa74ab62021-04-20 11:46:27 +020068More information about the nRF5340 DK platform can be found in:
69`nRF5340 DK product page <https://www.nordicsemi.com/Software-and-tools/Development-Kits/nRF5340-DK>`__
Øyvind Rønningstadba9aac02020-09-14 15:19:28 +020070
71More information about the nRF9160 DK platform can be found in:
72`nRF9160 DK product page <https://www.nordicsemi.com/Software-and-tools/Development-Kits/nRF9160-DK>`__
73
Jamie McCrae13ff4572021-04-06 10:47:12 +010074More information about the BL5340 platform can be found in:
75`BL5340 product page <https://www.lairdconnect.com/wireless-modules/bluetooth-modules/bluetooth-5-modules/bl5340-series-multi-core-bluetooth-52-802154-nfc-modules>`__
76
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020077***************************
78How to integrate another OS
79***************************
David Hu5079a042021-04-07 17:16:59 +080080
81OS migration to Armv8-M platforms
82=================================
83To work with TF-M on Armv8-M platforms, the OS needs to support the Armv8-M
84architecture and, in particular, it needs to be able to run in the non-secure
85world. More information about OS migration to the Armv8-M architecture can be
86found in the :doc:`OS requirements <os_migration_guide_armv8m>`. Depending upon
87the system configuration this may require configuring drivers to use appropriate
88address ranges.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020089
90Interface with TF-M
91===================
92The files needed for the interface with TF-M are exported at the
Raef Coles4fed4632020-12-08 12:56:47 +000093``<install_dir>/interface`` path. The NS side is only allowed to call
David Hu5079a042021-04-07 17:16:59 +080094TF-M secure functions (veneers) from the NS Thread mode.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020095
David Hu5079a042021-04-07 17:16:59 +080096TF-M interface header files are exported in ``<install_dir>/interface/include``
97directory. For example, the Protected Storage (PS) service PSA API is declared
98in the file ``<install_dir>/interface/include/psa/protected_storage.h``.
99
100TF-M also exports a reference implementation of PSA APIs for NS clients in the
101``<install_dir>/interface/src``.
102
103On Armv8-M TrustZone based platforms, NS OS shall implement interface API
104``tfm_ns_interface_dispatch()`` to integrate with TF-M implementation of PSA
105APIs. See ``interface/include/tfm_ns_interface.h`` for the detailed declaration
106of ``tfm_ns_interface_dispatch()``.
107TF-M provides an example of ``tfm_ns_interface_dispatch()`` implementation on
108Armv8-M TrustZone based platforms. In this example, NS OS calls mutex in
109``tfm_ns_interface_dispatch()`` to synchronize multiple NS client calls to TF-M.
110See ``interface/src/tfm_ns_interface.c.example`` for more details.
111
112TF-M provides a reference implementation of NS mailbox on multi-core platforms,
113under folder ``interface/src/multi_core``.
David Hu0e6b44e2021-07-08 20:48:19 +0800114See :doc:`Mailbox design </docs/technical_references/design_docs/dual-cpu/mailbox_design_on_dual_core_system>`
David Hu5079a042021-04-07 17:16:59 +0800115for TF-M multi-core mailbox design.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200116
117Interface with non-secure world regression tests
118================================================
119A non-secure application that wants to run the non-secure regression tests
120needs to call the ``tfm_non_secure_client_run_tests()``. This function is
121exported into the header file ``test_framework_integ_test.h`` inside the
122``<build_dir>/install`` folder structure in the test specific files,
123i.e. ``<build_dir>/install/export/tfm/test/inc``. The non-secure regression
124tests are precompiled and delivered as a static library which is available in
125``<build_dir>/install/export/tfm/test/lib``, so that the non-secure application
126needs to link against the library to be able to invoke the
Kevin Pengc6d74502020-03-04 16:55:37 +0800127``tfm_non_secure_client_run_tests()`` function. The PS non-secure side
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200128regression tests rely on some OS functionality e.g. threads, mutexes etc. These
129functions comply with CMSIS RTOS2 standard and have been exported as thin
130wrappers defined in ``os_wrapper.h`` contained in
131``<build_dir>/install/export/tfm/test/inc``. OS needs to provide the
132implementation of these wrappers to be able to run the tests.
133
134NS client Identification
135========================
David Wang96787522021-09-22 20:51:01 +0800136
137The NS client identification (NSID) is specified by either SPM or NSPE RTOS.
138If SPM manages the NSID (default option), then the same NSID (-1) will be used
139for all connections from NS clients.
140For the case that NSPE RTOS manages the NSID and/or different NSIDs should be
141used for different NS clients. See
142:doc:`Non-secure Client Extension Integration Guide </docs/integration_guide/non-secure_client_extension_integration_guide>`.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200143
Mate Toth-Pal12d7a182019-04-28 14:05:21 +0200144*********************
145Non-secure interrupts
146*********************
147Non-secure interrupts are allowed to preempt Secure thread mode.
148With the current implementation, a NSPE task can spoof the identity of another
149NSPE task. This is an issue only when NSPE has provisions for task isolation.
150Note, that ``AIRCR.PRIS`` is still set to restrict the priority range available
151to NS interrupts to the lower half of available priorities so that it wouldn't
152be possible for any non-secure interrupt to preempt a higher-priority secure
153interrupt.
154
Raef Coles558487a2020-10-29 13:09:44 +0000155**********************************
156Integration with non-Cmake systems
157**********************************
158
159Generated Files
160===============
161
162Files that are derived from PSA manifests are generated at build-time by cmake.
163For integration with systems that do no use cmake, the files must be generated
164manually.
165
166The ``tools/tfm_parse_manifest_list.py`` script can be invoked manually. Some
167arguments will be needed to be provided. Please refer to
168``tfm_parse_manifest_list.py --help`` for more details.
169
170Some variables are used in the template files, these will need to be set in the
171environment before the script will succeed when the script is not run via cmake.
172
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200173--------------
174
Raef Colesa198a442020-11-24 11:42:53 +0000175*Copyright (c) 2017-2021, Arm Limited. All rights reserved.*