feat(fwu): migrate FWU metadata structure to version 2

The latest version of the FWU specification [1] has changes to the
metadata structure. This is version 2 of the structure.

Primary changes include
 - bank_state field in the top level structure
 - Total metadata size in the top level structure
 - Image description structures now optional
 - Number of banks and images per bank values part of the structure

Make changes to the structure to align with version 2 of the structure
defined in the specification. These changes also remove support for
version 1 of the metadata structure.

[1] - https://developer.arm.com/documentation/den0118/latest/

Change-Id: I84b4e742e463cae92375dde8b4603b4a581d62d8
Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
This commit is contained in:
Sughosh Ganu 2024-02-01 12:47:13 +05:30
parent 7ae16196cc
commit a89d58bb20
2 changed files with 47 additions and 1 deletions

View file

@ -9,6 +9,10 @@
#include <stdbool.h>
#define FWU_BANK_STATE_ACCEPTED 0xFCU
#define FWU_BANK_STATE_VALID 0xFEU
#define FWU_BANK_STATE_INVALID 0xFFU
void fwu_init(void);
bool fwu_is_trial_run_state(void);
const struct fwu_metadata *fwu_get_metadata(void);

View file

@ -14,6 +14,8 @@
#include <stdint.h>
#include <tools_share/uuid.h>
#define NR_OF_MAX_FW_BANKS 4
/* Properties of image in a bank */
struct fwu_image_properties {
@ -45,6 +47,29 @@ struct fwu_image_entry {
} __packed;
/* Firmware Image descriptor */
struct fwu_fw_store_descriptor {
/* Number of Banks */
uint8_t num_banks;
/* Reserved */
uint8_t reserved;
/* Number of images per bank */
uint16_t num_images;
/* Size of image_entry(all banks) in bytes */
uint16_t img_entry_size;
/* Size of image bank info structure in bytes */
uint16_t bank_info_entry_size;
/* Array of fwu_image_entry structs */
struct fwu_image_entry img_entry[NR_OF_IMAGES_IN_FW_BANK];
} __packed;
/*
* FWU metadata filled by the updater and consumed by TF-A for
* various purposes as below:
@ -66,8 +91,25 @@ struct fwu_metadata {
/* Previous bank index with which device booted successfully */
uint32_t previous_active_index;
/* Size of the entire metadata in bytes */
uint32_t metadata_size;
/* Offset of the image descriptor structure */
uint16_t desc_offset;
/* Reserved */
uint16_t reserved1;
/* Bank state */
uint8_t bank_state[NR_OF_MAX_FW_BANKS];
/* Reserved */
uint32_t reserved2;
#if PSA_FWU_METADATA_FW_STORE_DESC
/* Image entry information */
struct fwu_image_entry img_entry[NR_OF_IMAGES_IN_FW_BANK];
struct fwu_fw_store_descriptor fw_desc;
#endif
} __packed;