mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-06-02 09:46:37 +03:00
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
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 */
|
||||
|
||||
12
cmd/part.c
12
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"
|
||||
|
||||
@@ -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;"
|
||||
|
||||
@@ -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, ....)
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -396,6 +396,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
|
||||
|
||||
@@ -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 \
|
||||
|
||||
@@ -243,6 +243,39 @@ int fwu_sync_mdata(struct fwu_mdata *mdata, int part)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
||||
@@ -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},
|
||||
|
||||
@@ -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
|
||||
|
||||
227
test/cmd/part.c
Normal file
227
test/cmd/part.c
Normal file
@@ -0,0 +1,227 @@
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* Test for part command
|
||||
*
|
||||
* Copyright (C) 2026 Amarula Solutions
|
||||
* Written by Dario Binacchi <dario.binacchi@amarulasolutions.com>
|
||||
*/
|
||||
|
||||
#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);
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user