blob: d88d51bc5203f26c1a8a42d154a5827d42cf5728 [file] [log] [blame]
Gyorgy Szingdb9783c2019-04-17 21:08:48 +02001###################################
2Details for the platform/ext folder
3###################################
4This folder has code that has been imported from other projects. This means the
5files in this folder and subfolders have Apache 2.0 license which is different
6to BSD 3.0 license applied to the parent TF-M project.
7
8.. Note::
9 This folder is strictly Apache 2.0 with the exception of cmake files.
10 Maintainers should be consulted if this needs to be revisited.
11
12***********
13Sub-folders
14***********
15
16cmsis
17=====
18This folder contains core and compiler specific header files imported from the
19``CMSIS_5`` project.
20
21common
22======
Raef Colesa657a9c2019-10-24 14:36:43 +010023
24armclang and gcc
25----------------
26These contain the linker scripts used to configure the memory regions in TF-M
27regions.
28
29cc312
30-----
31This folder contains cmake and code files to interact with the CC312
32cryptographic accelerator. Integrating a platform with the CC312 requires some
33configuration, of which an example can be seen in the
34``platform/ext/musca_b1.cmake`` file.
35
36To configure the CC312 at build time, a few cmake arguments can be specified.
37
38- ``CRYPTO_HW_ACCELERATOR``
39 - ``ON`` All possible mbedtls cryptographic operations will be offloaded to
40 the CC312 accelerator.
41 - ``OFF`` The cryptographic accelerator will be ignored and software
42 cryptography will be used.
43
44- ``CRYPTO_HW_ACCELERATOR_OTP_STATE``
45 - ``DISABLED`` The HW accelerator will not use any data from its onboard OTP
46 (One Time Programmable) memory.
47 - ``PROVISIONING`` This special mode is used to program cryptographic
48 material into the OTP memory. When the flag is set TF-M will not boot, but
49 will instead program the hardware unique key, the root of trust private key
50 and the attestation private key into the OTP memory. This mode is not
51 compatible with
52 ``CRYPTO_HW_ACCELERATOR=ON``.
53 - ``ENABLED`` The HW accelerator will use the previously programmed data as
54 the hardware unique key, the root of trust private key and the attestation
55 private key. This mode requires ``CRYPTO_HW_ACCELERATOR=ON``.
56
57
58.. Warning::
59
60 Provisioning **can not** be reversed, and data in the OTP memory **can not**
61 be changed once set.
62
63other
64-----
65This folder also contains stdout redirection to UART, a temporary memory mapped
66flash implementation for the bootloader and ``tfm_mbedcrypto_config.h`` for all
67the targets.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020068
69drivers
70=======
71This folder contains the headers with CMSIS compliant driver definitions that
72that TF-M project expects a target to provide.
73
74target_cfg.h
75------------
76This file is expected to define the following macros respectively.
77
78- ``TFM_DRIVER_STDIO`` - This macro should expand to a structure of type
79 ``ARM_DRIVER_USART``. TFM redirects its standard input and output to this
80 instance of USART.
81- ``NS_DRIVER_STDIO`` - This macro should expand to a structure of type
82 ``ARM_DRIVER_USART``. Non-Secure application redirects its standard input and
83 output to this instance of USART.
84
85target
86======
87This folder contains the files for individual target.
88
89Flash layout header file
90------------------------
91Target must provide a header file, called ``flash_layout.h``, which defines the
92information explained in the follow subsections. The defines must be named
93as they are in the subsections.
94
95BL2 bootloader
96^^^^^^^^^^^^^^
97The BL2 bootloader requires the following definitions:
98
99- ``FLASH_BASE_ADDRESS`` - Defines the first valid address in the flash.
100- ``FLASH_AREA_BL2_OFFSET`` - Defines the offset from the flash base address
101 where the BL2 - MCUBOOT area starts.
102- ``FLASH_AREA_BL2_SIZE`` - Defines the size of the BL2 area.
David Vinczebb207982019-08-21 15:13:04 +0200103- ``FLASH_AREA_SCRATCH_OFFSET`` - Defines the offset from the flash base
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200104 address where the scratch area starts, which is used during image swapping.
David Vinczebb207982019-08-21 15:13:04 +0200105- ``FLASH_AREA_SCRATCH_SIZE`` - Defines the size of the scratch area. The
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200106 minimal size must be as the biggest sector size in the flash.
107- ``FLASH_DEV_NAME`` - Specifies the flash device used by BL2.
108
David Vinczebb207982019-08-21 15:13:04 +0200109The BL2 requires further definitions depending on the number of images, the
110meaning of these macros are also slightly different:
111
112- Required definitions in case of 1 image (S and NS images are concatenated
113 and handled together as one binary blob):
114
115 - ``FLASH_AREA_0_OFFSET`` - Defines the offset from the flash base address
116 where the primary image area starts, which hosts the active firmware
117 image.
118 - ``FLASH_AREA_0_SIZE`` - Defines the size of the primary image area.
119 - ``FLASH_AREA_2_OFFSET`` - Defines the offset from the flash base address
120 where the secondary image area starts, which is a placeholder for new
121 firmware images.
122 - ``FLASH_AREA_2_SIZE`` - Defines the size of the secondary image area.
123
124- Required definitions in case of 2 images (S and NS images are handled and
125 updated separately):
126
127 - ``FLASH_AREA_0_OFFSET`` - Defines the offset from the flash base address
128 where the primary image areas start, which host the active firmware
129 images. It is also the offset of the primary (active) secure image area.
130 - ``FLASH_AREA_0_SIZE`` - Defines the size of the primary secure image area.
131 - ``FLASH_AREA_1_OFFSET`` - Defines the offset from the flash base address
132 where the primary (active) non-secure image area starts.
133 - ``FLASH_AREA_1_SIZE`` - Defines the size of the primary non-secure image
134 area.
135 - ``FLASH_AREA_2_OFFSET`` - Defines the offset from the flash base address
136 where the secondary image areas start, which are placeholders for new
137 firmware images. It is also the offset of the secondary secure image area.
138 - ``FLASH_AREA_2_SIZE`` - Defines the size of the secondary secure image
139 area.
140 - ``FLASH_AREA_3_OFFSET`` - Defines the offset from the flash base address
141 where the secondary non-secure image area starts.
142 - ``FLASH_AREA_3_SIZE`` - Defines the size of the secondary non-secure image
143 area.
144
145The table below shows a fraction of the flash layout in case of 2 and 1
146updatable images with the related flash areas that hold the firmware images:
147
148+-----------------------+--------------------+-----------------------+-----------------------------+
149| Image number: 2 | Image number: 1 |
150+=======================+====================+=======================+=============================+
151| **Flash area** | **Content** | **Flash area** | **Content** |
152+-----------------------+--------------------+-----------------------+-----------------------------+
153| FLASH_AREA_0 | | Secure image | FLASH_AREA_0 | | Secure + Non-secure image |
154| | | primary slot | | | primary slot |
155+-----------------------+--------------------+-----------------------+ +
156| FLASH_AREA_1 | | Non-secure image | | |
157| | | primary slot | | |
158+-----------------------+--------------------+-----------------------+-----------------------------+
159| FLASH_AREA_2 | | Secure image | FLASH_AREA_2 | | Secure + Non-secure image |
160| | | secondary slot | | | secondary slot |
161+-----------------------+--------------------+-----------------------+ +
162| FLASH_AREA_3 | | Non-secure image | | |
163| | | secondary slot | | |
164+-----------------------+--------------------+-----------------------+-----------------------------+
165| FLASH_AREA_SCRATCH | Scratch area | FLASH_AREA_SCRATCH | Scratch area |
166+-----------------------+--------------------+-----------------------+-----------------------------+
167
Raef Colesa4952592019-10-01 11:43:18 +0100168- ``IMAGE_EXECUTABLE_RAM_START`` - Defines the start of the region to which
169 images are allowed to be loaded. Only used if ``MCUBOOT_UPGRADE_STRATEGY`` is
170 configured to be ``RAM_LOADING``.
171
172- ``IMAGE_EXECUTABLE_RAM_SIZE`` - Defines the size of the region to which images
173 are allowed to be loaded. Only used if ``MCUBOOT_UPGRADE_STRATEGY`` is
174 configured to be ``RAM_LOADING``.
175
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200176Assemble tool
177^^^^^^^^^^^^^
Sverteczky, Marcell79ae9152019-06-06 15:00:11 +0200178The ``assemble.py`` tool is used to concatenate secure and non-secure binary
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200179to a single binary blob. It requires the following definitions:
180
181- ``SECURE_IMAGE_OFFSET`` - Defines the offset from the single binary blob base
182 address, where the secure image starts.
183- ``SECURE_IMAGE_MAX_SIZE`` - Defines the maximum size of the secure image area.
184- ``NON_SECURE_IMAGE_OFFSET`` - Defines the offset from the single binary blob
185 base address, where the non-secure image starts.
186- ``NON_SECURE_IMAGE_MAX_SIZE`` - Defines the maximum size of the non-secure
187 image area.
188
Sverteczky, Marcell79ae9152019-06-06 15:00:11 +0200189Image tool
190^^^^^^^^^^^^^
191The ``imgtool.py`` tool is used to handle the tasks related to signing the
David Vinczed8fbe0e2019-08-12 15:58:57 +0200192binary. It requires the following definition:
Sverteczky, Marcell79ae9152019-06-06 15:00:11 +0200193
Raef Colesa4952592019-10-01 11:43:18 +0100194- ``IMAGE_LOAD_ADDRESS`` - Defines the address to where the image is loaded and
195 is executed from. Only used if ``MCUBOOT_UPGRADE_STRATEGY`` is configured to
196 be ``RAM_LOADING``.
Sverteczky, Marcell79ae9152019-06-06 15:00:11 +0200197
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200198Secure Storage (SST) Service definitions
199^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
200The SST service requires the following definitions:
201
202- ``SST_FLASH_AREA_ADDR`` - Defines the flash area address where the secure
203 store area starts.
Vikas Katariya7d74ddb2019-09-19 11:59:57 +0100204- ``SST_FLASH_AREA_SIZE`` - Defines the size of the dedicated flash area
205 for secure storage.
TudorCretuba8a3fa2019-07-22 10:05:12 +0100206- ``SST_SECTOR_SIZE`` - Defines the size of the external flash sectors.
Vikas Katariya7d74ddb2019-09-19 11:59:57 +0100207- ``SST_SECTORS_PER_BLOCK`` - Defines the number of contiguous SST_SECTOR_SIZE
208 to form an SST_BLOCK_SIZE.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200209- ``SST_FLASH_DEV_NAME`` - Specifies the flash device used by SST to store the
210 data.
211- ``SST_FLASH_PROGRAM_UNIT`` - Defines the smallest flash programmable unit in
212 bytes.
213- ``SST_MAX_ASSET_SIZE`` - Defines the maximum asset size to be stored in the
214 SST area.
215- ``SST_NUM_ASSETS`` - Defines the maximum number of assets to be stored in the
216 SST area.
217
218.. Note::
219
220 The sectors must be consecutive.
221
TudorCretuba8a3fa2019-07-22 10:05:12 +0100222Internal Trusted Storage (ITS) Service definitions
223^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
224The ITS service requires the following definitions:
225
226- ``ITS_FLASH_AREA_ADDR`` - Defines the flash area address where the internal
227 trusted storage area starts.
David Hu74977d22019-10-22 10:26:03 +0800228- ``ITS_FLASH_AREA_SIZE`` - Defines the size of the dedicated flash area for the
229 internal trusted storage.
TudorCretuba8a3fa2019-07-22 10:05:12 +0100230- ``ITS_SECTOR_SIZE`` - Defines the size of the internal flash sectors.
David Hu74977d22019-10-22 10:26:03 +0800231- ``ITS_SECTORS_PER_BLOCK`` - Defines the number of contiguous ITS_SECTOR_SIZE
232 to form an ITS_BLOCK_SIZE.
TudorCretuba8a3fa2019-07-22 10:05:12 +0100233- ``ITS_FLASH_DEV_NAME`` - Specifies the internal flash device used by ITS to
234 store the data.
235- ``ITS_FLASH_PROGRAM_UNIT`` - Defines the smallest flash programmable unit in
236 bytes.
237- ``ITS_MAX_ASSET_SIZE`` - Defines the maximum asset size to be stored in the
238 ITS area.
239- ``ITS_NUM_ASSETS`` - Defines the maximum number of assets to be stored in the
240 ITS area.
241
242.. Note::
243
244 The sectors must be consecutive.
245
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200246***************************************
247Expose target support for HW components
248***************************************
249Services may require HW components to be supported by the target to enable some
250features (e.g. SST service with rollback protection, etc). The following
251definitions need to be set in the .cmake file if the target has the following
252HW components:
253
254- ``TARGET_NV_COUNTERS_ENABLE`` - Specifies that the target has non-volatile
255 (NV) counters.
256
257--------------
258
259*Copyright (c) 2017-2019, Arm Limited. All rights reserved.*