From patchwork Thu Jun 9 12:29:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 580292 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5806:0:0:0:0 with SMTP id j6csp732891max; Thu, 9 Jun 2022 05:30:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzE+mAGsPGL8v83hO1lc6Bmg1FYXvtRZ5VBg4BgJebgap2aojRzMLw8LOHQ4GlHoA1nTYDc X-Received: by 2002:a05:6e02:78a:b0:2d3:af3f:a9e2 with SMTP id q10-20020a056e02078a00b002d3af3fa9e2mr22172045ils.96.1654777836470; Thu, 09 Jun 2022 05:30:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654777836; cv=none; d=google.com; s=arc-20160816; b=H+0iklfaFAIo0fZqjy3LssbhROFL84YUH/kqmy8ir0qF/QObUubS5p+k6qcDElUbYR 8zCmpfciZc37FqV+r7HHGh+PScPbZ4jmSXrJPTt7uEye6oEDt6/GXd8BzXhZsd0q4rfY 0dBuV3bgu6sEEaZCzo6yrsz/nu55A6E5C1Mlz0BdzLtRRE5YD9zty3xK+NBF8kS2K75j ykDywX673vYvoTUAdEcgNs+l3fEocSB4ri6JlL8nr4ddsnSKYVmwYiGdg65f1cjItqA0 owsYTxb29C1VPGlXESYbjAsJLygvHZVaAi+cM5OFo+BnvXcmIw1JOn6NBTXsjMdRPNCS 2ziA== 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=R5nBnYgJ977BH2Yy3daNfDXM7fzuD/JhNsUaNoz3uZg=; b=ySy8qJhBLAFFrmh9bbhFYH/UPiD0Q8qhSNFoR7drbbjmG1JJRhix1hAyF5y+9woJ4B we7I7Z0bGlpUjgJglGC3A7p6yIzV2Abhk2oBcWPgWURT+ObjKr0E7sEF9i4QQ+BOEjnR 4xA1L+CEdeqKgveiDiI7fJVOpdGJHHhutBPHMCiXozUvVwDFd9jt761GbgpFswCgMIA5 qlWZ5eFZn++ATLIvLYwXFMrOtcM5UlBPwV5nUsYptUXf5rJAGS3pqvwWjpop1AOkX+3A S0wn/AiqIVMm43ojpCe2pJYW1Ama7TkLUu/GXvQFJhZK6xY6yXyCnLMG9BOROkpK/fg+ glcA== 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 d2-20020a056e021c4200b002d3aada5a01si36942789ilg.141.2022.06.09.05.30.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 05:30:36 -0700 (PDT) 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 5F2AC843B5; Thu, 9 Jun 2022 14:30:33 +0200 (CEST) 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 64FBF843B9; Thu, 9 Jun 2022 14:30:31 +0200 (CEST) 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 C93F6843A1 for ; Thu, 9 Jun 2022 14:30:25 +0200 (CEST) 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 2EC0212FC; Thu, 9 Jun 2022 05:30:25 -0700 (PDT) Received: from a076522.blr.arm.com (a076522.blr.arm.com [10.162.16.44]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C2FD73F766; Thu, 9 Jun 2022 05:30:20 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Takahiro Akashi , Patrick Delaunay , Patrice Chotard , Simon Glass , Bin Meng , Tom Rini , Etienne Carriere , Michal Simek , Jassi Brar Subject: [PATCH v5 00/23] FWU: Add FWU Multi Bank Update feature support Date: Thu, 9 Jun 2022 17:59:47 +0530 Message-Id: <20220609123010.1017463-1-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.25.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.5 at phobos.denx.de X-Virus-Status: Clean The patchset adds support for the FWU Multi Bank Update[1] feature. Certain aspects of the Dependable Boot[2] specification have also been implemented. The FWU multi bank update feature is used for supporting multiple sets(also called banks) of firmware image(s), allowing the platform to boot from a different bank, in case it fails to boot from the active bank. This functionality is supported by keeping the relevant information in a structure called metadata, which provides information on the images. Among other parameters, the metadata structure contains information on the currect active bank that is being used to boot image(s). Functionality is being added to work with the UEFI capsule driver in u-boot. The metadata is read to gather information on the update bank, which is the bank to which the firmware images would be flashed to. On a successful completion of the update of all components, the active bank field in the metadata is updated, to reflect the bank from which the platform will boot on the subsequent boots. Currently, the feature is being enabled on the STM32MP157C-DK2 and Synquacer boards. The DK2 board boots a FIP image from a uSD card partitioned with the GPT partioning scheme, while the Synquacer board boots a FIP image from a MTD partitioned SPI NOR flash device. This feature also requires changes in a previous stage of bootloader, which parses the metadata and selects the bank to boot the image(s) from. Support has being added in tf-a(BL2 stage) for the STM32MP157C-DK2 board to boot the active bank images. These changes have been merged to the upstream tf-a repository. Earlier, two separate patchsets were being sent. The patchset sent by me was adding support for the feature, and enabling the feature on the ST board. The other set of patches were being sent by Masami Hiramatsu, which were enabling the feature on the Synquacer platform. This patchset contains both set of patches, along with the associated documentation and the python test script for testing the feature. The upstreaming effort for this feature had been put on a temporary hold to address the fixing of some issues in the capsule update code, primarily using a per platform image GUID for the updatable images. Now that the series has been merged, upstreaming effort for the FWU update feature is being resumed. Hence, this version does not have any review comments being addressed. [1] - https://developer.arm.com/documentation/den0118/a [2] - https://git.codelinaro.org/linaro/dependable-boot/mbfw/uploads/6f7ddfe3be24e18d4319e108a758d02e/mbfw.pdf Jassi Brar (1): developerbox: synquacer: Use FIP as the updatable image Masami Hiramatsu (9): FWU: Add FWU metadata access driver for non-GPT MTD devices dt/bindings: firmware: Add FWU metadata on MTD devices binding tools: Add mkfwumdata tool for FWU metadata image FWU: doc: Update documentation for the FWU non-GPT MTD synquacer: Update for TBBR (BL2) based new FIP layout FWU: synquacer: Add FWU Multi bank update support for DeveloperBox FWU: synquacer: Generate dfu_alt_info from devicetree partition doc: synquacer: Add how to enable FWU Multi Bank Update [TEMP]configs: synquacer: Add FWU support for DeveloperBox Sughosh Ganu (13): dt/bindings: Add bindings for FWU Metadata storage device FWU: Add FWU metadata structure and driver for accessing metadata FWU: Add FWU metadata access driver for GPT partitioned block devices stm32mp1: dk2: Add a node for the FWU metadata device stm32mp1: dk2: Add image information for capsule updates FWU: stm32mp1: Add helper functions for accessing FWU metadata FWU: STM32MP1: Add support to read boot index from backup register FWU: Add boot time checks as highlighted by the FWU specification FWU: Add support for the FWU Multi Bank Update feature FWU: cmd: Add a command to read FWU metadata mkeficapsule: Add support for generating empty capsules FWU: doc: Add documentation for the FWU feature sandbox: fwu: Add support for testing FWU feature on sandbox arch/arm/dts/stm32mp157c-dk2-u-boot.dtsi | 7 + .../synquacer-sc2a11-developerbox-u-boot.dtsi | 40 +- arch/arm/mach-stm32mp/include/mach/stm32.h | 4 + arch/sandbox/Kconfig | 6 + arch/sandbox/dts/test.dts | 45 +- board/sandbox/sandbox.c | 49 ++ board/socionext/developerbox/Kconfig | 14 + board/socionext/developerbox/Makefile | 1 + board/socionext/developerbox/developerbox.c | 17 +- board/socionext/developerbox/fwu_plat.c | 200 ++++++++ board/st/stm32mp1/stm32mp1.c | 141 ++++++ cmd/Kconfig | 7 + cmd/Makefile | 1 + cmd/fwu_mdata.c | 74 +++ common/board_r.c | 5 + configs/sandbox64_defconfig | 12 +- configs/synquacer_developerbox_defconfig | 10 +- doc/board/socionext/developerbox.rst | 110 +++++ doc/develop/uefi/fwu_updates.rst | 200 ++++++++ doc/develop/uefi/index.rst | 1 + doc/develop/uefi/uefi.rst | 2 + .../firmware/fwu-mdata.txt | 18 + .../firmware/uboot,fwu-mdata-mtd.yaml | 38 ++ doc/mkeficapsule.1 | 29 +- drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/fwu-mdata/Kconfig | 24 + drivers/fwu-mdata/Makefile | 8 + drivers/fwu-mdata/fwu-mdata-uclass.c | 459 ++++++++++++++++++ drivers/fwu-mdata/fwu_mdata_gpt_blk.c | 404 +++++++++++++++ drivers/fwu-mdata/fwu_mdata_mtd.c | 308 ++++++++++++ include/configs/stm32mp15_common.h | 4 + include/configs/synquacer.h | 21 +- include/dm/uclass-id.h | 1 + include/fwu.h | 74 +++ include/fwu_mdata.h | 67 +++ lib/Kconfig | 6 + lib/Makefile | 1 + lib/efi_loader/efi_capsule.c | 231 ++++++++- lib/efi_loader/efi_setup.c | 3 +- lib/fwu_updates/Kconfig | 31 ++ lib/fwu_updates/Makefile | 7 + lib/fwu_updates/fwu.c | 206 ++++++++ lib/fwu_updates/fwu_mtd.c | 173 +++++++ .../test_capsule_firmware_fit.py | 1 - .../py/tests/test_fwu_updates/capsule_defs.py | 10 + test/py/tests/test_fwu_updates/conftest.py | 78 +++ .../test_fwu_updates/test_fwu_updates.py | 367 ++++++++++++++ tools/Kconfig | 9 + tools/Makefile | 4 + tools/eficapsule.h | 8 + tools/mkeficapsule.c | 139 +++++- tools/mkfwumdata.c | 298 ++++++++++++ 53 files changed, 3903 insertions(+), 73 deletions(-) create mode 100644 board/socionext/developerbox/fwu_plat.c create mode 100644 cmd/fwu_mdata.c create mode 100644 doc/develop/uefi/fwu_updates.rst create mode 100644 doc/device-tree-bindings/firmware/fwu-mdata.txt create mode 100644 doc/device-tree-bindings/firmware/uboot,fwu-mdata-mtd.yaml create mode 100644 drivers/fwu-mdata/Kconfig create mode 100644 drivers/fwu-mdata/Makefile create mode 100644 drivers/fwu-mdata/fwu-mdata-uclass.c create mode 100644 drivers/fwu-mdata/fwu_mdata_gpt_blk.c create mode 100644 drivers/fwu-mdata/fwu_mdata_mtd.c create mode 100644 include/fwu.h create mode 100644 include/fwu_mdata.h create mode 100644 lib/fwu_updates/Kconfig create mode 100644 lib/fwu_updates/Makefile create mode 100644 lib/fwu_updates/fwu.c create mode 100644 lib/fwu_updates/fwu_mtd.c create mode 100644 test/py/tests/test_fwu_updates/capsule_defs.py create mode 100644 test/py/tests/test_fwu_updates/conftest.py create mode 100644 test/py/tests/test_fwu_updates/test_fwu_updates.py create mode 100644 tools/mkfwumdata.c