From patchwork Thu Nov 25 07:12:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 519367 Delivered-To: patch@linaro.org Received: by 2002:ac0:c605:0:0:0:0:0 with SMTP id p5csp367611imj; Wed, 24 Nov 2021 23:13:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJxhUlo+cZd0/YDp7aoFBfwsLphp9rkYuMUDWTAldPRi6lrfKwqn9mfNnNVQmtdPw9Hi/zg5 X-Received: by 2002:a17:906:619:: with SMTP id s25mr28909392ejb.237.1637824416868; Wed, 24 Nov 2021 23:13:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637824416; cv=none; d=google.com; s=arc-20160816; b=ByNQilIB9l1XgPTL2ZRq2Gqhxqr0sf+8qubxTRQCrTO+HBPz3vR3lkNJHO7Sj3oK8h 33a7GBYqAK5A0KsEgtXsFAHlM2S2lkWMd1VCGDhslneSWa4GFe6lf1Sky+7odZba2pSN lbwlWP4RX8oRIFUSNHhae8Ob7m20+/974LZb54sVqC8m0w32jxTuLIUlsyvdKMo2Qqnl WJIWhLefNfi6p26sKEPr71aLf1jm9jJ5ygMlRIwg3zGmktuOIImhdiPm0pwsH7PgY1zG OZX+ZlnOYPx7TPRR3oNEPot4U0AQrYhxHvplCGHcjpRlzjtARh7QAWEq8rH1UPPGd/2H V+Dw== 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:message-id:date:subject:cc:to :from; bh=cB96PtX9O8hw+ZoZSwmCF5mRrpg9M7NG4fEWvyVwlS0=; b=eZ/Yf0E5jFc1JE2SAkYykRzRO/wGRjxqiTves+UKv61gVO7usE9IkhnKnBFmWuS+h0 FgIL6c9talcryOoDJthijEn9C6PyRVuSvee419Wc2ZBHgjFfIGfbDgx8+/SrpIp/C74b 5YHAiVm+gvqbU8uOcp+7YnQVrYmnWVcMPT0R989onAJmBz5lPc+hvA+k0etqTAcXNlWW mnwokSoeZg1R7s8Z9k1J+Q0QGcsYA1xt1OuxCNbTEZuHhtmhXxGICenia8FOYyNBVmKp FkYVFUUGaYb7cxLAZlAB0p6XEAon7HqIOTnTGLxR55k/fnp0p/A/3CoO32EZ7eV4QPnM D1Hw== 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 a3si4922088edy.464.2021.11.24.23.13.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Nov 2021 23:13:36 -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 8F3C983003; Thu, 25 Nov 2021 08:13:33 +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 5F0C182FB3; Thu, 25 Nov 2021 08:13:32 +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,LOTS_OF_MONEY, 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 65EBB8128B for ; Thu, 25 Nov 2021 08:13:28 +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 BB1611FB; Wed, 24 Nov 2021 23:13:27 -0800 (PST) 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 37DAE3F5A1; Wed, 24 Nov 2021 23:13:23 -0800 (PST) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Patrick Delaunay , Patrice Chotard , Heinrich Schuchardt , Alexander Graf , Simon Glass , Bin Meng , Peng Fan , AKASHI Takahiro , Ilias Apalodimas , Jose Marinho , Grant Likely , Jason Liu Subject: [RESEND RFC PATCH 00/10] FWU: Add support for FWU Multi Bank Update feature Date: Thu, 25 Nov 2021 12:42:52 +0530 Message-Id: <20211125071302.3644-1-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.17.1 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.37 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.2 at phobos.denx.de X-Virus-Status: Clean (resending to including the first paragraph which got deleted for some reason). 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 board which boots a FIP image from a uSD card partitioned with the GPT partioning scheme. This also requires changes in the previous stage of bootloader, which parses the metadata and selects the bank to boot the image(s) from. Support is being added in tf-a(BL2 stage) for the STM32MP157C-DK2 board to boot the active bank images. These changes are under review currently[3]. Todo's ------ 1) Add a test(selftest) for the metadata access. 2) Add a tool for generation of the metadata. Not sure if this needs to be part of the u-boot repository though. 3) Add a tool for generation of the firmware accept/reject dummy capsule. Need to check if this can be added to the mkeficapsule tool in u-boot. [1] - https://developer.arm.com/documentation/den0118/a [2] - https://staging-git.codelinaro.org/linaro/firmware-dual-banked-updates/test [3] - https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/12566 Sughosh Ganu (10): GPT: Add function to get gpt header and partition entries stm32mp: dfu: Move the ram partitions to the end of the dfu_alt_info variable FWU: Add metadata structure and functions for accessing metadata FWU: Add metadata access functions for GPT partitioned block devices FWU: stm32mp1: Add helper functions for accessing metadata FWU: STM32MP1: Add support to read boot index from backup register EFI: FMP: Add provision to update image's ImageTypeId in image descriptor FWU: Add boot time checks as highlighted by the FWU specification FWU: Add support for FWU Multi Bank Update feature FWU: cmd: Add a command to read metadata arch/arm/mach-stm32mp/include/mach/stm32.h | 1 + board/st/common/stm32mp_dfu.c | 11 +- board/st/stm32mp1/stm32mp1.c | 70 ++ cmd/Kconfig | 6 + cmd/Makefile | 1 + cmd/fwu_metadata.c | 65 ++ common/board_r.c | 6 + disk/part_efi.c | 10 + include/fwu_metadata.h | 140 ++++ include/part.h | 14 + lib/Kconfig | 32 + lib/Makefile | 1 + lib/efi_loader/efi_capsule.c | 190 +++++- lib/efi_loader/efi_firmware.c | 76 ++- lib/fwu_updates/Makefile | 11 + lib/fwu_updates/fwu.c | 170 +++++ lib/fwu_updates/fwu_metadata.c | 275 ++++++++ lib/fwu_updates/fwu_metadata_gpt_blk.c | 716 +++++++++++++++++++++ 18 files changed, 1784 insertions(+), 11 deletions(-) create mode 100644 cmd/fwu_metadata.c create mode 100644 include/fwu_metadata.h create mode 100644 lib/fwu_updates/Makefile create mode 100644 lib/fwu_updates/fwu.c create mode 100644 lib/fwu_updates/fwu_metadata.c create mode 100644 lib/fwu_updates/fwu_metadata_gpt_blk.c