diff mbox series

[2/3] arm-bsp/uefi_capsule: Add UEFI capsule generation class

Message ID 20230127192122.19338-3-gowtham.sureshkumar@arm.com
State New
Headers show
Series Add UEFI capsule generation support | expand

Commit Message

Gowtham Suresh Kumar Jan. 27, 2023, 7:21 p.m. UTC
From: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>

This class currently supports only a single firmware binary. The
required capsule parameters needs to be set, if not the build fails.

Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
---
 meta-arm/classes/uefi_capsule.bbclass | 46 +++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100644 meta-arm/classes/uefi_capsule.bbclass

Comments

Ilias Apalodimas Feb. 1, 2023, 9:42 a.m. UTC | #1
Hi all,

On Fri, 27 Jan 2023 at 21:22, Gowtham Suresh Kumar
<gowtham.sureshkumar@arm.com> wrote:
>
> From: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
>
> This class currently supports only a single firmware binary. The
> required capsule parameters needs to be set, if not the build fails.
>
> Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
> ---
>  meta-arm/classes/uefi_capsule.bbclass | 46 +++++++++++++++++++++++++++
>  1 file changed, 46 insertions(+)
>  create mode 100644 meta-arm/classes/uefi_capsule.bbclass
>
> diff --git a/meta-arm/classes/uefi_capsule.bbclass b/meta-arm/classes/uefi_capsule.bbclass
> new file mode 100644
> index 00000000..0c3d3845
> --- /dev/null
> +++ b/meta-arm/classes/uefi_capsule.bbclass
> @@ -0,0 +1,46 @@
> +# This class generates UEFI capsules
> +# The current class supports generating a capsule with single firmware binary
> +
> +inherit python3native
> +
> +IMAGE_TYPES += "uefi_capsule"
> +
> +# edk2 base tools should be installed in the native sysroot directory
> +do_image_uefi_capsule[depends] += "edk2-basetools-native:do_populate_sysroot"
> +
> +# By default the wic image is used to create a capsule
> +CAPSULE_IMGTYPE ?= "wic"
> +
> +# IMGDEPLOYDIR is used as the default location of firmware binary for which the capsule needs to be created
> +CAPSULE_IMGLOCATION ?= "${IMGDEPLOYDIR}"
> +
> +# The generated capsule by default has uefi.capsule extension
> +CAPSULE_EXTENSION ?= "uefi.capsule"
> +
> +# The following variables must be set to be able to generate a capsule update
> +UEFI_FIRMWARE_BINARY ?= ""
> +UEFI_FIRMWARE_VERSION ?= ""
> +UEFI_FIRMWARE_LSV ?= ""
> +UEFI_FIRMWARE_GUID ?= ""
> +UEFI_FIRMWARE_UPDATE_INDEX ?= ""
> +
> +# Check if the required variables are set
> +python() {
> +    for var in ["UEFI_FIRMWARE_BINARY", "UEFI_FIRMWARE_VERSION", "UEFI_FIRMWARE_LSV", "UEFI_FIRMWARE_GUID", "UEFI_FIRMWARE_UPDATE_INDEX"]:
> +        if not d.getVar(var):
> +            raise bb.parse.SkipRecipe(f"{var} not set")
> +}
> +
> +IMAGE_CMD:uefi_capsule(){
> +
> +    # Force the GenerateCapsule script to use python3
> +    export PYTHON_COMMAND=${PYTHON}
> +
> +    ${STAGING_DIR_NATIVE}/usr/bin/edk2-BaseTools/BinWrappers/PosixLike/GenerateCapsule -e -o \
> +    ${CAPSULE_IMGLOCATION}/${UEFI_FIRMWARE_BINARY}.${CAPSULE_EXTENSION} --fw-version ${UEFI_FIRMWARE_VERSION} \
> +    --lsv ${UEFI_FIRMWARE_LSV} --guid ${UEFI_FIRMWARE_GUID} --verbose --update-image-index \
> +    ${UEFI_FIRMWARE_UPDATE_INDEX} --verbose ${CAPSULE_IMGLOCATION}/${UEFI_FIRMWARE_BINARY}
> +}

