From patchwork Fri Mar 22 10:57:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 781833 Delivered-To: patch@linaro.org Received: by 2002:adf:cf01:0:b0:33e:7753:30bd with SMTP id o1csp1273312wrj; Fri, 22 Mar 2024 03:58:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX9VvlwBCJKhNxM8RPiCbrKoK4rjEo9E/z6iguUw2wljIm8MbJ3ubm7gSUiOttSVNVf6jHJn5JccvlTWa7Zuqxf X-Google-Smtp-Source: AGHT+IHkaKkBWwURWxre7E6r/MBkowe/2c8MHl5GBIlP8A/ehGEC9ymiVhyF0CjduVkhtKNrN5ul X-Received: by 2002:a05:600c:3b28:b0:414:f50:3588 with SMTP id m40-20020a05600c3b2800b004140f503588mr1276304wms.27.1711105093735; Fri, 22 Mar 2024 03:58:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711105093; cv=none; d=google.com; s=arc-20160816; b=uzZPEeWGL4bKiPhRXkNzk/cLoNcVyvs2HgAKVf9BI4TPKnT2ul2oSUSHF8UWUpV/Ud UfLPpKZ9AsLjJK+cbTu/SOIG1JdKk6YI+xuHZNS+tqI7qhakCCmTcJK36XMp1yGuZJZI WmzRTw2YfFPvg+QHNJefkBUacNqGe0iuxYaLKifZJ90cYpiJkxBpleklY2nuyVdXkh1D YpI2q+5GUQdIB4UGzzncbjSlXCZQ3ku/yvCCRK3toaCEfKwON83O18qP7Jw+aJIJEhRy H/Gd9QfXHGL6KWPgbWNg7xXkSUosxtkpf9MB8ZDsgDakZcWA2CTpc0oploxPDND7RhLX 16Xw== 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=EcISRjsF03+wOqOqPRjCIG2joXEkJrugelJLqqbr5Ms=; fh=0N5B6qkcMBA6jkGlVm0TO2/VsrtNXZ70rAYU1YyFA9g=; b=NeBuyHNwrnqXJsAAJV+3e/utnKpxeUkh8gh33MU0462W7hAjk5yGbDrluQQbetPUbg CE1H7M7t/RgKoax5sJqKBXA19Sd/Xc1LsPmVZqS78S69qEeFtYCdinhk7fSM5jCbCQ7/ ggQitkEPBOaydPebHz+upqA3aRH5jZS+yaETE1O2W8Lr+TwUe8NyHZnx/ewZ8InkY2sg WlQ0l84XYDsGpMVKEBJ+vnkudtu1mQcimqQDuqC9As2pNEk0/MLreBLMBjtC+BjvdpJK CoYFBU80TgMg2EBEoSku+CyhV5CktcKsGZeKRMg14SUuQGEJ7VTDzMMyj1Wb1yRhuO5r FyjQ==; 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 m13-20020a5d6a0d000000b0033e417b70c5si133925wru.496.2024.03.22.03.58.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 03:58: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 518EF88178; Fri, 22 Mar 2024 11:58:12 +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 2948388137; Fri, 22 Mar 2024 11:58:11 +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 62E5C87F6A for ; Fri, 22 Mar 2024 11:58:08 +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 B77611007; Fri, 22 Mar 2024 03:58:41 -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 D7C003F64C; Fri, 22 Mar 2024 03:58:04 -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 Subject: [PATCH v3 00/20] FWU: Add support for FWU metadata version 2 Date: Fri, 22 Mar 2024 16:27:13 +0530 Message-Id: <20240322105733.203888-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 patch series adds support for version 2 of the FWU metadata. The version 2 metadata structure is defined in the latest revision of the FWU specification [1]. The earlier versions of these patches were migrating to a version 2 only support in U-Boot, similar to TF-A. However, based on feedback from ST [2], this series has been updated to support both versions. A platform would still be needed to enable one of the two versions of metadata through a config symbol. TF-A has code which reads the FWU metadata and boots the platform from the active partition. TF-A has decided to migrate the FWU code to a version 2 only support. These changes have been merged in upstream TF-A. These changes have been tested on the ST DK2 board, which uses the GPT based partitioning scheme. Both V1 and V2 metadata versions have been tested on the DK2 board. These changes need to be tested on platforms with MTD partitioned storage devices. @Michal and @Kojima-san, please help in this testing. Note: The CI is breaking on some sandbox py tests, but the errors look unrelated. I will look into those issues, but the code review can proceed. [1] - https://developer.arm.com/documentation/den0118/latest/ [2] - https://lists.denx.de/pipermail/u-boot/2024-February/546277.html Changes since V2: * New patch which retains support for V1 of metadata * Earlier patch was catering to v2 only support. These changes support both versions of metadata. * Earlier patch was migrating to v2 only support. These changes support both versions. * Support both metadata versions instead of only v2. * Added documentation changes. * Make changes to have the test work with v1 metadata. * Make changes to have the test work with updated logic in fwu code. * Changes to indicate support for both v1 and v2 instead of only v2. * Add config symbol for selecting either of the two metadata versions. Sughosh Ganu (20): configs: fwu: remove FWU configs for metadata V2 support tools: mkfwumdata: fix the size parameter to the fwrite call drivers: fwu: add the size parameter to the metadata access API's drivers: fwu: mtd: allocate buffer for image info dynamically fwu: metadata: add support for version 2 of the structure fwu: metadata: add a version agnostic structure fwu: metadata: add functions for handling version specific metadata fields fwu: make changes to access version agnostic structure fields capsule: fwu: transition the platform state on a successful update fwu: add config symbols for enabling FWU metadata versions fwu: mtd: remove unused argument from function call fwu: mtd: get MTD partition specific info from driver fwu: mtd: obtain image information from version agnostic structure cmd: fwu: make changes for supporting FWU metadata version 2 tools: mkfwumdata: add support for metadata version 2 tools: mkfwumdata: add logic to append vendor data to the FWU metadata test: fwu: make changes to the FWU metadata access test doc: fwu: make changes to reflect support for FWU metadata v2 MAINTAINERS: add entry for FWU multi bank update feature configs: fwu: re-enable FWU configs MAINTAINERS | 8 + cmd/fwu_mdata.c | 39 ++-- configs/corstone1000_defconfig | 1 + configs/sandbox64_defconfig | 1 + configs/synquacer_developerbox_defconfig | 2 +- doc/board/socionext/developerbox.rst | 7 +- doc/develop/uefi/fwu_updates.rst | 20 +- doc/mkfwumdata.1 | 16 +- drivers/fwu-mdata/fwu-mdata-uclass.c | 10 +- drivers/fwu-mdata/gpt_blk.c | 23 +- drivers/fwu-mdata/raw_mtd.c | 78 ++++--- include/fwu.h | 147 ++++++++++++- include/fwu_mdata.h | 71 ++++++- lib/efi_loader/efi_capsule.c | 14 +- lib/fwu_updates/Kconfig | 14 ++ lib/fwu_updates/Makefile | 2 + lib/fwu_updates/fwu.c | 204 ++++++++++++------ lib/fwu_updates/fwu_mtd.c | 34 +-- lib/fwu_updates/fwu_v1.c | 167 +++++++++++++++ lib/fwu_updates/fwu_v2.c | 260 +++++++++++++++++++++++ test/dm/fwu_mdata.c | 16 +- tools/mkfwumdata.c | 235 ++++++++++++++++---- 22 files changed, 1153 insertions(+), 216 deletions(-) create mode 100644 lib/fwu_updates/fwu_v1.c create mode 100644 lib/fwu_updates/fwu_v2.c Tested-by: Michal Simek