Sherry Zhang | 0b9738a | 2021-01-07 14:26:01 +0800 | [diff] [blame] | 1 | ####################### |
| 2 | Firmware Update Service |
| 3 | ####################### |
| 4 | |
| 5 | :Author: Sherry Zhang |
| 6 | :Organization: Arm Limited |
Sherry Zhang | 0b9738a | 2021-01-07 14:26:01 +0800 | [diff] [blame] | 7 | |
| 8 | .. contents:: Table of Contents |
Anton Komlev | 3ae2ac3 | 2023-01-03 14:56:47 +0000 | [diff] [blame] | 9 | :depth: 3 |
Sherry Zhang | 0b9738a | 2021-01-07 14:26:01 +0800 | [diff] [blame] | 10 | |
| 11 | *************************************** |
| 12 | Introduction of Firmware Update service |
| 13 | *************************************** |
| 14 | The Firmware Update(FWU) service provides the functionality of updating firmware |
| 15 | images. It provides a standard interface for updating firmware and it is |
| 16 | platform independent. TF-M defines a shim layer to support cooperation between |
| 17 | bootloader and FWU service. |
| 18 | |
| 19 | This partition supports the following features: |
| 20 | |
Sherry Zhang | 7146895 | 2022-10-19 14:09:05 +0800 | [diff] [blame] | 21 | - Query the firmware store information. |
| 22 | - Image preparation: prepare a new firmware image in the component's firmware store. |
| 23 | - Image installation: install prepared firmware images on all components that have been prepared for installation. |
| 24 | - Image trial: manage a trial of new firmware images atomically on all components that are in TRIAL state. |
| 25 | |
| 26 | A typical flow through the component states is shown below [1]_. |
| 27 | |
Anton Komlev | b3f6466 | 2023-01-28 11:53:05 +0000 | [diff] [blame] | 28 | .. figure:: /design_docs/media/fwu-states.svg |
Sherry Zhang | 7146895 | 2022-10-19 14:09:05 +0800 | [diff] [blame] | 29 | :scale: 65 % |
| 30 | :align: center |
| 31 | :name: The component state model transitions. |
Sherry Zhang | 0b9738a | 2021-01-07 14:26:01 +0800 | [diff] [blame] | 32 | |
| 33 | ********** |
| 34 | Components |
| 35 | ********** |
| 36 | The structure of the TF-M Firmware Update service is listed below: |
Anton Komlev | 525ee34 | 2021-10-19 16:09:31 +0100 | [diff] [blame] | 37 | +-----------------------------+---------------------------------------------------------------+---------------------------------------------------------------------------------------+ |
| 38 | | **Component name** | **Description** | **Location** | |
| 39 | +=============================+===============================================================+=======================================================================================+ |
Summer Qin | 2db78c8 | 2022-10-10 17:17:44 +0800 | [diff] [blame] | 40 | | Client API interface | This module exports the client API of PSA Firmware Update to | ``./interface/src/tfm_fwu_api.c`` | |
| 41 | | | the users. | | |
Anton Komlev | 525ee34 | 2021-10-19 16:09:31 +0100 | [diff] [blame] | 42 | +-----------------------------+---------------------------------------------------------------+---------------------------------------------------------------------------------------+ |
Summer Qin | 2db78c8 | 2022-10-10 17:17:44 +0800 | [diff] [blame] | 43 | | Manifest | The manifest file is a description of the service components. | ``./secure_fw/partitions/firmware_update/tfm_firmware_update.yaml`` | |
Anton Komlev | 525ee34 | 2021-10-19 16:09:31 +0100 | [diff] [blame] | 44 | +-----------------------------+---------------------------------------------------------------+---------------------------------------------------------------------------------------+ |
Sherry Zhang | 7146895 | 2022-10-19 14:09:05 +0800 | [diff] [blame] | 45 | | NSPE client API interface | This module exports the client API of PSA Firmware Update to | ``./interface/src/tfm_fwu_api.c`` | |
| 46 | | | the NSPE(i.e. to the applications). | | |
| 47 | +-----------------------------+---------------------------------------------------------------+---------------------------------------------------------------------------------------+ |
Summer Qin | 2db78c8 | 2022-10-10 17:17:44 +0800 | [diff] [blame] | 48 | | IPC request handlers | This module handles all the secure requests in IPC model. | ``./secure_fw/partitions/firmware_update/tfm_fwu_req_mngr.c`` | |
Antonio de Angelis | 9d496a5 | 2025-01-07 21:18:00 +0000 | [diff] [blame] | 49 | | | It maintains the image state context and calls the image ID | | |
Anton Komlev | 525ee34 | 2021-10-19 16:09:31 +0100 | [diff] [blame] | 50 | | | converter to achieve the firmware update functionalities. | | |
| 51 | +-----------------------------+---------------------------------------------------------------+---------------------------------------------------------------------------------------+ |
Anton Komlev | 525ee34 | 2021-10-19 16:09:31 +0100 | [diff] [blame] | 52 | | Shim layer between FWU and | This module provides the APIs with the functionality of | ``./secure_fw/partitions/firmware_update/bootloader/tfm_bootloader_fwu_abstraction.h``| |
| 53 | | bootloader | operating the bootloader to cooperate with the Firmware Update| | |
| 54 | | | service | | |
| 55 | +-----------------------------+---------------------------------------------------------------+---------------------------------------------------------------------------------------+ |
| 56 | | Shim layer example based on | This module is the implementation of the shim layer between | ``./secure_fw/partitions/firmware_update/bootloader/mcuboot/tfm_mcuboot_fwu.c`` | |
| 57 | | MCUboot | FWU and bootloader based on MCUboot. | | |
| 58 | | | | | |
| 59 | +-----------------------------+---------------------------------------------------------------+---------------------------------------------------------------------------------------+ |
Sherry Zhang | 0b9738a | 2021-01-07 14:26:01 +0800 | [diff] [blame] | 60 | |
| 61 | *********************** |
| 62 | Service API description |
| 63 | *********************** |
Sherry Zhang | 7146895 | 2022-10-19 14:09:05 +0800 | [diff] [blame] | 64 | This service follows the PSA Firmware Update API spec of version 1.0 [1]_. Please refer to |
| 65 | Firmware Update spec for the detailed description. |
Sherry Zhang | 0b9738a | 2021-01-07 14:26:01 +0800 | [diff] [blame] | 66 | |
| 67 | ************************************* |
| 68 | Shim Layer between FWU and bootloader |
| 69 | ************************************* |
| 70 | The firmware update operations are achieved by calling the shim layer APIs |
| 71 | between bootloader and FWU. |
| 72 | |
| 73 | Shim layer introduction |
| 74 | ======================= |
| 75 | This shim layer provides the APIs with the functionality of operating the |
| 76 | bootloader to cooperate with the Firmware Update service. This shim layer |
| 77 | is decoupled from bootloader implementation. Users can specify a specific |
| 78 | bootloader by setting ``TFM_FWU_BOOTLOADER_LIB`` build configuration and |
| 79 | adding the specific build scripts into that file. By default, the MCUboot |
| 80 | is chosen as the bootloader. |
| 81 | |
| 82 | Interfaces of the shim Layer |
| 83 | ============================ |
| 84 | |
| 85 | fwu_bootloader_init(function) |
| 86 | ----------------------------- |
| 87 | Prototype |
| 88 | ^^^^^^^^^ |
| 89 | .. code-block:: c |
| 90 | |
| 91 | psa_status_t fwu_bootloader_init(void); |
| 92 | |
| 93 | Description |
| 94 | ^^^^^^^^^^^ |
Michel Jaouen | 0a06eb3 | 2022-04-22 14:38:06 +0200 | [diff] [blame] | 95 | Bootloader related initialization for the firmware update. It reads |
| 96 | some necessary shared data from the memory if needed. It initializes |
| 97 | the flash drivers defined in FLASH_DRIVER_LIST. Platform can define |
| 98 | FLASH_DRIVER_LIST in flash_layout.h to overload the default driver list. |
Sherry Zhang | 0b9738a | 2021-01-07 14:26:01 +0800 | [diff] [blame] | 99 | |
| 100 | Parameters |
| 101 | ^^^^^^^^^^ |
| 102 | N/A |
| 103 | |
| 104 | fwu_bootloader_staging_area_init(function) |
| 105 | ------------------------------------------ |
David Hu | 050756f | 2021-04-13 17:53:01 +0800 | [diff] [blame] | 106 | **Prototype** |
| 107 | |
Sherry Zhang | 0b9738a | 2021-01-07 14:26:01 +0800 | [diff] [blame] | 108 | .. code-block:: c |
| 109 | |
Sherry Zhang | 7146895 | 2022-10-19 14:09:05 +0800 | [diff] [blame] | 110 | psa_status_t fwu_bootloader_staging_area_init(psa_fwu_component_t component, |
| 111 | const void *manifest, |
| 112 | size_t manifest_size); |
Sherry Zhang | 0b9738a | 2021-01-07 14:26:01 +0800 | [diff] [blame] | 113 | |
David Hu | 050756f | 2021-04-13 17:53:01 +0800 | [diff] [blame] | 114 | **Description** |
| 115 | |
Sherry Zhang | 7146895 | 2022-10-19 14:09:05 +0800 | [diff] [blame] | 116 | The component is in READY state. Prepare the staging area of the component for image download. |
Sherry Zhang | 0b9738a | 2021-01-07 14:26:01 +0800 | [diff] [blame] | 117 | For example, initialize the staging area, open the flash area, and so on. |
Sherry Zhang | 0b9738a | 2021-01-07 14:26:01 +0800 | [diff] [blame] | 118 | |
David Hu | 050756f | 2021-04-13 17:53:01 +0800 | [diff] [blame] | 119 | **Parameters** |
| 120 | |
Sherry Zhang | 7146895 | 2022-10-19 14:09:05 +0800 | [diff] [blame] | 121 | - ``component``: The identifier of the target component in bootloader. |
| 122 | - ``manifest``: A pointer to a buffer containing a detached manifest for the update. |
| 123 | If the manifest is bundled with the firmware image, manifest must be NULL. |
| 124 | - ``manifest_size``: Size of the manifest buffer in bytes. |
Sherry Zhang | 0b9738a | 2021-01-07 14:26:01 +0800 | [diff] [blame] | 125 | |
| 126 | fwu_bootloader_load_image(function) |
| 127 | ----------------------------------- |
David Hu | 050756f | 2021-04-13 17:53:01 +0800 | [diff] [blame] | 128 | **Prototype** |
Sherry Zhang | 0b9738a | 2021-01-07 14:26:01 +0800 | [diff] [blame] | 129 | |
| 130 | .. code-block:: c |
| 131 | |
Sherry Zhang | 7146895 | 2022-10-19 14:09:05 +0800 | [diff] [blame] | 132 | psa_status_t fwu_bootloader_load_image(psa_fwu_component_t component, |
Sherry Zhang | 0b9738a | 2021-01-07 14:26:01 +0800 | [diff] [blame] | 133 | size_t image_offset, |
| 134 | const void *block, |
| 135 | size_t block_size); |
| 136 | |
David Hu | 050756f | 2021-04-13 17:53:01 +0800 | [diff] [blame] | 137 | **Description** |
| 138 | |
Sherry Zhang | 7146895 | 2022-10-19 14:09:05 +0800 | [diff] [blame] | 139 | Load the image into the target component. |
Sherry Zhang | 0b9738a | 2021-01-07 14:26:01 +0800 | [diff] [blame] | 140 | |
David Hu | 050756f | 2021-04-13 17:53:01 +0800 | [diff] [blame] | 141 | **Parameters** |
| 142 | |
Sherry Zhang | 7146895 | 2022-10-19 14:09:05 +0800 | [diff] [blame] | 143 | - ``component``: The identifier of the target component in bootloader. |
Sherry Zhang | 0b9738a | 2021-01-07 14:26:01 +0800 | [diff] [blame] | 144 | - ``image_offset``: The offset of the image being passed into block, in bytes. |
| 145 | - ``block``: A buffer containing a block of image data. This might be a complete image or a subset. |
| 146 | - ``block_size``: Size of block. |
| 147 | |
| 148 | fwu_bootloader_install_image(function) |
| 149 | --------------------------------------------- |
David Hu | 050756f | 2021-04-13 17:53:01 +0800 | [diff] [blame] | 150 | **Prototype** |
| 151 | |
Sherry Zhang | 0b9738a | 2021-01-07 14:26:01 +0800 | [diff] [blame] | 152 | .. code-block:: c |
| 153 | |
Sherry Zhang | 7146895 | 2022-10-19 14:09:05 +0800 | [diff] [blame] | 154 | psa_status_t fwu_bootloader_install_image(psa_fwu_component_t *candidates, |
| 155 | uint8_t number); |
Sherry Zhang | 0b9738a | 2021-01-07 14:26:01 +0800 | [diff] [blame] | 156 | |
David Hu | 050756f | 2021-04-13 17:53:01 +0800 | [diff] [blame] | 157 | **Description** |
| 158 | |
Sherry Zhang | 0b9738a | 2021-01-07 14:26:01 +0800 | [diff] [blame] | 159 | Check the authenticity and integrity of the image. If a reboot is required to |
| 160 | complete the check, then mark this image as a candidate so that the next time |
Antonio de Angelis | 9d496a5 | 2025-01-07 21:18:00 +0000 | [diff] [blame] | 161 | bootloader runs it will take this image as a candidate one to boot-up. Return |
Sherry Zhang | 0b9738a | 2021-01-07 14:26:01 +0800 | [diff] [blame] | 162 | the error code PSA_SUCCESS_REBOOT. |
| 163 | |
David Hu | 050756f | 2021-04-13 17:53:01 +0800 | [diff] [blame] | 164 | **Parameters** |
| 165 | |
Sherry Zhang | 7146895 | 2022-10-19 14:09:05 +0800 | [diff] [blame] | 166 | - ``candidates``: A list of components in CANDIDATE state. |
| 167 | - ``number``: Number of components in CANDIDATE state. |
Sherry Zhang | 0b9738a | 2021-01-07 14:26:01 +0800 | [diff] [blame] | 168 | |
| 169 | fwu_bootloader_mark_image_accepted(function) |
| 170 | -------------------------------------------- |
David Hu | 050756f | 2021-04-13 17:53:01 +0800 | [diff] [blame] | 171 | **Prototype** |
| 172 | |
Sherry Zhang | 0b9738a | 2021-01-07 14:26:01 +0800 | [diff] [blame] | 173 | .. code-block:: c |
| 174 | |
Sherry Zhang | 7146895 | 2022-10-19 14:09:05 +0800 | [diff] [blame] | 175 | psa_status_t fwu_bootloader_mark_image_accepted(const psa_fwu_component_t *trials, |
| 176 | uint8_t number); |
Sherry Zhang | 0b9738a | 2021-01-07 14:26:01 +0800 | [diff] [blame] | 177 | |
David Hu | 050756f | 2021-04-13 17:53:01 +0800 | [diff] [blame] | 178 | **Description** |
| 179 | |
Sherry Zhang | 7146895 | 2022-10-19 14:09:05 +0800 | [diff] [blame] | 180 | Call this API to mark the TRIAL(running) image in component as confirmed to avoid |
Antonio de Angelis | 9d496a5 | 2025-01-07 21:18:00 +0000 | [diff] [blame] | 181 | revert when next time boot-up. Usually, this API is called after the running |
Sherry Zhang | 0b9738a | 2021-01-07 14:26:01 +0800 | [diff] [blame] | 182 | images have been verified as valid. |
| 183 | |
David Hu | 050756f | 2021-04-13 17:53:01 +0800 | [diff] [blame] | 184 | **Parameters** |
| 185 | |
Sherry Zhang | 7146895 | 2022-10-19 14:09:05 +0800 | [diff] [blame] | 186 | - ``trials``: A list of components in TRIAL state. |
| 187 | - ``number``: Number of components in TRIAL state. |
Sherry Zhang | 0b9738a | 2021-01-07 14:26:01 +0800 | [diff] [blame] | 188 | |
Sherry Zhang | 7146895 | 2022-10-19 14:09:05 +0800 | [diff] [blame] | 189 | fwu_bootloader_reject_staged_image(function) |
| 190 | -------------------------------------------- |
David Hu | 050756f | 2021-04-13 17:53:01 +0800 | [diff] [blame] | 191 | **Prototype** |
| 192 | |
Sherry Zhang | 0b9738a | 2021-01-07 14:26:01 +0800 | [diff] [blame] | 193 | .. code-block:: c |
| 194 | |
Sherry Zhang | 7146895 | 2022-10-19 14:09:05 +0800 | [diff] [blame] | 195 | psa_status_t fwu_bootloader_reject_staged_image(psa_fwu_component_t component); |
Sherry Zhang | 0b9738a | 2021-01-07 14:26:01 +0800 | [diff] [blame] | 196 | |
David Hu | 050756f | 2021-04-13 17:53:01 +0800 | [diff] [blame] | 197 | **Description** |
| 198 | |
Sherry Zhang | 7146895 | 2022-10-19 14:09:05 +0800 | [diff] [blame] | 199 | The component is in STAGED state. Call this API to Uninstall the staged image in the |
Antonio de Angelis | 9d496a5 | 2025-01-07 21:18:00 +0000 | [diff] [blame] | 200 | component so that this image will not be treated as a candidate next time boot-up. |
Sherry Zhang | 0b9738a | 2021-01-07 14:26:01 +0800 | [diff] [blame] | 201 | |
David Hu | 050756f | 2021-04-13 17:53:01 +0800 | [diff] [blame] | 202 | **Parameters** |
| 203 | |
Sherry Zhang | 7146895 | 2022-10-19 14:09:05 +0800 | [diff] [blame] | 204 | - ``component``: The identifier of the target component in bootloader. |
| 205 | |
| 206 | fwu_bootloader_reject_trial_image(function) |
| 207 | -------------------------------------------- |
| 208 | **Prototype** |
| 209 | |
| 210 | .. code-block:: c |
| 211 | |
| 212 | psa_status_t fwu_bootloader_reject_trial_image(psa_fwu_component_t component); |
| 213 | |
| 214 | **Description** |
| 215 | |
| 216 | The component is in TRIAL state. Mark the running image in the component as rejected. |
| 217 | |
| 218 | **Parameters** |
| 219 | |
| 220 | - ``component``: The identifier of the target component in bootloader. |
| 221 | |
| 222 | fwu_bootloader_clean_component(function) |
| 223 | ---------------------------------------- |
| 224 | **Prototype** |
| 225 | |
| 226 | .. code-block:: c |
| 227 | |
| 228 | psa_status_t fwu_bootloader_clean_component(psa_fwu_component_t component); |
| 229 | |
| 230 | **Description** |
| 231 | |
| 232 | The component is in FAILED or UPDATED state. Clean the staging area of the component. |
| 233 | |
| 234 | **Parameters** |
| 235 | |
| 236 | - ``component``: The identifier of the target component in bootloader. |
Sherry Zhang | 0b9738a | 2021-01-07 14:26:01 +0800 | [diff] [blame] | 237 | |
| 238 | fwu_bootloader_get_image_info(function) |
| 239 | --------------------------------------- |
David Hu | 050756f | 2021-04-13 17:53:01 +0800 | [diff] [blame] | 240 | **Prototype** |
| 241 | |
Sherry Zhang | 0b9738a | 2021-01-07 14:26:01 +0800 | [diff] [blame] | 242 | .. code-block:: c |
| 243 | |
Sherry Zhang | 7146895 | 2022-10-19 14:09:05 +0800 | [diff] [blame] | 244 | psa_status_t fwu_bootloader_get_image_info(psa_fwu_component_t component, |
| 245 | bool query_state, |
| 246 | bool query_impl_info, |
| 247 | psa_fwu_component_info_t *info); |
Sherry Zhang | 0b9738a | 2021-01-07 14:26:01 +0800 | [diff] [blame] | 248 | |
David Hu | 050756f | 2021-04-13 17:53:01 +0800 | [diff] [blame] | 249 | **Description** |
| 250 | |
Sherry Zhang | 0b9738a | 2021-01-07 14:26:01 +0800 | [diff] [blame] | 251 | Get the image information of the given bootloader_image_id in the staging area |
| 252 | or the running area. |
| 253 | |
David Hu | 050756f | 2021-04-13 17:53:01 +0800 | [diff] [blame] | 254 | **Parameters** |
| 255 | |
Sherry Zhang | 7146895 | 2022-10-19 14:09:05 +0800 | [diff] [blame] | 256 | - ``component``: The identifier of the target component in bootloader. |
| 257 | - ``query_state``: Whether query the 'state' field of psa_fwu_component_info_t. |
| 258 | - ``query_impl_info``: Whether Query 'impl' field of psa_fwu_component_info_t. |
| 259 | - ``info``: Buffer containing return the component information. |
Sherry Zhang | 0b9738a | 2021-01-07 14:26:01 +0800 | [diff] [blame] | 260 | |
| 261 | ****************************************** |
| 262 | Additional shared data between BL2 and SPE |
| 263 | ****************************************** |
| 264 | An additional TLV area "image version" is added into the shared memory between |
| 265 | BL2 and TF-M. So that the firmware update partition can get the image version. |
| 266 | Even though the image version information is also included in the ``BOOT RECORD`` |
| 267 | TLV area which is encoded by CBOR, adding a dedicated ``image version`` TLV area |
| 268 | is preferred to avoid involving the CBOR encoder which can increase the code |
| 269 | size. The FWU partition will read the shared data at the partition |
| 270 | initialization. |
| 271 | |
Sherry Zhang | 7146895 | 2022-10-19 14:09:05 +0800 | [diff] [blame] | 272 | ********************************************* |
| 273 | Build configurations related to FWU partition |
| 274 | ********************************************* |
| 275 | - ``TFM_PARTITION_FIRMWARE_UPDATE`` Controls whether FWU partition is enabled or not. |
| 276 | - ``TFM_FWU_BOOTLOADER_LIB`` Bootloader configure file for FWU partition. |
| 277 | - ``TFM_CONFIG_FWU_MAX_WRITE_SIZE`` The maximum permitted size for block in psa_fwu_write, in bytes. |
| 278 | - ``TFM_FWU_BUF_SIZE`` Size of the FWU internal data transfer buffer (defaults to |
| 279 | TFM_CONFIG_FWU_MAX_WRITE_SIZE if not set). |
| 280 | - ``FWU_STACK_SIZE`` The stack size of FWU Partition. |
| 281 | - ``FWU_DEVICE_CONFIG_FILE`` The device configuration file for FWU partition. The default value is |
| 282 | the configuration file generated for MCUboot. The following macros should be defined in the |
| 283 | configuration file: |
Sherry Zhang | 0b9738a | 2021-01-07 14:26:01 +0800 | [diff] [blame] | 284 | |
Sherry Zhang | 7146895 | 2022-10-19 14:09:05 +0800 | [diff] [blame] | 285 | - ``FWU_COMPONENT_NUMBER`` The number of components on the device. |
Sherry Zhang | 0b9738a | 2021-01-07 14:26:01 +0800 | [diff] [blame] | 286 | |
Sherry Zhang | 7146895 | 2022-10-19 14:09:05 +0800 | [diff] [blame] | 287 | .. Note:: |
Sherry Zhang | 0b9738a | 2021-01-07 14:26:01 +0800 | [diff] [blame] | 288 | |
Sherry Zhang | 7146895 | 2022-10-19 14:09:05 +0800 | [diff] [blame] | 289 | In this design, component ID ranges from 0 to ``FWU_COMPONENT_NUMBER`` - 1. |
Sherry Zhang | 0b9738a | 2021-01-07 14:26:01 +0800 | [diff] [blame] | 290 | |
Sherry Zhang | 7146895 | 2022-10-19 14:09:05 +0800 | [diff] [blame] | 291 | - ``FWU_SUPPORT_TRIAL_STATE`` Whether TRIAL component state is supported. |
| 292 | - ``TEST_NS_FWU`` FWU nonsecure tests switch. |
| 293 | - ``TEST_S_FWU`` FWU secure tests switch. |
| 294 | |
| 295 | .. Note:: |
| 296 | |
| 297 | The running image which supports revert mechanism should be confirmed before initiating a |
| 298 | firmware update process. For example, if the running image is built with |
| 299 | ``-DMCUBOOT_UPGRADE_STRATEGY=SWAP_USING_MOVE``, the image should be confirmed either by |
| 300 | adding ``-DMCUBOOT_CONFIRM_IMAGE=ON`` build option or by calling ``psa_fwu_accept()`` API |
| 301 | before initiating a firmware update process. Otherwise, ``PSA_ERROR_BAD_STATE`` will be |
| 302 | returned by ``psa_fwu_start()``. |
| 303 | |
| 304 | ************************************* |
| 305 | Limitations of current implementation |
| 306 | ************************************* |
| 307 | Currently, the MCUboot based implementation does not record image update results like failure or |
| 308 | success. And FWU partition does not detect failure errors in bootloader installation. If an image |
| 309 | installation fails in the bootloader and the old image still runs after reboot, ``PSA_FWU_READY`` |
| 310 | state will be returned by ``psa_fwu_query()`` after reboot. |
| 311 | |
| 312 | Currently, image download recovery after a reboot is not supported. If a reboot happens in image |
| 313 | preparation, the downloaded image data will be ignored after the reboot. |
Sherry Zhang | 0b9738a | 2021-01-07 14:26:01 +0800 | [diff] [blame] | 314 | |
| 315 | *********************************** |
| 316 | Benefits Analysis on this Partition |
| 317 | *********************************** |
| 318 | |
| 319 | Implement the FWU functionality in the non-secure side |
| 320 | ====================================================== |
David Hu | 050756f | 2021-04-13 17:53:01 +0800 | [diff] [blame] | 321 | The APIs listed in PSA Firmware Update API spec [1]_ can also be implemented in |
Summer Qin | 2db78c8 | 2022-10-10 17:17:44 +0800 | [diff] [blame] | 322 | the non-secure side. |
Sherry Zhang | 0b9738a | 2021-01-07 14:26:01 +0800 | [diff] [blame] | 323 | |
Sherry Zhang | 7146895 | 2022-10-19 14:09:05 +0800 | [diff] [blame] | 324 | Pros and Cons for implementing FWU APIs in secure side |
Sherry Zhang | 0b9738a | 2021-01-07 14:26:01 +0800 | [diff] [blame] | 325 | ====================================================== |
| 326 | |
| 327 | Pros |
| 328 | ---- |
| 329 | - It protects the image in the passive or staging area from being tampered with |
| 330 | by the NSPE. Otherwise, a malicious actor from NSPE can tamper the image |
| 331 | stored in the non-secure area to break image update. |
| 332 | |
| 333 | - It protects secure image information from disclosure. In some cases, the |
| 334 | non-secure side shall not be permitted to get secure image information. |
| 335 | |
| 336 | - It protects the active image from being manipulated by NSPE. Some bootloader |
| 337 | supports testing the image. After the image is successfully installed and |
| 338 | starts to run, the user should set the image as permanent image if the image |
| 339 | passes the test. To achieve this, the area of the active image needs to be |
| 340 | accessed. In this case, implementing FWU service in SPE can prevent NSPE |
| 341 | from manipulating the active image area. |
| 342 | |
| 343 | - On some devices, such as the Arm Musca-B1 board, the passive or staging area |
| 344 | is restricted as secure access only. In this case, the FWU partition should |
| 345 | be implemented in the secure side. |
| 346 | |
| 347 | Cons |
| 348 | ---- |
| 349 | - It increases the image size of the secure image. |
| 350 | - It increases the execution latency and footprint. Compared to implementing |
| 351 | FWU in NSPE directly, calling the Firmware Update APIs which are implemented |
| 352 | in the secure side increases the execution latency and footprint. |
| 353 | - It can increase the attack surface of the secure runtime. |
| 354 | |
| 355 | Users can decide whether to call the FWU service in TF-M directly or implement |
| 356 | the Firmware Update APIs in the non-secure side based on the pros and cons |
| 357 | analysis above. |
| 358 | |
David Hu | 050756f | 2021-04-13 17:53:01 +0800 | [diff] [blame] | 359 | ********* |
| 360 | Reference |
| 361 | ********* |
| 362 | |
Antonio de Angelis | 9d496a5 | 2025-01-07 21:18:00 +0000 | [diff] [blame] | 363 | .. [1] `PSA Firmware Update API <https://arm-software.github.io/psa-api/fwu/1.0/>`_ |
David Hu | 050756f | 2021-04-13 17:53:01 +0800 | [diff] [blame] | 364 | |
| 365 | -------------- |
| 366 | |
Summer Qin | 2db78c8 | 2022-10-10 17:17:44 +0800 | [diff] [blame] | 367 | *Copyright (c) 2021-2022, Arm Limited. All rights reserved.* |