From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 89D9BECAAA1 for ; Tue, 6 Sep 2022 08:00:00 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5DCF084927; Tue, 6 Sep 2022 09:59:58 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="DvOyM5g4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2B53A84996; Tue, 6 Sep 2022 09:59:57 +0200 (CEST) Received: from mail-oa1-x2a.google.com (mail-oa1-x2a.google.com [IPv6:2001:4860:4864:20::2a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 786D6848DE for ; Tue, 6 Sep 2022 09:59:54 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=etienne.carriere@linaro.org Received: by mail-oa1-x2a.google.com with SMTP id 586e51a60fabf-1274ec87ad5so11422828fac.0 for ; Tue, 06 Sep 2022 00:59:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=1ihoNie7uRw5UU9D2RkjwUxRNHt/nCEzUYUPzo+HdI0=; b=DvOyM5g4cwKyOM7sHMc4alN/hvJy7zY5asmIhpfR128eiBngnmKGj6QJAI6Rv9DmtJ LJ65YYKqLl9+rlmhAlG1QZS5K/WkXPV0EQ36PYyNqN9tbEH+nrp1PpDyfTNbL9vPWERR caFUItQmVL90tqMxqRWlLjnpQ3C1EMe0FCGtOBMybwpMdnIc8P8JERsVp/Z5WGui/KZ3 sRCdng2sPUmMaZssDmrY/3D72pBlVJV5xw6LgyLaxn+9NTUknT80QBh4khJ6oQd/9A5r gbry8NzuKUs5nwTvbKKwn3NW8nE2am8ooG9LEanN1fONQzV7X78weUwh7fAlS9VCdh2n mH5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=1ihoNie7uRw5UU9D2RkjwUxRNHt/nCEzUYUPzo+HdI0=; b=2DU7BDvoRJG7Q4euYWQTHLFw+sEwLYesNeyyVarqYlWnCJ1Ye3m2ZCOtolFhnIp31+ Zeckvpshnn3F0XsrQpiHIfd5YWKk53wbyUea6GjlMyJDXANqK6K6U8KWZ49F7s1862me RdnewgQ6shazb1KL+1Dp7cFAbpD3YtbDeIMr1I3HwCc+tu++xK88yFhDNM4qHZDN3sTX 8I5/gPZ0XXnIei0p+wjZe4Pyw/ZC/CGrdmmvRlG9oBuHTsEy3LOahyLr0XYhp/nDJV2d vYMsXUj/IhihLjqS0rDLWyaKNs/ZXPEEc/zoImLsgIwUIY/6bGS5UnLIuDW6AoYSPCtR eWBg== X-Gm-Message-State: ACgBeo03t1v90UmhvT+fP9uLUGnnj8+hoUxC9ZPIorYfPIekka8MQE6D ksslykO/fTAOJUY7VA3nrdw6wJ96anOsVQBSR1acgA== X-Google-Smtp-Source: AA6agR67uUFZOUMcwh7WpswWkvUPl7MWWqPJeMd+NJ0V2Rku5iSHxYUYOq/Gla/SoxaVz45dTtg6L1TaAGcomJYuYTw= X-Received: by 2002:a05:6870:8181:b0:127:806f:ab0b with SMTP id k1-20020a056870818100b00127806fab0bmr3387728oae.217.1662451193134; Tue, 06 Sep 2022 00:59:53 -0700 (PDT) MIME-Version: 1.0 References: <20220826095716.1676150-1-sughosh.ganu@linaro.org> <20220826095716.1676150-12-sughosh.ganu@linaro.org> In-Reply-To: <20220826095716.1676150-12-sughosh.ganu@linaro.org> From: Etienne Carriere Date: Tue, 6 Sep 2022 09:59:42 +0200 Message-ID: Subject: Re: [PATCH v9 11/15] FWU: cmd: Add a command to read FWU metadata To: Sughosh Ganu Cc: u-boot@lists.denx.de, Heinrich Schuchardt , Ilias Apalodimas , Takahiro Akashi , Patrick Delaunay , Patrice Chotard , Simon Glass , Bin Meng , Tom Rini , Michal Simek , Jassi Brar Content-Type: text/plain; charset="UTF-8" X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.6 at phobos.denx.de X-Virus-Status: Clean On Fri, 26 Aug 2022 at 11:58, 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 > Reviewed-by: Ilias Apalodimas > --- > Changes since V8: None > > cmd/Kconfig | 6 ++++ > cmd/Makefile | 1 + > cmd/fwu_mdata.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 86 insertions(+) > create mode 100644 cmd/fwu_mdata.c Reviewed-by: Etienne Carriere > > diff --git a/cmd/Kconfig b/cmd/Kconfig > index 211ebe9c87..3abc60b63e 100644 > --- a/cmd/Kconfig > +++ b/cmd/Kconfig > @@ -161,6 +161,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" > + depends on 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 6e87522b62..ff6e160f4a 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..725b4c17d3 > --- /dev/null > +++ b/cmd/fwu_mdata.c > @@ -0,0 +1,79 @@ > +/* SPDX-License-Identifier: GPL-2.0-or-later */ > +/* > + * Copyright (c) 2022, Linaro Limited > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > + > +static void print_mdata(struct fwu_mdata *mdata) > +{ > + int i, j; > + struct fwu_image_entry *img_entry; > + struct fwu_image_bank_info *img_info; > + > + 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); > + > + printf("\tImage Info\n"); > + for (i = 0; i < CONFIG_FWU_NUM_IMAGES_PER_BANK; 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 < CONFIG_FWU_NUM_BANKS; j++) { > + img_info = &img_entry->img_bank_info[j]; > + printf("Image Guid: %pUL\n", &img_info->image_uuid); > + printf("Image Acceptance: %s\n", > + img_info->accepted == 0x1 ? "yes" : "no"); > + } > + } > +} > + > +int do_fwu_mdata_read(struct cmd_tbl *cmdtp, int flag, > + int argc, char * const argv[]) > +{ > + struct udevice *dev; > + int ret = CMD_RET_SUCCESS, res; > + struct fwu_mdata mdata = { 0 }; > + > + if (uclass_get_device(UCLASS_FWU_MDATA, 0, &dev) || !dev) { > + log_err("Unable to get FWU metadata device\n"); > + return CMD_RET_FAILURE; > + } > + > + res = fwu_mdata_check(dev); > + if (res < 0) { > + log_err("FWU Metadata check failed\n"); > + ret = CMD_RET_FAILURE; > + goto out; > + } > + > + res = fwu_get_mdata(dev, &mdata); > + if (res < 0) { > + log_err("Unable to get valid FWU metadata\n"); > + ret = CMD_RET_FAILURE; > + goto out; > + } > + > + print_mdata(&mdata); > + > +out: > + return ret; > +} > + > +U_BOOT_CMD( > + fwu_mdata_read, 1, 1, do_fwu_mdata_read, > + "Read and print FWU metadata", > + "" > +); > -- > 2.34.1 >