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 AA8C0C433EF for ; Fri, 10 Jun 2022 12:08:06 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 61638843E7; Fri, 10 Jun 2022 14:08:04 +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="I5T3BBPN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8B46E843F2; Fri, 10 Jun 2022 14:08:02 +0200 (CEST) Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) (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 E916B842A6 for ; Fri, 10 Jun 2022 14:07:59 +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=ilias.apalodimas@linaro.org Received: by mail-ej1-x62e.google.com with SMTP id o7so19784381eja.1 for ; Fri, 10 Jun 2022 05:07:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=s1OPUC0LyJlngaX82s7qTpK448bKjsS7yWdiibGmnPw=; b=I5T3BBPNrxx2CqIwHfWDl0YEqOfXpNfThL4kUpZS/mRfFWwPgpgAIWoM1gj/mZYvzH TKbp9WW3KAE9OKTu7gTuNLLerpESbSorgAjcJQQRA0rWcfn8V4EfL2nyP5IUMHUiZmyL RPfPBgiVt723YDRbHqgHLper8aXTA8sUEnw3rM4jJvHY5yF8QV2d3+/UpsaCeP61ItG1 9h23e/2VecjRfM7sCQh8HcqNtD5v01jW3AZIoq6KTsWcfZaLecjQoB/dhMMM2Yc9VB7k Y521rxcqEw1kyg136f88g0X66uWKJaOigRK8DDPPUwnSdRQLh4yCvb4wjPPufws7Em3O rCTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=s1OPUC0LyJlngaX82s7qTpK448bKjsS7yWdiibGmnPw=; b=TA7tP0mwsPz/WMS4pJ0rXnquZsQ2h2XYmHm/FzKNT6MLhw6YPpk1j+GdoUtMQFmEhH 5J0/Bc4oWcbcv36SQXyU6uONBuojJo3A6z1qs2u8T6SEDy8k7/stdyPZBGcjuBi+3D/Q GgkDiAHENZkVqIchaV0EeIBkEdzNc/XorIGMOm5hgjHKblvDDxnnjk4UbMHlOZPQ1ASM bwpU9/KwdFEUs/wiiy5yA4WOYoWZcLyZ3fLAXKioC5dh1uv1jnEyH1HI/nWzRCuOERbx g6IlCyUN3YzVN0RhOa4xOII3KDygtMnOg6L+Tk9NasWxZRrHKe1vgISfAOnnua+sj6rQ YANw== X-Gm-Message-State: AOAM533xgTQf5JQqBjT4ZJCQ+hTNsZq5Rj4nPdFTNIlasPYcXcZPqinM wgpRuvrki1ZIbVb3mgqgw4Botg== X-Google-Smtp-Source: ABdhPJzd5VTasQOPnY9nSbp6z7ADn20ktTwmTPyeRj17XqeErvYKwCWTFhqBY70ZS03QkvSNIp19lw== X-Received: by 2002:a17:907:7d8e:b0:711:cf4b:9c5 with SMTP id oz14-20020a1709077d8e00b00711cf4b09c5mr24388747ejc.637.1654862879398; Fri, 10 Jun 2022 05:07:59 -0700 (PDT) Received: from hera (46-15-185.adsl.cyta.gr. [46.103.15.185]) by smtp.gmail.com with ESMTPSA id g23-20020a170906595700b006f3ef214d9fsm11860826ejr.5.2022.06.10.05.07.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jun 2022 05:07:58 -0700 (PDT) Date: Fri, 10 Jun 2022 15:07:55 +0300 From: Ilias Apalodimas To: Sughosh Ganu Cc: u-boot@lists.denx.de, Heinrich Schuchardt , Takahiro Akashi , Patrick Delaunay , Patrice Chotard , Simon Glass , Bin Meng , Tom Rini , Etienne Carriere , Michal Simek , Jassi Brar Subject: Re: [PATCH v5 10/23] FWU: cmd: Add a command to read FWU metadata Message-ID: References: <20220609123010.1017463-1-sughosh.ganu@linaro.org> <20220609123010.1017463-11-sughosh.ganu@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220609123010.1017463-11-sughosh.ganu@linaro.org> 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.5 at phobos.denx.de X-Virus-Status: Clean 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 > --- > 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 > +#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; > + 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