From patchwork Thu Nov 25 07:13:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 519380 Delivered-To: patch@linaro.org Received: by 2002:ac0:c605:0:0:0:0:0 with SMTP id p5csp369665imj; Wed, 24 Nov 2021 23:15:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJyXAH/WvSLA6h4d6nljYBLiGiOJ3L5pBeSUZ1wehymdLlWYVvPEhuXES4470lM2gY5FHrDJ X-Received: by 2002:a17:906:24ca:: with SMTP id f10mr28598571ejb.144.1637824540787; Wed, 24 Nov 2021 23:15:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637824540; cv=none; d=google.com; s=arc-20160816; b=uxhcP/QnJlINqY9UoEH3iLRP1K3NKLajJaSfMYzs/JNQFHxEHjruSltesD8zO+EXDz D9Yhn+TTNra3efYdY2CTG1jRAy+EIi7PjQ9LX2J5GQ7fIP5MnVJM7Cg89XISW3VWMM73 mJ7Z2Dz9QfmP5kSAUHQXUV5nM0/UwelFef1iQKshyn6cb3p+l4Y33PeVEs80UFAikVcX mMP5EGZVk0lr6vLHlUAPHwKTSedfqy/tlEHb01I+aq5d0ZVIGDrF3YFdPlkNyWeLaSgQ c4shptFgHRWe0TQwEse2TqzUPaBQa3VC9uR2bRnlmml0dlx3VnXKeY5JrW4wnzUBgDNv jDrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:in-reply-to :message-id:date:subject:cc:to:from; bh=PbHQ/60R6UQvWZgFqO/N3oqhLZzikbEmE7bSNVmEkr4=; b=hy48MRkjixEGYa+EZOaOuA/7vvRpcv971itKA2Hs+S9u9G4c3izLZfIRl2m7Z/hFez b5utXvs05Tai+H7k4KD6GLzRJ7v3CC5zlVT6eXfrWAXnibJlst58X2l0DU2Ez98skdhK b3IkZj8coQt7xrH36oIwSlbwjZjqGuaP8uP2tDpdX/3eyXYoFqr0F0FM7eiszELv7Obu RE6mJKFB5Mvjc7EqoO3xphwJEd5kFHScMCpKBWD58Y3aLp9+AZCxD6618hfFVSXPBYx6 KCxUG2E6WKEYYPDsaGgcQPUhE/u+O68K4C5nLMhYQohBU2ZHJclCCiBsDOf4I037WEK8 6O7Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id gk1si6741841ejc.48.2021.11.24.23.15.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Nov 2021 23:15:40 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E435A8377A; Thu, 25 Nov 2021 08:14:37 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id B3F2C83767; Thu, 25 Nov 2021 08:14:14 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 19B4683759 for ; Thu, 25 Nov 2021 08:14:11 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8B29E1595; Wed, 24 Nov 2021 23:14:10 -0800 (PST) Received: from a076522.blr.arm.com (a076522.blr.arm.com [10.162.16.44]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C452C3F5A1; Wed, 24 Nov 2021 23:14:06 -0800 (PST) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Patrick Delaunay , Patrice Chotard , Heinrich Schuchardt , Alexander Graf , Simon Glass , Bin Meng , Peng Fan , AKASHI Takahiro , Ilias Apalodimas , Jose Marinho , Grant Likely , Jason Liu , Sughosh Ganu Subject: [RESEND RFC PATCH 10/10] FWU: cmd: Add a command to read metadata Date: Thu, 25 Nov 2021 12:43:02 +0530 Message-Id: <20211125071302.3644-11-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211125071302.3644-1-sughosh.ganu@linaro.org> References: <20211125071302.3644-1-sughosh.ganu@linaro.org> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.37 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean 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 --- 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 +#include +#include + +#include + +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", + "" +);