blob: f0f2a1ef552eafc39208b5f10b1b5f4cf303b09e [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 Berke07fc95f2020-08-18 15:24:14 +020031- Corstone-300 Ecosystem FVP (Cortex-M55 SSE-300 MPS2+)
Marton Berke8c2f5242020-07-28 14:52:29 +020032- Corstone-300 Ethos-U55 FVP (Cortex-M55 plus Ethos-U55 SSE-300 MPS3)
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020033- Musca-B1 test chip board (Cortex-M33 SSE-200 subsystem)
Marton Berke8aae06f2019-11-25 16:46:12 +010034- Musca-S1 test chip board (Cortex-M33 SSE-200 subsystem)
Kevin Peng0a142112018-09-21 10:42:22 +080035- CoreLink SSE-200 Subsystem for MPS3 (AN524)
Gabor Tothf07e92e2020-11-20 13:55:06 +010036- Corstone SSE-300 with Ethos-U55 Example Subsystem for MPS3 (AN547)
Ludovic Barre8a77bdd2020-03-26 19:53:07 +010037- STM32L5xx: Cortex-M33 based platform (STM32L562 and STM32L552 socs)
Øyvind Rønningstadba9aac02020-09-14 15:19:28 +020038- nRF9160 DK (Cortex-M33)
Andrzej Głąbekaa74ab62021-04-20 11:46:27 +020039- nRF5340 DK (Cortex-M33 Application MCU)
Jamie McCrae13ff4572021-04-06 10:47:12 +010040- BL5340 DVK (Cortex-M33 Application MCU)
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020041
42The files related to the supported platforms are contained under the
43``platform`` subfolder. The platform specific files are under
44``platform/ext/target``, which is organised by boards
45(e.g. ``platform/ext/target/mps2``), while the folder ``platform/ext/common``
46is used to store source and header files which are platform generic.
47
48More information about subsystems supported by the MPS2+ board can be found in:
49`MPS2+ homepage <https://developer.arm.com/products/system-design/development-boards/fpga-prototyping-boards/mps2>`__
50
Gabor Tothf07e92e2020-11-20 13:55:06 +010051More information about subsystems supported by the MPS3 board can be found in:
52`MPS3 homepage <https://developer.arm.com/products/system-design/development-boards/fpga-prototyping-boards/mps3>`__
53
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020054More information about the Musca-B1 test chip board can be found in:
55`Musca-B1 homepage <https://www.arm.com/products/development-tools/development-boards/musca-b1-iot>`__
56
Marton Berke8aae06f2019-11-25 16:46:12 +010057More information about the Musca-S1 test chip board can be found in:
58`Musca-S1 homepage <https://www.arm.com/company/news/2019/05/arm-demonstrates-new-iot-test-chip-and-board>`__
59
Kevin Peng0a142112018-09-21 10:42:22 +080060More information about subsystems supported by the MPS3 board can be found in:
61`MPS3 homepage <https://www.arm.com/products/development-tools/development-boards/mps3>`__
62
Marton Berke8c2f5242020-07-28 14:52:29 +020063More information about the Corstone-300 FVPs can be found in:
64`Arm Ecosystem FVPs homepage <https://developer.arm.com/tools-and-software/open-source-software/arm-platforms-software/arm-ecosystem-fvps>`__
65
Ludovic Barre8a77bdd2020-03-26 19:53:07 +010066More information about the STM32L5xx platform can be found in:
67`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>`__
68
Andrzej Głąbekaa74ab62021-04-20 11:46:27 +020069More information about the nRF5340 DK platform can be found in:
70`nRF5340 DK product page <https://www.nordicsemi.com/Software-and-tools/Development-Kits/nRF5340-DK>`__
Øyvind Rønningstadba9aac02020-09-14 15:19:28 +020071
72More information about the nRF9160 DK platform can be found in:
73`nRF9160 DK product page <https://www.nordicsemi.com/Software-and-tools/Development-Kits/nRF9160-DK>`__
74
Jamie McCrae13ff4572021-04-06 10:47:12 +010075More information about the BL5340 platform can be found in:
76`BL5340 product page <https://www.lairdconnect.com/wireless-modules/bluetooth-modules/bluetooth-5-modules/bl5340-series-multi-core-bluetooth-52-802154-nfc-modules>`__
77
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020078***************************
79How to integrate another OS
80***************************
David Hu5079a042021-04-07 17:16:59 +080081
82OS migration to Armv8-M platforms
83=================================
84To work with TF-M on Armv8-M platforms, the OS needs to support the Armv8-M
85architecture and, in particular, it needs to be able to run in the non-secure
86world. More information about OS migration to the Armv8-M architecture can be
87found in the :doc:`OS requirements <os_migration_guide_armv8m>`. Depending upon
88the system configuration this may require configuring drivers to use appropriate
89address ranges.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020090
91Interface with TF-M
92===================
93The files needed for the interface with TF-M are exported at the
Raef Coles4fed4632020-12-08 12:56:47 +000094``<install_dir>/interface`` path. The NS side is only allowed to call
David Hu5079a042021-04-07 17:16:59 +080095TF-M secure functions (veneers) from the NS Thread mode.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020096
David Hu5079a042021-04-07 17:16:59 +080097TF-M interface header files are exported in ``<install_dir>/interface/include``
98directory. For example, the Protected Storage (PS) service PSA API is declared
99in the file ``<install_dir>/interface/include/psa/protected_storage.h``.
100
101TF-M also exports a reference implementation of PSA APIs for NS clients in the
102``<install_dir>/interface/src``.
103
104On Armv8-M TrustZone based platforms, NS OS shall implement interface API
105``tfm_ns_interface_dispatch()`` to integrate with TF-M implementation of PSA
106APIs. See ``interface/include/tfm_ns_interface.h`` for the detailed declaration
107of ``tfm_ns_interface_dispatch()``.
108TF-M provides an example of ``tfm_ns_interface_dispatch()`` implementation on
109Armv8-M TrustZone based platforms. In this example, NS OS calls mutex in
110``tfm_ns_interface_dispatch()`` to synchronize multiple NS client calls to TF-M.
111See ``interface/src/tfm_ns_interface.c.example`` for more details.
112
113TF-M provides a reference implementation of NS mailbox on multi-core platforms,
114under folder ``interface/src/multi_core``.
David Hu0e6b44e2021-07-08 20:48:19 +0800115See :doc:`Mailbox design </docs/technical_references/design_docs/dual-cpu/mailbox_design_on_dual_core_system>`
David Hu5079a042021-04-07 17:16:59 +0800116for TF-M multi-core mailbox design.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200117
118Interface with non-secure world regression tests
119================================================
120A non-secure application that wants to run the non-secure regression tests
121needs to call the ``tfm_non_secure_client_run_tests()``. This function is
122exported into the header file ``test_framework_integ_test.h`` inside the
123``<build_dir>/install`` folder structure in the test specific files,
124i.e. ``<build_dir>/install/export/tfm/test/inc``. The non-secure regression
125tests are precompiled and delivered as a static library which is available in
126``<build_dir>/install/export/tfm/test/lib``, so that the non-secure application
127needs to link against the library to be able to invoke the
Kevin Pengc6d74502020-03-04 16:55:37 +0800128``tfm_non_secure_client_run_tests()`` function. The PS non-secure side
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200129regression tests rely on some OS functionality e.g. threads, mutexes etc. These
130functions comply with CMSIS RTOS2 standard and have been exported as thin
131wrappers defined in ``os_wrapper.h`` contained in
132``<build_dir>/install/export/tfm/test/inc``. OS needs to provide the
133implementation of these wrappers to be able to run the tests.
134
135NS client Identification
136========================
137See
David Hu0e6b44e2021-07-08 20:48:19 +0800138:doc:`ns client identification documentation </docs/technical_references/design_docs/tfm_ns_client_identification>`.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200139
Mate Toth-Pal12d7a182019-04-28 14:05:21 +0200140*********************
141Non-secure interrupts
142*********************
143Non-secure interrupts are allowed to preempt Secure thread mode.
144With the current implementation, a NSPE task can spoof the identity of another
145NSPE task. This is an issue only when NSPE has provisions for task isolation.
146Note, that ``AIRCR.PRIS`` is still set to restrict the priority range available
147to NS interrupts to the lower half of available priorities so that it wouldn't
148be possible for any non-secure interrupt to preempt a higher-priority secure
149interrupt.
150
Raef Coles558487a2020-10-29 13:09:44 +0000151**********************************
152Integration with non-Cmake systems
153**********************************
154
155Generated Files
156===============
157
158Files that are derived from PSA manifests are generated at build-time by cmake.
159For integration with systems that do no use cmake, the files must be generated
160manually.
161
162The ``tools/tfm_parse_manifest_list.py`` script can be invoked manually. Some
163arguments will be needed to be provided. Please refer to
164``tfm_parse_manifest_list.py --help`` for more details.
165
166Some variables are used in the template files, these will need to be set in the
167environment before the script will succeed when the script is not run via cmake.
168
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200169--------------
170
Raef Colesa198a442020-11-24 11:42:53 +0000171*Copyright (c) 2017-2021, Arm Limited. All rights reserved.*