Skip to contentSkip to conversation

mkeficapsule: Support multi-payload capsules

PATCH New Balaji Selvanathan 1 participant 7 messages Nov 15

lore
Share & tools
lore
#0 lore raw

v2 cover mkeficapsule: Support multi-payload capsules

This series adds support for bundling multiple firmware images into a single UEFI capsule, driven through mkeficapsule's config file.

It builds on earlier work from [1] adding config-file-driven capsule generation to mkeficapsule. That series produced one payload per capsule; this one extends the parser to group payloads that share the same output capsule file into a single multi-payload capsule, adds a new API to build that capsule, and extends signing so each payload in a multi-payload capsule can be signed independently.

This series is part of work to bring multi-payload single capsule based capsule update to Qualcomm boards. It applies to all boards, not just Qualcomm.

[1] https://lore.kernel.org/u-boot/[email protected]/

Changes in v2:
- Squash the signing patch into the multi-payload creation API patch,
and the grouping patch into the config file parser patch
- Exit with an error when entries sharing a capsule file include
accept or revert types
- Drop the EFI_CAPSULE_CFG_FILE and EFI_USE_CAPSULE_CFG_FILE Kconfig
symbols. The sandbox capsule tests pass the config file to
mkeficapsule by its fixed path
- Mention the --cfg-file long option in the commit message, and add it
and the config file keys to the mkeficapsule man page
- Reformat the config key list in the documentation as a definition
list and explain hardware-instance, monotonic-count, capsule-type
and oemflags
- Fix the capsule test setup: run mkeficapsule before the filesystem
image is created and drop a leftover virt-make-fs call, so the
config file capsules end up in the test image
- Use the current SANDBOX_FIT_IMAGE_GUID in the sandbox config file
- Link to v1: https://lore.kernel.org/u-boot/[email protected]/

---
Balaji Selvanathan (6):
tools: mkeficapsule: Add multi-payload capsule creation API
tools: mkeficapsule: Add support for parsing capsule params from config file
doc: Document capsule generation through a config file
sandbox: capsule: Add a config file for generating capsules
test: capsule: Generate capsules through config file
test: capsule: Add functional test for multi-payload capsule update

 doc/develop/uefi/uefi.rst                          | 140 ++++++
 doc/mkeficapsule.1                                 |  55 +++
 .../tests/test_efi_capsule/capsule_gen_binman.dts  |   2 +
 test/py/tests/test_efi_capsule/conftest.py         |  13 +-
 .../tests/test_efi_capsule/sandbox_capsule_cfg.txt | 118 +++++
 .../test_efi_capsule/test_capsule_firmware_raw.py  |  36 ++
 .../test_capsule_firmware_signed_raw.py            |  33 ++
 tools/Makefile                                     |  10 +-
 tools/eficapsule.h                                 | 128 ++++++
 tools/mkeficapsule.c                               | 306 +++++++++++--
 tools/mkeficapsule_parse.c                         | 474 +++++++++++++++++++++
 11 files changed, 1277 insertions(+), 38 deletions(-)

---
base-commit: 574b1adad70a19d95c65e0f37f9c36d94fb5418f
change-id: 20260725-mkeficapsule-9c1dd6c05b48

Best regards,

Signature · 1 line
Balaji Selvanathan <[email protected]>
#1 lore raw

PATCH v2 1/6 tools: mkeficapsule: Add multi-payload capsule creation API

Add create_multi_payload_fwbin() to bundle up to 16 firmware images into a single capsule file. Only normal blob payloads can be combined, accept and revert capsules are rejected.

Per the UEFI FMP capsule spec, signing is a per-image property, so each payload in a multi-payload capsule can be signed independently. A signed payload gets its own authentication header and PKCS#7 signature written after its image header, using the existing create_auth_data()/free_sig_data() helpers from the single-payload path. Unsigned payloads in the same capsule are not affected.

---
Changes in v2:
- add per-payload signing here, folded in from the separate signing patch of v1

---
 tools/eficapsule.h   |  61 +++++++++++++
 tools/mkeficapsule.c | 252 ++++++++++++++++++++++++++++++++++++++++++++++-----
 2 files changed, 292 insertions(+), 21 deletions(-)
