Add UEFI capsule generation support
cover Add UEFI capsule generation support
From: Gowtham Suresh Kumar <[email protected]>
The following patches adds a class for UEFI capsule generation, a recipe for installing edk2 base tools in the sysroot and configures the corstone1000 recipe to build a UEFI capsule.
Gowtham Suresh Kumar (3):
arm/edk2-basetools: Add edk2 base tool native recipe arm-bsp/uefi_capsule: Add UEFI capsule generation class arm-bsp/corstone1000-image: Generate UEFI capsule for corstone1000
platform
.../recipes-bsp/images/corstone1000-image.bb | 9 +++- meta-arm/classes/uefi_capsule.bbclass | 46 +++++++++++++++++++ .../edk2-basetools/edk2-basetools_202211.bb | 24 ++++++++++ 3 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 meta-arm/classes/uefi_capsule.bbclass create mode 100644 meta-arm/recipes-devtools/edk2-basetools/edk2-basetools_202211.bb
--
2.17.1
PATCH 1/3 arm/edk2-basetools: Add edk2 base tool native recipe
From: Gowtham Suresh Kumar <[email protected]>
The native recipe installs the UEFI capsule generation tool along with the other base tools to native sysroot.
--- .../edk2-basetools/edk2-basetools_202211.bb | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 meta-arm/recipes-devtools/edk2-basetools/edk2-basetools_202211.bb
meta-arm/recipes-devtools/edk2-basetools/edk2-basetools_202211.bb new file +24 -0
@@ -0,0 +1,24 @@ +# Install EDK2 Base Tools in native sysroot. Currently the BaseTools are not +# built, they are just copied to native sysroot. This is sufficient for +# generating UEFI capsules as it only depends on some python scripts. Other +# tools need to be built first before adding to sysroot. + +DESCRIPTION = "EDK2 Base Tools" +LICENSE = "BSD-2-Clause-Patent" + +# EDK2 +SRC_URI = "git://github.com/tianocore/edk2.git;branch=master;protocol=https" +LIC_FILES_CHKSUM = "file://License.txt;md5=2b415520383f7964e96700ae12b4570a" + +SRCREV = "fff6d81270b57ee786ea18ad74f43149b9f03494" + +S = "${WORKDIR}/git" + +RDEPENDS:${PN} += "python3-core" + +do_install () { + mkdir -p ${D}${bindir}/edk2-BaseTools + cp -r ${WORKDIR}/git/BaseTools/* ${D}${bindir}/edk2-BaseTools/ +} + +BBCLASSEXTEND = "native"
Signature · 1 line
2.17.1
Re: [meta-arm] [PATCH 1/3] arm/edk2-basetools: Add edk2 base tool native recipe
Quoted 17 lines · Gowtham Suresh Kumar
From: Gowtham Suresh Kumar <[email protected]>
The native recipe installs the UEFI capsule generation tool along with the other base tools to native sysroot.
Signed-off-by Gowtham Suresh Kumar <[email protected]>--- .../edk2-basetools/edk2-basetools_202211.bb | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 meta-arm/recipes-devtools/edk2-basetools/edk2-basetools_202211.bbmeta-arm/recipes-devtools/edk2-basetools/edk2-basetools_202211.bb new file +0
-0
meta-arm/recipes-devtools/edk2-basetools/edk2-basetools_202211.bb line 6
Quoted 6 lines
meta-arm/recipes-devtools/edk2-basetools/edk2-basetools_202211.bb new file +6
-0@@ -0,0 +1,24 @@ +# Install EDK2 Base Tools in native sysroot. Currently the BaseTools are not +# built, they are just copied to native sysroot. This is sufficient for +# generating UEFI capsules as it only depends on some python scripts. Other +# tools need to be built first before adding to sysroot. + +DESCRIPTION = "EDK2 Base Tools"
This ^ should be SUMMARY
Quoted 5 lines
meta-arm/recipes-devtools/edk2-basetools/edk2-basetools_202211.bb new file +5
-0+LICENSE = "BSD-2-Clause-Patent" + +# EDK2 +SRC_URI = "git://github.com/tianocore/edk2.git;branch=master;protocol=https" +LIC_FILES_CHKSUM = "file://License.txt;md5=2b415520383f7964e96700ae12b4570a"
meta-arm/recipes-devtools/edk2-basetools/edk2-basetools_202211.bb line 21
Quoted 10 lines
meta-arm/recipes-devtools/edk2-basetools/edk2-basetools_202211.bb new file +10
-0+ +SRCREV = "fff6d81270b57ee786ea18ad74f43149b9f03494" + +S = "${WORKDIR}/git" + +RDEPENDS:${PN} += "python3-core" + +do_install () { + mkdir -p ${D}${bindir}/edk2-BaseTools + cp -r ${WORKDIR}/git/BaseTools/* ${D}${bindir}/edk2-BaseTools/
You could potentially have a host contamination warning here.
Quoted 6 lines
meta-arm/recipes-devtools/edk2-basetools/edk2-basetools_202211.bb new file +3
-0+} + +BBCLASSEXTEND = "native"Signature · 1 line
2.17.1
Re: [meta-arm] [PATCH 1/3] arm/edk2-basetools: Add edk2 base tool native recipe
Hello Denys,
I do not see any warnings related to host contamination when I use the recipe. Can you please provide more details on it? If you are referring to the ownership issue with cp command, does it also affect native recipes? This recipe is just populating the required edk2 tools to the native staging directory to use for UEFI capsule image generation.
Best regards,
Gowtham Suresh Kumar
________________________________
From: Denys Dmytriyenko <[email protected]>
Sent: Friday, January 27, 2023 9:27 PM
To: Gowtham Suresh Kumar <[email protected]>
Cc: [email protected] <[email protected]>; Ross Burton <[email protected]>; nd <[email protected]>
Subject: Re: [meta-arm] [PATCH 1/3] arm/edk2-basetools: Add edk2 base tool native recipe
Quoted 17 lines · Gowtham Suresh Kumar
From: Gowtham Suresh Kumar <[email protected]>
The native recipe installs the UEFI capsule generation tool along with the other base tools to native sysroot.
Signed-off-by Gowtham Suresh Kumar <[email protected]>--- .../edk2-basetools/edk2-basetools_202211.bb | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 meta-arm/recipes-devtools/edk2-basetools/edk2-basetools_202211.bbmeta-arm/recipes-devtools/edk2-basetools/edk2-basetools_202211.bb new file +0
-0
meta-arm/recipes-devtools/edk2-basetools/edk2-basetools_202211.bb line 6
Quoted 6 lines
meta-arm/recipes-devtools/edk2-basetools/edk2-basetools_202211.bb new file +6
-0@@ -0,0 +1,24 @@ +# Install EDK2 Base Tools in native sysroot. Currently the BaseTools are not +# built, they are just copied to native sysroot. This is sufficient for +# generating UEFI capsules as it only depends on some python scripts. Other +# tools need to be built first before adding to sysroot. + +DESCRIPTION = "EDK2 Base Tools"
This ^ should be SUMMARY
Quoted 5 lines
meta-arm/recipes-devtools/edk2-basetools/edk2-basetools_202211.bb new file +5
-0+LICENSE = "BSD-2-Clause-Patent" + +# EDK2 +SRC_URI = "git://github.com/tianocore/edk2.git;branch=master;protocol=https" +LIC_FILES_CHKSUM = "file://License.txt;md5=2b415520383f7964e96700ae12b4570a"
meta-arm/recipes-devtools/edk2-basetools/edk2-basetools_202211.bb line 21
Quoted 10 lines
meta-arm/recipes-devtools/edk2-basetools/edk2-basetools_202211.bb new file +10
-0+ +SRCREV = "fff6d81270b57ee786ea18ad74f43149b9f03494" + +S = "${WORKDIR}/git" + +RDEPENDS:${PN} += "python3-core" + +do_install () { + mkdir -p ${D}${bindir}/edk2-BaseTools + cp -r ${WORKDIR}/git/BaseTools/* ${D}${bindir}/edk2-BaseTools/
You could potentially have a host contamination warning here.
Quoted 6 lines
meta-arm/recipes-devtools/edk2-basetools/edk2-basetools_202211.bb new file +3
-1+} + +BBCLASSEXTEND = "native" --2.17.1
Re: [meta-arm] [PATCH 1/3] arm/edk2-basetools: Add edk2 base tool native recipe
Quoted 5 lines · Gowtham Suresh Kumar
Hello Denys,
I do not see any warnings related to host contamination when I use the recipe. Can you please provide more details on it? If you are referring to the ownership issue with cp command, does it also affect native recipes?
Correct, the ownership issue won't affect the native recipe. But you are not adding native-only recipe, you are adding a regular target recipe and extending it to also provide a native variant.
If you only intend to use this in a native environment exclusively and it doesn't make sense for a target or nativesdk variants, you should make the recipe native-only. By naming it edk2-basetools-native_202211.bb, having "inherit native" line and dropping BBCLASSEXTEND = "native"
Quoted 65 lines
This recipe is just populating the required edk2 tools to the native staging directory to use for UEFI capsule image generation.
Best regards,
Gowtham Suresh Kumar
________________________________
From: Denys Dmytriyenko <[email protected]>
Sent: Friday, January 27, 2023 9:27 PM
To: Gowtham Suresh Kumar <[email protected]>
Cc: [email protected] <[email protected]>; Ross Burton <[email protected]>; nd <[email protected]>
Subject: Re: [meta-arm] [PATCH 1/3] arm/edk2-basetools: Add edk2 base tool native recipeQuoted 17 lines · Gowtham Suresh Kumar
From: Gowtham Suresh Kumar <[email protected]>
The native recipe installs the UEFI capsule generation tool along with the other base tools to native sysroot.
Signed-off-by Gowtham Suresh Kumar <[email protected]>--- .../edk2-basetools/edk2-basetools_202211.bb | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 meta-arm/recipes-devtools/edk2-basetools/edk2-basetools_202211.bbmeta-arm/recipes-devtools/edk2-basetools/edk2-basetools_202211.bb new file +0
-0meta-arm/recipes-devtools/edk2-basetools/edk2-basetools_202211.bb line 6
Quoted 6 lines
meta-arm/recipes-devtools/edk2-basetools/edk2-basetools_202211.bb new file +6
-0@@ -0,0 +1,24 @@ +# Install EDK2 Base Tools in native sysroot. Currently the BaseTools are not +# built, they are just copied to native sysroot. This is sufficient for +# generating UEFI capsules as it only depends on some python scripts. Other +# tools need to be built first before adding to sysroot. + +DESCRIPTION = "EDK2 Base Tools"This ^ should be SUMMARY
Quoted 5 lines
meta-arm/recipes-devtools/edk2-basetools/edk2-basetools_202211.bb new file +5
-0+LICENSE = "BSD-2-Clause-Patent" + +# EDK2 +SRC_URI = "git://github.com/tianocore/edk2.git;branch=master;protocol=https" +LIC_FILES_CHKSUM = "file://License.txt;md5=2b415520383f7964e96700ae12b4570a"meta-arm/recipes-devtools/edk2-basetools/edk2-basetools_202211.bb line 21
Quoted 10 lines
meta-arm/recipes-devtools/edk2-basetools/edk2-basetools_202211.bb new file +10
-0+ +SRCREV = "fff6d81270b57ee786ea18ad74f43149b9f03494" + +S = "${WORKDIR}/git" + +RDEPENDS:${PN} += "python3-core" + +do_install () { + mkdir -p ${D}${bindir}/edk2-BaseTools + cp -r ${WORKDIR}/git/BaseTools/* ${D}${bindir}/edk2-BaseTools/You could potentially have a host contamination warning here.
Quoted 6 lines
meta-arm/recipes-devtools/edk2-basetools/edk2-basetools_202211.bb new file +3
-1+} + +BBCLASSEXTEND = "native" --2.17.1
PATCH 2/3 arm-bsp/uefi_capsule: Add UEFI capsule generation class
In reply to [email protected]From: Gowtham Suresh Kumar <[email protected]>
This class currently supports only a single firmware binary. The required capsule parameters needs to be set, if not the build fails.
--- meta-arm/classes/uefi_capsule.bbclass | 46 +++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 meta-arm/classes/uefi_capsule.bbclass
meta-arm/classes/uefi_capsule.bbclass new file +46 -0
@@ -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}"
Signature · 1 line
2.17.1
Re: [meta-arm] [PATCH 2/3] arm-bsp/uefi_capsule: Add UEFI capsule generation class
Hi all,
Quoted 51 lines · Gowtham Suresh Kumar
From: Gowtham Suresh Kumar <[email protected]>
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 <[email protected]>--- meta-arm/classes/uefi_capsule.bbclass | 46 +++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 meta-arm/classes/uefi_capsule.bbclassmeta-arm/classes/uefi_capsule.bbclass new file +33
-0@@ -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") +} +
meta-arm/classes/uefi_capsule.bbclass line 43
Quoted 10 lines
meta-arm/classes/uefi_capsule.bbclass new file +10
-0+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?
Regards
/Ilias
Quoted 15 lines
meta-arm/classes/uefi_capsule.bbclass new file +3
-1+ +# 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: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/meta-arm/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
PATCH 3/3 arm-bsp/corstone1000-image: Generate UEFI capsule for corstone1000 platform
In reply to [email protected]From: Gowtham Suresh Kumar <[email protected]>
Inherits the UEFI capsule generation class and configures the capsule variables for the wic.nopt image
--- meta-arm-bsp/recipes-bsp/images/corstone1000-image.bb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
meta-arm-bsp/recipes-bsp/images/corstone1000-image.bb +8 -1
@@ -7,10 +7,17 @@ COMPATIBLE_MACHINE = "corstone1000" inherit image inherit wic_nopt tfm_sign_image +inherit uefi_capsule PACKAGE_INSTALL = "" -IMAGE_FSTYPES += "wic wic.nopt" +IMAGE_FSTYPES += "wic wic.nopt uefi_capsule" + +UEFI_FIRMWARE_BINARY = "corstone1000-image-${MACHINE}.wic.nopt" +UEFI_FIRMWARE_VERSION = "5" +UEFI_FIRMWARE_LSV = "0" +UEFI_FIRMWARE_GUID = "e2bb9c06-70e9-4b14-97a3-5a7913176e3f" +UEFI_FIRMWARE_UPDATE_INDEX = "0" do_sign_images() { # Sign TF-A BL2
Signature · 1 line
2.17.1
Jon Mason
AppliedQuoted 5 lines · On Fri, 27 Jan 2023 19:21:19 +0000, [email protected] wrote:
The following patches adds a class for UEFI capsule generation, a recipe for installing edk2 base tools in the sysroot and configures the corstone1000 recipe to build a UEFI capsule.
Quoted 7 lines
Gowtham Suresh Kumar (3):
arm/edk2-basetools: Add edk2 base tool native recipe arm-bsp/uefi_capsule: Add UEFI capsule generation class arm-bsp/corstone1000-image: Generate UEFI capsule for corstone1000
platform[...]
Applied, thanks!
[1/3] arm/edk2-basetools: Add edk2 base tool native recipe
commit: 5914ae11f47fe85541b7c2f796a4b18ac7b49227
[2/3] arm-bsp/uefi_capsule: Add UEFI capsule generation class
commit: f0945f499c49a10f15f05b0da6efbf01659ca03c
[3/3] arm-bsp/corstone1000-image: Generate UEFI capsule for corstone1000 platform
commit: 3af64cee5bf963359e1aa304e55ff673b07f0294Best regards,
Signature · 1 line
Jon Mason <[email protected]>
Jon Mason
AppliedQuoted 5 lines · On Fri, 27 Jan 2023 19:21:19 +0000, [email protected] wrote:
The following patches adds a class for UEFI capsule generation, a recipe for installing edk2 base tools in the sysroot and configures the corstone1000 recipe to build a UEFI capsule.
Quoted 7 lines
Gowtham Suresh Kumar (3):
arm/edk2-basetools: Add edk2 base tool native recipe arm-bsp/uefi_capsule: Add UEFI capsule generation class arm-bsp/corstone1000-image: Generate UEFI capsule for corstone1000
platform[...]
Applied, thanks!
[1/3] arm/edk2-basetools: Add edk2 base tool native recipe
commit: 5914ae11f47fe85541b7c2f796a4b18ac7b49227
[2/3] arm-bsp/uefi_capsule: Add UEFI capsule generation class
commit: f0945f499c49a10f15f05b0da6efbf01659ca03c
[3/3] arm-bsp/corstone1000-image: Generate UEFI capsule for corstone1000 platform
commit: 3af64cee5bf963359e1aa304e55ff673b07f0294Best regards,
Signature · 1 line
Jon Mason <[email protected]>
Jon Mason
AppliedQuoted 5 lines · On Fri, 27 Jan 2023 19:21:19 +0000, [email protected] wrote:
The following patches adds a class for UEFI capsule generation, a recipe for installing edk2 base tools in the sysroot and configures the corstone1000 recipe to build a UEFI capsule.
Quoted 7 lines
Gowtham Suresh Kumar (3):
arm/edk2-basetools: Add edk2 base tool native recipe arm-bsp/uefi_capsule: Add UEFI capsule generation class arm-bsp/corstone1000-image: Generate UEFI capsule for corstone1000
platform[...]
Applied, thanks!
[1/3] arm/edk2-basetools: Add edk2 base tool native recipe
commit: ccf216ce4d5e149d907ab2777b2b39d71b90bd53
[2/3] arm-bsp/uefi_capsule: Add UEFI capsule generation class
commit: 7a1649137389bff0ad1a4825a2dc148290437a3b
[3/3] arm-bsp/corstone1000-image: Generate UEFI capsule for corstone1000 platform
commit: 2792359e0a6d2663b0d8b523e2290b14029cc4fbBest regards,
Signature · 1 line
Jon Mason <[email protected]>