From patchwork Mon Feb 12 07:46:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 772022 Delivered-To: patch@linaro.org Received: by 2002:adf:9dca:0:b0:33b:4db1:f5b3 with SMTP id q10csp2000199wre; Sun, 11 Feb 2024 23:47:40 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXzeeXbmdF4nvYuqn9P97VZ/vd/NmlSlSG9e9+ySZGEmmJ/+fZMW/vSOakXkbbAlV8kDx6pW2qo7LkS+3hE95gP X-Google-Smtp-Source: AGHT+IEXTzlC+kiFrRiwDsDUScYmejWPL9WdRiNbtTkDrIAXA8H9YbRqfrDeil3VOw1tW55RPrmm X-Received: by 2002:a17:906:110e:b0:a3c:23b4:e99 with SMTP id h14-20020a170906110e00b00a3c23b40e99mr4649504eja.75.1707724060332; Sun, 11 Feb 2024 23:47:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707724060; cv=none; d=google.com; s=arc-20160816; b=SFLYrhMgiP2dmeuvGFISrU1er+kTNKQbxa/rgyBH63GrrI9wIPv7+ryBQIYUXTd3Wy mJKQv46MilgQ1uh7ixZ3GEZQhzC266HNVaUWjybJKc32Oz7yAjq4RgN4QX47mcoauP6B pDFGi4ktoXpkLj8ox4fxf9N70WQqvLzvNlxvNyhvIERDLsTto9rATdAwBG0LoWzVCBa8 DrwbwLg2QIVNsGUZiqS4v0SCawrU0iJIZk0/5ypFu2sowAfVpyW5dYsrMiKI11IA9ang 4d2k4QBGZv8KFIxC5BQ5899Yq6Xo6621gSP7zS/1aPNdSI3blSne4sfrFdRHnvVDq8J8 OQXg== 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:message-id:date:subject:cc:to:from; bh=+sXIY1MfKeOy3IZGXWAHmrXfbCZ78g0IXT8F0G48lVg=; fh=HwwA6Vc9bGpwrFiCu758z8pOX4FP7nXD+gEU0WPBI4Q=; b=W92v8tMcMXR0pe2tcQB+o8fhpY3uG+OPYl+1v/WlanFwApKAoID3I7kyS2MzlgYk45 eNxQVxDZbXEZxZxKZ5VLk1m6qZDUJ9Rl1ih+wXlID208IiHgk2ctJXclDw8zeAj1CWyW v5T99U1PtJayJaEl5dye3w5RPtrvt4Cj86rma5k7C3t/I+WPoPzpEhTmYrZb9NwJXTJ5 J95KzI96njM3fVqhXkXJ3JkmV/I0si471sLhyb0waOqCn6HY+/ctjYgY8eE8Wy4j/6G4 82UxeCXPzAGydaMd6vWtzSvlAeypmglI6L83zwe7lcOBz1umCVYYSSj7+8Nz1ChPL+GX W/xg==; darn=linaro.org 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 X-Forwarded-Encrypted: i=1; AJvYcCWQV+JN/CBmPOYnJMedn+AsAwTqTcC3DQ6s3RNZKkxr/U8s+yvebNRGqbsR+ClYHIvB3zPIOn5Dzyz7EfuPHuyFqVvQ+1vNWaWDTXErvcOi2F5DrnAgq6zwSumdfJh7/lCDCpgUVxxEAVZuUOP3mffsdVVKxirCK5CX56f3C7haFzO3qT3cUuPQwD6Q7mW+9obcSRChCL6ZrIwncSMxKH2r5o4lbFmmkFSyJ7TgLHHTpK6Hhn8tZmWTtNf0+r8qwalaQzMDgDSRbUqf4Lvbtyp2sAklMuvv2uzf3qwELKL35Gcu91D1gFLRuhh89kfSRVA5qdUzAaxu0R4lp6wJK4gsGt3/y+jwnYH1m0ZEZ1VMBkvoBxjgGkipMcuDgjhA7zzyIGj7cYfQUcNw49zlI8OMlJDAyssiyLfYMJxYwukcSSgH9xR8X8zZ2jyDiGFLKD3YaSWuVmyCHLAZxOr4rQvMZitE8GEaX4pKEH02BMveCnoVCr0+1+KE6gvSUJiATpg1WRwrbsjPTAU8yNaSxWdCafUblI7jLMZbHIrs41FXcWAciVdaBa14XggLJPEtp/2fEMuTbMmP7VYuq3cX3xIxckaMKVj1FlXemmJWdWfsTpK1pS7QnlR8v1RivYdzf54Bl/WOR0/94fPSrFTYDQRD3e69t1///wQ20KGUXqNmkCk5+7u/AJhYvBVaZiffn1PJ8cI6SdFpR61HNXqeUlzr9F9A0lxKSncPCaGo8+CfaaxJQEl3nUDJrATC4L7MJElvkczbBszpzCwBk6FQ4cJ+FTpqqHJiQN4+KwkTHeaYTTfeKl0hg6eVxbnvKiEp9hY8B1Og+tL0E9Mh9EC8Oai0yyheMPzdpyaicn9YawDYrJ8BUbS41f0Ui0iksZzKYNh/Gk53wFO2iB6U 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 pw6-20020a17090720a600b00a37f92a289bsi3554678ejb.592.2024.02.11.23.47.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 23:47:40 -0800 (PST) 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 E762487EBF; Mon, 12 Feb 2024 08:47:38 +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 2013787EBD; Mon, 12 Feb 2024 08:47:37 +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 7A63487C80 for ; Mon, 12 Feb 2024 08:47:34 +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 5A5B4DA7; Sun, 11 Feb 2024 23:48:15 -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 C8F9F3F7BD; Sun, 11 Feb 2024 23:47:30 -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 Subject: [PATCH v2 00/21] FWU: Migrate FWU metadata to version 2 Date: Mon, 12 Feb 2024 13:16:51 +0530 Message-Id: <20240212074712.3657076-1-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 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 The following patches migrate the FWU metadata access code to version 2 of the structure. This is based on the structure definition as defined in the latest rev of the FWU Multi Bank Update specification [1]. Since the version 1 of the structure has currently been adopted on a couple of platforms, it was decided to have a clean migration of the metadata to version 2 only, instead of supporting both the versions of the structure. Also, based on consultations with the main author of the specification, it is expected that any further changes in the structure would be minor tweaks, and not be significant. Hence a migration to version 2. Similar migration is also being done in TF-A, including migrating the ST platform port to support version 2 of the metadata structure [2]. @Michal, I tested the metadata for the two image per bank case, and it works fine on the ST board. Kindly test this on your board as well. @Kojima-san, Please help in testing the version 2 on your board. Thanks. [1] - https://developer.arm.com/documentation/den0118/latest/ [2] - https://review.trustedfirmware.org/q/topic:%22topics/fwu_metadata_v2_migration%22 Changes since V1: * Do not define flexible array members inside the structures. * Access the image information related fields in the metadata using the helper functions defined in an earlier patch. * Access fwu_fw_store_desc structure using pointer arithmetic. Sughosh Ganu (21): configs: fwu: remove FWU configs for metadata V2 migration fwu: metadata: migrate to version 2 of the structure drivers: fwu: add the size parameter to the metadata access API's fwu: add helper functions for getting image description offsets fwu: make changes to support version 2 of FWU metadata fwu: add some API's for metadata version 2 access drivers: fwu: mtd: allocate buffer for image info dynamically drivers: fwu: allocate memory for metadata copies fwu: add a function to put a bank in Trial State capsule: accept a bank on a successful update fwu: mtd: modify the DFU API's to align with metadata version 2 efi_firmware: fwu: do not read FWU metadata on sandbox efi_firmware: fwu: get the number of FWU banks at runtime cmd: fwu: align the command with metadata version 2 test: fwu: align the FWU metadata access test with version 2 fwu: remove the config symbols for number of banks and images tools: mkfwumdata: migrate to metadata version 2 tools: mkfwumdata: add logic to append vendor data to the FWU metadata tools: mkfwumdata: fix the size parameter to the fwrite call configs: fwu: re-enable FWU configs doc: fwu: make changes for supporting FWU Metadata version 2 arch/sandbox/Kconfig | 6 - board/armltd/corstone1000/corstone1000.c | 2 +- cmd/fwu_mdata.c | 45 ++- configs/synquacer_developerbox_defconfig | 1 - doc/board/socionext/developerbox.rst | 9 +- doc/develop/uefi/fwu_updates.rst | 12 +- doc/usage/cmd/fwu_mdata.rst | 12 +- drivers/fwu-mdata/fwu-mdata-uclass.c | 10 +- drivers/fwu-mdata/gpt_blk.c | 27 +- drivers/fwu-mdata/raw_mtd.c | 85 +++-- include/fwu.h | 139 +++++++- include/fwu_mdata.h | 56 +++- lib/efi_loader/efi_capsule.c | 12 +- lib/efi_loader/efi_firmware.c | 20 +- lib/fwu_updates/Kconfig | 11 - lib/fwu_updates/fwu.c | 401 +++++++++++++++++++---- lib/fwu_updates/fwu_mtd.c | 81 +++-- test/dm/fwu_mdata.c | 56 ++-- test/dm/fwu_mdata_disk_image.h | 124 +++---- tools/mkfwumdata.c | 132 ++++++-- 20 files changed, 924 insertions(+), 317 deletions(-)