tools/eficapsule.h +61 -0
index 97d077536d5..e51e549e674 100644
@@ -54,6 +54,12 @@ typedef struct efi_guid {
 /* flags */
 #define CAPSULE_FLAGS_PERSIST_ACROSS_RESET      0x00010000
 
+enum capsule_type {
+	CAPSULE_NORMAL_BLOB = 0,
+	CAPSULE_ACCEPT,
+	CAPSULE_REVERT,
+};
+
 struct efi_capsule_header {
 	efi_guid_t capsule_guid;
 	uint32_t header_size;
@@ -145,4 +151,59 @@ struct fmp_payload_header_params {
 	uint32_t fw_version;
 };
 
+/**
+ * struct efi_capsule_params - Capsule parameters
+ * @image_guid: Guid value of the payload input image
+ * @image_index: Image index value
+ * @hardware_instance: Hardware instance to be used for the image
+ * @fmp: FMP payload header used for storing firmware version
+ * @monotonic_count: Monotonic count value to be used for signed capsule
+ * @privkey_file: Path to private key used in capsule signing
+ * @cert_file: Path to public key certificate used in capsule signing
+ * @input_file: Path to payload input image
+ * @capsule_file: Path to the output capsule file
+ * @oemflags: Oemflags to be populated in the capsule header
+ * @capsule: Capsule Type, normal or accept or revert
+ */
+struct efi_capsule_params {
+	efi_guid_t *image_guid;
+	unsigned long image_index;
+	unsigned long hardware_instance;
+	struct fmp_payload_header_params fmp;
+	uint64_t monotonic_count;
+	char *privkey_file;
+	char *cert_file;
+	char *input_file;
+	char *capsule_file;
+	unsigned long oemflags;
+	enum capsule_type capsule;
+};
+
+#define MAX_PAYLOADS_PER_CAPSULE 16
+
+/**
+ * struct efi_capsule_params_array - Array of capsule parameters
+ * @count: Number of parameters in the array
+ * @params: Array of pointers to capsule parameters
+ */
+struct efi_capsule_params_array {
+	int count;
+	struct efi_capsule_params *params[MAX_PAYLOADS_PER_CAPSULE];
+};
+
+/**
+ * create_multi_payload_fwbin - create a multi-payload uefi capsule file
+ * @path:	Path to a created capsule file
+ * @params_array: Array of capsule parameters for multiple payloads
+ *
+ * This function creates a UEFI capsule file with multiple payloads.
+ * All payloads must be normal blob type capsules.
+ *
+ * Return:
+ * * 0  - on success
+ * * -1 - on failure
+ */
+int create_multi_payload_fwbin(char *path,
+			       struct efi_capsule_params_array *params_array);
+
 #endif /* _EFI_CAPSULE_H */
tools/mkeficapsule.c +231 -21

303 lines not on this page · raw message

Signature · 1 line
2.34.1
#2 lore raw

PATCH v2 2/6 tools: mkeficapsule: Add support for parsing capsule params from config file

In reply to Balaji Selvanathan

Add support for specifying the parameters needed for capsule generation through a config file, instead of passing them through command-line. Parameters for more than a single capsule file can be specified, resulting in generation of multiple capsules through a single invocation of the command.

The config file can be passed to the mkeficapsule tool using the -f option, or its long form --cfg-file:

 $ ./tools/mkeficapsule -f <path/to/the/config/file>
 $ ./tools/mkeficapsule --cfg-file <path/to/the/config/file>

Entries that name the same output file with the capsule: key are combined into one multi-payload capsule. Each entry is a block in curly braces, for example:

 {
	image-guid: <guid1>
	image-index: 1
	payload: payload1.bin
	capsule: firmware_update.capsule
 }
 {
	image-guid: <guid2>
	image-index: 2
	payload: payload2.bin
	capsule: firmware_update.capsule

}

This generates a single firmware_update.capsule holding both payloads. An entry with a capsule file of its own gives a normal single-payload capsule. Accept and revert capsules cannot be combined with other payloads, so a group that mixes them is rejected with an error.

---
Changes in v2:
- mention the --cfg-file long option in the commit message
- drop the EFI_CAPSULE_CFG_FILE and EFI_USE_CAPSULE_CFG_FILE Kconfig symbols
- group entries sharing a capsule file into a multi-payload capsule and exit with an error when such entries include accept or revert types. This was a separate patch in v1 that rewrote this code
- exit after printing the version for -V, instead of falling through to the -f handler with a NULL config file

---
 tools/Makefile             |  10 +-
 tools/eficapsule.h         |  67 +++++++
 tools/mkeficapsule.c       |  54 ++++--
 tools/mkeficapsule_parse.c | 474 +++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 590 insertions(+), 15 deletions(-)
tools/Makefile +6 -4
index 535a5d51c89..41f035b6820 100644
@@ -267,11 +267,13 @@ HOSTCFLAGS_mkeficapsule.o += \
 	$(shell pkg-config --cflags gnutls 2> /dev/null || echo "")
 HOSTLDLIBS_mkeficapsule += \
 	$(shell pkg-config --libs gnutls 2> /dev/null || echo "-lgnutls")
-mkeficapsule-objs := generated/lib/uuid.o \
-	generated/lib/sha1.o \
-	$(LIBFDT_OBJS) \
-	mkeficapsule.o
+HOSTLDLIBS_mkeficapsule += \
+	$(shell pkg-config --libs uuid 2> /dev/null || echo "-luuid")
 hostprogs-always-$(CONFIG_TOOLS_MKEFICAPSULE) += mkeficapsule
+mkeficapsule-objs := mkeficapsule.o mkeficapsule_parse.o \
+		     generated/lib/uuid.o \
+		     generated/lib/sha1.o \
+		     $(LIBFDT_OBJS)
 
 include tools/fwumdata_src/fwumdata.mk
 
tools/eficapsule.h +67 -0

77 lines not on this page · raw message

tools/mkeficapsule.c +43 -11

121 lines not on this page · raw message

tools/mkeficapsule_parse.c new file +474 -0

474 lines not on this page · raw message

Signature · 1 line
2.34.1
#3 lore raw

PATCH v2 3/6 doc: Document capsule generation through a config file

In reply to Balaji Selvanathan

The UEFI capsule can now be generated by specifying the capsule parameters through a config file. Highlight these changes in the documentation.

Also document that payloads sharing the same capsule filename are automatically grouped into a single multi-payload capsule, and that payloads in such a group can be individually signed, with an example config demonstrating both behaviours.

---
Changes in v2:
- drop the paragraph on the EFI_CAPSULE_CFG_FILE Kconfig symbol, it is no longer part of this series' tool patches
- mention the --cfg-file long option, add it to the mkeficapsule man page and list the config file keys there
- split the example config into separate code blocks
- format the capsule parameter keys as a definition list and explain hardware-instance, monotonic-count, capsule-type and oemflags,
- state that mixing normal and accept/revert entries in one capsule is an error

---
 doc/develop/uefi/uefi.rst | 140 ++++++++++++++++++++++++++++++++++++++++++++++
 doc/mkeficapsule.1        |  55 ++++++++++++++++++
 2 files changed, 195 insertions(+)
doc/develop/uefi/uefi.rst +140 -0
index 3ca22b572a9..c13069eda2d 100644
@@ -318,6 +318,146 @@ Run the following command
       --guid <image GUID> \
       <capsule_file_name>
 
+Alternatively, the capsules can be generated through a config file, using
+the ``-f`` option or its long form ``--cfg-file``:
+
+.. code-block:: console
+
+    $ mkeficapsule --cfg-file </path/to/the/config/file>
+
+The config file describes the parameters that are used for generating
+one or more capsules. The parameters for a given capsule file are
+specified within curly braces, in the form of "key:value" pairs. All
+the parameters that are currently supported by the mkeficapsule tool
+can be specified through the config file.
+
+The following entries generate two normal capsules, the first one signed:
+
+.. code-block:: none
+
+	{
+	    image-guid: 02f4d760-cfd5-43bd-8e2d-a42acb33c660
+	    hardware-instance: 0
+	    monotonic-count: 1
+	    payload: u-boot.bin
+	    image-index: 1
+	    fw-version: 2
+	    private-key: /path/to/priv/key
+	    pub-key-cert: /path/to/pub/key
+	    capsule: u-boot.capsule
+	}
+	{
+	    image-guid: 4ce292da-1dd8-428d-a1c2-77743ef8b96e
+	    hardware-instance: 0
+	    payload: u-boot.itb
+	    image-index: 2
+	    fw-version: 7
+	    oemflags: 0x8000
+	    capsule: fit.capsule
+	}
+
+An accept capsule is generated with the following entry:
+
+.. code-block:: none
+
+	{
+	    capsule-type: accept
+	    image-guid: 4ce292da-1dd8-428d-a1c2-77743ef8b96e
+	    capsule: accept.capsule
+	}
+
+and a revert capsule, which takes no GUID, with this one:
+
+.. code-block:: none
+
+	{
+	    capsule-type: revert
+	    capsule: revert.capsule
+	}
+
+All the entries above can be put in a single config file, in which case
+all four capsules are generated by one invocation of mkeficapsule.
+
+The following keys specify the capsule parameters:
+
+image-guid
+    Image GUID
+
+image-index
+    Image index value
+
+fw-version
+    Image version
+
+private-key
+    Path to the private key file used for capsule signing
+
+pub-key-cert
+    Path to the public key crt file used for capsule signing
+
+payload
+    Path to the capsule payload file
+
+capsule
+    Path to the output capsule file that is generated
+
+hardware-instance
+    Hardware instance value, used to tell apart multiple devices that
+    share the same image GUID
+
+monotonic-count
+    Monotonic count value, which has to be increased with every signed
+    capsule generated for an image
+
+capsule-type
+    Specifies the capsule type: ``normal`` (the default), ``accept`` or
+    ``revert``
+
+oemflags
+    16bit OEM flags value, populated in the capsule header
+
+Generating multi-payload capsules
+**********************************
+
+Payloads that specify the same ``capsule:`` filename in the config file
+are automatically grouped together and bundled into a single multi-payload
+capsule, instead of each producing its own separate capsule file. All the
+payloads in such a group must use ``capsule-type: normal`` (the default);
+if a group mixes normal payloads with accept or revert capsules, the tool
+exits with an error.
+
+Payloads in a group may individually specify ``private-key``,
+``pub-key-cert`` and ``monotonic-count`` to be signed. Each payload is
+signed independently, so a single multi-payload capsule can contain a mix
+of signed and unsigned payloads.
+
+The following example config groups two payloads into a single
+``update.capsule``, with the first payload signed and the second left
+unsigned:
+
+.. code-block:: none
+
+	{
+	    image-guid: 02f4d760-cfd5-43bd-8e2d-a42acb33c660
+	    hardware-instance: 0
+	    monotonic-count: 1
+	    private-key: /path/to/priv/key
+	    pub-key-cert: /path/to/pub/key
+	    payload: u-boot.bin
+	    image-index: 1
+	    capsule: update.capsule
+	}
+	{
+	    image-guid: 4ce292da-1dd8-428d-a1c2-77743ef8b96e
+	    hardware-instance: 0
+	    payload: u-boot.itb
+	    image-index: 2
+	    capsule: update.capsule
+	}
+
+This generates a single ``update.capsule`` file containing both payloads.
+
+
 Capsule with firmware version
 *****************************
 
doc/mkeficapsule.1 +55 -0

61 lines not on this page · raw message

Signature · 1 line
2.34.1
#4 lore raw

PATCH v2 4/6 sandbox: capsule: Add a config file for generating capsules

In reply to Balaji Selvanathan

Add a config file listing the capsules to be generated through the mkeficapsule config-file parser. This is for sandbox capsule update tests.

Fix Test05, which had two identical blocks (same image-guid and image-index) that would now silently merge into an unintended 2-payload capsule under the parser's new grouping-by-filename behavior; give the second block its own index and GUID so Test05 instead demonstrates multi-payload grouping on purpose.

Add Test116 to cover a multi-payload capsule with a signed first payload and an unsigned second payload, and Test06/Test15 to cover the same raw-image update path (rather than the existing FIT-image examples), with Test06 unsigned and Test15 signing each payload independently.

---
Changes in v2:
- drop the sandbox_defconfig changes, the tests now use the config file by its fixed path, so the EFI_CAPSULE_CFG_FILE and EFI_USE_CAPSULE_CFG_FILE Kconfig symbols are not needed
- use the current SANDBOX_FIT_IMAGE_GUID for the FIT image capsules, the old GUID was left over from an earlier version of this config file

---
 .../tests/test_efi_capsule/sandbox_capsule_cfg.txt | 118 +++++++++++++++++++++
 1 file changed, 118 insertions(+)
test/py/tests/test_efi_capsule/sandbox_capsule_cfg.txt new file +118 -0
new file mode 100644
index 00000000000..4ff4eedcbe8
@@ -0,0 +1,118 @@
+{
+	image-index: 1
+	image-guid: 46610520-469E-59DC-A8DD-C11832B877EA
+	payload: u-boot_bin_env.itb
+	capsule: Test04
+
+}
+{
+	image-index: 1
+	image-guid: 058B7D83-50D5-4C47-A195-60D86AD341C4
+	payload: u-boot_bin_env.itb
+	capsule: Test05
+
+}
+{
+	image-index: 2
+	image-guid: B0ECDF61-24BC-4A61-A0A9-095A77279E84
+	payload: u-boot_bin_env.itb
+	capsule: Test05
+}
+{
+	image-index: 1
+	monotonic-count: 1
+	private-key: SIGNER.key
+	pub-key-cert: SIGNER.crt
+	image-guid: 46610520-469E-59DC-A8DD-C11832B877EA
+	payload: u-boot_bin_env.itb
+	capsule: Test13
+}
+{
+	image-index: 1
+	monotonic-count: 1
+	private-key: SIGNER2.key
+	pub-key-cert: SIGNER2.crt
+	image-guid: 46610520-469E-59DC-A8DD-C11832B877EA
+	payload: u-boot_bin_env.itb
+	capsule: Test14
+}
+{
+	image-index: 1
+	fw-version: 5
+	image-guid: 46610520-469E-59DC-A8DD-C11832B877EA
+	payload: u-boot_bin_env.itb
+	capsule: Test104
+}
+{
+	image-index: 1
+	fw-version: 2
+	image-guid: 46610520-469E-59DC-A8DD-C11832B877EA
+	payload: u-boot_bin_env.itb
+	capsule: Test105
+
+}
+{
+	image-index: 1
+	fw-version: 5
+	monotonic-count: 1
+	private-key: SIGNER.key
+	pub-key-cert: SIGNER.crt
+	image-guid: 46610520-469E-59DC-A8DD-C11832B877EA
+	payload: u-boot_bin_env.itb
+	capsule: Test114
+}
+{
+	image-index: 1
+	fw-version: 2
+	monotonic-count: 1
+	private-key: SIGNER.key
+	pub-key-cert: SIGNER.crt
+	image-guid: 46610520-469E-59DC-A8DD-C11832B877EA
+	payload: u-boot_bin_env.itb
+	capsule: Test115
+}
+{
+	image-index: 1
+	monotonic-count: 1
+	private-key: SIGNER.key
+	pub-key-cert: SIGNER.crt
+	image-guid: 46610520-469E-59DC-A8DD-C11832B877EA
+	payload: u-boot_bin_env.itb
+	capsule: Test116
+}
+{
+	image-index: 2
+	image-guid: 339B1ED4-A9C4-4A4E-A3E4-04138A91734B
+	payload: u-boot_bin_env.itb
+	capsule: Test116
+}
+{
+	image-index: 1
+	image-guid: 985F2937-7C2E-5E9A-8A5E-8E063312964B
+	payload: u-boot.bin.new
+	capsule: Test06
+}
+{
+	image-index: 2
+	image-guid: 9E339473-C2EB-530A-A69B-0CD6BBBED40E
+	payload: u-boot.env.new
+	capsule: Test06
+}
+{
+	image-index: 1
+	monotonic-count: 1
+	private-key: SIGNER.key
+	pub-key-cert: SIGNER.crt
+	image-guid: 985F2937-7C2E-5E9A-8A5E-8E063312964B
+	payload: u-boot.bin.new
+	capsule: Test15
+}
+{
+	image-index: 2
+	monotonic-count: 1
+	private-key: SIGNER.key
+	pub-key-cert: SIGNER.crt
+	image-guid: 9E339473-C2EB-530A-A69B-0CD6BBBED40E
+	payload: u-boot.env.new
+	capsule: Test15
+}
Signature · 1 line
2.34.1
#5 lore raw

PATCH v2 5/6 test: capsule: Generate capsules through config file

In reply to Balaji Selvanathan

Add logic to generate capsules through a config file while testing the EFI capsule update functionality. The sandbox variant generates its capsules by passing sandbox_capsule_cfg.txt to mkeficapsule with -f, after binman has built the FIT image the payloads refer to. The sandbox_flattree variant keeps generating them through binman, so both paths stay covered.

---
Changes in v2:
- select the config file path by board in the test setup, using a fixed path and a preprocessor define for the binman devicetree, instead of the EFI_USE_CAPSULE_CFG_FILE and EFI_CAPSULE_CFG_FILE Kconfig symbols, which are dropped.
- run mkeficapsule before the filesystem image is created, so the generated capsules end up in the image

---
 test/py/tests/test_efi_capsule/capsule_gen_binman.dts |  2 ++
 test/py/tests/test_efi_capsule/conftest.py            | 13 +++++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)
test/py/tests/test_efi_capsule/capsule_gen_binman.dts +2 -0
index 1a62c260474..11889f936d0 100644
@@ -54,6 +54,7 @@
 		};
 	};
 