That tool also supports a .yaml file to configure.  You can see an
example here [0].  Can we do something similar?


[0] https://gitlab.com/Linaro/trustedsubstrate/meta-ts/-/blob/master/meta-trustedsubstrate/recipes-bsp/capsule-update/capsule-update_0.1.bb#L39

Regards
/Ilias
> +
> +# The firmware binary should be created before generating the capsule
> +IMAGE_TYPEDEP:uefi_capsule:append = "${CAPSULE_IMGTYPE}"
> --
> 2.17.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#4335): https://lists.yoctoproject.org/g/meta-arm/message/4335
> Mute This Topic: https://lists.yoctoproject.org/mt/96573808/4721553
> Group Owner: meta-arm+owner@lists.yoctoproject.org
> Unsubscribe: https://lists.yoctoproject.org/g/meta-arm/unsub [ilias.apalodimas@linaro.org]
> -=-=-=-=-=-=-=-=-=-=-=-
>
diff mbox series

Patch

diff --git a/meta-arm/classes/uefi_capsule.bbclass b/meta-arm/classes/uefi_capsule.bbclass
new file mode 100644
index 00000000..0c3d3845
--- /dev/null
+++ b/meta-arm/classes/uefi_capsule.bbclass
@@ -0,0 +1,46 @@ 
+# This class generates UEFI capsules
+# The current class supports generating a capsule with single firmware binary
+
+inherit python3native
+
+IMAGE_TYPES += "uefi_capsule"
+
+# edk2 base tools should be installed in the native sysroot directory
+do_image_uefi_capsule[depends] += "edk2-basetools-native:do_populate_sysroot"
+
+# By default the wic image is used to create a capsule
+CAPSULE_IMGTYPE ?= "wic"
+
+# IMGDEPLOYDIR is used as the default location of firmware binary for which the capsule needs to be created
+CAPSULE_IMGLOCATION ?= "${IMGDEPLOYDIR}"
+
+# The generated capsule by default has uefi.capsule extension
+CAPSULE_EXTENSION ?= "uefi.capsule"
+
+# The following variables must be set to be able to generate a capsule update
+UEFI_FIRMWARE_BINARY ?= ""
+UEFI_FIRMWARE_VERSION ?= ""
+UEFI_FIRMWARE_LSV ?= ""
+UEFI_FIRMWARE_GUID ?= ""
+UEFI_FIRMWARE_UPDATE_INDEX ?= ""
+
+# Check if the required variables are set
+python() {
+    for var in ["UEFI_FIRMWARE_BINARY", "UEFI_FIRMWARE_VERSION", "UEFI_FIRMWARE_LSV", "UEFI_FIRMWARE_GUID", "UEFI_FIRMWARE_UPDATE_INDEX"]:
+        if not d.getVar(var):
+            raise bb.parse.SkipRecipe(f"{var} not set")
+}
+
+IMAGE_CMD:uefi_capsule(){
+
+    # Force the GenerateCapsule script to use python3
+    export PYTHON_COMMAND=${PYTHON}
+
+    ${STAGING_DIR_NATIVE}/usr/bin/edk2-BaseTools/BinWrappers/PosixLike/GenerateCapsule -e -o \
+    ${CAPSULE_IMGLOCATION}/${UEFI_FIRMWARE_BINARY}.${CAPSULE_EXTENSION} --fw-version ${UEFI_FIRMWARE_VERSION} \
+    --lsv ${UEFI_FIRMWARE_LSV} --guid ${UEFI_FIRMWARE_GUID} --verbose --update-image-index \
+    ${UEFI_FIRMWARE_UPDATE_INDEX} --verbose ${CAPSULE_IMGLOCATION}/${UEFI_FIRMWARE_BINARY}
+}
+
+# The firmware binary should be created before generating the capsule
+IMAGE_TYPEDEP:uefi_capsule:append = "${CAPSULE_IMGTYPE}"