Galanakis, Minos | 41f8597 | 2019-09-30 15:56:40 +0100 | [diff] [blame] | 1 | ################# |
| 2 | Integration guide |
| 3 | ################# |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 4 | The purpose of this document is to provide a guide on how to integrate TF-M |
| 5 | with other hardware platforms and operating systems. |
| 6 | |
| 7 | ***************** |
| 8 | How to build TF-M |
| 9 | ***************** |
Summer Qin | ab1dd99 | 2021-05-25 13:58:55 +0800 | [diff] [blame] | 10 | Follow the :doc:`Build instructions </docs/technical_references/instructions/tfm_build_instruction>`. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 11 | |
| 12 | ******************************************************** |
| 13 | How to export files for building non-secure applications |
| 14 | ******************************************************** |
Summer Qin | ab1dd99 | 2021-05-25 13:58:55 +0800 | [diff] [blame] | 15 | Explained in the :doc:`Build instructions </docs/technical_references/instructions/tfm_build_instruction>`. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 16 | |
| 17 | ************************* |
| 18 | How to add a new platform |
| 19 | ************************* |
Robert Wakim | 12018a1 | 2021-06-29 11:47:03 +0100 | [diff] [blame] | 20 | |
| 21 | :doc:`Porting TF-M to a New Hardware </docs/integration_guide/porting_TFM_to_a_new_hardware>` |
| 22 | contains guidance on how to add a new platform. |
| 23 | |
| 24 | ******************* |
| 25 | Supported Platforms |
| 26 | ******************* |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 27 | The 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 Berke | 8c2f524 | 2020-07-28 14:52:29 +0200 | [diff] [blame] | 31 | - Corstone-300 Ethos-U55 FVP (Cortex-M55 plus Ethos-U55 SSE-300 MPS3) |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 32 | - Musca-B1 test chip board (Cortex-M33 SSE-200 subsystem) |
Marton Berke | 8aae06f | 2019-11-25 16:46:12 +0100 | [diff] [blame] | 33 | - Musca-S1 test chip board (Cortex-M33 SSE-200 subsystem) |
Kevin Peng | 0a14211 | 2018-09-21 10:42:22 +0800 | [diff] [blame] | 34 | - CoreLink SSE-200 Subsystem for MPS3 (AN524) |
Gabor Toth | f07e92e | 2020-11-20 13:55:06 +0100 | [diff] [blame] | 35 | - Corstone SSE-300 with Ethos-U55 Example Subsystem for MPS3 (AN547) |
Gabor Abonyi | 25c955b | 2022-01-13 09:58:22 +0100 | [diff] [blame] | 36 | - Corstone SSE-300 with Ethos-U55 Example Subsystem for MPS3 (AN552) |
| 37 | - Corstone-300 Ethos-U55 Ecosystem FVP (FVP_SSE300_MPS3) |
Ludovic Barre | 8a77bdd | 2020-03-26 19:53:07 +0100 | [diff] [blame] | 38 | - STM32L5xx: Cortex-M33 based platform (STM32L562 and STM32L552 socs) |
Øyvind Rønningstad | ba9aac0 | 2020-09-14 15:19:28 +0200 | [diff] [blame] | 39 | - nRF9160 DK (Cortex-M33) |
Andrzej Głąbek | aa74ab6 | 2021-04-20 11:46:27 +0200 | [diff] [blame] | 40 | - nRF5340 DK (Cortex-M33 Application MCU) |
Jamie McCrae | 13ff457 | 2021-04-06 10:47:12 +0100 | [diff] [blame] | 41 | - BL5340 DVK (Cortex-M33 Application MCU) |
Gabor Abonyi | 25a713f | 2021-10-15 09:01:03 +0200 | [diff] [blame] | 42 | - Corstone-Polaris Ethos-U55 FVP (Olympus CPU plus Ethos-U55) |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 43 | |
| 44 | The 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`` |
| 48 | is used to store source and header files which are platform generic. |
| 49 | |
| 50 | More 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 Toth | f07e92e | 2020-11-20 13:55:06 +0100 | [diff] [blame] | 53 | More 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 Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 56 | More 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 Berke | 8aae06f | 2019-11-25 16:46:12 +0100 | [diff] [blame] | 59 | More 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 Peng | 0a14211 | 2018-09-21 10:42:22 +0800 | [diff] [blame] | 62 | More 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 Berke | 8c2f524 | 2020-07-28 14:52:29 +0200 | [diff] [blame] | 65 | More 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 Barre | 8a77bdd | 2020-03-26 19:53:07 +0100 | [diff] [blame] | 68 | More 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łąbek | aa74ab6 | 2021-04-20 11:46:27 +0200 | [diff] [blame] | 71 | More 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ønningstad | ba9aac0 | 2020-09-14 15:19:28 +0200 | [diff] [blame] | 73 | |
| 74 | More 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 McCrae | 13ff457 | 2021-04-06 10:47:12 +0100 | [diff] [blame] | 77 | More 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 Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 80 | *************************** |
| 81 | How to integrate another OS |
| 82 | *************************** |
David Hu | 5079a04 | 2021-04-07 17:16:59 +0800 | [diff] [blame] | 83 | |
| 84 | OS migration to Armv8-M platforms |
| 85 | ================================= |
| 86 | To work with TF-M on Armv8-M platforms, the OS needs to support the Armv8-M |
| 87 | architecture and, in particular, it needs to be able to run in the non-secure |
| 88 | world. More information about OS migration to the Armv8-M architecture can be |
| 89 | found in the :doc:`OS requirements <os_migration_guide_armv8m>`. Depending upon |
| 90 | the system configuration this may require configuring drivers to use appropriate |
| 91 | address ranges. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 92 | |
| 93 | Interface with TF-M |
| 94 | =================== |
| 95 | The files needed for the interface with TF-M are exported at the |
Raef Coles | 4fed463 | 2020-12-08 12:56:47 +0000 | [diff] [blame] | 96 | ``<install_dir>/interface`` path. The NS side is only allowed to call |
David Hu | 5079a04 | 2021-04-07 17:16:59 +0800 | [diff] [blame] | 97 | TF-M secure functions (veneers) from the NS Thread mode. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 98 | |
David Hu | 5079a04 | 2021-04-07 17:16:59 +0800 | [diff] [blame] | 99 | TF-M interface header files are exported in ``<install_dir>/interface/include`` |
| 100 | directory. For example, the Protected Storage (PS) service PSA API is declared |
| 101 | in the file ``<install_dir>/interface/include/psa/protected_storage.h``. |
| 102 | |
| 103 | TF-M also exports a reference implementation of PSA APIs for NS clients in the |
| 104 | ``<install_dir>/interface/src``. |
| 105 | |
| 106 | On Armv8-M TrustZone based platforms, NS OS shall implement interface API |
| 107 | ``tfm_ns_interface_dispatch()`` to integrate with TF-M implementation of PSA |
| 108 | APIs. See ``interface/include/tfm_ns_interface.h`` for the detailed declaration |
| 109 | of ``tfm_ns_interface_dispatch()``. |
| 110 | TF-M provides an example of ``tfm_ns_interface_dispatch()`` implementation on |
| 111 | Armv8-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. |
| 113 | See ``interface/src/tfm_ns_interface.c.example`` for more details. |
| 114 | |
| 115 | TF-M provides a reference implementation of NS mailbox on multi-core platforms, |
| 116 | under folder ``interface/src/multi_core``. |
David Hu | 0e6b44e | 2021-07-08 20:48:19 +0800 | [diff] [blame] | 117 | See :doc:`Mailbox design </docs/technical_references/design_docs/dual-cpu/mailbox_design_on_dual_core_system>` |
David Hu | 5079a04 | 2021-04-07 17:16:59 +0800 | [diff] [blame] | 118 | for TF-M multi-core mailbox design. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 119 | |
| 120 | Interface with non-secure world regression tests |
| 121 | ================================================ |
| 122 | A non-secure application that wants to run the non-secure regression tests |
| 123 | needs to call the ``tfm_non_secure_client_run_tests()``. This function is |
| 124 | exported into the header file ``test_framework_integ_test.h`` inside the |
| 125 | ``<build_dir>/install`` folder structure in the test specific files, |
| 126 | i.e. ``<build_dir>/install/export/tfm/test/inc``. The non-secure regression |
| 127 | tests 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 |
| 129 | needs to link against the library to be able to invoke the |
Kevin Peng | c6d7450 | 2020-03-04 16:55:37 +0800 | [diff] [blame] | 130 | ``tfm_non_secure_client_run_tests()`` function. The PS non-secure side |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 131 | regression tests rely on some OS functionality e.g. threads, mutexes etc. These |
| 132 | functions comply with CMSIS RTOS2 standard and have been exported as thin |
| 133 | wrappers defined in ``os_wrapper.h`` contained in |
| 134 | ``<build_dir>/install/export/tfm/test/inc``. OS needs to provide the |
| 135 | implementation of these wrappers to be able to run the tests. |
| 136 | |
| 137 | NS client Identification |
| 138 | ======================== |
David Wang | 9678752 | 2021-09-22 20:51:01 +0800 | [diff] [blame] | 139 | |
| 140 | The NS client identification (NSID) is specified by either SPM or NSPE RTOS. |
| 141 | If SPM manages the NSID (default option), then the same NSID (-1) will be used |
| 142 | for all connections from NS clients. |
| 143 | For the case that NSPE RTOS manages the NSID and/or different NSIDs should be |
| 144 | used for different NS clients. See |
| 145 | :doc:`Non-secure Client Extension Integration Guide </docs/integration_guide/non-secure_client_extension_integration_guide>`. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 146 | |
Mate Toth-Pal | 12d7a18 | 2019-04-28 14:05:21 +0200 | [diff] [blame] | 147 | ********************* |
| 148 | Non-secure interrupts |
| 149 | ********************* |
| 150 | Non-secure interrupts are allowed to preempt Secure thread mode. |
| 151 | With the current implementation, a NSPE task can spoof the identity of another |
| 152 | NSPE task. This is an issue only when NSPE has provisions for task isolation. |
| 153 | Note, that ``AIRCR.PRIS`` is still set to restrict the priority range available |
| 154 | to NS interrupts to the lower half of available priorities so that it wouldn't |
| 155 | be possible for any non-secure interrupt to preempt a higher-priority secure |
| 156 | interrupt. |
| 157 | |
Raef Coles | 558487a | 2020-10-29 13:09:44 +0000 | [diff] [blame] | 158 | ********************************** |
| 159 | Integration with non-Cmake systems |
| 160 | ********************************** |
| 161 | |
| 162 | Generated Files |
| 163 | =============== |
| 164 | |
| 165 | Files that are derived from PSA manifests are generated at build-time by cmake. |
| 166 | For integration with systems that do no use cmake, the files must be generated |
| 167 | manually. |
| 168 | |
| 169 | The ``tools/tfm_parse_manifest_list.py`` script can be invoked manually. Some |
| 170 | arguments will be needed to be provided. Please refer to |
| 171 | ``tfm_parse_manifest_list.py --help`` for more details. |
| 172 | |
| 173 | Some variables are used in the template files, these will need to be set in the |
| 174 | environment before the script will succeed when the script is not run via cmake. |
| 175 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 176 | -------------- |
| 177 | |
Gabor Abonyi | 25c955b | 2022-01-13 09:58:22 +0100 | [diff] [blame] | 178 | *Copyright (c) 2017-2022, Arm Limited. All rights reserved.* |