+#if !defined(CAPSULE_GEN_FROM_CFG_FILE)
 	capsule1 {
 		filename = "Test04";
 		efi-capsule {
@@ -165,4 +166,5 @@
 			};
 		};
 	};
+#endif /* CAPSULE_GEN_FROM_CFG_FILE */
 };
test/py/tests/test_efi_capsule/conftest.py +11 -2
index ad0cda59ebf..601d09b7b72 100644
@@ -77,16 +77,25 @@ def efi_capsule_data(request, ubman):
 
         pythonpath = os.environ.get('PYTHONPATH', '')
         os.environ['PYTHONPATH'] = pythonpath + ':' + '%s/scripts/dtc/pylibfdt' % ubman.config.build_dir
+        # sandbox generates its capsules through the mkeficapsule config
+        # file, other variants such as sandbox_flattree use binman
+        cfg_file_gen = ubman.config.board_type == 'sandbox'
+        cpp_opts = '-DCAPSULE_GEN_FROM_CFG_FILE' if cfg_file_gen else ''
         check_call('cd %s; '
-                   'cc -E -I %s/include -x assembler-with-cpp -o capsule_gen_tmp.dts %s/test/py/tests/test_efi_capsule/capsule_gen_binman.dts; '
+                   'cc -E %s -I %s/include -x assembler-with-cpp -o capsule_gen_tmp.dts %s/test/py/tests/test_efi_capsule/capsule_gen_binman.dts; '
                    'dtc -I dts -O dtb capsule_gen_tmp.dts -o capsule_binman.dtb;'
-                   % (data_dir, ubman.config.source_dir, ubman.config.source_dir), shell=True)
+                   % (data_dir, cpp_opts, ubman.config.source_dir, ubman.config.source_dir), shell=True)
         check_call('cd %s; '
                    './tools/binman/binman --toolpath %s/tools build -u -d %s/capsule_binman.dtb -O %s -m --allow-missing -I %s -I ./board/sandbox -I ./arch/sandbox/dts'
                    % (ubman.config.source_dir, ubman.config.build_dir, data_dir, data_dir, data_dir), shell=True)
         check_call('cp %s/Test* %s' % (ubman.config.build_dir, data_dir), shell=True)
         os.environ['PYTHONPATH'] = pythonpath
 
