Skip to content

Commit c6bae61

Browse files
committed
Refactor doc for TF-M supported targets
Add documentation for more TF-M-related configurations: * TF-M version supported * Support for TF-M bootloader and two image slots * post binary hooks Combine documentation for dual-core and Armv8-M targets, as the steps are basically identical. This reduces maintenance required and improves readability.
1 parent fca2f44 commit c6bae61

File tree

1 file changed

+20
-111
lines changed

1 file changed

+20
-111
lines changed

docs/porting/security/psa_targets_in_mbed-os.md

Lines changed: 20 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Before reading this document, please read [porting a custom board](../porting/po
1616
To help create PSA targets, we have added a few generic targets to `targets/targets.json`:
1717

1818
* `PSA_Target`: Root level PSA target.
19-
* `PSA_V7_M`: Single v7-M generic PSA target, which doesn't employ hardware isolation between the NSPE and the SPE. PSA secure service emulation enables PSA API compatibility.
19+
* `PSA_V7_M`: Single v7-M generic PSA target, which doesn't employ hardware isolation between the NSPE and the SPE, so TF-M is not supported. PSA secure service emulation enables PSA API compatibility.
2020
* `PSA_DUAL_CORE`: Dual-core generic PSA target. A dual-core PSA target has at least two cores that are either Armv7-M or Armv6-M. One core will be used for the SPE and another for the NSPE. Hardware isolation between the cores enables PSA compliance. On dual-core targets, TF-M
2121
runs on the SPE and provides PSA services, and Mbed OS runs on the NSPE.
2222
* `PSA_V8_M`: Armv8-M generic PSA target, which employs hardware to isolate the NSPE from the SPE. TF-M runs on the SPE and provides PSA services, and Mbed OS runs on the NSPE.
@@ -39,10 +39,10 @@ Example of a single-core Armv7-M PSA target's inheritance:
3939
}
4040
```
4141

42-
### Adding single-core PSA targets
42+
### Adding single-core (non-TF-M) PSA targets
4343

4444
Mbed OS's PSA service emulation provides PSA compatibility for single-core PSA
45-
targets.
45+
targets which do not support TF-M.
4646

4747
The following example shows a PSA-enabled single-core target, `K64F`:
4848

@@ -163,16 +163,20 @@ In this case, you must add the following additional attributes:
163163
]
164164
```
165165

166-
### Adding dual-core PSA targets
166+
### Adding TF-M (dual-core or Armv8-M) PSA targets
167167

168-
A target can be categorized as a dual-core target if it has at least two cores that are either Armv7-M or Armv6-M. On dual-core PSA targets, TF-M runs on the SPE and provides PSA services.
168+
An Mbed OS (NSPE) target that supports TF-M must contain the following attributes (in addition to other target attributes defined in [porting a custom board](../porting/porting-a-custom-board.html) and [porting targets](../porting/porting-the-hal-apis.html)):
169169

170-
An Mbed OS (NSPE) target must contain the following attributes (in addition to other target attributes defined in [porting a custom board](../porting/porting-a-custom-board.html) and [porting targets](../porting/porting-the-hal-apis.html)):
171-
172-
* `inherits`: PSA generic target `PSA_DUAL_CORE`, unless the target has to inherit
170+
* `inherits`: PSA generic target `PSA_DUAL_CORE` or `PSA_V8_M`, unless the target has to inherit
173171
from one of its family targets.
172+
* `extra_labels`: `TARGET_`[label] paths to enable.
173+
* `TFM_LATEST`: If the latest release of TF-M is supported by the target.
174+
* `TFM_V`[major]`_`[minor]: If a legacy release of TF-M is supported by the target.
175+
* `macros_add`: C/C++ macros that are globally set during compilation.
176+
* `BL2`: If the TF-M bootloader is supported by the target.
177+
* `MCUBOOT_IMAGE_NUMBER=2`: If the secure and non-secure images are in two separate bootloader slots.
174178
* `tfm_target_name`: Target name in TF-M.
175-
* `tfm_bootloader_supported`: If TF-M bootloader is supported by the target.
179+
* `tfm_bootloader_supported`: If the TF-M bootloader is supported by the target.
176180

