blob: a5f7e0345cec860670c0efc69be856b12c4225cb [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======
23This folder contains stdout redirection to UART, a temporary memory mapped flash
Jamie Fox0d87f662019-09-20 11:22:03 +010024implementation for the bootloader and ``tfm_mbedcrypto_config.h`` for all the
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020025targets.
26
27drivers
28=======
29This folder contains the headers with CMSIS compliant driver definitions that
30that TF-M project expects a target to provide.
31
32target_cfg.h
33------------
34This file is expected to define the following macros respectively.
35
36- ``TFM_DRIVER_STDIO`` - This macro should expand to a structure of type
37 ``ARM_DRIVER_USART``. TFM redirects its standard input and output to this
38 instance of USART.
39- ``NS_DRIVER_STDIO`` - This macro should expand to a structure of type
40 ``ARM_DRIVER_USART``. Non-Secure application redirects its standard input and
41 output to this instance of USART.
42
43target
44======
45This folder contains the files for individual target.
46
47Flash layout header file
48------------------------
49Target must provide a header file, called ``flash_layout.h``, which defines the
50information explained in the follow subsections. The defines must be named
51as they are in the subsections.
52
53BL2 bootloader
54^^^^^^^^^^^^^^
55The BL2 bootloader requires the following definitions:
56
57- ``FLASH_BASE_ADDRESS`` - Defines the first valid address in the flash.
58- ``FLASH_AREA_BL2_OFFSET`` - Defines the offset from the flash base address
59 where the BL2 - MCUBOOT area starts.
60- ``FLASH_AREA_BL2_SIZE`` - Defines the size of the BL2 area.
David Vinczebb207982019-08-21 15:13:04 +020061- ``FLASH_AREA_SCRATCH_OFFSET`` - Defines the offset from the flash base
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020062 address where the scratch area starts, which is used during image swapping.
David Vinczebb207982019-08-21 15:13:04 +020063- ``FLASH_AREA_SCRATCH_SIZE`` - Defines the size of the scratch area. The
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020064 minimal size must be as the biggest sector size in the flash.
65- ``FLASH_DEV_NAME`` - Specifies the flash device used by BL2.
66
David Vinczebb207982019-08-21 15:13:04 +020067The BL2 requires further definitions depending on the number of images, the
68meaning of these macros are also slightly different:
69
70- Required definitions in case of 1 image (S and NS images are concatenated
71 and handled together as one binary blob):
72
73 - ``FLASH_AREA_0_OFFSET`` - Defines the offset from the flash base address
74 where the primary image area starts, which hosts the active firmware
75 image.
76 - ``FLASH_AREA_0_SIZE`` - Defines the size of the primary image area.
77 - ``FLASH_AREA_2_OFFSET`` - Defines the offset from the flash base address
78 where the secondary image area starts, which is a placeholder for new
79 firmware images.
80 - ``FLASH_AREA_2_SIZE`` - Defines the size of the secondary image area.
81
82- Required definitions in case of 2 images (S and NS images are handled and
83 updated separately):
84
85 - ``FLASH_AREA_0_OFFSET`` - Defines the offset from the flash base address
86 where the primary image areas start, which host the active firmware
87 images. It is also the offset of the primary (active) secure image area.
88 - ``FLASH_AREA_0_SIZE`` - Defines the size of the primary secure image area.
89 - ``FLASH_AREA_1_OFFSET`` - Defines the offset from the flash base address
90 where the primary (active) non-secure image area starts.
91 - ``FLASH_AREA_1_SIZE`` - Defines the size of the primary non-secure image
92 area.
93 - ``FLASH_AREA_2_OFFSET`` - Defines the offset from the flash base address
94 where the secondary image areas start, which are placeholders for new
95 firmware images. It is also the offset of the secondary secure image area.
96 - ``FLASH_AREA_2_SIZE`` - Defines the size of the secondary secure image
97 area.
98 - ``FLASH_AREA_3_OFFSET`` - Defines the offset from the flash base address
99 where the secondary non-secure image area starts.
100 - ``FLASH_AREA_3_SIZE`` - Defines the size of the secondary non-secure image
101 area.
102
103The table below shows a fraction of the flash layout in case of 2 and 1
104updatable images with the related flash areas that hold the firmware images:
105
106+-----------------------+--------------------+-----------------------+-----------------------------+
107| Image number: 2 | Image number: 1 |
108+=======================+====================+=======================+=============================+
109| **Flash area** | **Content** | **Flash area** | **Content** |
110+-----------------------+--------------------+-----------------------+-----------------------------+
111| FLASH_AREA_0 | | Secure image | FLASH_AREA_0 | | Secure + Non-secure image |
112| | | primary slot | | | primary slot |
113+-----------------------+--------------------+-----------------------+ +
114| FLASH_AREA_1 | | Non-secure image | | |
115| | | primary slot | | |
116+-----------------------+--------------------+-----------------------+-----------------------------+
117| FLASH_AREA_2 | | Secure image | FLASH_AREA_2 | | Secure + Non-secure image |
118| | | secondary slot | | | secondary slot |
119+-----------------------+--------------------+-----------------------+ +
120| FLASH_AREA_3 | | Non-secure image | | |
121| | | secondary slot | | |
122+-----------------------+--------------------+-----------------------+-----------------------------+
123| FLASH_AREA_SCRATCH | Scratch area | FLASH_AREA_SCRATCH | Scratch area |
124+-----------------------+--------------------+-----------------------+-----------------------------+
125
Raef Colesa4952592019-10-01 11:43:18 +0100126- ``IMAGE_EXECUTABLE_RAM_START`` - Defines the start of the region to which
127 images are allowed to be loaded. Only used if ``MCUBOOT_UPGRADE_STRATEGY`` is
128 configured to be ``RAM_LOADING``.
129
130- ``IMAGE_EXECUTABLE_RAM_SIZE`` - Defines the size of the region to which images
131 are allowed to be loaded. Only used if ``MCUBOOT_UPGRADE_STRATEGY`` is
132 configured to be ``RAM_LOADING``.
133
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200134Assemble tool
135^^^^^^^^^^^^^
Sverteczky, Marcell79ae9152019-06-06 15:00:11 +0200136The ``assemble.py`` tool is used to concatenate secure and non-secure binary
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200137to a single binary blob. It requires the following definitions:
138
139- ``SECURE_IMAGE_OFFSET`` - Defines the offset from the single binary blob base
140 address, where the secure image starts.
141- ``SECURE_IMAGE_MAX_SIZE`` - Defines the maximum size of the secure image area.
142- ``NON_SECURE_IMAGE_OFFSET`` - Defines the offset from the single binary blob
143 base address, where the non-secure image starts.
144- ``NON_SECURE_IMAGE_MAX_SIZE`` - Defines the maximum size of the non-secure
145 image area.
146
Sverteczky, Marcell79ae9152019-06-06 15:00:11 +0200147Image tool
148^^^^^^^^^^^^^
149The ``imgtool.py`` tool is used to handle the tasks related to signing the
David Vinczed8fbe0e2019-08-12 15:58:57 +0200150binary. It requires the following definition:
Sverteczky, Marcell79ae9152019-06-06 15:00:11 +0200151
Raef Colesa4952592019-10-01 11:43:18 +0100152- ``IMAGE_LOAD_ADDRESS`` - Defines the address to where the image is loaded and
153 is executed from. Only used if ``MCUBOOT_UPGRADE_STRATEGY`` is configured to
154 be ``RAM_LOADING``.
Sverteczky, Marcell79ae9152019-06-06 15:00:11 +0200155
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200156Secure Storage (SST) Service definitions
157^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
158The SST service requires the following definitions:
159
160- ``SST_FLASH_AREA_ADDR`` - Defines the flash area address where the secure
161 store area starts.
Vikas Katariya7d74ddb2019-09-19 11:59:57 +0100162- ``SST_FLASH_AREA_SIZE`` - Defines the size of the dedicated flash area
163 for secure storage.
TudorCretuba8a3fa2019-07-22 10:05:12 +0100164- ``SST_SECTOR_SIZE`` - Defines the size of the external flash sectors.
Vikas Katariya7d74ddb2019-09-19 11:59:57 +0100165- ``SST_SECTORS_PER_BLOCK`` - Defines the number of contiguous SST_SECTOR_SIZE
166 to form an SST_BLOCK_SIZE.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200167- ``SST_FLASH_DEV_NAME`` - Specifies the flash device used by SST to store the
168 data.
169- ``SST_FLASH_PROGRAM_UNIT`` - Defines the smallest flash programmable unit in
170 bytes.
171- ``SST_MAX_ASSET_SIZE`` - Defines the maximum asset size to be stored in the
172 SST area.
173- ``SST_NUM_ASSETS`` - Defines the maximum number of assets to be stored in the
174 SST area.
175
176.. Note::
177
178 The sectors must be consecutive.
179
TudorCretuba8a3fa2019-07-22 10:05:12 +0100180Internal Trusted Storage (ITS) Service definitions
181^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
182The ITS service requires the following definitions:
183
184- ``ITS_FLASH_AREA_ADDR`` - Defines the flash area address where the internal
185 trusted storage area starts.
David Hu74977d22019-10-22 10:26:03 +0800186- ``ITS_FLASH_AREA_SIZE`` - Defines the size of the dedicated flash area for the
187 internal trusted storage.
TudorCretuba8a3fa2019-07-22 10:05:12 +0100188- ``ITS_SECTOR_SIZE`` - Defines the size of the internal flash sectors.
David Hu74977d22019-10-22 10:26:03 +0800189- ``ITS_SECTORS_PER_BLOCK`` - Defines the number of contiguous ITS_SECTOR_SIZE
190 to form an ITS_BLOCK_SIZE.
TudorCretuba8a3fa2019-07-22 10:05:12 +0100191- ``ITS_FLASH_DEV_NAME`` - Specifies the internal flash device used by ITS to
192 store the data.
193- ``ITS_FLASH_PROGRAM_UNIT`` - Defines the smallest flash programmable unit in
194 bytes.
195- ``ITS_MAX_ASSET_SIZE`` - Defines the maximum asset size to be stored in the
196 ITS area.
197- ``ITS_NUM_ASSETS`` - Defines the maximum number of assets to be stored in the
198 ITS area.
199
200.. Note::
201
202 The sectors must be consecutive.
203
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200204***************************************
205Expose target support for HW components
206***************************************
207Services may require HW components to be supported by the target to enable some
208features (e.g. SST service with rollback protection, etc). The following
209definitions need to be set in the .cmake file if the target has the following
210HW components:
211
212- ``TARGET_NV_COUNTERS_ENABLE`` - Specifies that the target has non-volatile
213 (NV) counters.
214
215--------------
216
217*Copyright (c) 2017-2019, Arm Limited. All rights reserved.*