public inbox for u-boot@lists.denx.de
 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>,
	Takahiro Akashi <takahiro.akashi@linaro.org>,
	Patrick Delaunay <patrick.delaunay@foss.st.com>,
	Patrice Chotard <patrice.chotard@foss.st.com>,
	Simon Glass <sjg@chromium.org>, Bin Meng <bmeng.cn@gmail.com>,
	Tom Rini <trini@konsulko.com>,
	Etienne Carriere <etienne.carriere@linaro.org>,
	Michal Simek <monstr@monstr.eu>,
	Jassi Brar <jaswinder.singh@linaro.org>
Subject: Re: [PATCH v5 10/23] FWU: cmd: Add a command to read FWU metadata
Date: Fri, 10 Jun 2022 15:07:55 +0300	[thread overview]
Message-ID: <YqM0GzV95fTYnR/1@hera> (raw)
In-Reply-To: <20220609123010.1017463-11-sughosh.ganu@linaro.org>

On Thu, Jun 09, 2022 at 05:59:57PM +0530, Sughosh Ganu wrote:
> Add a command to read the metadata as specified in the FWU
> specification and print the fields of the metadata.
> 
> Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
> ---
>  cmd/Kconfig     |  7 +++++
>  cmd/Makefile    |  1 +
>  cmd/fwu_mdata.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 82 insertions(+)
>  create mode 100644 cmd/fwu_mdata.c
> 
> diff --git a/cmd/Kconfig b/cmd/Kconfig
> index 09193b61b9..275becd837 100644
> --- a/cmd/Kconfig
> +++ b/cmd/Kconfig
> @@ -144,6 +144,13 @@ config CMD_CPU
>  	  internal name) and clock frequency. Other information may be
>  	  available depending on the CPU driver.
>  
> +config CMD_FWU_METADATA
> +	bool "fwu metadata read"
> +	depends on FWU_MULTI_BANK_UPDATE
> +	default y if FWU_MULTI_BANK_UPDATE
> +	help
> +	  Command to read the metadata and dump it's contents
> +
>  config CMD_LICENSE
>  	bool "license"
>  	select BUILD_BIN2C
> diff --git a/cmd/Makefile b/cmd/Makefile
> index 5e43a1e022..259a93bc65 100644
> --- a/cmd/Makefile
> +++ b/cmd/Makefile
> @@ -76,6 +76,7 @@ obj-$(CONFIG_CMD_FPGA) += fpga.o
>  obj-$(CONFIG_CMD_FPGAD) += fpgad.o
>  obj-$(CONFIG_CMD_FS_GENERIC) += fs.o
>  obj-$(CONFIG_CMD_FUSE) += fuse.o
> +obj-$(CONFIG_CMD_FWU_METADATA) += fwu_mdata.o
>  obj-$(CONFIG_CMD_GETTIME) += gettime.o
>  obj-$(CONFIG_CMD_GPIO) += gpio.o
>  obj-$(CONFIG_CMD_HVC) += smccc.o
> diff --git a/cmd/fwu_mdata.c b/cmd/fwu_mdata.c
> new file mode 100644
> index 0000000000..bc20ca26a3
> --- /dev/null
> +++ b/cmd/fwu_mdata.c
> @@ -0,0 +1,74 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +/*
> + * Copyright (c) 2022, Linaro Limited
> + */
> +
> +#include <command.h>
> +#include <dm.h>
> +#include <fwu.h>
> +#include <fwu_mdata.h>
> +#include <log.h>
> +#include <stdio.h>
> +#include <stdlib.h>
> +
> +#include <linux/types.h>
> +
> +static void print_mdata(struct fwu_mdata *mdata)
> +{
> +	int i, j;
> +	struct fwu_image_entry *img_entry;
> +	struct fwu_image_bank_info *img_info;
> +	u32 nimages, nbanks;

nit but we don't really need those two.  Just use the define.

> +
> +	printf("\tFWU Metadata\n");
> +	printf("crc32: %#x\n", mdata->crc32);
> +	printf("version: %#x\n", mdata->version);
> +	printf("active_index: %#x\n", mdata->active_index);
> +	printf("previous_active_index: %#x\n", mdata->previous_active_index);
> +
> +	nimages = CONFIG_FWU_NUM_IMAGES_PER_BANK;
> +	nbanks = CONFIG_FWU_NUM_BANKS;
> +	printf("\tImage Info\n");
> +	for (i = 0; i < nimages; i++) {
> +		img_entry = &mdata->img_entry[i];
> +		printf("\nImage Type Guid: %pUL\n", &img_entry->image_type_uuid);
> +		printf("Location Guid: %pUL\n", &img_entry->location_uuid);
> +		for (j = 0; j < nbanks; j++) {
> +			img_info = &img_entry->img_bank_info[j];
> +			printf("Image Guid:  %pUL\n", &img_info->image_uuid);
> +			printf("Image Acceptance: %#x\n", img_info->accepted);

Can we do 'yes/no' on the image acceptance please?

> +		}
> +	}
> +}
> +
> +int do_fwu_mdata_read(struct cmd_tbl *cmdtp, int flag,
> +		     int argc, char * const argv[])
> +{
> +	struct udevice *dev;
> +	int ret = CMD_RET_SUCCESS;
> +	struct fwu_mdata *mdata = NULL;
> +
> +	if (uclass_get_device(UCLASS_FWU_MDATA, 0, &dev) || !dev) {
> +		log_err("Unable to get FWU metadata device\n");
> +		return CMD_RET_FAILURE;
> +	}
> +
> +	ret = fwu_get_mdata(&mdata);
> +	if (ret < 0) {
> +		log_err("Unable to get valid FWU metadata\n");
> +		ret = CMD_RET_FAILURE;
> +		goto out;
> +	}
> +
> +	print_mdata(mdata);
> +
> +out:
> +	free(mdata);
> +	return ret;
> +}
> +
> +U_BOOT_CMD(
> +	fwu_mdata_read,	1,	1,	do_fwu_mdata_read,
> +	"Read and print FWU metadata",
> +	""
> +);
> -- 
> 2.25.1
> 