177181
The supported values are `true` and `false`.
178182
* `tfm_supported_toolchains`: Supported TF-M toolchains.
@@ -183,108 +187,11 @@ An Mbed OS (NSPE) target must contain the following attributes (in addition to o
183187
The supported values are `ARMCLANG` and `GNUARM`.
184188
* `tfm_delivery_dir`: The directory to which TF-M binaries will be copied.
185189
* `TFM_OUTPUT_EXT`: Optional attribute that indicates the output extension of the TF-M secure binary.
190+
* `post_binary_hook`:
191+
* `function`: The target's post binary hook ([class].[method]) in `tools/targets/__init__.py` for image signing, required if the TF-M bootloader support is supported.
192+
* `secure_image_filename`: The file name of the TF-M secure binary, to be signed by the post binary hook.
186193

187-
The following example shows a PSA enabled dual-core target, `PSoC64`:
188-
189-
```json
190-
"CY8CKIT_064S2_4343W": {
191-
"inherits": [
192-
"MCU_PSOC6_M4"
193-
],
194-
"features_add": [
195-
"BLE",
196-
"PSA"
197-
],
198-
"components_add": [
199-
"WHD",
200-
"4343W",
201-
"CYW43XXX"
202-
],
203-
"components_remove": [
204-
"QSPIF"
205-
],
206-
"supported_form_factors": [
207-
"ARDUINO"
208-
],
209-
"device_has_remove": [
210-
"ANALOGOUT",
211-
"QSPI"
212-
],
213-
"extra_labels_add": [
214-
"PSOC6_02",
215-
"MXCRYPTO_02",
216-
"CORDIO",
217-
"TFM",
218-
"TFM_DUALCPU"
219-
],
220-
"macros_add": [
221-
"CYB0644ABZI_S2D44",
222-
"CYBSP_WIFI_CAPABLE",
223-
"TFM_MULTI_CORE_MULTI_CLIENT_CALL=1"
224-
],
225-
"detect_code": [
226-
"190A"
227-
],
228-
"post_binary_hook": {
229-
"function": "PSOC6Code.sign_image"
230-
},
231-
"forced_reset_timeout": 5,
232-
"overrides": {
233-
"network-default-interface-type": "WIFI"
234-
},
235-
"program_cycle_s": 10,
236-
"tfm_target_name": "psoc64",
237-
"tfm_bootloader_supported": false,
238-
"tfm_default_toolchain": "GNUARM",
239-
"tfm_supported_toolchains": [
240-
"GNUARM"
241-
],
242-
"tfm_delivery_dir": "TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_064S2_4343W",
243-
"TFM_OUTPUT_EXT": "hex"
244-
}
245-
```
246-
247-
Please note the config options `macros_add`, `extra_labels_add` and `device_has_remove`. To add or remove `macros`, `extra_labels` or target capabilities, a PSA target definition must use
248-
[macros/extra_labels/device_has]`_add` or [macros/extra_labels/device_has]`_remove` (not `macros`, `extra_labels` or `device_has`).
249-
250-
To add or remove a feature, use `feature_`[add/remove].
251-
252-
By default, a TF-M build generates a `bin` file. If the target requires a `hex` file, you need to add the attribute `"TFM_OUTPUT_EXT": "hex"` to the target definition. The build script will convert `bin` to `hex`, then copy the `hex` to `tfm_delivery_dir`.
253-
254-
This dual-core PSA target doesn't inherit from `PSA_DUAL_CORE` because it has to inherit from one of its family targets. Hence, we have added additional attributes:
255-
256-
```json
257-
"features_add": [
258-
"PSA"
259-
],
260-
"extra_labels_add": [
261-
"TFM",
262-
"TFM_DUALCPU"
263-
]
264-
```
265-
266-
If a dual-core PSA target can inherit from `PSA_DUAL_CORE`, then there is no need to add these additional attributes.
267-
268-
### Adding Armv8-M PSA targets
269-
270-
An Mbed OS (NSPE) target must contain the following attributes (in addition to other target attributes defined in [porting a custom board](../porting/porting-a-custom-board.html)
271-
and [porting targets](../porting/porting-the-hal-apis.html)):
272-
273-
* `inherits`: PSA generic target `PSA_V8_M`, unless the target has to inherit from
274-
one of its family targets.
275-
* `tfm_target_name`: Target name in TF-M.
276-
* `tfm_bootloader_supported`: If TF-M bootloader is supported by the target.
277-
278-
The supported values are `true` and `false`.
279-
* `tfm_supported_toolchains`: Supported TF-M toolchains.
280-
281-
The supported values are `ARMCLANG` and `GNUARM`.
282-
* `tfm_default_toolchain`: Default TF-M toolchain.
283-
284-
The supported values are `ARMCLANG` and `GNUARM`.
285-
286-
* `tfm_delivery_dir`: The directory to which TF-M binary will be copied.
287-
* `TFM_OUTPUT_EXT`: Optional attribute that indicates the output extension of the TF-M secure binary.
194+
**Note**: When `inherits` is used, some of attributes are set by the PSA generic target.
288195

289196
The following example shows a PSA-enabled Armv8-M PSA target, `ARM_MUSCA_A1`:
290197

@@ -345,17 +252,19 @@ To add or remove a feature, use `feature_`[add/remove].
345252

346253
By default, a TF-M build generates a `bin` file. If the target requires a `hex` file, you need to add the attribute `"TFM_OUTPUT_EXT": "hex"` to the target definition. The build script will convert `bin` to `hex`, then copy the `hex` to `tfm_delivery_dir`. You must also update `secure_image_filename` to match the new file extension.
347254

348-
If an Armv8-M PSA target cannot inherit from `PSA_V8_M` because it has to inherit from one of its family targets, you must add the following attributes:
255+
If a PSA target cannot inherit from `PSA_V8_M` or `PSA_DUAL_CORE` because it has to inherit from one of its family targets, you must declare PSA and TF-M attributes manually. For example,
349256

350257
```json
351258
"features_add": [
352259
"PSA"
353260
],
354261
"extra_labels_add": [
355262
"TFM",
263+
"TFM_LATEST",
356264
"TFM_V8M"
357265
]
358266
```
267+
(Please adjust the TF-M version and target architecture accordingly.)
359268

360269
## Build and validation
361270

0 commit comments

Comments
 (0)