[PATCH 07/14] efi_loader: Add config option to indicate fmp header presence

Heinrich Schuchardt xypron.glpk at gmx.de
Sat Dec 5 11:34:24 CET 2020


On 11/26/20 7:41 PM, Sughosh Ganu wrote:
> 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.

Why do we need a config option? Can't we detect the header?

Can we harmonize the capsule format in EDK II and U-Boot?

Best regards

Heinrich

>
> Signed-off-by: Sughosh Ganu <sughosh.ganu at linaro.org>
> ---
>   lib/efi_loader/Kconfig        |  7 +++++++
>   lib/efi_loader/efi_firmware.c | 12 ++++++++++++
>   2 files changed, 19 insertions(+)
>
> 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);
>   }
>
>



More information about the U-Boot mailing list