blob: 690e7af4c396f5d1f49d7f4c751de73f3ca39244 [file] [log] [blame]
Andrew Geissler9347dd42023-03-03 12:38:41 -06001# This class generates UEFI capsules
2# The current class supports generating a capsule with single firmware binary
3
4DEPENDS += "gettext-native"
5inherit python3native
6
7IMAGE_TYPES += "uefi_capsule"
8
9# edk2 base tools should be installed in the native sysroot directory
10do_image_uefi_capsule[depends] += "edk2-basetools-native:do_populate_sysroot"
11
12# By default the wic image is used to create a capsule
13CAPSULE_IMGTYPE ?= "wic"
14
15# IMGDEPLOYDIR is used as the default location of firmware binary for which the capsule needs to be created
16CAPSULE_IMGLOCATION ?= "${IMGDEPLOYDIR}"
17
18# The generated capsule by default has uefi.capsule extension
19CAPSULE_EXTENSION ?= "uefi.capsule"
20
21# The following variables must be set to be able to generate a capsule update
22UEFI_FIRMWARE_BINARY ?= ""
23UEFI_CAPSULE_CONFIG ?= ""
24
25# Check if the required variables are set
26python() {
27 for var in ["UEFI_FIRMWARE_BINARY", "UEFI_CAPSULE_CONFIG"]:
28 if not d.getVar(var):
29 raise bb.parse.SkipRecipe(f"{var} not set")
30}
31
32IMAGE_CMD:uefi_capsule(){
33
34 # Force the GenerateCapsule script to use python3
35 export PYTHON_COMMAND=${PYTHON}
36
37 # Copy the firmware and the capsule config json to current directory
38 if [ -e ${CAPSULE_IMGLOCATION}/${UEFI_FIRMWARE_BINARY} ]; then
39 cp ${CAPSULE_IMGLOCATION}/${UEFI_FIRMWARE_BINARY} . ;
40 fi
41
42 export UEFI_FIRMWARE_BINARY=${UEFI_FIRMWARE_BINARY}
43 envsubst < ${UEFI_CAPSULE_CONFIG} > ./${MACHINE}-capsule-update-image.json
44
45 ${STAGING_DIR_NATIVE}/usr/bin/edk2-BaseTools/BinWrappers/PosixLike/GenerateCapsule \
46 -e -o ${IMGDEPLOYDIR}/${UEFI_FIRMWARE_BINARY}.${CAPSULE_EXTENSION} -j \
47 ${MACHINE}-capsule-update-image.json
48
49 # Remove the firmware to avoid contamination of IMGDEPLOYDIR
50 rm ${UEFI_FIRMWARE_BINARY}
51
52}
53
54# The firmware binary should be created before generating the capsule
55IMAGE_TYPEDEP:uefi_capsule:append = "${CAPSULE_IMGTYPE}"