From patchwork Mon Feb 12 07:47:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 772036 Delivered-To: patch@linaro.org Received: by 2002:adf:9dca:0:b0:33b:4db1:f5b3 with SMTP id q10csp2000759wre; Sun, 11 Feb 2024 23:49:59 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWlyVqhLnH+xuEE9z9ygOuaUGH0D86rW7AugRDtQ8dsApKs6DwJEJsrzNN/8gzg4Mj2CeM6YT2q2GTuLes0Ynvw X-Google-Smtp-Source: AGHT+IF166ptPH5zzuuB+gFJykN4pF5QwFDSiFfXsgMfqWVrZStUbxTe843sGUoE6p1SiG1Ox5+j X-Received: by 2002:aa7:df13:0:b0:561:ae42:cb20 with SMTP id c19-20020aa7df13000000b00561ae42cb20mr1390861edy.9.1707724199651; Sun, 11 Feb 2024 23:49:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707724199; cv=none; d=google.com; s=arc-20160816; b=EmignItzjstY9ljIRpzzY1C8hS2l+9DDYm9NP0AtysOM8okeFCYGTyoqTkqDy7aKmm S2GKVIdWCckHiV4ua4H6fKihyz6+ba0qexRmgZ8lH32INN1bQz/e52ve8FvKUo9OShwA TctFnDSwKBaLjLS+Hpai5ht88m5uTgje7ck13mTaozlm/8P0rsfn7hD2yOQ6EI+to560 papGwrRVTdE/1mx1i8rNyxRQTF9MwJVS/I2CMUl+Ek1zYasop8YVEUVMvSENIRUdfbHH VccSWHmKFHtOpcIpSZ2aM70iwnDp8+Es/LhrN8AaGH0Cbt8LmeA4sSP3CLEsLTQljcOl GFEA== 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=1yg+H6nLcbECGH1uXclyW7334eWKM7pEeGu+CKtmCss=; fh=UvV102NEPPkYo5FFCG2E/6Z0JAhYBuQKPP+ICMvC3n8=; b=tK/MAqAPLtCZE28jgxxjkniGK9Ny1fTDYvntiZSUFMaEuRH4avVlABBjO8yUPS2X2u MuxthhXVaFfrKwl61tUHU/juKre3no8OtGaDw5idMkUyYcuoFZ6uLbWN3JyHUXzUxZCI YWvMD8TfAYRmRAsSBhi+4exeWuyB/JC78SgmLSZ39RkpGqRxRuQHme7SyiBz4iJPAF0x 8D6UrNImd1l7oH+jgRiv2/pVUgzNwU3FvyP8Z/iydZ7IB8CUlcveT6eKdK8CJqxftON+ An8KXocaJmwfSy6Sru1XypjQiJPFX/+wBfop+zF5KY1bBUrlksCADj2F1RJmqFxioUp9 mxNQ==; darn=linaro.org 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 X-Forwarded-Encrypted: i=1; AJvYcCWR9+smPW3pNg/gNmeIGgNwVD3SYxLNY7b3Zlg3L1gGnlzMocaiowxaBUPE2Mukq4Q3s/FFqUrGa8UFTr3WQSKwquCV/I1MN4i+tGJV5dv97yg5JYEkuXJ5cNzAW0XKLAoqCcuCkH6HpUgpcFFBYE1Psn12c/JMu9awu3m/E9V0najNkkNHdlO6GlnRpubce5NX5aDRmEx1nIwC45PYh7FZvC8igq0V5tAuvWYTtEXcZGnMqXDqWC/RaHqACdJwYXZyT9Xl6HEfrPMl3szGLVXHnejU46jL85kpb/iAmEdAA2SvyOccp0zhmcUmGk+CL6GxS6O1MgxETD4prr4zHo6hUNP+sYGCg0ZoK6VDt6f6RCo7VBznnLE4o+TknSDga4j+g74zNGlIwH2MM+IghEDtASEvJ/Zm9+b/A1SIES1rA+x2SR79j6ekka5ZHb3ueKgp+eGrE/bq6yPN+vaHZLHtQ+y9jnpkpH76PwbWcodYr3VyqP1pLxGMR8QIVwu5Qe2BlNKV7bg07CnPSe9jTqMKY5WYLeOi2oEt4h5clRJWSqw9JSZ05OW5Fcc+V4iclw0i4vvPvfdqW9w6GV/HvKhk3owWQa5fd0T0B0hEUoweJ/MoLObGKjS4GMyy2oOuLx7mXCifUfH3wr+iQ3RNR40GOhg+8M0ZTyKkUuA+sfSxQ4bxuwoBqdTBJUD/MlAivSb/RJo6LG2gftau/kogDb2FiHiTAESKxxP7gMiOps0EVL7K812SckzdMiq85etOPhpbV+UgtoS7KVCjsuwQAcR0TjwruSZIAOkPGftYiWOmH4NXgZVmqUd/jM+1hN3t3tu9AGd5WBxViVANz1JFMCGtTLxJ1MhSpaOmKh3wZdsaWhQ= Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id x20-20020aa7d6d4000000b00560ef5203cfsi2428923edr.98.2024.02.11.23.49.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 23:49:59 -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 05D6087EF7; Mon, 12 Feb 2024 08:48:31 +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 4AEE487EF4; Mon, 12 Feb 2024 08:48:30 +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 0BEA987F06 for ; Mon, 12 Feb 2024 08:48:27 +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 186D8DA7; Sun, 11 Feb 2024 23:49:08 -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 4C67F3F762; Sun, 11 Feb 2024 23:48:23 -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 , Michal Simek , Jassi Brar , Sughosh Ganu Subject: [PATCH v2 14/21] cmd: fwu: align the command with metadata version 2 Date: Mon, 12 Feb 2024 13:17:05 +0530 Message-Id: <20240212074712.3657076-15-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240212074712.3657076-1-sughosh.ganu@linaro.org> References: <20240212074712.3657076-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 --- Changes since V1: * Use the helper functions from the previous patch to access the image information in the metadata. cmd/fwu_mdata.c | 45 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/cmd/fwu_mdata.c b/cmd/fwu_mdata.c index 5ecda455df..6d5ed7a187 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 = fwu_get_fw_desc(mdata)->num_banks; + num_images = fwu_get_fw_desc(mdata)->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 = fwu_img_entry_offset(mdata, 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); + &img_entry->image_type_guid); + printf("Location Guid: %pUL\n", &img_entry->location_guid); + for (j = 0; j < num_banks; j++) { + img_info = fwu_img_bank_info_offset(mdata, i, j); + 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; }