blob: 30e4d5719a51d1e238a3f47e158d1054412a6e04 [file] [log] [blame]
Julian Hall7af7f902023-02-16 11:07:32 +00001Overview
2--------
3The ability to update device firmware and related resources is a key requirement for
4maintaining security over a device's lifetime. Keeping firmware up-to-date with security
5fixes and feature enhancements is important for defending against emerging threats.
6Because firmware forms the security foundation of a device, it is important to apply
7updates in a timely manner to minimize risks exposed by firmware vulnerabilities. Any
8remote firmware update mechanism carries a risk of failure. As firmware is critical to
9the operation of a device, failures during the update process that lead to corrupted
10firmware have the potential to be highly disruptive. Any update mechanism intended
11for use with a large population of devices must offer robustness guarantees sufficient
12to keep the risk of failure at an acceptable level.
13
14Firmware update support within the Trusted Services project consists of a set of reusable
15firmware components that can be deployed within different execution environments to enable
16platform integrators to create firmware update solutions, tailored for their platform.
17The components are intended to be integrated into platform firmware and will be used in
18conjunction with a third-party update client, such as mender, swupd or fwupd, to create
19an end-to-end solution. The features supported aim to meet requirements for robustness
20and security. These include:
21
22 - Banked A/B robust update support
23 - Transactional multi-component updates with ACID (Atomicity, Consistency, Isolation,
24 Durability) guarantees
25 - Partial updates where not all components are updated
26 - Trial of an update with bootloader or client initiated rollback
27 - Anti-rollback counter management
28 - Standardized signaling to bootloader via the FWU Metadata structure
29 - Flexible installer framework to support different image types
30 - Image directory for advertising updatable components
31 - Compatible with UEFI FMP capsule update model and ESRT
32
33To support test and development and to provide a useful reference, the Trusted Services
34project maintains a reference integration with the following characteristics:
35
36 - Dual flash system where firmware is loaded from a dedicated secure world flash device.
37 - Secure flash is formatted with UEFI MBR/GPT with separate partitions for FWU metadata
38 and firmware banks.
39 - TF-A is used as the bootloader with separate firmware components packaged in a FIP
40 image.
41 - The Update Agent runs within a secure partition and exposes an FF-A based ABI that
Gyorgy Szing0accdf72023-04-13 01:55:22 +020042 conforms to the `Arm FWU-A specification`_.
43 - Test and development on supported :ref:`Target Platforms`.
Julian Hall7af7f902023-02-16 11:07:32 +000044
45Source Code Location
46--------------------
47Within the Trusted Services project, source code related to FWU can be found under the
48following subdirectories (relative to the project root).
49
50.. list-table::
51 :header-rows: 1
52
53 * - Directory
54 - Contains
55 * - components/service/fwu
56 - Service components for implementing the FWU service provider.
57 * - protocols/service/fwu
58 - Public service access protocol (ABI) definition.
Gyorgy Szing0accdf72023-04-13 01:55:22 +020059 * - components/media/volume
Julian Hall7af7f902023-02-16 11:07:32 +000060 - Storage volume access.
61
62Testing is covered in more detail in a later section. However, if you want a simple way
63of building and testing FWU components, the component-test deployment may be built for a
64native PC environment. The built executable includes an extensive set of FWU related tests
65that exercise the core Update Agent in various configurations. To build and run these tests
Gyorgy Szing0accdf72023-04-13 01:55:22 +020066on a Linux PC, use the following (from TS root directory):
Julian Hall7af7f902023-02-16 11:07:32 +000067
Gyorgy Szing0accdf72023-04-13 01:55:22 +020068.. code-block:: bash
Julian Hall7af7f902023-02-16 11:07:32 +000069
Gyorgy Szing0accdf72023-04-13 01:55:22 +020070 mkdir -p ~/compt-linux-pc
71 cmake -S deployments/component-test/linux-pc -B ~/compt-linux-pc
72 cmake --build ~/compt-linux-pc
73 ~/compt-linux-pc/component-test -v -g Fwu
Julian Hall7af7f902023-02-16 11:07:32 +000074
Gyorgy Szing0accdf72023-04-13 01:55:22 +020075Output will look like this::
76
77 TEST(FwuCopyInstallerTests, installAndCopy) - 1 ms
78 TEST(FwuRawInstallerTests, normalInstallFlow) - 1 ms
79 TEST(FwuMetadataManagerTests, checkAndRepairInaccessibleStorage) - 0 ms
80 TEST(FwuMetadataManagerTests, checkAndRepairAccessibleStorage) - 1 ms
81 TEST(FwuRollbackTests, bootloaderFallback) - 0 ms
82 TEST(FwuRollbackTests, selectPreviousAfterActivation) - 0 ms
83 TEST(FwuRollbackTests, selectPreviousPriorToActivation) - 0 ms
84 TEST(FwuPowerFailureTests, powerFailureDuringTrial) - 0 ms
85 TEST(FwuPowerFailureTests, powerFailureDuringStaging) - 0 ms
86 TEST(FwuUpdateScenarioTests, partialFirmwareUpdateFlow) - 0 ms
87 TEST(FwuUpdateScenarioTests, wholeFirmwareUpdateFlow) - 0 ms
88 TEST(FwuInvalidBehaviourTests, invalidOperationsInTrial) - 0 ms
89 TEST(FwuInvalidBehaviourTests, invalidOperationsInStaging) - 0 ms
90 TEST(FwuInvalidBehaviourTests, invalidOperationsInRegular) - 0 ms
91 TEST(FwuImageDirectoryTests, zeroFwLocations) - 0 ms
92 TEST(FwuImageDirectoryTests, multipleFwLocations) - 0 ms
93 TEST(FwuImageDirectoryTests, singleFwLocation) - 1 ms
94 TEST(FwuImageDirectoryTests, streamRecycling) - 0 ms
95 TEST(FwuImageDirectoryTests, streamedReads) - 0 ms
96
97 OK (234 tests, 19 ran, 3452 checks, 0 ignored, 215 filtered out, 5 ms)
Julian Hall7af7f902023-02-16 11:07:32 +000098
99Concepts and Assumptions
100------------------------
101Before describing details of the design, some important concepts and assumptions are
102introduced in this section.
103
104Update Packaging
105''''''''''''''''
106A set of firmware images that forms an update will be packaged in some way to enable
107it to be delivered to a device for installation. No particular packaging method is assumed
108by the FWU Update Agent. Any unpacking will be performed before individual images are
109presented to the FWU service for installation. The only assumption that the Update Agent
110relies on is that each image is identified by an image type UUID/GUID. The UEFI specification
111defines the FMP Capsule format that acts as a container for a set of arbitrary images. The
112reference integration maintained by the Trusted Services project uses UEFI FMP capsules
113but the FWU service can be used with any packaging method.
114
115Transactional Updates
116'''''''''''''''''''''
117A firmware update package may contain multiple images that all need to be installed as a
118set in order to successfully update a device's firmware. To avoid the hazard of booting
119a device using partially installed firmware, the FWU-A specification supports transactional
120updates where as set of separate image install operations are grouped together to form a
121single update transaction. The FWU-A specification defines a behavioral model where images
Gyorgy Szing0accdf72023-04-13 01:55:22 +0200122are installed during the *STAGING* state. Entry to the *STAGING* state is triggered by the
123client making the ``fwu_begin_staging`` ABI call. This is followed a set of one or more install
Julian Hall7af7f902023-02-16 11:07:32 +0000124operations where images are written to the Update Agent. After committing the final image
Gyorgy Szing0accdf72023-04-13 01:55:22 +0200125in the set, the client marks the end of the transaction by calling ``fwu_end_staging``.
Julian Hall7af7f902023-02-16 11:07:32 +0000126
127Banked Firmware Store
128'''''''''''''''''''''
129To offer the guarantee that device firmware is never left in an unbootable state, a valid
130version of firmware is always held in flash. Flash storage is organized into A and B banks
131where one bank holds a valid set of images while updates are installed in the other bank.
132The bootloader is capable of booting from either bank, as instructed by the FWU metadata
133written by the Update Agent. Where firmware storage is distributed across multiple locations,
134A and B volumes must exist for each location.
135
136Update Agent
137''''''''''''
138The Update Agent is a logical component defined in the FWU-A specification reference model.
139The Update Agent handles requests from a client to install a set of images in preparation
140for activating the updated firmware. In the TS project, the role of the Update Agent is
141reflected by a firmware component with the same name.
142
143Firmware Directory
144''''''''''''''''''
145The FWU-A specification defines a stream endpoint that can be read by a client to obtain a
146listing of updatable firmware components. In the TS implementation, this is backed by the
147Firmware Directory component that is populated with information about the booted firmware.
148
149Storage Volumes
150''''''''''''''''
151All NV storage accessed by the Update Agent is represented by a set of volume objects. A
152volume presents a unit of storage as a seekable file with support for conventional file IO
153operations. The volume provides a uniform interface for all storage operations performed by
Gyorgy Szing0accdf72023-04-13 01:55:22 +0200154the Update Agent. The volume uses and extends the *io_dev* driver model from the TF-A project.
Julian Hall7af7f902023-02-16 11:07:32 +0000155Concrete volume objects can access different types of storage such as:
156
157 - A raw flash device
158 - A disk partition
Gyorgy Szing0accdf72023-04-13 01:55:22 +0200159 - Storage managed by a subsystem
Julian Hall7af7f902023-02-16 11:07:32 +0000160
161Installers
162''''''''''
163Trusted Services FWU support provides a framework for updating arbitrary firmware images.
164From the framework's perspective, an image is just a binary blob, identified by an image
165type UUID. To allow for image format specific installation, a common installer interface is
166defined to allow for alternative concrete installers. Installers can update the entire
167contents of a volume or modify parts of a volume. Where a volume holds a container such
168as a FIP, a specialized installer with knowledge of the container format can provide finer
169grain updates of the container contents. An installer implements an enumerate method to
170return information about images that it can handle. The Firmware Directory is formed by
171aggregating the information returned by each installer's enumerate method.
172
173Firmware Locations
174''''''''''''''''''
175The Update Agent can manage firmware distributed across multiple locations e.g. different
176flash partitions, different flash devices or different subsystems. The concept of a firmware
177location is used in the TS implementation to provide a generalized model for handling
178distributed firmware. Each location is assigned an integer ID that is used to bind together:
179
180 - A pair of storage volumes (for A + B banks)
181 - A set of one or more installers. The set of installers configured for the location
182 determines which image types are updatable for the location.
183
184Installers are categorized as one of the following types:
185
186 - **Whole volume installer** - updates the entire contents of a volume. The whole volume
187 contents is presented as an entry in the firmware directory.
188 - **Sub-volume installer** - updates components contained within a volume. Each image
189 contained within the active volume is presented as an entry in the firmware directory.
190 - **Whole volume copy installer** - copies entire volume contents from one volume to
191 another. Contributes no entries to the firmware directory.
192
193A platform integrator is responsible for selecting which installers are configured for a
194location. Each location must be assigned at least one installer. Any combination of different
195types of installer could make sense in a platform configuration. Here are some example
196configurations:
197
198.. list-table::
199 :header-rows: 1
200
201 * - Location configuration
202 - Update capability for location
203 * - *WholeVolumeInstaller*
204 - A single entry appears in the firmware directory for the location that corresponds to
205 the entire volume contents. An incoming update package must include an image that
206 corresponds to the directory entry.
207 * - *WholeVolumeInstaller + SubVolumeInstaller*
208 - Firmware directory entries appear for the whole volume and for each updatable component
209 contained within the volume. An incoming update package must include either one or more
210 sub-volume images or a whole volume image for this location.
211 * - *WholeVolumeInstaller + SubVolumeInstaller + WholeVolumeCopyInstaller*
212 - Firmware directory entries appear for the whole volume and for each updatable component
213 contained within the volume. If no image for this location is included in an incoming
214 update package, the currently active volume contents is copied to the update volume.
215 * - *WholeVolumeCopyInstaller*
216 - This configuration can be used if it is necessary to prevent updates for a location.
217 For any update transaction, the currently active volume contents will always be copied
218 to the update volume for this location.
219
220Design Description
221------------------
222FWU components within the TS project are designed for reuse in alternative deployments. The
223project currently maintains two FWU deployments, both sharing many common components:
224
225 - **fwu/config/default-sp** - the Update Agent runs within a secure partition. The client
Gyorgy Szing0accdf72023-04-13 01:55:22 +0200226 invokes ABI operations via FF-A based RPC. Updates are applied to a dedicated SWd flash device.
227 - **fwu-tool/linux-pc** - the Update Agent runs within a command-line application.
Julian Hall7af7f902023-02-16 11:07:32 +0000228 Updates are applied to a disk image file residing in the host filesystem.
229
230There is clear separation between different classes of component making component-level reuse
231straight-forward. The following diagram illustrates the main FWU components. The direction of
232the arrows linking components shows the direction of a dependency between associated
233components (i.e. A→B means that A depends on B).
234
Gyorgy Szing0accdf72023-04-13 01:55:22 +0200235.. image:: ../image/update-agent-components.svg
Julian Hall7af7f902023-02-16 11:07:32 +0000236
237Core Components
238''''''''''''''''
239Any FWU deployment that supports a banked firmware store is expected to use the core set of
240FWU components. Core components are partitioned between:
241
242 - **Generic Update Agent** - manages update transactions and streams used for transferring
243 image data. Also owns the FW Directory.
244 - **Banked FW Store** - manages banked access to storage and communication with the bootloader
245 via FWU metadata.
246
247Generic Update Agent Model
248""""""""""""""""""""""""""
249The following class diagram models the generic Update Agent:
250
Gyorgy Szing0accdf72023-04-13 01:55:22 +0200251.. uml:: ../uml/UpdateAgentClassDiagram.puml
Julian Hall7af7f902023-02-16 11:07:32 +0000252
253Classes in the model perform the following roles:
254
255.. list-table::
256 :header-rows: 1
257
258 * - Class
259 - Description
260 - Source files
261 * - *update_agent*
262 - Coordinates update transactions from start to finish. Implements the FWU state machine that
263 enforces correct behaviour during an update. Provides functions that form the public interface
264 for an instance of the Update Agent.
265 - components/service/fwu/agent/update_agent.h, components/service/fwu/agent/update_agent.c
266 * - *stream_manager*
267 - Manages a pool of stream objects for client initiated stream read and write operations. Streams
268 are used for writing image data and reading FWU objects such as the image directory.
269 - components/service/fwu/agent/stream_manager.h, components/service/fwu/agent/stream_manager.c
270 * - *fw_directory*
271 - Holds information about the currently active firmware. The contents of the fw_directory is
272 updated by a fw_inspector at boot time. Forms the source of the information returned to a
273 client that reads the image directory object.
274 - components/service/fwu/agent/fw_directory.h, components/service/fwu/agent/fw_directory.c
275 * - *img_dir_serializer*
276 - Serializes information about currently active firmware in-line with the FWU-A specification.
277 - components/service/fwu/agent/img_dir_serializer.h, components/service/fwu/agent/img_dir_serializer.c
278 * - *fw_inspector*
279 - Called by the update_agent to inspect firmware and update the contents of the fw_directory to
280 provide a fresh view of active firmware. To allow for alternative inspection strategies, the
281 concrete fw_inspector to use is determined by deployment specific configuration code and passed
282 to the update_agent at initialization. The direct_fw_inspector is a concrete fw_inspector that
283 relies on direct access to the set of installers registered as part of the Update Agent configuration.
284 - components/service/fwu/inspector/fw_inspector.h, components/service/fwu/inspector/direct/direct_fw_inspector.h,
285 components/service/fwu/inspector/direct/direct_fw_inspector.c
286
287Banked FW Store Model
288""""""""""""""""""""""
289The update_agent interacts with the fw_store via a common interface. No details about the nature of the fw_store
290are exposed to the update_agent. The following class diagram models a particular realization of the fw_store
291interface that implements the A/B bank scheme:
292
Gyorgy Szing0accdf72023-04-13 01:55:22 +0200293.. uml:: ../uml/FwStoreClassDiagram.puml
Julian Hall7af7f902023-02-16 11:07:32 +0000294
295Classes in the model perform the following roles:
296
297.. list-table::
298 :header-rows: 1
299
300 * - Class
301 - Description
302 - Source files
303 * - *fw_store*
304 - Manages updates to banked storage volumes.
305 - components/service/fwu/fw_store/fw_store.h,
306 components/service/fwu/fw_store/banked/banked_fw_store.h,
307 components/service/fwu/fw_store/banked/banked_fw_store.c
308 * - *bank_tracker*
309 - Tracks usage and accepted state of firmware banks.
310 - components/service/fwu/fw_store/banked/bank_tracker.h,
311 components/service/fwu/fw_store/banked/bank_tracker.c
312 * - *metadata_manager*
313 - Manages storage and updates to the FWU metadata used for signaling to the bootloader. Responsible for
314 detecting and repairing corrupted metadata.
315 - components/service/fwu/fw_store/banked/metadata_manager.h,
316 components/service/fwu/fw_store/banked/metadata_manager.c
317 * - *metadata_serializer*
318 - Serializes update bank state in a standard format for compatibility with the boot loader. To ensure
319 version compatibility through fw updates, alternative realizations of the metadata_serializer may be
320 selected at runtime. Currently support for V1 and V2 formats (as defined by the FWU-A specification).
321 - components/service/fwu/fw_store/banked/metadata_serializer/metadata_serializer.h
322 * - *installer*
323 - Base class for installers. Defines a common interface for installing images associated with a location.
324 - components/service/fwu/installer/installer.h,
325 components/service/fwu/installer/installer.c
326 * - *installer_index*
327 - Holds pointers to the set of concrete installers registered during platform configuration.
328 - components/service/fwu/installer/installer_index.h,
329 components/service/fwu/installer/installer_index.c
330 * - *volume*
331 - Presents a unit of storage is a seekable file. Supports byte-orient read and writes operation
332 to storage. All NV storage is accessed by the Update Agent using volumes. The set of volume objects
333 needed for a deployment are created as part of platform specific initialisation.
334 - components/media/volume/volume.h,
335 components/media/volume/volume.c
336 * - *volume_index*
337 - Holds pointers to the set of concrete volumes registered during platform configuration.
338 - components/media/volume/index/volume_index.h,
339 components/media/volume/index/volume_index.c
340
341Service Interface
342''''''''''''''''''
343For deployments where the Update Agent needs to be remotely callable, the fwu_provider implements an
344RPC interface that accepts call requests, de-serializes call parameters and calls the corresponding
345interface functions provided by the update_agent. In the reference deployment, where the Update
346Agent runs within an SP, the fwu_provider receives call requests, made via FF-A, and returns responses
347to the remote client. The fwu_provider may be used with any RPC layer where remote calling is required.
348
349Platform Configuration
350----------------------
351A platform specific configuration tells the Update Agent about storage for firmware and defines the
352policy for the way the firmware can be update. Configuration steps result in the creation of:
353
354 - A set of concrete installer objects registered with the installer_index. This defines the
355 type of images that can be updated.
356 - A set of concrete volume objects registered with the volume_index. This defines where images
357 can be installed.
358
359Each installer is assigned a location ID to bind the installer to a particular firmware location.
360Location IDs are integer values defined by the configuration code. For example, where firmware
Gyorgy Szinge6b38462024-10-24 17:36:45 +0200361consists of AP firmware, SCP firmware and RSE firmware, location IDs could be assigned as follows:
Julian Hall7af7f902023-02-16 11:07:32 +0000362
363.. list-table::
364 :header-rows: 1
365
366 * - Location
367 - ID
368 * - AP firmware
369 - 0
370 * - SCP firmware
371 - 1
Gyorgy Szinge6b38462024-10-24 17:36:45 +0200372 * - RSE firmware
Julian Hall7af7f902023-02-16 11:07:32 +0000373 - 2
374
375When volume objects are added to the volume index, each one is assigned a volume ID which is
376formed by combining the corresponding location ID with the bank index to which the volume
377provides access to.
378
379The types of installer and volume needed will depend on factors such as:
380
381 - How NV storage is accessed by the Update Agent.
382 - The type of images that need to be installed.
383 - How flash storage is partitioned e.g. is GPT used or some other partition description method.
384
385Source files related to FWU configuration:
386
387.. list-table::
388 :header-rows: 1
389
390 * - Directory
391 - Contains
392 * - components/service/fwu/config
393 - Configuration strategies for provisioning installers and volumes
394 * - components/service/fwu/installer/factory
395 - Factories for constructing different types of installer
396 * - components/media/volume/factory
397 - Factories for constructing different types of volume
398
399Update Agent Configuration using GPT
400''''''''''''''''''''''''''''''''''''
401The TS FWU service implementation includes a GPT based configurator that automatically discovers
402the set of installers and volumes to construct, based on the contents of the GPT that describes
403the flash layout. The following diagram illustrates a typical flash partition layout. Note that
404not all partitions contain firmware.
405
Gyorgy Szing0accdf72023-04-13 01:55:22 +0200406.. image:: ../image/gpt-based-flash-layout.svg
Julian Hall7af7f902023-02-16 11:07:32 +0000407
408A deployment of the Update Agent is built with an installer factory that has the capability to
409construct a set of installers that are suitable for a family of platforms where common image
410types and update policy applies. An installer factory is capable of constructing a concrete set
411of installers for installing images into a particular set of partitions, identified by partition
412type GUID. A platform may not incorporate the complete set of partition types. The default
413installer factory (under components/service/fwu/installer/factory/default) includes rules for
414constructing installers for:
415
416 - **AP Firmware** - where application firmware is contained within a FIP
417 - **SCP Firmware** - binary boot image for SCP
Gyorgy Szinge6b38462024-10-24 17:36:45 +0200418 - **RSE Firmware** - binary boot image for RSE
Julian Hall7af7f902023-02-16 11:07:32 +0000419
420The GPT based configurator relies on access to the GPT partition table. During initialization
421of the Update Agent, the configurator iterates over each partition entry. If no installers are
422registered for the partition, the partition type GUID is offered to the installer factory. If
423at least one installer is constructed, a volume object is constructed to provide access to the
424partition. This partition will hold one of the banked copies of the image identified by the
425partition type GUID. If one or more installers have already been constructed for the partition
426type GUID, an additional volume object is constructed to provide access to the second
427banked partition.
428
429The designation of bank index to partition is determined from the PartitionName field in the
430partition entry. The first UTF-16 character (0 or 1) is interpreted as the bank index assigned
431to the partition. Different conventions are possible if an alternative configurator is used.
432
433FWU Command Line Application
434----------------------------
Gyorgy Szing0accdf72023-04-13 01:55:22 +0200435The *fwu-tool* deployment integrates the Update Agent within a command-line application that can be
436run on a Linux PC. Instead of updating images stored in flash, the application operates on a GPT
437formatted disk image file residing in the host machine's filesystem. (Refer to :ref:`UEFI disk image
438creation instructions` to see how a disk image can be created.) The core components of the
439application are identical to those used in embedded deployments. To build and run the fwu
440application, use the following commands from the root of the checked-out TS project:
Julian Hall7af7f902023-02-16 11:07:32 +0000441
Gyorgy Szing0accdf72023-04-13 01:55:22 +0200442.. code-block:: bash
Julian Hall7af7f902023-02-16 11:07:32 +0000443
Gyorgy Szing0accdf72023-04-13 01:55:22 +0200444 mkdir -p ~/fwu-tool
445 cmake -S deployments/fwu-tool/linux-pc -B ~/fwu-tool
446 cmake --build ~/fwu-tool
Julian Hall7af7f902023-02-16 11:07:32 +0000447
Gyorgy Szing0accdf72023-04-13 01:55:22 +0200448 ~/fwu-tool/fwu-tool -h
449 Usage: fwu disk-filename [-dir -meta] [-boot-index number -meta-ver number] [-img filename -img-type uuid]
Julian Hall7af7f902023-02-16 11:07:32 +0000450
Gyorgy Szing0accdf72023-04-13 01:55:22 +0200451 disk-filename Disk image file to update
452 -dir Print image directory
453 -meta Print FWU metadata
454 -boot-index Override default boot index [0..n]
455 -meta-ver Specify FWU metadata to use
456 -img File containing image update
457 -img-type Canonical UUID of image to update
Julian Hall7af7f902023-02-16 11:07:32 +0000458
Gyorgy Szing0accdf72023-04-13 01:55:22 +0200459Some sample disk image files can be found under ``components/media/disk/disk_images``
460
461The sample disk image file *multi_location_fw.img* includes a GPT with entries for the firmware
Julian Hall7af7f902023-02-16 11:07:32 +0000462and metadata partitions illustrated in the diagram above. Note that the sample disk image
463does not contain valid FWU metadata within the primary and backup metadata partitions. This
464condition is detected by the Update Agent which writes valid metadata that reflects the contents
465of the disk image file. Subsequent invocations of the app will use the valid metadata previously
466written to the disk image.
467
468The app can of course be used with flash image files created by a firmware build system.
469The command-line interface currently restricts updates to consist of just a single image,
470identified by an image type UUID. Extending the command-line interface to support multi-image
471update transactions is possible by for example adding the capability to process an FMP capsule
472file containing multiple images.
473
474Testing the Update Agent
475------------------------
476FWU components are tested in both native PC and embedded environments. PC based tests use the
Gyorgy Szing0accdf72023-04-13 01:55:22 +0200477*fwu_dut* C++ class to simulate the role of the bootloader and to allow device reboot scenarios
Julian Hall7af7f902023-02-16 11:07:32 +0000478to be recreated. The simulated device-under-test maintains NV storage state through reboots
479to mimic real device behaviour. Test components that support PC based testing are summarized
480in the following table:
481
482.. list-table::
483 :header-rows: 1
484
485 * - Component
486 - Description
487 - Project Directory
488 * - *fwu_dut*
489 - Base class to represent a device-under-test (DUT). Presents an interface used by test
490 cases that allows for test-case reuse with different fwu_dut specializations.
491 - components/service/fwu/test/fwu_dut
492 * - *sim_fwu_dut*
493 - A specialization of the fwu_dut class that adds bootloader simulation and various
494 other test support capabilities.
495 - components/service/fwu/test/fwu_dut/sim
496 * - *proxy_fwu_dut*
497 - A specialization of the fwu_dut class that acts as a proxy for the fwu_dut that
498 actually hosts the Update Agent.
499 - components/service/fwu/test/fwu_dut/proxy
500 * - *fwu_client*
501 - Presents FWU methods (begin_staging, end_staging etc.) for use by test cases.
502 - components/service/fwu/test/fwu_client
503 * - *direct_fwu_client*
504 - An fwu_client that calls Update Agent interface functions directly.
505 - components/service/fwu/test/fwu_client/direct
506 * - *remote_fwu_client*
507 - An fwu_client that makes RPC call requests to invoke Update Agent operations. Call
508 parameters are serialized using the FWU access protocol.
509 - components/service/fwu/test/fwu_client/remote
510 * - *image_directory_checker*
511 - A test support class that fetches the serialized image directory and provides
512 methods for checking the fetched content.
513 - components/service/fwu/test/image_directory_checker
514 * - *metadata_checker*
515 - Provides methods to check that the fetched FWU metadata reflects the state expected
516 by test cases. Decouples test code from the underlying metadata format. Support
517 for V1 and V2 metadata is provided.
518 - components/service/fwu/test/metadata_checker
519 * - *metadata_fetcher*
520 - Provides an interface for fetching the metadata associated with the DUT. Depending
521 on the deployment, different strategies for fetching the metadata are needed.
522 - components/service/fwu/test/metadata_fetcher
523
524An extensive set of test suites uses the test framework components listed above to test
Gyorgy Szing0accdf72023-04-13 01:55:22 +0200525various update scenarios. The following test suites live under ``components/service/fwu/test/ref_scenarios``
Julian Hall7af7f902023-02-16 11:07:32 +0000526
527.. list-table::
528 :header-rows: 1
529
530 * - Test Suite
531 - Description
532 * - *image_directory_tests*
533 - Tests reading of the image directory via the Update Agent stream interface.
534 * - *invalid_behaviour_tests*
535 - Tests to check that invalid requests are rejected with the expected error codes.
536 * - *oversize_image_tests*
537 - Tests to check defenses against attempts to install images that are too big for
538 the available storage.
539 * - *power_failure_tests*
540 - Tests recreate power-failure scenarios at various points during an update transaction.
541 Tests check that a viable set of firmware is always available.
542 * - *rollback_tests*
543 - Tests recreate bootloader initiated and update client requested rollback scenarios.
544 * - *update_scenario_tests*
545 - Various normal update scenarios with a well-behaved client.
546
547The test suites list above are included in the following TS test deployments:
548
Gyorgy Szing0accdf72023-04-13 01:55:22 +0200549 - **component-test** - runs tests in a native PC environment using a *direct_fwu_client*.
550 - **ts-service-test** - runs tests in a native PC environment using a *remote_fwu_client*.
Julian Hall7af7f902023-02-16 11:07:32 +0000551
552Reference Integration Test Environment
553--------------------------------------
554The following diagram provides an overview of the planned reference integration and test
555environment used for testing on FVP.
556
Gyorgy Szing0accdf72023-04-13 01:55:22 +0200557.. image:: ../image/fwu-reference-integration.svg
Julian Hall7af7f902023-02-16 11:07:32 +0000558
559--------------
560
Gyorgy Szing0accdf72023-04-13 01:55:22 +0200561_`Arm FWU-A specification`: https://developer.arm.com/documentation/den0118
562
Julian Hall7af7f902023-02-16 11:07:32 +0000563*Copyright (c) 2023, Arm Limited and Contributors. All rights reserved.*
564
565SPDX-License-Identifier: BSD-3-Clause