blob: 41f10ed940bbe5a2b09b3b508c7227ad787ba42c [file] [log] [blame]
Gyorgy Szingdb9783c2019-04-17 21:08:48 +02001######################
2TF-M integration guide
3######################
4The 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*****************
10Follow the :doc:`Build instructions <tfm_build_instruction>`.
11
12********************************************************
13How to export files for building non-secure applications
14********************************************************
15Explained in the :doc:`Build instructions <tfm_build_instruction>`.
16
17*************************
18How to add a new platform
19*************************
20The hardware platforms currently supported are:
21
22- Soft Macro Model (SMM) Cortex-M33 SSE-200 subsystem for MPS2+ (AN521)
23- Cortex-M23 IoT Kit subsystem for MPS2+ (AN519)
24- Musca-A1 test chip board (Cortex-M33 SSE-200 subsystem)
25- Musca-B1 test chip board (Cortex-M33 SSE-200 subsystem)
26
27The files related to the supported platforms are contained under the
28``platform`` subfolder. The platform specific files are under
29``platform/ext/target``, which is organised by boards
30(e.g. ``platform/ext/target/mps2``), while the folder ``platform/ext/common``
31is used to store source and header files which are platform generic.
32
33More information about subsystems supported by the MPS2+ board can be found in:
34`MPS2+ homepage <https://developer.arm.com/products/system-design/development-boards/fpga-prototyping-boards/mps2>`__
35
36More information about the Musca-A1 test chip board can be found in:
37`Musca-A homepage <https://developer.arm.com/products/system-design/development-boards/iot-test-chips-and-boards/musca-a-test-chip-board>`__
38
39More information about the Musca-B1 test chip board can be found in:
40`Musca-B1 homepage <https://www.arm.com/products/development-tools/development-boards/musca-b1-iot>`__
41
42Generic drivers and startup/scatter files
43=========================================
44The addition of a new platform means the creation of a new subfolder inside
45``target/<board_name>`` to provide an implementation of the drivers currently
46used by TF-M, in particular MPC, PPC, and USART drivers. In addition to the
47drivers, startup and scatter files need to be provided for the supported
48toolchains.
49
50There are also board specific drivers which are used by the board
51platform to interact with the external world, for example during tests, that
52have to be provided, e.g. to blink LEDs or count time in the MPS2 board.
53
54.. Note::
55
56 Currently SST and BL2 bootloader use different flash interface
57
58Target configuration files
59==========================
60Inside the base root folder of the selected target, each implementation has to
61provide its own copy of ``target_cfg.c/.h``. This file has target specific
62configuration functions and settings that are called by the TF-M during the
63platform configuration step during TF-M boot. Examples of the configurations
64performed during this phase are the MPC configuration, the SAU configuration,
65or eventually PPC configuration if supported by the hardware platform.
66Similarly, the ``uart_stdout.c`` is used to provide functions needed to redirect
67the stdout on UART (this is currently used by TF-M to log messages).
68
69Platform retarget files
70=======================
71An important part that each new platform has to provide is the set of retarget
72files which are contained inside the ``retarget`` folder. These files define the
73peripheral base addresses for the platform, both for the secure and non-secure
74aliases (when available), and bind those addresses to the base addresses used by
75the devices available in the hardware platform.
76
77***************************
78How to integrate another OS
79***************************
80To work with TF-M, the OS needs to support the Armv8-M architecture and, in
81particular, it needs to be able to run in the non-secure world. More
82information about OS migration to the Armv8-M architecture can be found in the
83:doc:`OS requirements <os_migration_guide_armv8m>`. Depending upon the system
84configuration this may require configuring drivers to use appropriate address
85ranges.
86
87Interface with TF-M
88===================
89The files needed for the interface with TF-M are exported at the
90``<build_dir>/install/export/tfm`` path. The NS side is only allowed to call
91TF-M secure functions (veneers) from the NS Thread mode. For this reason, the
92API is a collection of functions in the ``<build_dir>/install/export/tfm/inc``
93directory. For example, the interface for the Secure STorage (SST) service
94is described in the file ``psa_sst_api.h`` as a collection of functions that
95call service veneer functions. This API is a wrapper for the secure veneers,
96and returns the return value from the service to the caller.
97
98The secure storage service uses a numerical ID, to identify the clients that use
99the service. For details see
100:doc:`ns client identification documentation <tfm_ns_client_identification>`.
101
102Interface with non-secure world regression tests
103================================================
104A non-secure application that wants to run the non-secure regression tests
105needs to call the ``tfm_non_secure_client_run_tests()``. This function is
106exported into the header file ``test_framework_integ_test.h`` inside the
107``<build_dir>/install`` folder structure in the test specific files,
108i.e. ``<build_dir>/install/export/tfm/test/inc``. The non-secure regression
109tests are precompiled and delivered as a static library which is available in
110``<build_dir>/install/export/tfm/test/lib``, so that the non-secure application
111needs to link against the library to be able to invoke the
112``tfm_non_secure_client_run_tests()`` function. The SST non-secure side
113regression tests rely on some OS functionality e.g. threads, mutexes etc. These
114functions comply with CMSIS RTOS2 standard and have been exported as thin
115wrappers defined in ``os_wrapper.h`` contained in
116``<build_dir>/install/export/tfm/test/inc``. OS needs to provide the
117implementation of these wrappers to be able to run the tests.
118
119NS client Identification
120========================
121See
122:doc:`ns client identification documentation <tfm_ns_client_identification>`.
123
124--------------
125
126*Copyright (c) 2017-2019, Arm Limited. All rights reserved.*