Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 1 | ################################### |
| 2 | Details for the platform/ext folder |
| 3 | ################################### |
| 4 | This folder has code that has been imported from other projects. This means the |
| 5 | files in this folder and subfolders have Apache 2.0 license which is different |
| 6 | to 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 | *********** |
| 13 | Sub-folders |
| 14 | *********** |
| 15 | |
| 16 | cmsis |
| 17 | ===== |
| 18 | This folder contains core and compiler specific header files imported from the |
| 19 | ``CMSIS_5`` project. |
| 20 | |
| 21 | common |
| 22 | ====== |
Raef Coles | a657a9c | 2019-10-24 14:36:43 +0100 | [diff] [blame] | 23 | |
| 24 | armclang and gcc |
| 25 | ---------------- |
| 26 | These contain the linker scripts used to configure the memory regions in TF-M |
| 27 | regions. |
| 28 | |
| 29 | cc312 |
| 30 | ----- |
| 31 | This folder contains cmake and code files to interact with the CC312 |
| 32 | cryptographic accelerator. Integrating a platform with the CC312 requires some |
| 33 | configuration, of which an example can be seen in the |
| 34 | ``platform/ext/musca_b1.cmake`` file. |
| 35 | |
| 36 | To 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 | |
| 63 | other |
| 64 | ----- |
| 65 | This folder also contains stdout redirection to UART, a temporary memory mapped |
| 66 | flash implementation for the bootloader and ``tfm_mbedcrypto_config.h`` for all |
| 67 | the targets. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 68 | |
| 69 | drivers |
| 70 | ======= |
| 71 | This folder contains the headers with CMSIS compliant driver definitions that |
| 72 | that TF-M project expects a target to provide. |
| 73 | |
| 74 | target_cfg.h |
| 75 | ------------ |
| 76 | This 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 | |
| 85 | target |
| 86 | ====== |
| 87 | This folder contains the files for individual target. |
| 88 | |
| 89 | Flash layout header file |
| 90 | ------------------------ |
| 91 | Target must provide a header file, called ``flash_layout.h``, which defines the |
| 92 | information explained in the follow subsections. The defines must be named |
| 93 | as they are in the subsections. |
| 94 | |
| 95 | BL2 bootloader |
| 96 | ^^^^^^^^^^^^^^ |
| 97 | The 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 Vincze | bb20798 | 2019-08-21 15:13:04 +0200 | [diff] [blame] | 103 | - ``FLASH_AREA_SCRATCH_OFFSET`` - Defines the offset from the flash base |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 104 | address where the scratch area starts, which is used during image swapping. |
David Vincze | bb20798 | 2019-08-21 15:13:04 +0200 | [diff] [blame] | 105 | - ``FLASH_AREA_SCRATCH_SIZE`` - Defines the size of the scratch area. The |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 106 | 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 Vincze | bb20798 | 2019-08-21 15:13:04 +0200 | [diff] [blame] | 109 | The BL2 requires further definitions depending on the number of images, the |
| 110 | meaning 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 | |
| 145 | The table below shows a fraction of the flash layout in case of 2 and 1 |
| 146 | updatable 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 Coles | a495259 | 2019-10-01 11:43:18 +0100 | [diff] [blame] | 168 | - ``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 Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 176 | Assemble tool |
| 177 | ^^^^^^^^^^^^^ |
Sverteczky, Marcell | 79ae915 | 2019-06-06 15:00:11 +0200 | [diff] [blame] | 178 | The ``assemble.py`` tool is used to concatenate secure and non-secure binary |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 179 | to 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, Marcell | 79ae915 | 2019-06-06 15:00:11 +0200 | [diff] [blame] | 189 | Image tool |
| 190 | ^^^^^^^^^^^^^ |
| 191 | The ``imgtool.py`` tool is used to handle the tasks related to signing the |
David Vincze | d8fbe0e | 2019-08-12 15:58:57 +0200 | [diff] [blame] | 192 | binary. It requires the following definition: |
Sverteczky, Marcell | 79ae915 | 2019-06-06 15:00:11 +0200 | [diff] [blame] | 193 | |
Raef Coles | a495259 | 2019-10-01 11:43:18 +0100 | [diff] [blame] | 194 | - ``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, Marcell | 79ae915 | 2019-06-06 15:00:11 +0200 | [diff] [blame] | 197 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 198 | Secure Storage (SST) Service definitions |
| 199 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 200 | The 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 Katariya | 7d74ddb | 2019-09-19 11:59:57 +0100 | [diff] [blame] | 204 | - ``SST_FLASH_AREA_SIZE`` - Defines the size of the dedicated flash area |
| 205 | for secure storage. |
TudorCretu | ba8a3fa | 2019-07-22 10:05:12 +0100 | [diff] [blame] | 206 | - ``SST_SECTOR_SIZE`` - Defines the size of the external flash sectors. |
Vikas Katariya | 7d74ddb | 2019-09-19 11:59:57 +0100 | [diff] [blame] | 207 | - ``SST_SECTORS_PER_BLOCK`` - Defines the number of contiguous SST_SECTOR_SIZE |
| 208 | to form an SST_BLOCK_SIZE. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 209 | - ``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 | |
TudorCretu | ba8a3fa | 2019-07-22 10:05:12 +0100 | [diff] [blame] | 222 | Internal Trusted Storage (ITS) Service definitions |
| 223 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 224 | The 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 Hu | 74977d2 | 2019-10-22 10:26:03 +0800 | [diff] [blame] | 228 | - ``ITS_FLASH_AREA_SIZE`` - Defines the size of the dedicated flash area for the |
| 229 | internal trusted storage. |
TudorCretu | ba8a3fa | 2019-07-22 10:05:12 +0100 | [diff] [blame] | 230 | - ``ITS_SECTOR_SIZE`` - Defines the size of the internal flash sectors. |
David Hu | 74977d2 | 2019-10-22 10:26:03 +0800 | [diff] [blame] | 231 | - ``ITS_SECTORS_PER_BLOCK`` - Defines the number of contiguous ITS_SECTOR_SIZE |
| 232 | to form an ITS_BLOCK_SIZE. |
TudorCretu | ba8a3fa | 2019-07-22 10:05:12 +0100 | [diff] [blame] | 233 | - ``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 Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 246 | *************************************** |
| 247 | Expose target support for HW components |
| 248 | *************************************** |
| 249 | Services may require HW components to be supported by the target to enable some |
| 250 | features (e.g. SST service with rollback protection, etc). The following |
| 251 | definitions need to be set in the .cmake file if the target has the following |
| 252 | HW 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.* |