From patchwork Fri Mar 22 10:57:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 781847 Delivered-To: patch@linaro.org Received: by 2002:adf:cf01:0:b0:33e:7753:30bd with SMTP id o1csp1274475wrj; Fri, 22 Mar 2024 04:01:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWSDmJcMkmxgGaVlBQoRNrUDSV9poDSwkGu8ePiLHVyLovGfKTyA98rRkOrV0s8F1ZyN/zxxbjxl3H7LLpHG/Wq X-Google-Smtp-Source: AGHT+IEK1x6I4k9/GIZHi8d8IXzvgCC7afzFs5uFwO0lu/7RHKetIRIyt0uZsqQuTJC8wzokBTHA X-Received: by 2002:a5d:588d:0:b0:33e:bb68:62b3 with SMTP id n13-20020a5d588d000000b0033ebb6862b3mr1849493wrf.1.1711105273602; Fri, 22 Mar 2024 04:01:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711105273; cv=none; d=google.com; s=arc-20160816; b=Snp/iCJwPMhLrb6pO83KkfFo4qB8B0zbEUL4vK9ELGxyj6DhCk+bkMmWNdxV0S8S9S V2tqXX3/Ba3BghlG4/3QfpVqV7/SfdiHy4S1uV9hGdNcGVQ9YA2sCqjaw3b+uc3sefwz XhVVW2RJL2zz6DIJO3iwhntUEjwrqa8z/eL0ec2zgkZWVbAS4MtD1HEthfXrrrGIKJa8 zYmF0XibxCqG13gJvOJDgUc/rlrxn62/pMfBpBCXTOKI5nDiA38F2DKts6sqIfY7++8x 7yfCohLdsNQSzfvNTzNqE3CCszXGzZYeJkeiqFiB14OyaadfdxF432EVgb2jewvsAl1X lWMw== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=99DaORYBAohKFSIeYXocUUFtD5UtJe8vtrl3Sa4KKC8=; fh=0OBOeNvG1YwOz62VjCAPxJsyowuZOMIwtNTktJXXBMY=; b=sEd7zKzOb5BzStl0ILST6x2ZGii9JqAuMDnNArqLIrbcN3rdJW6Y3i0WLen2IRhs/i INSJob/gOmylT11rZv9h9qVORIQxLgaWcFJRAFfnHNzeTC/9QCF4G2I9ecmFkFQswO37 dvrwGDk5LJOM2BXCkBr+RAL6QqDlOeILBhjemACZxna161QeS6XKblJKUrNVNwbTGU3Z /ZNTwktyZ9/bmTA2sW67iu74tjVkrwKItt1VLR0kKeiluaURHnra3Hf0G4srzoLM5owX 8adY/ROjiE4R99PskAsMSF1bJdrbOMcLa3bSQupxwcgVUs2owP2um+nXGXRkI8p3YjlN zmJw==; dara=google.com 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 cs16-20020a056000089000b0033e827a3d8esi862672wrb.463.2024.03.22.04.01.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 04:01:13 -0700 (PDT) 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 D1C33881F9; Fri, 22 Mar 2024 11:59:01 +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 40FB1881C2; Fri, 22 Mar 2024 11:59:00 +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 339CE881C5 for ; Fri, 22 Mar 2024 11:58:57 +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 C56641691; Fri, 22 Mar 2024 03:59:30 -0700 (PDT) Received: from a079122.blr.arm.com (a079122.arm.com [10.162.17.48]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E66723F64C; Fri, 22 Mar 2024 03:58:53 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Yann GAUTIER , Etienne Carriere , Patrick DELAUNAY - foss , Michal Simek , Masahisa Kojima , Michal Simek , Sughosh Ganu Subject: [PATCH v3 14/20] cmd: fwu: make changes for supporting FWU metadata version 2 Date: Fri, 22 Mar 2024 16:27:27 +0530 Message-Id: <20240322105733.203888-15-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240322105733.203888-1-sughosh.ganu@linaro.org> References: <20240322105733.203888-1-sughosh.ganu@linaro.org> MIME-Version: 1.0 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.8 at phobos.denx.de X-Virus-Status: Clean Add support for displaying data specific to FWU metadata version 2. Because the size of the v2 metadata structure is read from the structure itself, allocate memory for the metadata structure by first getting the size of the structure. Signed-off-by: Sughosh Ganu --- Changes since V2: * Earlier patch was migrating to v2 only support. These changes support both versions. cmd/fwu_mdata.c | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/cmd/fwu_mdata.c b/cmd/fwu_mdata.c index 5ecda455df..3c8be576ac 100644 --- a/cmd/fwu_mdata.c +++ b/cmd/fwu_mdata.c @@ -13,27 +13,33 @@ #include -static void print_mdata(struct fwu_mdata *mdata) +static void print_mdata(struct fwu_data *data) { 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("crc32: %#x\n", data->crc32); + printf("version: %#x\n", data->version); + printf("active_index: %#x\n", data->active_index); + printf("previous_active_index: %#x\n", data->previous_active_index); + + if (data->version == 2) { + for (i = 0; i < 4; i++) + printf("bank_state[%d]: %#x\n", + i, data->bank_state[i]); + } printf("\tImage Info\n"); for (i = 0; i < CONFIG_FWU_NUM_IMAGES_PER_BANK; i++) { - img_entry = &mdata->img_entry[i]; + img_entry = &data->fwu_images[i]; printf("\nImage Type Guid: %pUL\n", - &img_entry->image_type_uuid); - printf("Location Guid: %pUL\n", &img_entry->location_uuid); + &img_entry->image_type_guid); + printf("Location Guid: %pUL\n", &img_entry->location_guid); 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 Guid: %pUL\n", &img_info->image_guid); printf("Image Acceptance: %s\n", img_info->accepted == 0x1 ? "yes" : "no"); } @@ -43,20 +49,11 @@ static void print_mdata(struct fwu_mdata *mdata) int do_fwu_mdata_read(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]) { - int ret = CMD_RET_SUCCESS, res; - struct fwu_mdata mdata; - - res = fwu_get_mdata(&mdata); - if (res < 0) { - log_err("Unable to get valid FWU metadata\n"); - ret = CMD_RET_FAILURE; - goto out; - } + struct fwu_data *data = fwu_get_data(); - print_mdata(&mdata); + print_mdata(data); -out: - return ret; + return CMD_RET_SUCCESS; } U_BOOT_CMD(