blob: 7979c65153c1577c4394148f09a4bab715c0eff4 [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)
Gabor Abonyi25c955b2022-01-13 09:58:22 +010036- Corstone SSE-300 with Ethos-U55 Example Subsystem for MPS3 (AN552)
37- Corstone-300 Ethos-U55 Ecosystem FVP (FVP_SSE300_MPS3)
Ludovic Barre8a77bdd2020-03-26 19:53:07 +010038- STM32L5xx: Cortex-M33 based platform (STM32L562 and STM32L552 socs)
Øyvind Rønningstadba9aac02020-09-14 15:19:28 +020039- nRF9160 DK (Cortex-M33)
Andrzej Głąbekaa74ab62021-04-20 11:46:27 +020040- nRF5340 DK (Cortex-M33 Application MCU)
Jamie McCrae13ff4572021-04-06 10:47:12 +010041- BL5340 DVK (Cortex-M33 Application MCU)
Gabor Abonyi25a713f2021-10-15 09:01:03 +020042- Corstone-Polaris Ethos-U55 FVP (Olympus CPU plus Ethos-U55)
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020043
44The files related to the supported platforms are contained under the
45``platform`` subfolder. The platform specific files are under
46``platform/ext/target``, which is organised by boards
47(e.g. ``platform/ext/target/mps2``), while the folder ``platform/ext/common``
48is used to store source and header files which are platform generic.
49
50More information about subsystems supported by the MPS2+ board can be found in:
51`MPS2+ homepage <https://developer.arm.com/products/system-design/development-boards/fpga-prototyping-boards/mps2>`__
52
Gabor Tothf07e92e2020-11-20 13:55:06 +010053More information about subsystems supported by the MPS3 board can be found in:
54`MPS3 homepage <https://developer.arm.com/products/system-design/development-boards/fpga-prototyping-boards/mps3>`__
55
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020056More information about the Musca-B1 test chip board can be found in:
57`Musca-B1 homepage <https://www.arm.com/products/development-tools/development-boards/musca-b1-iot>`__
58
Marton Berke8aae06f2019-11-25 16:46:12 +010059More information about the Musca-S1 test chip board can be found in:
60`Musca-S1 homepage <https://www.arm.com/company/news/2019/05/arm-demonstrates-new-iot-test-chip-and-board>`__
61
Kevin Peng0a142112018-09-21 10:42:22 +080062More information about subsystems supported by the MPS3 board can be found in:
63`MPS3 homepage <https://www.arm.com/products/development-tools/development-boards/mps3>`__
64
Marton Berke8c2f5242020-07-28 14:52:29 +020065More information about the Corstone-300 FVPs can be found in:
66`Arm Ecosystem FVPs homepage <https://developer.arm.com/tools-and-software/open-source-software/arm-platforms-software/arm-ecosystem-fvps>`__
67
Ludovic Barre8a77bdd2020-03-26 19:53:07 +010068More information about the STM32L5xx platform can be found in:
69`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>`__
70
Andrzej Głąbekaa74ab62021-04-20 11:46:27 +020071More information about the nRF5340 DK platform can be found in:
72`nRF5340 DK product page <https://www.nordicsemi.com/Software-and-tools/Development-Kits/nRF5340-DK>`__
Øyvind Rønningstadba9aac02020-09-14 15:19:28 +020073
74More information about the nRF9160 DK platform can be found in:
75`nRF9160 DK product page <https://www.nordicsemi.com/Software-and-tools/Development-Kits/nRF9160-DK>`__
76
Jamie McCrae13ff4572021-04-06 10:47:12 +010077More information about the BL5340 platform can be found in:
78`BL5340 product page <https://www.lairdconnect.com/wireless-modules/bluetooth-modules/bluetooth-5-modules/bl5340-series-multi-core-bluetooth-52-802154-nfc-modules>`__
79
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020080***************************
81How to integrate another OS
82***************************
David Hu5079a042021-04-07 17:16:59 +080083
84OS migration to Armv8-M platforms
85=================================
86To work with TF-M on Armv8-M platforms, the OS needs to support the Armv8-M
87architecture and, in particular, it needs to be able to run in the non-secure
88world. More information about OS migration to the Armv8-M architecture can be
89found in the :doc:`OS requirements <os_migration_guide_armv8m>`. Depending upon
90the system configuration this may require configuring drivers to use appropriate
91address ranges.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020092
93Interface with TF-M
94===================
95The files needed for the interface with TF-M are exported at the
Raef Coles4fed4632020-12-08 12:56:47 +000096``<install_dir>/interface`` path. The NS side is only allowed to call
David Hu5079a042021-04-07 17:16:59 +080097TF-M secure functions (veneers) from the NS Thread mode.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020098
David Hu5079a042021-04-07 17:16:59 +080099TF-M interface header files are exported in ``<install_dir>/interface/include``
100directory. For example, the Protected Storage (PS) service PSA API is declared
101in the file ``<install_dir>/interface/include/psa/protected_storage.h``.
102
103TF-M also exports a reference implementation of PSA APIs for NS clients in the
104``<install_dir>/interface/src``.
105
106On Armv8-M TrustZone based platforms, NS OS shall implement interface API
107``tfm_ns_interface_dispatch()`` to integrate with TF-M implementation of PSA
108APIs. See ``interface/include/tfm_ns_interface.h`` for the detailed declaration
109of ``tfm_ns_interface_dispatch()``.
110TF-M provides an example of ``tfm_ns_interface_dispatch()`` implementation on
111Armv8-M TrustZone based platforms. In this example, NS OS calls mutex in
112``tfm_ns_interface_dispatch()`` to synchronize multiple NS client calls to TF-M.
113See ``interface/src/tfm_ns_interface.c.example`` for more details.
114
115TF-M provides a reference implementation of NS mailbox on multi-core platforms,
116under folder ``interface/src/multi_core``.
David Hu0e6b44e2021-07-08 20:48:19 +0800117See :doc:`Mailbox design </docs/technical_references/design_docs/dual-cpu/mailbox_design_on_dual_core_system>`
David Hu5079a042021-04-07 17:16:59 +0800118for TF-M multi-core mailbox design.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200119
120Interface with non-secure world regression tests
121================================================
122A non-secure application that wants to run the non-secure regression tests
123needs to call the ``tfm_non_secure_client_run_tests()``. This function is
124exported into the header file ``test_framework_integ_test.h`` inside the
125``<build_dir>/install`` folder structure in the test specific files,
126i.e. ``<build_dir>/install/export/tfm/test/inc``. The non-secure regression
127tests are precompiled and delivered as a static library which is available in
128``<build_dir>/install/export/tfm/test/lib``, so that the non-secure application
129needs to link against the library to be able to invoke the
Kevin Pengc6d74502020-03-04 16:55:37 +0800130``tfm_non_secure_client_run_tests()`` function. The PS non-secure side
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200131regression tests rely on some OS functionality e.g. threads, mutexes etc. These
132functions comply with CMSIS RTOS2 standard and have been exported as thin
133wrappers defined in ``os_wrapper.h`` contained in
134``<build_dir>/install/export/tfm/test/inc``. OS needs to provide the
135implementation of these wrappers to be able to run the tests.
136
137NS client Identification
138========================
David Wang96787522021-09-22 20:51:01 +0800139
140The NS client identification (NSID) is specified by either SPM or NSPE RTOS.
141If SPM manages the NSID (default option), then the same NSID (-1) will be used
142for all connections from NS clients.
143For the case that NSPE RTOS manages the NSID and/or different NSIDs should be
144used for different NS clients. See
145:doc:`Non-secure Client Extension Integration Guide </docs/integration_guide/non-secure_client_extension_integration_guide>`.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200146
Mate Toth-Pal12d7a182019-04-28 14:05:21 +0200147*********************
148Non-secure interrupts
149*********************
150Non-secure interrupts are allowed to preempt Secure thread mode.
151With the current implementation, a NSPE task can spoof the identity of another
152NSPE task. This is an issue only when NSPE has provisions for task isolation.
153Note, that ``AIRCR.PRIS`` is still set to restrict the priority range available
154to NS interrupts to the lower half of available priorities so that it wouldn't
155be possible for any non-secure interrupt to preempt a higher-priority secure
156interrupt.
157
Raef Coles558487a2020-10-29 13:09:44 +0000158**********************************
159Integration with non-Cmake systems
160**********************************
161
162Generated Files
163===============
164
165Files that are derived from PSA manifests are generated at build-time by cmake.
166For integration with systems that do no use cmake, the files must be generated
167manually.
168
169The ``tools/tfm_parse_manifest_list.py`` script can be invoked manually. Some
170arguments will be needed to be provided. Please refer to
171``tfm_parse_manifest_list.py --help`` for more details.
172
173Some variables are used in the template files, these will need to be set in the
174environment before the script will succeed when the script is not run via cmake.
175
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200176--------------
177
Gabor Abonyi25c955b2022-01-13 09:58:22 +0100178*Copyright (c) 2017-2022, Arm Limited. All rights reserved.*