+        if cfg_file_gen:
+            cfg_file = ubman.config.source_dir + '/test/py/tests/test_efi_capsule/sandbox_capsule_cfg.txt'
+            check_call('cd %s; %s/tools/mkeficapsule -f %s'
+                       % (data_dir, ubman.config.build_dir, cfg_file), shell=True)
+
         # Create a 16MiB partition as the EFI system partition in the disk
         # image
         fsfile = fs_helper.mk_fs(ubman.config, 'vfat', 0x1000000,
Signature · 1 line
2.34.1
#6 lore raw

PATCH v2 6/6 test: capsule: Add functional test for multi-payload capsule update

In reply to Balaji Selvanathan

Add pytest coverage that exercises a real multi-payload capsule update end-to-end: a single capsule file containing two raw-image payloads is applied and both target regions (U-Boot binary and U-Boot environment) are verified to have been updated from one capsule apply. test_efi_capsule_fw6 covers the unsigned case and test_efi_capsule_auth6 covers the signed case, where each payload in the capsule is signed independently.

---
 .../test_efi_capsule/test_capsule_firmware_raw.py  | 36 ++++++++++++++++++++++
 .../test_capsule_firmware_signed_raw.py            | 33 ++++++++++++++++++++
 2 files changed, 69 insertions(+)
test/py/tests/test_efi_capsule/test_capsule_firmware_raw.py +36 -0
index b8cb483b380..a7c2ceb421f 100644
@@ -238,3 +238,39 @@ class TestEfiCapsuleFirmwareRaw:
             check_file_removed(ubman, disk_img, capsule_files)
 
             verify_content(ubman, '100000', 'u-boot:Old')
+
+    def test_efi_capsule_fw6(
+            self, u_boot_config, ubman, efi_capsule_data):
+        """ Test Case 6
+        Update U-Boot and U-Boot environment on SPI Flash using a single
+        multi-payload capsule, raw image format
+        0x100000-0x150000: U-Boot binary (but dummy)
+        0x150000-0x200000: U-Boot environment (but dummy)
+        """
+        disk_img = efi_capsule_data
+        capsule_files = ['Test06']
+        with ubman.log.section('Test Case 6-a, before reboot'):
+            capsule_setup(ubman, disk_img, '0x0000000000000004')
+            init_content(ubman, '100000', 'u-boot.bin.old', 'Old')
+            init_content(ubman, '150000', 'u-boot.env.old', 'Old')
+            place_capsule_file(ubman, capsule_files)
+
+        capsule_early = u_boot_config.buildconfig.get(
+            'config_efi_capsule_on_disk_early')
+        capsule_auth = u_boot_config.buildconfig.get(
+            'config_efi_capsule_authenticate')
+
+        # reboot
+        ubman.restart_uboot(expect_reset = capsule_early)
+
+        with ubman.log.section('Test Case 6-b, after reboot'):
+            if not capsule_early:
+                exec_manual_update(ubman, disk_img, capsule_files)
+
+            check_file_removed(ubman, disk_img, capsule_files)
+
+            expected = 'u-boot:Old' if capsule_auth else 'u-boot:New'
+            verify_content(ubman, '100000', expected)
+
+            expected = 'u-boot-env:Old' if capsule_auth else 'u-boot-env:New'
+            verify_content(ubman, '150000', expected)
test/py/tests/test_efi_capsule/test_capsule_firmware_signed_raw.py +33 -0
index a500c499bb9..284fbf68cbe 100644
@@ -190,3 +190,36 @@ class TestEfiCapsuleFirmwareSignedRaw():
             check_file_removed(ubman, disk_img, capsule_files)
 
             verify_content(ubman, '100000', 'u-boot:Old')
+
+    def test_efi_capsule_auth6(
+            self, u_boot_config, ubman, efi_capsule_data):
+        """Test Case 6 - Update U-Boot and U-Boot environment on SPI
+        Flash using a single signed multi-payload capsule, raw image
+        format
+        0x100000-0x150000: U-Boot binary (but dummy)
+        0x150000-0x200000: U-Boot environment (but dummy)
+
+        Each payload in the multi-payload capsule is signed
+        independently. If both signatures are valid, the authentication
+        should pass and both firmware images should be updated.
+        """
+        disk_img = efi_capsule_data
+        capsule_files = ['Test15']
+        with ubman.log.section('Test Case 6-a, before reboot'):
+            capsule_setup(ubman, disk_img, '0x0000000000000004')
+            init_content(ubman, '100000', 'u-boot.bin.old', 'Old')
+            init_content(ubman, '150000', 'u-boot.env.old', 'Old')
+            place_capsule_file(ubman, capsule_files)
+
+        do_reboot_dtb_specified(u_boot_config, ubman, 'test_sig.dtb')
+
+        capsule_early = u_boot_config.buildconfig.get(
+            'config_efi_capsule_on_disk_early')
+        with ubman.log.section('Test Case 6-b, after reboot'):
+            if not capsule_early:
+                exec_manual_update(ubman, disk_img, capsule_files)
+
+            check_file_removed(ubman, disk_img, capsule_files)
+
+            verify_content(ubman, '100000', 'u-boot:New')
+            verify_content(ubman, '150000', 'u-boot-env:New')
Signature · 1 line
2.34.1