All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sughosh Ganu <sughosh.ganu@linaro.org>
To: u-boot@lists.denx.de
Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>,
	Patrice Chotard <patrice.chotard@foss.st.com>,
	Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Alexander Graf <agraf@csgraf.de>, Simon Glass <sjg@chromium.org>,
	Bin Meng <bmeng.cn@gmail.com>, Peng Fan <peng.fan@nxp.com>,
	AKASHI Takahiro <takahiro.akashi@linaro.org>,
	Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	Jose Marinho <jose.marinho@arm.com>,
	Grant Likely <grant.likely@arm.com>,
	Jason Liu <jason.hui.liu@nxp.com>,
	Sughosh Ganu <sughosh.ganu@linaro.org>
Subject: [RFC PATCH 10/10] FWU: cmd: Add a command to read metadata
Date: Thu, 25 Nov 2021 12:31:46 +0530	[thread overview]
Message-ID: <20211125070146.2389-11-sughosh.ganu@linaro.org> (raw)
In-Reply-To: <20211125070146.2389-1-sughosh.ganu@linaro.org>

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        |  6 +++++
 cmd/Makefile       |  1 +
 cmd/fwu_metadata.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 72 insertions(+)
 create mode 100644 cmd/fwu_metadata.c

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 5b30b13e43..1bf590caf0 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -137,6 +137,12 @@ 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"
+	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 891819ae0f..9dc05dd719 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -72,6 +72,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_metadata.o
 obj-$(CONFIG_CMD_GETTIME) += gettime.o
 obj-$(CONFIG_CMD_GPIO) += gpio.o
 obj-$(CONFIG_CMD_HVC) += smccc.o
diff --git a/cmd/fwu_metadata.c b/cmd/fwu_metadata.c
new file mode 100644
index 0000000000..3908b60dea
--- /dev/null
+++ b/cmd/fwu_metadata.c
@@ -0,0 +1,65 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2021, Linaro Limited
+ */
+
+#include <command.h>
+#include <fwu_metadata.h>
+#include <stdlib.h>
+
+#include <linux/types.h>
+
+static void print_metadata(struct fwu_metadata *metadata)
+{
+	int i, j;
+	struct fwu_image_entry *img_entry;
+	struct fwu_image_bank_info *img_info;
+	u32 nimages, nbanks;
+
+	printf("\tMetadata Read\n");
+	printf("crc32: %#x\n", metadata->crc32);
+	printf("version: %#x\n", metadata->version);
+	printf("active_index: %#x\n", metadata->active_index);
+	printf("previous_active_index: %#x\n", metadata->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 = &metadata->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);
+		}
+	}
+}
+
+int do_metadata_read(struct cmd_tbl *cmdtp, int flag,
+		     int argc, char * const argv[])
+{
+	int ret = CMD_RET_SUCCESS;
+	struct fwu_metadata *metadata;
+
+	printf("Trying to get the metadata\n");
+	ret = fwu_get_metadata(&metadata);
+	if (ret < 0) {
+		log_err("Unable to get valid metadata\n");
+		ret = CMD_RET_FAILURE;
+		goto out;
+	}
+
+	print_metadata(metadata);
+
+out:
+	free(metadata);
+	return ret;
+}
+
+U_BOOT_CMD(
+	metadata_read,	1,	1,	do_metadata_read,
+	"Read and print FWU metadata",
+	""
+);
-- 
2.17.1


      parent reply	other threads:[~2021-11-25  7:04 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-25  7:01 [RFC PATCH 00/10] FWU: Add support for FWU Multi Bank Update feature Sughosh Ganu
2021-11-25  7:01 ` [RFC PATCH 01/10] GPT: Add function to get gpt header and partition entries Sughosh Ganu
2021-12-07 15:35   ` Patrick DELAUNAY
2021-12-08  7:40     ` Sughosh Ganu
2021-12-09  1:32       ` AKASHI Takahiro
2021-12-09  9:00         ` Sughosh Ganu
2021-11-25  7:01 ` [RFC PATCH 02/10] stm32mp: dfu: Move the ram partitions to the end of the dfu_alt_info variable Sughosh Ganu
2021-12-08 13:13   ` Etienne Carriere
2021-12-09  9:04     ` Sughosh Ganu
2021-11-25  7:01 ` [RFC PATCH 03/10] FWU: Add metadata structure and functions for accessing metadata Sughosh Ganu
2021-12-08 13:53   ` Etienne Carriere
2021-12-09  9:42     ` Sughosh Ganu
2021-11-25  7:01 ` [RFC PATCH 04/10] FWU: Add metadata access functions for GPT partitioned block devices Sughosh Ganu
2021-12-07 14:23   ` Patrick DELAUNAY
2021-12-08  7:18     ` Sughosh Ganu
2021-12-09  2:32   ` Simon Glass
2021-12-09  9:01     ` Sughosh Ganu
2021-12-09  9:35   ` Jason Liu
2021-12-09  9:46     ` Sughosh Ganu
2021-11-25  7:01 ` [RFC PATCH 05/10] FWU: stm32mp1: Add helper functions for accessing metadata Sughosh Ganu
2021-12-07 14:33   ` Patrick DELAUNAY
2021-12-08 10:18     ` Sughosh Ganu
2021-11-25  7:01 ` [RFC PATCH 06/10] FWU: STM32MP1: Add support to read boot index from backup register Sughosh Ganu
2021-12-07 14:27   ` Patrick DELAUNAY
2021-12-08  7:21     ` Sughosh Ganu
2021-11-25  7:01 ` [RFC PATCH 07/10] EFI: FMP: Add provision to update image's ImageTypeId in image descriptor Sughosh Ganu
2021-11-25  7:01 ` [RFC PATCH 08/10] FWU: Add boot time checks as highlighted by the FWU specification Sughosh Ganu
2021-11-25  7:01 ` [RFC PATCH 09/10] FWU: Add support for FWU Multi Bank Update feature Sughosh Ganu
2021-11-25  7:01 ` Sughosh Ganu [this message]

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=20211125070146.2389-11-sughosh.ganu@linaro.org \
    --to=sughosh.ganu@linaro.org \
    --cc=agraf@csgraf.de \
    --cc=bmeng.cn@gmail.com \
    --cc=grant.likely@arm.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=jason.hui.liu@nxp.com \
    --cc=jose.marinho@arm.com \
    --cc=patrice.chotard@foss.st.com \
    --cc=patrick.delaunay@foss.st.com \
    --cc=peng.fan@nxp.com \
    --cc=sjg@chromium.org \
    --cc=takahiro.akashi@linaro.org \
    --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 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.