All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrice CHOTARD <patrice.chotard@foss.st.com>
To: Patrick Delaunay <patrick.delaunay@foss.st.com>, <u-boot@lists.denx.de>
Cc: Jaehoon Chung <jh80.chung@samsung.com>,
	Simon Glass <sjg@chromium.org>,
	U-Boot STM32 <uboot-stm32@st-md-mailman.stormreply.com>
Subject: Re: [PATCH 5/8] stm32mp: stm32prog: add support of UUID for FIP partition
Date: Fri, 22 Apr 2022 09:42:33 +0200	[thread overview]
Message-ID: <96607d26-b6da-6662-4f98-dfc464c3a526@foss.st.com> (raw)
In-Reply-To: <20220328192520.5.I94e74b521fd55dcc68ab8d000cb93ef48fc12f14@changeid>

Hi Patrick

On 3/28/22 19:25, Patrick Delaunay wrote:
> Add support of UUID for FIP parttion, required by Firmware update
> support in TF-A:
> - UUID TYPE for FIP partition: 19d5df83-11b0-457b-be2c-7559c13142a5
> - "fip-a" partition UUID: 4fd84c93-54ef-463f-a7ef-ae25ff887087
> - "fip-b" partition UUID: 09c54952-d5bf-45af-acee-335303766fb3
> 
> This check is done with a new partition type "FIP" associated
> at the FIP UUID.
> 
> The A/B partition UUID is detected by the partition name:
> "fip-a", "fip-b".
> 
> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
> ---
> 
>  .../mach-stm32mp/cmd_stm32prog/stm32prog.c    | 76 ++++++++++++++-----
>  .../mach-stm32mp/cmd_stm32prog/stm32prog.h    |  3 +-
>  2 files changed, 59 insertions(+), 20 deletions(-)
> 
> diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
> index 3e1fdee5b3..d3b3e1ed72 100644
> --- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
> +++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
> @@ -62,6 +62,28 @@ static const efi_guid_t uuid_mmc[3] = {
>  	ROOTFS_MMC2_UUID
>  };
>  
> +/* FIP type partition UUID used by TF-A*/
> +#define FIP_TYPE_UUID "19D5DF83-11B0-457B-BE2C-7559C13142A5"
> +
> +/* unique partition guid (uuid) for FIP partitions A/B */
> +#define FIP_A_UUID \
> +	EFI_GUID(0x4FD84C93, 0x54EF, 0x463F, \
> +		 0xA7, 0xEF, 0xAE, 0x25, 0xFF, 0x88, 0x70, 0x87)
> +
> +#define FIP_B_UUID \
> +	EFI_GUID(0x09C54952, 0xD5BF, 0x45AF, \
> +		 0xAC, 0xEE, 0x33, 0x53, 0x03, 0x76, 0x6F, 0xB3)
> +
> +static const char * const fip_part_name[] = {
> +	"fip-a",
> +	"fip-b"
> +};
> +
> +static const efi_guid_t fip_part_uuid[] = {
> +	FIP_A_UUID,
> +	FIP_B_UUID
> +};
> +
>  /* order of column in flash layout file */
>  enum stm32prog_col_t {
>  	COL_OPTION,
> @@ -405,6 +427,8 @@ static int parse_type(struct stm32prog_data *data,
>  				part->bin_nb =
>  					dectoul(&p[7], NULL);
>  		}
> +	} else if (!strcmp(p, "FIP")) {
> +		part->part_type = PART_FIP;
>  	} else if (!strcmp(p, "System")) {
>  		part->part_type = PART_SYSTEM;
>  	} else if (!strcmp(p, "FileSystem")) {
> @@ -1056,9 +1080,10 @@ static int create_gpt_partitions(struct stm32prog_data *data)
>  	char uuid[UUID_STR_LEN + 1];
>  	unsigned char *uuid_bin;
>  	unsigned int mmc_id;
> -	int i;
> +	int i, j;
>  	bool rootfs_found;
>  	struct stm32prog_part_t *part;
> +	const char *type_str;
>  
>  	buf = malloc(buflen);
>  	if (!buf)
> @@ -1100,33 +1125,46 @@ static int create_gpt_partitions(struct stm32prog_data *data)
>  					   part->addr,
>  					   part->size);
>  
> -			if (part->part_type == PART_BINARY)
> -				offset += snprintf(buf + offset,
> -						   buflen - offset,
> -						   ",type="
> -						   LINUX_RESERVED_UUID);
> -			else
> -				offset += snprintf(buf + offset,
> -						   buflen - offset,
> -						   ",type=linux");
> +			switch (part->part_type) {
> +			case PART_BINARY:
> +				type_str = LINUX_RESERVED_UUID;
> +				break;
> +			case PART_FIP:
> +				type_str = FIP_TYPE_UUID;
> +				break;
> +			default:
> +				type_str = "linux";
> +				break;
> +			}
> +			offset += snprintf(buf + offset,
> +					   buflen - offset,
> +					   ",type=%s", type_str);
>  
>  			if (part->part_type == PART_SYSTEM)
>  				offset += snprintf(buf + offset,
>  						   buflen - offset,
>  						   ",bootable");
>  
> +			/* partition UUID */
> +			uuid_bin = NULL;
>  			if (!rootfs_found && !strcmp(part->name, "rootfs")) {
>  				mmc_id = part->dev_id;
>  				rootfs_found = true;
> -				if (mmc_id < ARRAY_SIZE(uuid_mmc)) {
> -					uuid_bin =
> -					  (unsigned char *)uuid_mmc[mmc_id].b;
> -					uuid_bin_to_str(uuid_bin, uuid,
> -							UUID_STR_FORMAT_GUID);
> -					offset += snprintf(buf + offset,
> -							   buflen - offset,
> -							   ",uuid=%s", uuid);
> -				}
> +				if (mmc_id < ARRAY_SIZE(uuid_mmc))
> +					uuid_bin = (unsigned char *)uuid_mmc[mmc_id].b;
> +			}
> +			if (part->part_type == PART_FIP) {
> +				for (j = 0; j < ARRAY_SIZE(fip_part_name); j++)
> +					if (!strcmp(part->name, fip_part_name[j])) {
> +						uuid_bin = (unsigned char *)fip_part_uuid[j].b;
> +						break;
> +					}
> +			}
> +			if (uuid_bin) {
> +				uuid_bin_to_str(uuid_bin, uuid, UUID_STR_FORMAT_GUID);
> +				offset += snprintf(buf + offset,
> +						   buflen - offset,
> +						   ",uuid=%s", uuid);
>  			}
>  
>  			offset += snprintf(buf + offset, buflen - offset, ";");
> diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h
> index 90cdc2ba47..b3e5c74810 100644
> --- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h
> +++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h
> @@ -94,9 +94,10 @@ struct stm32_header_v2 {
>  /* partition type in flashlayout file */
>  enum stm32prog_part_type {
>  	PART_BINARY,
> +	PART_FIP,
>  	PART_SYSTEM,
>  	PART_FILESYSTEM,
> -	RAW_IMAGE
> +	RAW_IMAGE,
>  };
>  
>  /* device information */
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
Thanks
Patrice

  reply	other threads:[~2022-04-22  7:42 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-28 17:25 [PATCH 0/8] stm32mp: command stm32prog improvements Patrick Delaunay
2022-03-28 17:25 ` [PATCH 1/8] stm32mp: stm32prog: fix comment Patrick Delaunay
2022-04-22  7:41   ` Patrice CHOTARD
2022-05-10  7:27   ` Patrice CHOTARD
2022-03-28 17:25 ` [PATCH 2/8] stm32mp: stm32prog: add CONFIG_CMD_STM32PROG_OTP Patrick Delaunay
2022-04-22  7:41   ` Patrice CHOTARD
2022-05-10  7:27   ` Patrice CHOTARD
2022-03-28 17:25 ` [PATCH 3/8] stm32mp: stm32prog: add TEE support in stm32prog command Patrick Delaunay
2022-04-22  7:42   ` Patrice CHOTARD
2022-05-10  7:27   ` Patrice CHOTARD
2022-03-28 17:25 ` [PATCH 4/8] stm32mp: stm32prog: add support of STM32IMAGE version 2 Patrick Delaunay
2022-04-22  7:42   ` Patrice CHOTARD
2022-05-10  7:27   ` Patrice CHOTARD
2022-03-28 17:25 ` [PATCH 5/8] stm32mp: stm32prog: add support of UUID for FIP partition Patrick Delaunay
2022-04-22  7:42   ` Patrice CHOTARD [this message]
2022-05-10  7:28   ` Patrice CHOTARD
2022-03-28 17:25 ` [PATCH 6/8] stm32mp: stm32prog: handle interruption during the first enumeration Patrick Delaunay
2022-04-22  7:42   ` Patrice CHOTARD
2022-05-10  7:29   ` Patrice CHOTARD
2022-03-28 17:25 ` [PATCH 7/8] stm32mp: stm32prog: handle U-Boot script in flashlayout alternate Patrick Delaunay
2022-04-22  7:43   ` Patrice CHOTARD
2022-05-10  7:30   ` Patrice CHOTARD
2022-03-28 17:25 ` [PATCH 8/8] stm32mp: stm32prog: handle flashlayout without STM32 image header Patrick Delaunay
2022-04-22  7:43   ` Patrice CHOTARD
2022-05-10  7:30   ` Patrice CHOTARD

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=96607d26-b6da-6662-4f98-dfc464c3a526@foss.st.com \
    --to=patrice.chotard@foss.st.com \
    --cc=jh80.chung@samsung.com \
    --cc=patrick.delaunay@foss.st.com \
    --cc=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    --cc=uboot-stm32@st-md-mailman.stormreply.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.