All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ilias Apalodimas <ilias.apalodimas@linaro.org>
To: Sughosh Ganu <sughosh.ganu@linaro.org>
Cc: u-boot@lists.denx.de, Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Masahisa Kojima <masahisa.kojima@linaro.org>,
	Patrice Chotard <patrice.chotard@foss.st.com>,
	Patrick Delaunay <patrick.delaunay@foss.st.com>,
	Yann Gautier <yann.gautier@st.com>,
	Etienne Carriere <etienne.carriere@foss.st.com>
Subject: Re: [PATCH 02/18] fwu: metadata: Migrate to version 2 of the structure
Date: Wed, 24 Jan 2024 13:22:54 +0200	[thread overview]
Message-ID: <ZbDzDv932QYnLsC2@hera> (raw)
In-Reply-To: <20240122115439.653871-3-sughosh.ganu@linaro.org>

Hi Sughosh,

On Mon, Jan 22, 2024 at 05:24:23PM +0530, Sughosh Ganu wrote:
> 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
>
> Migrate to the version 2 of the metadata structure.
>
> [1] - https://developer.arm.com/documentation/den0118/latest/
>
> Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
> ---
>  include/fwu_mdata.h | 56 +++++++++++++++++++++++++++++++++------------
>  1 file changed, 42 insertions(+), 14 deletions(-)
>
> diff --git a/include/fwu_mdata.h b/include/fwu_mdata.h
> index 56189e2f40..050ee969e3 100644
> --- a/include/fwu_mdata.h
> +++ b/include/fwu_mdata.h
> @@ -11,7 +11,7 @@
>
>  /**
>   * struct fwu_image_bank_info - firmware image information
> - * @image_uuid: Guid value of the image in this bank
> + * @image_guid: Guid value of the image in this bank
>   * @accepted: Acceptance status of the image
>   * @reserved: Reserved
>   *
> @@ -20,15 +20,15 @@
>   * acceptance status
>   */
>  struct fwu_image_bank_info {
> -	efi_guid_t  image_uuid;
> +	efi_guid_t  image_guid;
>  	uint32_t accepted;
>  	uint32_t reserved;
>  } __packed;
>
>  /**
>   * struct fwu_image_entry - information for a particular type of image
> - * @image_type_uuid: Guid value for identifying the image type
> - * @location_uuid: Guid of the storage volume where the image is located
> + * @image_type_guid: Guid value for identifying the image type
> + * @location_guid: Guid of the storage volume where the image is located
>   * @img_bank_info: Array containing properties of images
>   *
>   * This structure contains information on various types of updatable
> @@ -36,9 +36,30 @@ struct fwu_image_bank_info {
>   * information per bank.
>   */
>  struct fwu_image_entry {
> -	efi_guid_t image_type_uuid;
> -	efi_guid_t location_uuid;
> -	struct fwu_image_bank_info img_bank_info[CONFIG_FWU_NUM_BANKS];
> +	efi_guid_t image_type_guid;
> +	efi_guid_t location_guid;
> +	struct fwu_image_bank_info img_bank_info[];
> +} __packed;
> +
> +/**
> + * struct fwu_fw_desc_store - FWU updatable image information
> + * @num_banks: Number of firmware banks
> + * num_images: Number of images per bank
> + * @img_entry_size: The size of the img_entry array
> + * @bank_info_entry_size: The size of the img_bank_info array
> + * @img_entry: Array of image entries each giving information on a image
> + *
> + * This image descriptor structure contains information on the number of
> + * updatable banks and images per bank. It also gives the total sizes of
> + * the fwu_image_entry and fwu_image_bank_info arrays.
> + */
> +struct fwu_fw_store_desc {
> +	uint8_t  num_banks;
> +	uint8_t  reserved;
> +	uint16_t num_images;
> +	uint16_t img_entry_size;
> +	uint16_t bank_info_entry_size;
> +	struct fwu_image_entry img_entry[];

This is a bit problematic. When a struct is defined using flexible array
members, you are not supposed to include it on other structs or arrays [0].
We need a way of working around this

>  } __packed;
>
>  /**
> @@ -48,21 +69,28 @@ struct fwu_image_entry {
>   * @active_index: Index of the bank currently used for booting images
>   * @previous_active_inde: Index of the bank used before the current bank
>   *                        being used for booting
> - * @img_entry: Array of information on various firmware images that can
> - *             be updated
> + * @metadata_size: Size of the entire metadata structure, including the
> + *                 image descriptors
> + * @desc_offset: The offset from the start of this structure where the
> + *               image descriptor structure starts. 0 if absent
> + * @bank_state: State of each bank, valid, invalid or accepted
> + * @fw_desc: The structure describing the FWU updatable images
>   *
> - * This structure is used to store all the needed information for performing
> + * This is the top level structure used to store all information for performing
>   * multi bank updates on the platform. This contains info on the bank being
> - * used to boot along with the information needed for identification of
> - * individual images
> + * used to boot along with the information on state of individual banks.
>   */
>  struct fwu_mdata {
>  	uint32_t crc32;
>  	uint32_t version;
>  	uint32_t active_index;
>  	uint32_t previous_active_index;
> -
> -	struct fwu_image_entry img_entry[CONFIG_FWU_NUM_IMAGES_PER_BANK];
> +	uint32_t metadata_size;
> +	uint16_t desc_offset;
> +	uint16_t reserved1;
> +	uint8_t  bank_state[4];
> +	uint32_t reserved2;
> +	struct fwu_fw_store_desc fw_desc[];

ditto

>  } __packed;
>
>  #endif /* _FWU_MDATA_H_ */
> --
> 2.34.1
>

