From patchwork Mon Jan 22 11:54:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 764631 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:10c4:b0:337:62d3:c6d5 with SMTP id b4csp1059471wrx; Mon, 22 Jan 2024 03:57:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IG30Gqiw+TPEiPDz5cPK3hJvOM+aRg4S8Dcr496a62yzsF3V19uZlCJCXwKkS0S8GraDoEp X-Received: by 2002:a5d:4704:0:b0:336:76dc:9b48 with SMTP id y4-20020a5d4704000000b0033676dc9b48mr2607259wrq.91.1705924639909; Mon, 22 Jan 2024 03:57:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705924639; cv=none; d=google.com; s=arc-20160816; b=rIbgJkaDoJCit1xn6BayXN/ss/OgsBbR2i9e9B6PYyvcCozIjzr6AaKOXA2zb8AaEY Kn2i39aBr086Px7MBHwWc4HoUQ1k/XJVvDHN8yMK65GeOno6hfCjBbjad9icBL0Zx7Tw rS/NEva8WCYgPFOjUQAJGoyc0GgQM4rMhqQAU4gZ7gmT/4VrY5++e/IcwKFOgXPd47fI v7qyLzmXufBe0Iw+OzmBtg6RYWYNbzjoVz6hJT+oaFsPF6yJ68/m7xoL+rAwlNiwEUPI V74yQNl7OafQsFabPzZJRwu5FSZ3b6Su3vlaYpug31wfBZfr6tMCOoX7d/qTFxS3tp1q N6pw== 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=Ej4s/DTpyrI+pkNcmMjPAe2GvnwsXTYS516ngpD/ap0=; fh=rhmJ78R78zNUSUA9Nt0a5TbZO4CVsI4vi5GcqSIe+nI=; b=dPrPyx+Lqh+zr1ZALFJHfzCTykYgi/xfAxIIkRPcwaiiAxRdYnZORF8Emrrukcs1Qu /6gl+vlD4DY0SAqwbsF0XenQkW0MELGrAsUKirT7xzN3arWeNq/8hrvnX/X6JJv3qsjd TAL71ELrNdhICCTtBaIDAL29QUFh3WAbw0Z/WBTX6ORNNKw68vR/D0iwKXlsAQDTWn7+ OxoLPizDLM6h9vSScSDsIYrJWU7ByE/ta3o1W4rud4SFHhUrEuI1uaX9HT6PUgKxjDM5 TvWpgtmugV4F2/LgusGJOZDLURnJEj1ETxooFsVwFZ/Nj5Ezx5HdjKh0316/KHN7dCU6 8OKw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id o9-20020a5d62c9000000b00337cce91e79si5147120wrv.299.2024.01.22.03.57.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 03:57:19 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 DF8CA87BF6; Mon, 22 Jan 2024 12:55:56 +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 96B1587BC9; Mon, 22 Jan 2024 12:55:55 +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,T_SCC_BODY_TEXT_LINE 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 7837F87C00 for ; Mon, 22 Jan 2024 12:55:53 +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 058D91FB; Mon, 22 Jan 2024 03:56:39 -0800 (PST) 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 50E333F73F; Mon, 22 Jan 2024 03:55:50 -0800 (PST) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Masahisa Kojima , Patrice Chotard , Patrick Delaunay , Yann Gautier , Etienne Carriere , Sughosh Ganu Subject: [PATCH 13/18] cmd: fwu: Align the command with metadata version 2 Date: Mon, 22 Jan 2024 17:24:34 +0530 Message-Id: <20240122115439.653871-14-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240122115439.653871-1-sughosh.ganu@linaro.org> References: <20240122115439.653871-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 Make changes to the fwu_mdata_read command to have it align with the metadata version 2. Signed-off-by: Sughosh Ganu --- cmd/fwu_mdata.c | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/cmd/fwu_mdata.c b/cmd/fwu_mdata.c index 5ecda455df..7d99b8287f 100644 --- a/cmd/fwu_mdata.c +++ b/cmd/fwu_mdata.c @@ -16,6 +16,8 @@ static void print_mdata(struct fwu_mdata *mdata) { int i, j; + uint8_t num_banks; + uint16_t num_images; struct fwu_image_entry *img_entry; struct fwu_image_bank_info *img_info; @@ -25,15 +27,22 @@ static void print_mdata(struct fwu_mdata *mdata) printf("active_index: %#x\n", mdata->active_index); printf("previous_active_index: %#x\n", mdata->previous_active_index); + num_banks = mdata->fw_desc[0].num_banks; + num_images = mdata->fw_desc[0].num_images; + + for (i = 0; i < 4; i++) + printf("bank_state[%d]: %#x\n", i, mdata->bank_state[i]); + printf("\tImage Info\n"); - for (i = 0; i < CONFIG_FWU_NUM_IMAGES_PER_BANK; i++) { - img_entry = &mdata->img_entry[i]; + + for (i = 0; i < num_images; i++) { + img_entry = &mdata->fw_desc[0].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_entry->image_type_guid); + printf("Location Guid: %pUL\n", &img_entry->location_guid); + for (j = 0; j < 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,19 +52,35 @@ static void print_mdata(struct fwu_mdata *mdata) int do_fwu_mdata_read(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]) { + uint32_t mdata_size; + struct fwu_mdata *mdata = NULL; int ret = CMD_RET_SUCCESS, res; - struct fwu_mdata mdata; - res = fwu_get_mdata(&mdata); + res = fwu_get_mdata_size(&mdata_size); + if (res) { + log_err("Unable to get FWU metadata size\n"); + ret = CMD_RET_FAILURE; + goto out; + } + + mdata = malloc(mdata_size); + if (!mdata) { + log_err("Unable to allocate memory for FWU metadata\n"); + ret = CMD_RET_FAILURE; + goto out; + } + + res = fwu_get_mdata(mdata); if (res < 0) { log_err("Unable to get valid FWU metadata\n"); ret = CMD_RET_FAILURE; goto out; } - print_mdata(&mdata); + print_mdata(mdata); out: + free(mdata); return ret; }