From patchwork Thu Nov 26 18:41:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 333044 Delivered-To: patch@linaro.org Received: by 2002:a92:5e16:0:0:0:0:0 with SMTP id s22csp1543164ilb; Thu, 26 Nov 2020 10:43:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJxqB5KXcnaVk6Floea/bM0zpipKfi7fAsCQauwDoxEXWbd0/fMN21n19SS12tnQdJr+Sa4g X-Received: by 2002:a17:906:6b86:: with SMTP id l6mr3966881ejr.524.1606416209509; Thu, 26 Nov 2020 10:43:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606416209; cv=none; d=google.com; s=arc-20160816; b=ldiYGNLO0oC/xB9tCJTr3bFGe9w6tNr4iCsE7R8qCSN+LYNBfkdTczFCkuvGLVHw3j OxDc0H1jAYoXwahX/o5wm65YynykX8NNRU26VepXAvpw31PRAyXcoVP7d515XuTDqvtV XeBpV15Chifjvk3RfIz4yUxiqBIdYdQfQD331C1FcDgTT+NmXLf73e2Ig+l6mL0QnI6m CPlyMpnClBc5AHJ+g01d9xViTriBRwDzSAyvbtU4PUaz+9dcelP0Z/hXtl20XXLt/omd EFeHSVOfz8Xzyns9DFj017d3SfaVfPqhiNy5pLlykb+L6a1GYhTP49Is55Ype462SSrC hFgA== 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:references:in-reply-to :message-id:date:subject:cc:to:from; bh=v+ACP5YuSMoeegsYiXKQHKPz6JxcuSEtGANYHUVt0Gk=; b=ckkSNHPgkBLFnMCH95B/OP6Uyx8omujUcpqNiK3lNrHGeLDJDdNruwcuoe5ebYt6Sa I9ldAV6a1paTaykVJEPJwFaCg3YWUNqtRfpc8wvvQ6nTI30sqesNkhQSOl1/eGDYODBm V1fszkO0wQdmofxFRo6O82EbHVyzPNYHxX3N+KjEzYpnDISwtdP/AHjyR3CTamCMjCBX 06nuVj6/I3BzkCsWUwwhRoHX7sdlWFYuaFr5ioCeTBs1/N0eg4wGZ3EX+bzG92wUOGOX oqYWkoUY8ZLp4+DzfAwr4mdSyLdbY5kqy+Oiws6Dnl5mW4feY9k5stvUn/l2tyW8YoQH TEaQ== 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 a22si3782180eds.497.2020.11.26.10.43.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2020 10:43:29 -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 A1F3A826D6; Thu, 26 Nov 2020 19:42: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 F2289826EC; Thu, 26 Nov 2020 19:42:13 +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.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, URIBL_BLOCKED autolearn=ham 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 26CB7826DF for ; Thu, 26 Nov 2020 19:42:10 +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 6C91F15EC; Thu, 26 Nov 2020 10:42:09 -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 04BC73F23F; Thu, 26 Nov 2020 10:42:06 -0800 (PST) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Takahiro Akashi , Heinrich Schuchardt , Alexander Graf , Lukasz Majewski , Tuomas Tynkkynen , Tom Rini , Sughosh Ganu Subject: [PATCH 07/14] efi_loader: Add config option to indicate fmp header presence Date: Fri, 27 Nov 2020 00:11:03 +0530 Message-Id: <20201126184110.30521-8-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201126184110.30521-1-sughosh.ganu@linaro.org> References: <20201126184110.30521-1-sughosh.ganu@linaro.org> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean When building the capsule using scripts in edk2, an fmp header is added on top of the binary payload. Add a config option to indicate the presence of the header. When enabled, the pointer to the image needs to be adjusted as per the size of the header to point to the actual binary payload. Signed-off-by: Sughosh Ganu --- lib/efi_loader/Kconfig | 7 +++++++ lib/efi_loader/efi_firmware.c | 12 ++++++++++++ 2 files changed, 19 insertions(+) -- 2.17.1 diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index 0d1b1b5356..55e4787e32 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -138,6 +138,13 @@ config EFI_CAPSULE_FIRMWARE_MANAGEMENT Select this option if you want to enable capsule-based firmware update using Firmware Management Protocol. +config EFI_CAPSULE_FMP_HEADER + bool "Capsule uses FMP header" + depends on EFI_CAPSULE_FIRMWARE_MANAGEMENT + help + Select this option if the capsule is built using the + scripts in edk2. + config EFI_CAPSULE_FIRMWARE_FIT bool "FMP driver for FIT image" depends on EFI_CAPSULE_FIRMWARE_MANAGEMENT diff --git a/lib/efi_loader/efi_firmware.c b/lib/efi_loader/efi_firmware.c index 7e56077383..6c97604d8b 100644 --- a/lib/efi_loader/efi_firmware.c +++ b/lib/efi_loader/efi_firmware.c @@ -385,10 +385,22 @@ efi_status_t EFIAPI efi_firmware_raw_set_image( if (!image) return EFI_EXIT(EFI_INVALID_PARAMETER); + if (CONFIG_IS_ENABLED(EFI_CAPSULE_FMP_HEADER)) { + /* + * When building the capsule with the scripts in + * edk2, a FMP header is inserted above the capsule + * payload. Compensate for this header to get the + * actual payload that is to be updated. + */ + image += 0x10; + image_size -= 0x10; + } + if (dfu_write_by_alt(image_index - 1, (void *)image, image_size, NULL, NULL)) return EFI_EXIT(EFI_DEVICE_ERROR); + printf("%s: Capsule update complete!\n", __func__); return EFI_EXIT(EFI_SUCCESS); }