summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-07-15 21:38:47 -0600
committerBin Meng <bmeng@tinylab.org>2023-07-17 17:12:06 +0800
commit125194e6a136f2a3ef49d443f139b44a04e1bb9e (patch)
tree3c8948421454cfa9b2f1bfae919aa78fdc02ddfd /cmd
parentb279f5170a807a87a5726bcbeb0bc98937102eee (diff)
downloadu-boot-125194e6a136f2a3ef49d443f139b44a04e1bb9e.tar.gz
u-boot-125194e6a136f2a3ef49d443f139b44a04e1bb9e.tar.bz2
u-boot-125194e6a136f2a3ef49d443f139b44a04e1bb9e.zip
part: Allow setting the partition-table type
Some devices have multiple partition types available on the same media. It is sometimes useful to see these to check that everything is working correctly. Provide a way to manually set the partition-table type, avoiding the auto-detection process. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/part.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/cmd/part.c b/cmd/part.c
index 28f2b7ff9b..0ce190005d 100644
--- a/cmd/part.c
+++ b/cmd/part.c
@@ -182,6 +182,36 @@ static int do_part_number(int argc, char *const argv[])
return do_part_info(argc, argv, CMD_PART_INFO_NUMBER);
}
+static int do_part_set(int argc, char *const argv[])
+{
+ const char *devname, *partstr, *typestr;
+ struct blk_desc *desc;
+ int dev;
+
+ if (argc < 3)
+ return CMD_RET_USAGE;
+
+ /* Look up the device */
+ devname = argv[0];
+ partstr = argv[1];
+ typestr = argv[2];
+ dev = blk_get_device_by_str(devname, partstr, &desc);
+ if (dev < 0) {
+ printf("** Bad device specification %s %s **\n", devname,
+ partstr);
+ return CMD_RET_FAILURE;
+ }
+
+ desc->part_type = part_get_type_by_name(typestr);
+ if (!desc->part_type) {
+ printf("Unknown partition type '%s'\n", typestr);
+ return CMD_RET_FAILURE;
+ }
+ part_print(desc);
+
+ return 0;
+}
+
#ifdef CONFIG_PARTITION_TYPE_GUID
static int do_part_type(int argc, char *const argv[])
{
@@ -245,6 +275,8 @@ static int do_part(struct cmd_tbl *cmdtp, int flag, int argc,
return do_part_number(argc - 2, argv + 2);
else if (!strcmp(argv[1], "types"))
return do_part_types(argc - 2, argv + 2);
+ else if (!strcmp(argv[1], "set"))
+ return do_part_set(argc - 2, argv + 2);
#ifdef CONFIG_PARTITION_TYPE_GUID
else if (!strcmp(argv[1], "type"))
return do_part_type(argc - 2, argv + 2);
@@ -279,6 +311,8 @@ U_BOOT_CMD(
#endif
"part type <interface> <dev>:<part> <varname>\n"
" - set environment variable to partition type\n"
+ "part set <interface> <dev> type\n"
+ " - set partition type for a device\n"
"part types\n"
" - list supported partition table types"
);