summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rini <[email protected]>2026-05-13 07:53:21 -0600
committerTom Rini <[email protected]>2026-05-13 07:54:10 -0600
commit944427c3da6591f7971f48d91d69b60cbff3db12 (patch)
treec0166af53ee938843a09d5179c46ba08367bee79
parent36d4c653580824b16574560b21d4401614d8b68e (diff)
parent612256838acec75407b1a268459c3a9dbb63c7f9 (diff)
Merge tag 'u-boot-stm32-20260512' of https://source.denx.de/u-boot/custodians/u-boot-stm
CI: https://source.denx.de/u-boot/custodians/u-boot-stm/-/pipelines/30081 - reset: stm32: Fix compilation error - Remove remaining non-existant STM32_RESET flag - configs: stm32mp13: Add SPI-NAND UBI boot support - Support metadata-driven A/B boot for STM32MP25
-rw-r--r--arch/arm/mach-stm32mp/Kconfig1
-rw-r--r--board/st/stm32mp2/stm32mp2.c32
-rw-r--r--cmd/part.c12
-rw-r--r--doc/README.gpt2
-rw-r--r--doc/usage/cmd/part.rst6
-rw-r--r--drivers/reset/stm32/stm32-reset-mp21.c2
-rw-r--r--include/configs/stm32mp13_common.h13
-rw-r--r--include/configs/stm32mp25_st_common.h15
-rw-r--r--include/fwu.h11
-rw-r--r--include/part_efi.h3
-rw-r--r--lib/fwu_updates/fwu.c33
-rw-r--r--lib/uuid.c1
-rw-r--r--test/cmd/Makefile1
-rw-r--r--test/cmd/part.c227
-rw-r--r--test/dm/fwu_mdata.c48
-rw-r--r--test/dm/part.c53
16 files changed, 450 insertions, 10 deletions
diff --git a/arch/arm/mach-stm32mp/Kconfig b/arch/arm/mach-stm32mp/Kconfig
index b64965d204e..39f25869c1d 100644
--- a/arch/arm/mach-stm32mp/Kconfig
+++ b/arch/arm/mach-stm32mp/Kconfig
@@ -114,7 +114,6 @@ config STM32MP23X
select OF_BOARD
select PINCTRL_STM32
select STM32_RCC
- select STM32_RESET
select STM32_SERIAL
select STM32MP_TAMP_NVMEM
select SYS_ARCH_TIMER
diff --git a/board/st/stm32mp2/stm32mp2.c b/board/st/stm32mp2/stm32mp2.c
index 43bc583378e..5cbbbc322a3 100644
--- a/board/st/stm32mp2/stm32mp2.c
+++ b/board/st/stm32mp2/stm32mp2.c
@@ -208,4 +208,36 @@ void fwu_plat_get_bootidx(uint *boot_idx)
*boot_idx = (readl(TAMP_FWU_BOOT_INFO_REG) >>
TAMP_FWU_BOOT_IDX_OFFSET) & TAMP_FWU_BOOT_IDX_MASK;
}
+
+int fwu_platform_hook(struct udevice *dev, struct fwu_data *data)
+{
+ uint boot_idx;
+ efi_guid_t boot_uuid, root_uuid;
+ const efi_guid_t boot_type_guid = PARTITION_XBOOTLDR;
+ const efi_guid_t root_type_guid =
+ PARTITION_LINUX_FILE_SYSTEM_DATA_GUID;
+ char uuidbuf[UUID_STR_LEN + 1];
+ int retb, retr;
+
+ fwu_plat_get_bootidx(&boot_idx);
+
+ retb = fwu_mdata_get_image_guid(&boot_uuid, &boot_type_guid, boot_idx);
+ retr = fwu_mdata_get_image_guid(&root_uuid, &root_type_guid, boot_idx);
+
+ if (!retb && !retr) {
+ uuid_bin_to_str(boot_uuid.b, uuidbuf, UUID_STR_FORMAT_GUID);
+ env_set("boot_partuuid", uuidbuf);
+
+ uuid_bin_to_str(root_uuid.b, uuidbuf, UUID_STR_FORMAT_GUID);
+ env_set("root_partuuid", uuidbuf);
+ } else if (!retb && retr) {
+ log_warning("%s: found boot GUID but missing root GUID (%d)\n",
+ __func__, retr);
+ } else if (!retr && retb) {
+ log_warning("%s: found root GUID but missing boot GUID (%d)\n",
+ __func__, retb);
+ }
+
+ return 0;
+}
#endif /* CONFIG_FWU_MULTI_BANK_UPDATE */
diff --git a/cmd/part.c b/cmd/part.c
index 5e520d707f3..3191d5861fd 100644
--- a/cmd/part.c
+++ b/cmd/part.c
@@ -144,6 +144,10 @@ static int do_part_info(int argc, char *const argv[], enum cmd_part_info param)
err = part_get_info(desc, part, &info);
if (err)
return 1;
+ } else if (uuid_str_valid(argv[2])) {
+ part = part_get_info_by_uuid(desc, argv[2], &info);
+ if (part < 0)
+ return 1;
} else {
part = part_get_info_by_name(desc, argv[2], &info);
if (part < 0)
@@ -517,13 +521,13 @@ U_BOOT_CMD(
" flags can be -bootable (list only bootable partitions)\n"
"part start <interface> <dev> <part> <varname>\n"
" - set environment variable to the start of the partition (in blocks)\n"
- " part can be either partition number or partition name\n"
+ " part can be either partition number, UUID or name\n"
"part size <interface> <dev> <part> <varname>\n"
" - set environment variable to the size of the partition (in blocks)\n"
- " part can be either partition number or partition name\n"
+ " part can be either partition number, UUID or name\n"
"part number <interface> <dev> <part> <varname>\n"
- " - set environment variable to the partition number using the partition name\n"
- " part must be specified as partition name\n"
+ " - set environment variable to the partition number using the partition UUID or name\n"
+ " part must be specified as partition UUID or name\n"
"part name <interface> <dev> <part> <varname>\n"
" - set environment variable to the partition name using the partition number\n"
" part must be specified as partition number\n"
diff --git a/doc/README.gpt b/doc/README.gpt
index 386ac2e0fc8..a6e1fd7ce8d 100644
--- a/doc/README.gpt
+++ b/doc/README.gpt
@@ -286,6 +286,8 @@ Some strings can be also used at the place of known GUID :
(E6D6D379-F507-44C2-A23C-238F2A3DF928)
"u-boot-env" = PARTITION_U_BOOT_ENVIRONMENT
(3DE21764-95BD-54BD-A5C3-4ABE786F38A8)
+ "xbootldr" = PARTITION_XBOOTLDR
+ (BC13C2FF-59E6-4262-A352-B275FD6F7172)
"uuid_disk=...;name=u-boot,size=60MiB,uuid=...;
name=kernel,size=60MiB,uuid=...,type=linux;"
diff --git a/doc/usage/cmd/part.rst b/doc/usage/cmd/part.rst
index b91f6541f7f..a0e7be08a9a 100644
--- a/doc/usage/cmd/part.rst
+++ b/doc/usage/cmd/part.rst
@@ -52,7 +52,7 @@ The 'part list' command prints or sets an environment variable to the list of pa
an optional environment variable to store the list of partitions value into.
The 'part start' command sets an environment variable to the start of the partition (in blocks),
-part can be either partition number or partition name.
+part can be either partition number, partition UUID or partition name.
interface
interface for accessing the block device (mmc, sata, scsi, usb, ....)
@@ -64,7 +64,7 @@ part can be either partition number or partition name.
a variable to store the current start of the partition value into.
The 'part size' command sets an environment variable to the size of the partition (in blocks),
-part can be either partition number or partition name.
+part can be either partition number, partition UUID or partition name.
interface
interface for accessing the block device (mmc, sata, scsi, usb, ....)
@@ -76,7 +76,7 @@ part can be either partition number or partition name.
a variable to store the current size of the partition value into.
The 'part number' command sets an environment variable to the partition number using the partition name,
-part must be specified as partition name.
+part must be specified as partition UUID or partition name.
interface
interface for accessing the block device (mmc, sata, scsi, usb, ....)
diff --git a/drivers/reset/stm32/stm32-reset-mp21.c b/drivers/reset/stm32/stm32-reset-mp21.c
index 7d169d7582f..0e92b0f5d5d 100644
--- a/drivers/reset/stm32/stm32-reset-mp21.c
+++ b/drivers/reset/stm32/stm32-reset-mp21.c
@@ -5,7 +5,7 @@
*/
#include <dm.h>
-#include <stm32-reset-core.h>
+#include "stm32-reset-core.h"
#include <stm32mp21_rcc.h>
#include <dt-bindings/reset/st,stm32mp21-rcc.h>
diff --git a/include/configs/stm32mp13_common.h b/include/configs/stm32mp13_common.h
index 3e3f49abae0..e707b146f90 100644
--- a/include/configs/stm32mp13_common.h
+++ b/include/configs/stm32mp13_common.h
@@ -33,6 +33,12 @@
#define BOOT_TARGET_MMC1(func)
#endif
+#ifdef CONFIG_CMD_UBIFS
+#define BOOT_TARGET_UBIFS(func) func(UBIFS, ubifs, 0, UBI, boot)
+#else
+#define BOOT_TARGET_UBIFS(func)
+#endif
+
#ifdef CONFIG_CMD_USB
#define BOOT_TARGET_USB(func) func(USB, usb, 0)
#else
@@ -41,12 +47,14 @@
#define BOOT_TARGET_DEVICES(func) \
BOOT_TARGET_MMC1(func) \
+ BOOT_TARGET_UBIFS(func) \
BOOT_TARGET_MMC0(func) \
BOOT_TARGET_USB(func)
/*
* default bootcmd for stm32mp13:
* for serial/usb: execute the stm32prog command
+ * for nand or spi-nand boot, distro boot with ubifs on UBI partition
* for mmc boot (eMMC, SD card), distro boot on the same mmc device
*/
#define STM32MP_BOOTCMD "bootcmd_stm32mp=" \
@@ -56,7 +64,10 @@
"else " \
"run env_check;" \
"if test ${boot_device} = mmc;" \
- "then env set boot_targets \"mmc${boot_instance}\"; fi;" \
+ "then env set boot_targets \"mmc${boot_instance}\"; fi; " \
+ "if test ${boot_device} = nand ||" \
+ " test ${boot_device} = spi-nand ;" \
+ "then env set boot_targets ubifs0; fi;" \
"run distro_bootcmd;" \
"fi;\0"
diff --git a/include/configs/stm32mp25_st_common.h b/include/configs/stm32mp25_st_common.h
index cb679eb1be2..0b0267ae99b 100644
--- a/include/configs/stm32mp25_st_common.h
+++ b/include/configs/stm32mp25_st_common.h
@@ -8,7 +8,22 @@
#ifndef __CONFIG_STM32MP25_ST_COMMON_H__
#define __CONFIG_STM32MP25_ST_COMMON_H__
+#ifdef CONFIG_FWU_MULTI_BANK_UPDATE
+#define SCAN_DEV_FOR_BOOT_PARTS \
+ "setenv devplist; " \
+ "env exists boot_partuuid && " \
+ "part number ${devtype} ${devnum} ${boot_partuuid} devplist; " \
+ "env exists devplist || " \
+ "part list ${devtype} ${devnum} -bootable devplist; "
+
+#define ST_STM32MP25_FWU_ENV \
+ "altbootcmd=${bootcmd}\0"
+#else
+#define ST_STM32MP25_FWU_ENV
+#endif
+
#define STM32MP_BOARD_EXTRA_ENV \
+ ST_STM32MP25_FWU_ENV \
"usb_pgood_delay=2000\0" \
"console=ttySTM0\0"
diff --git a/include/fwu.h b/include/fwu.h
index 9cee8fb085c..68a51fb4296 100644
--- a/include/fwu.h
+++ b/include/fwu.h
@@ -397,6 +397,17 @@ void fwu_populate_mdata_image_info(struct fwu_data *data);
int fwu_get_mdata_size(uint32_t *mdata_size);
/**
+ * fwu_mdata_get_image_guid() - Get image GUID for a type and bank
+ * @image_guid: Pointer to be filled with the found image GUID
+ * @image_type_guid: Pointer to the image type GUID to search for
+ * @bank_index: Index of the bank
+ *
+ * Return: 0 if OK, -ve on error
+ */
+int fwu_mdata_get_image_guid(efi_guid_t *image_guid,
+ const efi_guid_t *image_type_guid, u32 bank_index);
+
+/**
* fwu_state_machine_updates() - Update FWU state of the platform
* @state: FWU bank state
* @update_index: Bank number to which images have been updated
diff --git a/include/part_efi.h b/include/part_efi.h
index 2cea5088046..5713b3018f4 100644
--- a/include/part_efi.h
+++ b/include/part_efi.h
@@ -60,6 +60,9 @@
#define PARTITION_U_BOOT_ENVIRONMENT \
EFI_GUID( 0x3de21764, 0x95bd, 0x54bd, \
0xa5, 0xc3, 0x4a, 0xbe, 0x78, 0x6f, 0x38, 0xa8)
+#define PARTITION_XBOOTLDR \
+ EFI_GUID( 0xbc13c2ff, 0x59e6, 0x4262, \
+ 0xa3, 0x52, 0xb2, 0x75, 0xfd, 0x6f, 0x71, 0x72)
/* Special ChromiumOS things */
#define PARTITION_CROS_KERNEL \
diff --git a/lib/fwu_updates/fwu.c b/lib/fwu_updates/fwu.c
index e82600a29a4..2b11e5da061 100644
--- a/lib/fwu_updates/fwu.c
+++ b/lib/fwu_updates/fwu.c
@@ -244,6 +244,39 @@ int fwu_sync_mdata(struct fwu_mdata *mdata, int part)
}
/**
+ * fwu_mdata_get_image_guid() - Get image GUID for a type and bank
+ * @image_guid: Pointer to be filled with the found image GUID
+ * @image_type_guid: Pointer to the image type GUID to search for
+ * @bank_index: Index of the bank
+ *
+ * Return: 0 if OK, -ve on error
+ */
+int fwu_mdata_get_image_guid(efi_guid_t *image_guid,
+ const efi_guid_t *image_type_guid, u32 bank_index)
+{
+ struct fwu_data *data = &g_fwu_data;
+ struct fwu_image_entry *image;
+ int i;
+
+ if (bank_index >= data->num_banks)
+ return -EINVAL;
+
+ for (i = 0; i < data->num_images; i++) {
+ image = &data->fwu_images[i];
+
+ if (!guidcmp(image_type_guid, &image->image_type_guid)) {
+ struct fwu_image_bank_info *bank;
+
+ bank = &image->img_bank_info[bank_index];
+ guidcpy(image_guid, &bank->image_guid);
+ return 0;
+ }
+ }
+
+ return -ENOENT;
+}
+
+/**
* fwu_mdata_copies_allocate() - Allocate memory for metadata
* @mdata_size: Size of the metadata structure
*
diff --git a/lib/uuid.c b/lib/uuid.c
index 3a666d0430d..d7c164ea06b 100644
--- a/lib/uuid.c
+++ b/lib/uuid.c
@@ -86,6 +86,7 @@ static const struct {
{"swap", NULL, PARTITION_LINUX_SWAP_GUID},
{"lvm", NULL, PARTITION_LINUX_LVM_GUID},
{"u-boot-env", NULL, PARTITION_U_BOOT_ENVIRONMENT},
+ {"xbootldr", NULL, PARTITION_XBOOTLDR},
{"cros-kern", NULL, PARTITION_CROS_KERNEL},
{"cros-root", NULL, PARTITION_CROS_ROOT},
{"cros-fw", NULL, PARTITION_CROS_FIRMWARE},
diff --git a/test/cmd/Makefile b/test/cmd/Makefile
index 5f2815b1bb6..8d6932f1176 100644
--- a/test/cmd/Makefile
+++ b/test/cmd/Makefile
@@ -26,6 +26,7 @@ obj-$(CONFIG_CMD_LOADM) += loadm.o
obj-$(CONFIG_CMD_MEMINFO) += meminfo.o
obj-$(CONFIG_CMD_MEMORY) += mem_copy.o
obj-$(CONFIG_CMD_MEM_SEARCH) += mem_search.o
+obj-$(CONFIG_CMD_PART) += part.o
ifdef CONFIG_CMD_PCI
obj-$(CONFIG_CMD_PCI_MPS) += pci_mps.o
endif
diff --git a/test/cmd/part.c b/test/cmd/part.c
new file mode 100644
index 00000000000..e0149011476
--- /dev/null
+++ b/test/cmd/part.c
@@ -0,0 +1,227 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Test for part command
+ *
+ * Copyright (C) 2026 Amarula Solutions
+ * Written by Dario Binacchi <[email protected]>
+ */
+
+#include <command.h>
+#include <dm.h>
+#include <env.h>
+#include <part.h>
+#include <vsprintf.h>
+#include <dm/test.h>
+#include <test/cmd.h>
+#include <test/test.h>
+#include <test/ut.h>
+
+static struct disk_partition gpt_parts[] = {
+ {
+ .start = 48,
+ .size = 1,
+ .name = "test1",
+ .uuid = "c5bce7a2-03f0-4d03-9048-01ff23b9d527",
+ },
+ {
+ .start = 49,
+ .size = 2,
+ .name = "test2",
+ .uuid = "9df346e8-2c53-4cd8-b9ac-3af83f9a9b74",
+ },
+};
+
+static char disk_guid[UUID_STR_LEN + 1] =
+ "8d60b397-1bb6-4d33-80ee-b1587d24c2f8";
+
+static int setup_gpt_partitions(struct unit_test_state *uts,
+ unsigned int mmc_dev_num)
+{
+ struct blk_desc *mmc_dev_desc;
+ char dev_str[10];
+ int i, ret;
+
+ if (!CONFIG_IS_ENABLED(MMC))
+ return -EAGAIN;
+
+ snprintf(dev_str, sizeof(dev_str), "%u", mmc_dev_num);
+
+ ret = blk_get_device_by_str("mmc", dev_str, &mmc_dev_desc);
+ if (ret == -ENODEV)
+ return -EAGAIN;
+
+ ut_asserteq(mmc_dev_num, ret);
+
+ if (CONFIG_IS_ENABLED(RANDOM_UUID)) {
+ for (i = 0; i < ARRAY_SIZE(gpt_parts); i++)
+ gen_rand_uuid_str(gpt_parts[i].uuid,
+ UUID_STR_FORMAT_STD);
+
+ gen_rand_uuid_str(disk_guid, UUID_STR_FORMAT_STD);
+ }
+
+ ut_assertok(gpt_restore(mmc_dev_desc, disk_guid, gpt_parts,
+ ARRAY_SIZE(gpt_parts)));
+ return 0;
+}
+
+static int cmd_test_part_number(struct unit_test_state *uts)
+{
+ unsigned int mmc_dev_num = 2;
+ char expected[10];
+ int i, ret;
+
+ ret = setup_gpt_partitions(uts, mmc_dev_num);
+ if (ret == -EAGAIN)
+ return ret;
+
+ ut_assertok(ret);
+
+ for (i = 0; i < ARRAY_SIZE(gpt_parts); i++) {
+ env_set("partnum", NULL);
+ ut_assertok(run_commandf("part number mmc %u %s partnum",
+ mmc_dev_num, gpt_parts[i].name));
+ snprintf(expected, sizeof(expected), "0x%x", i + 1);
+ ut_asserteq_str(expected, env_get("partnum"));
+ }
+
+ env_set("partnum", NULL);
+ ut_asserteq(1, run_commandf("part number mmc %u bogus partnum",
+ mmc_dev_num));
+ ut_assertnull(env_get("partnum"));
+
+ for (i = 0; i < ARRAY_SIZE(gpt_parts); i++) {
+ env_set("partnum", NULL);
+ ut_assertok(run_commandf("part number mmc %u %s partnum",
+ mmc_dev_num, gpt_parts[i].uuid));
+ snprintf(expected, sizeof(expected), "0x%x", i + 1);
+ ut_asserteq_str(expected, env_get("partnum"));
+ }
+
+ env_set("partnum", NULL);
+ ut_asserteq(1, run_commandf("part number mmc %u %s partnum",
+ mmc_dev_num,
+ "00000000-0000-0000-0000-000000000000"));
+ ut_assertnull(env_get("partnum"));
+
+ return 0;
+}
+CMD_TEST(cmd_test_part_number, UTF_CONSOLE);
+
+static int cmd_test_part_start(struct unit_test_state *uts)
+{
+ unsigned int mmc_dev_num = 2;
+ char expected[32];
+ int i, ret;
+
+ ret = setup_gpt_partitions(uts, mmc_dev_num);
+ if (ret == -EAGAIN)
+ return ret;
+
+ ut_assertok(ret);
+
+ for (i = 0; i < ARRAY_SIZE(gpt_parts); i++) {
+ env_set("partstart", NULL);
+ ut_assertok(run_commandf("part start mmc %u %d partstart",
+ mmc_dev_num, i + 1));
+ snprintf(expected, sizeof(expected), "%lx",
+ (unsigned long)gpt_parts[i].start);
+ ut_asserteq_str(expected, env_get("partstart"));
+ }
+
+ env_set("partstart", NULL);
+ ut_asserteq(1, run_commandf("part start mmc %u 3 partstart",
+ mmc_dev_num));
+ ut_assertnull(env_get("partstart"));
+
+ for (i = 0; i < ARRAY_SIZE(gpt_parts); i++) {
+ env_set("partstart", NULL);
+ ut_assertok(run_commandf("part start mmc %u %s partstart",
+ mmc_dev_num, gpt_parts[i].name));
+ snprintf(expected, sizeof(expected), "%lx",
+ (unsigned long)gpt_parts[i].start);
+ ut_asserteq_str(expected, env_get("partstart"));
+ }
+
+ env_set("partstart", NULL);
+ ut_asserteq(1, run_commandf("part start mmc %u bogus partstart",
+ mmc_dev_num));
+ ut_assertnull(env_get("partstart"));
+
+ for (i = 0; i < ARRAY_SIZE(gpt_parts); i++) {
+ env_set("partstart", NULL);
+ ut_assertok(run_commandf("part start mmc %u %s partstart",
+ mmc_dev_num, gpt_parts[i].uuid));
+ snprintf(expected, sizeof(expected), "%lx",
+ (unsigned long)gpt_parts[i].start);
+ ut_asserteq_str(expected, env_get("partstart"));
+ }
+
+ env_set("partstart", NULL);
+ ut_asserteq(1, run_commandf("part start mmc %u %s partstart",
+ mmc_dev_num,
+ "00000000-0000-0000-0000-000000000000"));
+ ut_assertnull(env_get("partstart"));
+
+ return 0;
+}
+CMD_TEST(cmd_test_part_start, UTF_CONSOLE);
+
+static int cmd_test_part_size(struct unit_test_state *uts)
+{
+ unsigned int mmc_dev_num = 2;
+ char expected[32];
+ int i, ret;
+
+ ret = setup_gpt_partitions(uts, mmc_dev_num);
+ if (ret == -EAGAIN)
+ return ret;
+
+ ut_assertok(ret);
+
+ for (i = 0; i < ARRAY_SIZE(gpt_parts); i++) {
+ env_set("partsize", NULL);
+ ut_assertok(run_commandf("part size mmc %u %d partsize",
+ mmc_dev_num, i + 1));
+ snprintf(expected, sizeof(expected), "%lx",
+ (unsigned long)gpt_parts[i].size);
+ ut_asserteq_str(expected, env_get("partsize"));
+ }
+
+ env_set("partsize", NULL);
+ ut_asserteq(1, run_commandf("part size mmc %u 3 partsize",
+ mmc_dev_num));
+ ut_assertnull(env_get("partsize"));
+
+ for (i = 0; i < ARRAY_SIZE(gpt_parts); i++) {
+ env_set("partsize", NULL);
+ ut_assertok(run_commandf("part size mmc %u %s partsize",
+ mmc_dev_num, gpt_parts[i].name));
+ snprintf(expected, sizeof(expected), "%lx",
+ (unsigned long)gpt_parts[i].size);
+ ut_asserteq_str(expected, env_get("partsize"));
+ }
+
+ env_set("partsize", NULL);
+ ut_asserteq(1, run_commandf("part size mmc %u bogus partsize",
+ mmc_dev_num));
+ ut_assertnull(env_get("partsize"));
+
+ for (i = 0; i < ARRAY_SIZE(gpt_parts); i++) {
+ env_set("partsize", NULL);
+ ut_assertok(run_commandf("part size mmc %u %s partsize",
+ mmc_dev_num, gpt_parts[i].uuid));
+ snprintf(expected, sizeof(expected), "%lx",
+ (unsigned long)gpt_parts[i].size);
+ ut_asserteq_str(expected, env_get("partsize"));
+ }
+
+ env_set("partsize", NULL);
+ ut_asserteq(1, run_commandf("part size mmc %u %s partsize",
+ mmc_dev_num,
+ "00000000-0000-0000-0000-000000000000"));
+ ut_assertnull(env_get("partsize"));
+
+ return 0;
+}
+CMD_TEST(cmd_test_part_size, UTF_CONSOLE);
diff --git a/test/dm/fwu_mdata.c b/test/dm/fwu_mdata.c
index cfe543d8a23..8624ccf61f7 100644
--- a/test/dm/fwu_mdata.c
+++ b/test/dm/fwu_mdata.c
@@ -143,3 +143,51 @@ static int dm_test_fwu_mdata_write(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_fwu_mdata_write, UTF_SCAN_FDT);
+
+static int dm_test_fwu_mdata_get_image_guid(struct unit_test_state *uts)
+{
+ efi_guid_t image_type_guid =
+ EFI_GUID(0x09d7cf52, 0x0720, 0x4710, \
+ 0x91, 0xd1, 0x08, 0x46, 0x9b, 0x7f, 0xe9, 0xc8);
+ efi_guid_t bank_0_image_guid =
+ EFI_GUID(0x10057a86, 0xdaf1, 0x4f93, \
+ 0xba, 0x7f, 0xb1, 0x95, 0xf7, 0xfa, 0x41, 0x70);
+ efi_guid_t bank_1_image_guid =
+ EFI_GUID(0xdb62ed3e, 0x6237, 0x4fb4, \
+ 0x80, 0xc4, 0x1b, 0x74, 0xd8, 0x46, 0xa8, 0xe7);
+ efi_guid_t wrong_image_type_guid =
+ EFI_GUID(0x12345678, 0x1302, 0x133f, \
+ 0x18, 0x0a, 0x14, 0x05, 0x18, 0x05, 0x14, 0x0b);
+ struct udevice *dev;
+ efi_guid_t image_guid;
+
+ ut_assertok(setup_blk_device(uts));
+ ut_assertok(populate_mmc_disk_image(uts));
+ ut_assertok(write_mmc_blk_device(uts));
+
+ /*
+ * Trigger lib/fwu_updates/fwu.c fwu_boottime_checks()
+ * to populate g_dev global pointer in that library.
+ */
+ ut_assertok(event_notify_null(EVT_POST_PREBOOT));
+
+ ut_assertok(uclass_first_device_err(UCLASS_FWU_MDATA, &dev));
+
+ ut_assertok(fwu_init());
+
+ ut_assertok(fwu_mdata_get_image_guid(&image_guid, &image_type_guid, 0));
+ ut_assertok(guidcmp(&image_guid, &bank_0_image_guid));
+
+ ut_assertok(fwu_mdata_get_image_guid(&image_guid, &image_type_guid, 1));
+ ut_assertok(guidcmp(&image_guid, &bank_1_image_guid));
+
+ ut_asserteq(-EINVAL, fwu_mdata_get_image_guid(&image_guid,
+ &image_type_guid, 2));
+
+ ut_asserteq(-ENOENT, fwu_mdata_get_image_guid(&image_guid,
+ &wrong_image_type_guid,
+ 0));
+
+ return 0;
+}
+DM_TEST(dm_test_fwu_mdata_get_image_guid, UTF_SCAN_FDT);
diff --git a/test/dm/part.c b/test/dm/part.c
index caae23bd4aa..ad37d7f406f 100644
--- a/test/dm/part.c
+++ b/test/dm/part.c
@@ -195,3 +195,56 @@ static int dm_test_part_get_info_by_type(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_part_get_info_by_type, UTF_SCAN_PDATA | UTF_SCAN_FDT);
+
+static int dm_test_part_get_info_by_uuid(struct unit_test_state *uts)
+{
+ struct disk_partition parts[] = {
+ {
+ .start = 48,
+ .size = 1,
+ .name = "test1",
+ .uuid = "c5bce7a2-03f0-4d03-9048-01ff23b9d527",
+ },
+ {
+ .start = 49,
+ .size = 1,
+ .name = "test2",
+ .uuid = "9df346e8-2c53-4cd8-b9ac-3af83f9a9b74",
+ },
+ };
+ char disk_guid[UUID_STR_LEN + 1] =
+ "8d60b397-1bb6-4d33-80ee-b1587d24c2f8";
+ struct blk_desc *mmc_dev_desc;
+ struct disk_partition info;
+ int part, i;
+
+ ut_asserteq(2, blk_get_device_by_str("mmc", "2", &mmc_dev_desc));
+
+ if (CONFIG_IS_ENABLED(RANDOM_UUID)) {
+ for (i = 0; i < ARRAY_SIZE(parts); i++)
+ gen_rand_uuid_str(parts[i].uuid, UUID_STR_FORMAT_STD);
+
+ gen_rand_uuid_str(disk_guid, UUID_STR_FORMAT_STD);
+ }
+
+ ut_assertok(gpt_restore(mmc_dev_desc, disk_guid, parts,
+ ARRAY_SIZE(parts)));
+
+ for (i = 0; i < ARRAY_SIZE(parts); i++) {
+ part = part_get_info_by_uuid(mmc_dev_desc, parts[i].uuid,
+ &info);
+
+ ut_asserteq(i + 1, part);
+ ut_asserteq_str(parts[i].name, info.name);
+ ut_asserteq(parts[i].start, info.start);
+ ut_asserteq(parts[i].size, info.size);
+ }
+
+ part = part_get_info_by_uuid(mmc_dev_desc,
+ "00000000-0000-0000-0000-000000000000",
+ &info);
+ ut_assert(part < 0);
+
+ return 0;
+}
+DM_TEST(dm_test_part_get_info_by_uuid, UTF_SCAN_PDATA | UTF_SCAN_FDT);