[0] git show b10bfd0019f601

  reply	other threads:[~2024-01-24 11:23 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-22 11:54 [PATCH 00/18] FWU: Migrate FWU metadata to version 2 Sughosh Ganu
2024-01-22 11:54 ` [PATCH 01/18] configs: fwu: Remove FWU configs for metadata V2 migration Sughosh Ganu
2024-01-24 11:25   ` Ilias Apalodimas
2024-01-22 11:54 ` [PATCH 02/18] fwu: metadata: Migrate to version 2 of the structure Sughosh Ganu
2024-01-24 11:22   ` Ilias Apalodimas [this message]
2024-01-22 11:54 ` [PATCH 03/18] drivers: fwu: Add the size parameter to the metadata access API's Sughosh Ganu
2024-01-22 11:54 ` [PATCH 04/18] fwu: Add some API's for metadata version 2 access Sughosh Ganu
2024-01-22 11:54 ` [PATCH 05/18] lib: fwu: Make changes to support version 2 of FWU metadata Sughosh Ganu
2024-01-22 11:54 ` [PATCH 06/18] drivers: fwu: mtd: Allocate buffer for image info dynamically Sughosh Ganu
2024-01-22 11:54 ` [PATCH 07/18] drivers: fwu: Allocate memory for metadata copies Sughosh Ganu
2024-01-22 11:54 ` [PATCH 08/18] fwu: Add a function to put a bank in Trial State Sughosh Ganu
2024-01-22 11:54 ` [PATCH 09/18] capsule: Accept a bank on a successful update Sughosh Ganu
2024-01-22 11:54 ` [PATCH 10/18] fwu: mtd: Modify the DFU API's to align with metadata version 2 Sughosh Ganu
2024-01-22 11:54 ` [PATCH 11/18] efi_firmware: fwu: Do not read FWU metadata on sandbox Sughosh Ganu
2024-01-22 11:54 ` [PATCH 12/18] efi_firmware: fwu: Get the number of FWU banks at runtime Sughosh Ganu
2024-01-22 11:54 ` [PATCH 13/18] cmd: fwu: Align the command with metadata version 2 Sughosh Ganu
2024-01-22 11:54 ` [PATCH 14/18] test: fwu: Align the FWU metadata access test with " Sughosh Ganu
2024-01-22 11:54 ` [PATCH 15/18] fwu: Remove the config symbols for number of banks and images Sughosh Ganu
2024-01-22 11:54 ` [PATCH 16/18] tools: mkfwumdata: Migrate to metadata version 2 Sughosh Ganu
2024-01-22 11:54 ` [PATCH 17/18] configs: fwu: Re-enable FWU configs Sughosh Ganu
2024-01-22 11:54 ` [PATCH 18/18] doc: fwu: Make changes for supporting FWU Metadata version 2 Sughosh Ganu
2024-01-24 10:05 ` [PATCH 00/18] FWU: Migrate FWU metadata to " Ilias Apalodimas
2024-01-26 15:09 ` Michal Simek
2024-01-29  6:34   ` Sughosh Ganu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZbDzDv932QYnLsC2@hera \
    --to=ilias.apalodimas@linaro.org \
    --cc=etienne.carriere@foss.st.com \
    --cc=masahisa.kojima@linaro.org \
    --cc=patrice.chotard@foss.st.com \
    --cc=patrick.delaunay@foss.st.com \
    --cc=sughosh.ganu@linaro.org \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    --cc=yann.gautier@st.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.