Regards
/Ilias

  reply	other threads:[~2022-06-10 12:08 UTC|newest]

Thread overview: 104+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-09 12:29 [PATCH v5 00/23] FWU: Add FWU Multi Bank Update feature support Sughosh Ganu
2022-06-09 12:29 ` [PATCH v5 01/23] dt/bindings: Add bindings for FWU Metadata storage device Sughosh Ganu
2022-06-16 13:34   ` Michal Simek
2022-06-17  6:21     ` Sughosh Ganu
2022-06-09 12:29 ` [PATCH v5 02/23] FWU: Add FWU metadata structure and driver for accessing metadata Sughosh Ganu
2022-06-21 10:54   ` Etienne Carriere
2022-06-23  6:24     ` Sughosh Ganu
2022-06-23 11:55       ` Etienne Carriere
2022-06-09 12:29 ` [PATCH v5 03/23] FWU: Add FWU metadata access driver for GPT partitioned block devices Sughosh Ganu
2022-06-21  9:34   ` Patrick DELAUNAY
2022-06-22 12:39     ` Patrick DELAUNAY
2022-06-28 10:01     ` Sughosh Ganu
2022-06-21 10:55   ` Etienne Carriere
2022-06-28 10:11     ` Sughosh Ganu
2022-06-09 12:29 ` [PATCH v5 04/23] stm32mp1: dk2: Add a node for the FWU metadata device Sughosh Ganu
2022-06-21  9:36   ` Patrick DELAUNAY
2022-06-09 12:29 ` [PATCH v5 05/23] stm32mp1: dk2: Add image information for capsule updates Sughosh Ganu
2022-06-09 12:29 ` [PATCH v5 06/23] FWU: stm32mp1: Add helper functions for accessing FWU metadata Sughosh Ganu
2022-06-10 11:53   ` Ilias Apalodimas
2022-06-13 12:37     ` Sughosh Ganu
2022-06-21  9:49   ` Patrick DELAUNAY
2022-06-23  6:04     ` Sughosh Ganu
2022-06-09 12:29 ` [PATCH v5 07/23] FWU: STM32MP1: Add support to read boot index from backup register Sughosh Ganu
2022-06-10 12:02   ` Ilias Apalodimas
2022-06-21 11:27   ` Patrick DELAUNAY
2022-06-23  6:30     ` Sughosh Ganu
2022-06-09 12:29 ` [PATCH v5 08/23] FWU: Add boot time checks as highlighted by the FWU specification Sughosh Ganu
2022-06-15  6:34   ` Heinrich Schuchardt
2022-06-15  6:39     ` Takahiro Akashi
2022-06-21 10:56   ` Etienne Carriere
2022-06-23  9:45     ` Sughosh Ganu
2022-06-23 12:32       ` Etienne Carriere
2022-06-28 10:42         ` Sughosh Ganu
2022-06-21 11:46   ` Patrick DELAUNAY
2022-06-23  9:49     ` Sughosh Ganu
2022-06-09 12:29 ` [PATCH v5 09/23] FWU: Add support for the FWU Multi Bank Update feature Sughosh Ganu
2022-06-21 10:56   ` Etienne Carriere
2022-06-21 11:55   ` Patrick DELAUNAY
2022-06-09 12:29 ` [PATCH v5 10/23] FWU: cmd: Add a command to read FWU metadata Sughosh Ganu
2022-06-10 12:07   ` Ilias Apalodimas [this message]
2022-06-13 12:38     ` Sughosh Ganu
2022-06-20 12:53   ` Michal Simek
2022-06-21 12:07   ` Patrick DELAUNAY
2022-06-09 12:29 ` [PATCH v5 11/23] mkeficapsule: Add support for generating empty capsules Sughosh Ganu
2022-06-09 16:27   ` Heinrich Schuchardt
2022-06-13 12:33     ` Sughosh Ganu
2022-06-15  5:11   ` Takahiro Akashi
2022-06-15 10:49     ` Sughosh Ganu
2022-06-16  1:01       ` Takahiro Akashi
2022-06-16  7:12         ` Sughosh Ganu
2022-06-17  0:46           ` Takahiro Akashi
2022-06-17  8:01             ` Sughosh Ganu
2022-06-21 10:58   ` Etienne Carriere
2022-06-09 12:29 ` [PATCH v5 12/23] FWU: doc: Add documentation for the FWU feature Sughosh Ganu
2022-06-21 12:12   ` Patrick DELAUNAY
2022-06-09 12:30 ` [PATCH v5 13/23] FWU: Add FWU metadata access driver for non-GPT MTD devices Sughosh Ganu
2022-06-21 10:56   ` Etienne Carriere
2022-06-21 12:39   ` Patrick DELAUNAY
2022-06-09 12:30 ` [PATCH v5 14/23] dt/bindings: firmware: Add FWU metadata on MTD devices binding Sughosh Ganu
2022-06-21 10:56   ` Etienne Carriere
2022-06-21 12:26   ` Patrick DELAUNAY
2022-06-09 12:30 ` [PATCH v5 15/23] tools: Add mkfwumdata tool for FWU metadata image Sughosh Ganu
2022-06-21 10:57   ` Etienne Carriere
2022-06-21 12:59     ` Michal Simek
2022-06-21 12:55   ` Patrick DELAUNAY
2022-06-09 12:30 ` [PATCH v5 16/23] FWU: doc: Update documentation for the FWU non-GPT MTD Sughosh Ganu
2022-06-09 12:30 ` [PATCH v5 17/23] synquacer: Update for TBBR (BL2) based new FIP layout Sughosh Ganu
2022-06-09 12:30 ` [PATCH v5 18/23] developerbox: synquacer: Use FIP as the updatable image Sughosh Ganu
2022-06-09 12:30 ` [PATCH v5 19/23] FWU: synquacer: Add FWU Multi bank update support for DeveloperBox Sughosh Ganu
2022-06-17 14:00   ` Michal Simek
2022-06-20  8:23   ` Michal Simek
2022-07-18 14:43     ` Jassi Brar
2022-07-18 14:46       ` Ilias Apalodimas
2022-07-18 15:08         ` Jassi Brar
2022-07-18 15:16           ` Ilias Apalodimas
2022-07-18 15:31             ` Jassi Brar
2022-07-18 15:34               ` Ilias Apalodimas
2022-07-18 15:34               ` Jassi Brar
2022-07-18 15:37                 ` Ilias Apalodimas
2022-07-18 21:00               ` Tom Rini
2022-07-19 15:23                 ` Jassi Brar
2022-07-20  1:17                   ` Tom Rini
2022-07-19 15:27                 ` Jassi Brar
2022-07-20  7:53                   ` Ilias Apalodimas
2022-07-20 14:30                     ` Jassi Brar
2022-07-22  8:37                       ` Ilias Apalodimas
2022-07-22 17:01                         ` Jassi Brar
2022-06-09 12:30 ` [PATCH v5 20/23] FWU: synquacer: Generate dfu_alt_info from devicetree partition Sughosh Ganu
2022-06-17 14:02   ` Michal Simek
2022-07-18 14:49     ` Jassi Brar
2022-07-20  1:13       ` Takahiro Akashi
2022-07-20  3:16         ` Jassi Brar
2022-06-09 12:30 ` [PATCH v5 21/23] doc: synquacer: Add how to enable FWU Multi Bank Update Sughosh Ganu
2022-06-17 13:59   ` Michal Simek
2022-06-09 12:30 ` [PATCH v5 22/23] [TEMP]configs: synquacer: Add FWU support for DeveloperBox Sughosh Ganu
2022-06-09 12:30 ` [PATCH v5 23/23] sandbox: fwu: Add support for testing FWU feature on sandbox Sughosh Ganu
2022-06-15  5:37   ` Takahiro Akashi
2022-06-15 12:10     ` Sughosh Ganu
2022-06-17  1:08       ` Takahiro Akashi
2022-06-17  7:57         ` Sughosh Ganu
2022-06-15  6:30   ` Takahiro Akashi
2022-06-15 12:13     ` Sughosh Ganu
2022-06-20 18:12 ` [PATCH v5 00/23] FWU: Add FWU Multi Bank Update feature support Patrick DELAUNAY
2022-06-21  9:23   ` 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=YqM0GzV95fTYnR/1@hera \
    --to=ilias.apalodimas@linaro.org \
    --cc=bmeng.cn@gmail.com \
    --cc=etienne.carriere@linaro.org \
    --cc=jaswinder.singh@linaro.org \
    --cc=monstr@monstr.eu \
    --cc=patrice.chotard@foss.st.com \
    --cc=patrick.delaunay@foss.st.com \
    --cc=sjg@chromium.org \
    --cc=sughosh.ganu@linaro.org \
    --cc=takahiro.akashi@linaro.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox