Add partition type GUID support for environment
v3 cover Add partition type GUID support for environment
This series adds support for locating partitions using GPT partition type GUID instead of unique partition UUID. This enables the saveenv command to work with partitions identified by their type rather than unique identifiers, providing flexibility for systems where partition UUIDs may vary across devices but types remain constant.
Patch 1 adds part_get_info_by_type_guid() function support Patch 2 adds scsi_get_blk_by_type_guid() function support Patch 3 adds support for partition type GUID based environment Patch 4 enables partition type GUID configs for QCM6490 and QCS615 Patch 5 adds unit test for the partition type GUID lookup functionality
---
Changes in v3:
- Addressed minor corrections in Patch 1 in part_get_info_by_type_guid function
- Refactor env_scsi_get_part and env_scsi_load functions based
on the choice configs in Patch 3
- Add unit test for the partition type GUID lookup functionality in Patch 5
- Link to v2: https://lore.kernel.org/u-boot/[email protected]/
Changes in v2:
- Compute blk_find_max_devnum(UCLASS_SCSI) only once in scsi_get_blk_by_type_guid()
- Introduce a Kconfig choice config to select between UUID-based
and type GUID-based partition lookup methods.
- Enable above new config in qcom_qcs615_defconfig and qcm6490_defconfig
- Link to v1: https://lore.kernel.org/u-boot/[email protected]/
---
Balaji Selvanathan (5):
disk: Add partition lookup by type GUID functionality
scsi: Add partition lookup by type GUID for SCSI devices
env: scsi: Add support for partition type GUID based environment
configs: Enable partition type GUID for QCM6490 and QCS615 boards
test: dm: Add partition type GUID lookup test
configs/qcm6490_defconfig | 5 +++++ configs/qcom_qcs615_defconfig | 5 +++++ disk/part.c | 37 +++++++++++++++++++++++++++++++ drivers/scsi/scsi-uclass.c | 28 ++++++++++++++++++++++-- env/Kconfig | 51 ++++++++++++++++++++++++++++++++++++------- env/scsi.c | 45 +++++++++++++++++++++++--------------- include/part.h | 21 ++++++++++++++++++ include/scsi.h | 11 ++++++++++ test/dm/part.c | 48 ++++++++++++++++++++++++++++++++++++++++ 9 files changed, 223 insertions(+), 28 deletions(-)
---
base-commit: e3405917a1806971d9e72a94186b299f05581e1a
change-id: 20260419-type-c6a48a1c273d
Best regards,
Signature · 1 line
Balaji Selvanathan <[email protected]>
PATCH v3 1/5 disk: Add partition lookup by type GUID functionality
Introduce part_get_info_by_type_guid() function to enable partition lookup using partition type GUID. This complements the existing UUID lookup functionality and provides more flexible partition discovery mechanisms.
---
Changes in v3:
- Addressed minor corrections in part_get_info_by_type_guid function
Changes in v2:
- No changes
--- disk/part.c | 37 +++++++++++++++++++++++++++++++++++++ include/part.h | 21 +++++++++++++++++++++ 2 files changed, 58 insertions(+)
disk/part.c +37 -0
@@ -731,6 +731,43 @@ int part_get_info_by_uuid(struct blk_desc *desc, const char *uuid,return -ENOENT ; } +int part_get_info_by_type_guid (struct blk_desc *desc,const char *type_guid, +struct disk_partition *info) +{ +struct part_driver *part_drv; +int ret; +int i; + +if (!CONFIG_IS_ENABLED (PARTITION_TYPE_GUID )) +return -ENOENT ; + + part_drv =part_driver_lookup_type (desc); +if (!part_drv) +return -ENOENT ; + +for (i =1 ; i <= part_drv->max_entries; i++) { + ret =part_driver_get_info (part_drv, desc, i, info); +if (ret) { +/* -ENOSYS means no ->get_info method. */ +if (ret == -ENOSYS ) +return ret; +/* +* Partition with this index can't be obtained, but +* further partitions might be, so keep checking. +*/ +continue ; + } + +if (!strncasecmp (type_guid,disk_partition_type_guid (info), +UUID_STR_LEN )) { +/* matched */ +return i; + } + } + +return -ENOENT ; +} +/** * Get partition info from device number and partition name. *
include/part.h +21 -0
@@ -327,6 +327,20 @@ int part_get_info_by_name(struct blk_desc *desc, const char *name,int part_get_info_by_uuid (struct blk_desc *desc,const char *uuid,struct disk_partition *info); +/** +* part_get_info_by_type_guid() - Search for a partition by type GUID +* among all available registered partitions +* +* @desc: block device descriptor +* @type_guid: the specified partition type GUID +* @info: the disk partition info +* +* Return: the partition number on match (starting on 1), -ENOENT on no match, +* otherwise error +*/ +int part_get_info_by_type_guid (struct blk_desc *desc,const char *type_guid, +struct disk_partition *info); +/** * part_get_info_by_dev_and_name_or_num() - Get partition info from dev number * and part name, or dev number and
@@ -404,6 +418,13 @@ static inline int part_get_info_by_uuid(struct blk_desc *desc, const char *uuid,return -ENOENT ; } +static inline int part_get_info_by_type_guid (struct blk_desc *desc, +const char *type_guid, +struct disk_partition *info) +{ +return -ENOENT ; +} + static inline int part_get_info_by_dev_and_name_or_num(const char *dev_iface, const char *dev_part_str,
Signature · 1 line
2.34.1
Re: [PATCH v3 1/5] disk: Add partition lookup by type GUID functionality
Hi Balaji,
Quoted 7 lines · Balaji Selvanathan
disk: Add partition lookup by type GUID functionality
Introduce
part_get_info_by_type_guid()function to enable partition lookup using partition type GUID. This complements the existing UUID lookup functionality and provides more flexible partition discovery mechanisms.
Quoted 5 lines
Signed-off-by Balaji Selvanathan <[email protected]>
disk/part.c| 37 +++++++++++++++++++++++++++++++++++++include/part.h | 21 +++++++++++++++++++++ 2 files changed, 58 insertions(+)
Regards,
Simon
PATCH v3 2/5 scsi: Add partition lookup by type GUID for SCSI devices
In reply to Balaji SelvanathanIntroduce scsi_get_blk_by_type_guid() function to enable SCSI partition discovery using partition type GUID. This function scans all available SCSI devices and searches for a partition matching the specified type GUID.
---
Changes in v3:
- No changes
Changes in v2:
- Compute blk_find_max_devnum(UCLASS_SCSI) only once in scsi_get_blk_by_type_guid()
--- drivers/scsi/scsi-uclass.c | 28 ++++++++++++++++++++++++++-- include/scsi.h | 11 +++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-)
drivers/scsi/scsi-uclass.c +26 -2
@@ -30,9 +30,10 @@ int scsi_get_blk_by_uuid(const char *uuid, struct disk_partition *part_info_ptr) {struct blk_desc *blk; -int i, ret; +int i, ret, max; -for (i =0 ; i <blk_find_max_devnum (UCLASS_SCSI ) +1 ; i++) { + max =blk_find_max_devnum (UCLASS_SCSI ) +1 ; +for (i =0 ; i < max; i++) { ret =blk_get_desc (UCLASS_SCSI , i, &blk);if (ret)continue ;
@@ -47,6 +48,29 @@ int scsi_get_blk_by_uuid(const char *uuid,return -ENODEV ; } +int scsi_get_blk_by_type_guid (const char *type_guid, +struct blk_desc **blk_desc_ptr, +struct disk_partition *part_info_ptr) +{ +struct blk_desc *blk; +int i, ret, max; + + max =blk_find_max_devnum (UCLASS_SCSI ) +1 ; +for (i =0 ; i < max; i++) { + ret =blk_get_desc (UCLASS_SCSI , i, &blk); +if (ret) +continue ; + + ret =part_get_info_by_type_guid (blk, type_guid, part_info_ptr); +if (ret >0 ) { + *blk_desc_ptr = blk; +return 0 ; + } + } + +return -ENODEV ; +} +int scsi_bus_reset (struct udevice *dev) {struct scsi_ops *ops =scsi_get_ops (dev);
include/scsi.h +11 -0
@@ -366,6 +366,17 @@ int scsi_scan_dev(struct udevice *dev, bool verbose);int scsi_get_blk_by_uuid (const char *uuid,struct blk_desc **blk_desc_ptr,struct disk_partition *part_info_ptr); +/** +* scsi_get_blk_by_type_guid() - Provides SCSI partition information by type GUID. +* +* @type_guid: Type GUID of the partition for fetching its info +* @blk_desc_ptr: Provides the blk descriptor +* @part_info_ptr: Provides partition info +* Return: 0 if OK, -ve on error +*/ +int scsi_get_blk_by_type_guid (const char *type_guid,struct blk_desc **blk_desc_ptr, +struct disk_partition *part_info_ptr); +#define SCSI_IDENTIFY 0xC0/* not used */ /* Hardware errors */
Signature · 1 line
2.34.1
Re: [PATCH v3 2/5] scsi: Add partition lookup by type GUID for SCSI devices
Quoted 25 lines · Balaji Selvanathan
Introduce
scsi_get_blk_by_type_guid()function to enable SCSI partition discovery using partition type GUID. This function scans all available SCSI devices and searches for a partition matching the specified type GUID.Reviewed-by Simon Glass <[email protected]>Signed-off-by Balaji Selvanathan <[email protected]>---
Changes in v3:
- No changesChanges in v2:
- Computeblk_find_max_devnum(UCLASS_SCSI)only once inscsi_get_blk_by_type_guid()--- drivers/scsi/scsi-uclass.c | 28 ++++++++++++++++++++++++++-- include/scsi.h | 11 +++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-)drivers/scsi/scsi-uclass.c +0
-0@@ -30,9 +30,10 @@ int scsi_get_blk_by_uuid(const char *uuid, struct disk_partition *part_info_ptr) {
drivers/scsi/scsi-uclass.c int scsi_get_blk_by_uuid(const char *uuid, · line 39
Quoted 10 lines
drivers/scsi/scsi-uclass.c +3
-2struct blk_desc *blk; -int i, ret; +int i, ret, max; -for (i =0 ; i <blk_find_max_devnum (UCLASS_SCSI ) +1 ; i++) { + max =blk_find_max_devnum (UCLASS_SCSI ) +1 ; +for (i =0 ; i < max; i++) { ret =blk_get_desc (UCLASS_SCSI , i, &blk);if (ret)continue ;
Changing scsi_get_blk_by_uuid() looks like an unrelated change.
PATCH v3 3/5 env: scsi: Add support for partition type GUID based environment
In reply to Balaji SelvanathanAdd support for locating SCSI environment partition using GPT type GUID instead of unique UUID. This enables the saveenv command to work with partitions identified by their type rather than unique identifiers, providing flexibility for systems where partition UUIDs may vary across devices but types remain constant.
Introduce a Kconfig choice statement to select between three partition lookup methods. The choice provides mutually exclusive options:ENV_SCSI_PART_USE_UUID (default), ENV_SCSI_PART_USE_TYPE_GUID, and ENV_SCSI_PART_USE_HW. The corresponding string configs depend on their respective selection method, creating a clear configuration structure.
Introduce CONFIG_ENV_SCSI_PART_TYPE_GUID configuration option that allows specifying a partition type GUID for environment storage. When SCSI_ENV_PART_USE_TYPE_GUID is enabled, the environment subsystem uses the type GUID based lookup method via scsi_get_blk_by_type_guid() to find the first matching partition.
Refactor env/scsi.c to use compile-time preprocessor conditionals instead of runtime string checks. Replace the previous logic that checked if CONFIG_ENV_SCSI_PART_UUID was empty with explicit #if/#elif branches for each method.
Elevate hardware partition selection from an implicit fallback to an explicit choice (ENV_SCSI_PART_USE_HW), improving configuration clarity. Move ENV_SCSI_HW_PARTITION to depend on this new option.
---
Changes in v3:
- Introduce a new choice config: ENV_SCSI_PART_USE_HW for ENV_SCSI_HW_PARTITION
- Refactor env_scsi_get_part and env_scsi_load functions based on the choice configs
Changes in v2:
- Introduce a Kconfig choice config to select between UUID-based and type GUID-based partition lookup methods.
--- env/Kconfig | 51 +++++++++++++++++++++++++++++++++++++++++++-------- env/scsi.c | 45 +++++++++++++++++++++++++++------------------ 2 files changed, 70 insertions(+), 26 deletions(-)
env/Kconfig +43 -8
@@ -780,10 +780,51 @@ config ENV_MMC_USE_DT The 2 defines CONFIG_ENV_OFFSET, CONFIG_ENV_OFFSET_REDUND are not used as fallback. +choice + prompt "SCSI partition selection method" + depends on ENV_IS_IN_SCSI + default ENV_SCSI_PART_USE_UUID + help + Select the method to identify the SCSI partition for environment storage. + +config ENV_SCSI_PART_USE_UUID + bool "Use partition UUID" + help + Use the partition's unique UUID to identify the SCSI partition + for environment storage. + +config ENV_SCSI_PART_USE_TYPE_GUID + bool "Use partition type GUID" + help + Use the partition type GUID to identify the SCSI partition + for environment storage. The first partition matching the + specified type GUID will be used. + +config ENV_SCSI_PART_USE_HW + bool "Use hardware partition number" + help + Use the hardware device number to identify the SCSI device + for environment storage. + +endchoice + +config ENV_SCSI_PART_UUID + string "SCSI partition UUID for saving environment" + depends on ENV_SCSI_PART_USE_UUID + help + UUID of the SCSI partition that you want to store the environment in. + +config ENV_SCSI_PART_TYPE_GUID + string "SCSI partition type GUID for saving environment" + depends on ENV_SCSI_PART_USE_TYPE_GUID + help + Type GUID of the SCSI partition to store the environment in. + Uses the first partition matching this type GUID. + config ENV_SCSI_HW_PARTITION string "SCSI hardware partition number" - depends on ENV_IS_IN_SCSI - default 0 + depends on ENV_SCSI_PART_USE_HW + default "0" help SCSI hardware partition device number on the platform where the environment is stored. Note that this is not related to any software
@@ -791,12 +832,6 @@ config ENV_SCSI_HW_PARTITION partition 0 or the first boot partition, which is 1 or some other defined partition. -config ENV_SCSI_PART_UUID - string "SCSI partition UUID for saving environment" - depends on ENV_IS_IN_SCSI - help - UUID of the SCSI partition that you want to store the environment in. - config ENV_USE_DEFAULT_ENV_TEXT_FILE bool "Create default environment from file" depends on !COMPILE_TEST
env/scsi.c +27 -18
61 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v3 3/5] env: scsi: Add support for partition type GUID based environment
Hi Balaji,
Quoted 28 lines · Balaji Selvanathan
env: scsi: Add support for partition type GUID based environment
Add support for locating SCSI environment partition using GPT type GUID instead of unique UUID. This enables the saveenv command to work with partitions identified by their type rather than unique identifiers, providing flexibility for systems where partition UUIDs may vary across devices but types remain constant.
Introduce a
Kconfigchoice statement to select between three partition lookup methods. The choice provides mutually exclusive options:ENV_SCSI_PART_USE_UUID(default),ENV_SCSI_PART_USE_TYPE_GUID, andENV_SCSI_PART_USE_HW. The corresponding string configs depend on their respective selection method, creating a clear configuration structure.Introduce
CONFIG_ENV_SCSI_PART_TYPE_GUIDconfiguration option that allows specifying a partition type GUID for environment storage. WhenSCSI_ENV_PART_USE_TYPE_GUIDis enabled, the environment subsystem uses the type GUID based lookup method viascsi_get_blk_by_type_guid()to find the first matching partition.[...]
env/Kconfig | 50 ++++++++++++++++++++++++++++++++++++++++++++++++--
env/scsi.c | 29 ++++++++++++++++++++++++++--- 2 files changed, 74 insertions(+), 5 deletions(-)
env/Kconfig config ENV_MMC_USE_DT · line 768
Quoted 6 lines
env/Kconfig +6
-0@@ -763,12 +763,58 @@ config ENV_MMC_USE_DT +config ENV_SCSI_PART_USE_TYPE_GUID + bool "Use partition type GUID" + help + Use the partition type GUID to identify the SCSI partition + for environment storage. The first partition matching the + specified type GUID will be used.
How about adding 'select PARTITION_TYPE_GUID' so that users do not have to manually enable it. Otherwise the lookup will silently fail at runtime when part_get_info_by_type_guid() returns -ENOENT
Regards,
Simon
Re: [PATCH v3 3/5] env: scsi: Add support for partition type GUID based environment
In reply to Balaji SelvanathanQuoted 18 lines · Balaji Selvanathan
Add support for locating SCSI environment partition using GPT type GUID instead of unique UUID. This enables the saveenv command to work with partitions identified by their type rather than unique identifiers, providing flexibility for systems where partition UUIDs may vary across devices but types remain constant.
Introduce a
Kconfigchoice statement to select between three partition lookup methods. The choice provides mutually exclusive options:ENV_SCSI_PART_USE_UUID(default),ENV_SCSI_PART_USE_TYPE_GUID, andENV_SCSI_PART_USE_HW. The corresponding string configs depend on their respective selection method, creating a clear configuration structure.Introduce
CONFIG_ENV_SCSI_PART_TYPE_GUIDconfiguration option that allows specifying a partition type GUID for environment storage. WhenSCSI_ENV_PART_USE_TYPE_GUIDis enabled, the environment subsystem uses the type GUID based lookup method viascsi_get_blk_by_type_guid()to find the first matching partition.
Quoted 4 lines
Refactor
env/scsi.cto use compile-time preprocessor conditionals instead of runtime string checks. Replace the previous logic that checked ifCONFIG_ENV_SCSI_PART_UUIDwas empty with explicit #if/#elif branches for each method.
Might be a bit cleaner to split the refactor and adding the new option into two patches. This is quite a bit going on in one patch.
Quoted 26 lines
Elevate hardware partition selection from an implicit fallback to an explicit choice (
ENV_SCSI_PART_USE_HW), improving configuration clarity. MoveENV_SCSI_HW_PARTITIONto depend on this new option.Signed-off-by Balaji Selvanathan <[email protected]>---
Changes in v3:
- Introduce a new choice config:ENV_SCSI_PART_USE_HWforENV_SCSI_HW_PARTITION
- Refactorenv_scsi_get_partandenv_scsi_loadfunctions based on the choice configsChanges in v2:
- Introduce aKconfigchoice config to select between UUID-based and type GUID-based partition lookup methods.--- env/Kconfig | 51 +++++++++++++++++++++++++++++++++++++++++++-------- env/scsi.c | 45 +++++++++++++++++++++++++++------------------ 2 files changed, 70 insertions(+), 26 deletions(-)env/Kconfig +0
-0
env/Kconfig config ENV_MMC_USE_DT · line 782
Quoted 3 lines
env/Kconfig +0
-0@@ -780,10 +780,51 @@ config ENV_MMC_USE_DT The 2 defines CONFIG_ENV_OFFSET, CONFIG_ENV_OFFSET_REDUND are not used as fallback.
We should update the help of config ENV_IS_IN_SCSI as well since it mentions these options below.
env/Kconfig config ENV_MMC_USE_DT · line 789
Quoted 7 lines
env/Kconfig +7
-0+choice + prompt "SCSI partition selection method" + depends on ENV_IS_IN_SCSI + default ENV_SCSI_PART_USE_UUID + help + Select the method to identify the SCSI partition for environment storage. +
I wish I would have thought of using choice in the recent changes I did. It is much cleaner to explicitly select which one you want. :-)
Quoted 30 lines
env/Kconfig +30
-0+config ENV_SCSI_PART_USE_UUID + bool "Use partition UUID" + help + Use the partition's unique UUID to identify the SCSI partition + for environment storage. + +config ENV_SCSI_PART_USE_TYPE_GUID + bool "Use partition type GUID" + help + Use the partition type GUID to identify the SCSI partition + for environment storage. The first partition matching the + specified type GUID will be used. + +config ENV_SCSI_PART_USE_HW + bool "Use hardware partition number" + help + Use the hardware device number to identify the SCSI device + for environment storage. + +endchoice + +config ENV_SCSI_PART_UUID + string "SCSI partition UUID for saving environment" + depends on ENV_SCSI_PART_USE_UUID + help + UUID of the SCSI partition that you want to store the environment in. + +config ENV_SCSI_PART_TYPE_GUID + string "SCSI partition type GUID for saving environment" + depends on ENV_SCSI_PART_USE_TYPE_GUID
env/Kconfig config ENV_MMC_USE_DT · line 827
Quoted 10 lines
env/Kconfig +6
-2+ help + Type GUID of the SCSI partition to store the environment in. + Uses the first partition matching this type GUID. + config ENV_SCSI_HW_PARTITION string "SCSI hardware partition number" - depends on ENV_IS_IN_SCSI - default 0 + depends on ENV_SCSI_PART_USE_HW + default "0"
Fixing the quotes here is technically an unrelated change, so could be a patch on it's own as well.
Quoted 49 lines
env/Kconfig +0
-6help SCSI hardware partition device number on the platform where the environment is stored. Note that this is not related to any software@@ -791,12 +832,6 @@ config ENV_SCSI_HW_PARTITION partition 0 or the first boot partition, which is 1 or some other defined partition. -config ENV_SCSI_PART_UUID - string "SCSI partition UUID for saving environment" - depends on ENV_IS_IN_SCSI - help - UUID of the SCSI partition that you want to store the environment in. - config ENV_USE_DEFAULT_ENV_TEXT_FILE bool "Create default environment from file" depends on !COMPILE_TESTenv/scsi.c +13
-8@@ -41,14 +41,19 @@ static inline struct env_scsi_info *env_scsi_get_part(void) is_scsi_scanned = true; } -if (CONFIG_ENV_SCSI_PART_UUID [0 ] =='\0' ) { -if (blk_get_device_part_str ("scsi" ,CONFIG_ENV_SCSI_HW_PARTITION , - &ep->blk, &ep->part, true)) -return NULL ; - }else { -if (scsi_get_blk_by_uuid (CONFIG_ENV_SCSI_PART_UUID , &ep->blk, &ep->part)) -return NULL ; - } +#if defined(CONFIG_ENV_SCSI_PART_USE_TYPE_GUID ) +if (scsi_get_blk_by_type_guid (CONFIG_ENV_SCSI_PART_TYPE_GUID , &ep->blk, &ep->part)) +return NULL ; + +#elif defined(CONFIG_ENV_SCSI_PART_USE_UUID ) +if (scsi_get_blk_by_uuid (CONFIG_ENV_SCSI_PART_UUID , &ep->blk, &ep->part)) +return NULL ; + +#elif defined(CONFIG_ENV_SCSI_PART_USE_HW ) +if (blk_get_device_part_str ("scsi" ,CONFIG_ENV_SCSI_HW_PARTITION , + &ep->blk, &ep->part, true)) +return NULL ; +#endif ep->count =CONFIG_ENV_SIZE / ep->part.blksz;
env/scsi.c static int env_scsi_load(void) · line 104
Quoted 10 lines
env/scsi.c +2
-5@@ -95,20 +100,24 @@ static int env_scsi_load(void)int ret;if (!ep) { -if (CONFIG_ENV_SCSI_PART_UUID [0 ] =='\0' ) -env_set_default ("SCSI partition " CONFIG_ENV_SCSI_HW_PARTITION " not found" ,0 ); -else -env_set_default (CONFIG_ENV_SCSI_PART_UUID " partition not found" ,0 ); - +#if defined(CONFIG_ENV_SCSI_PART_USE_TYPE_GUID ) +env_set_default (CONFIG_ENV_SCSI_PART_TYPE_GUID " partition not found" ,0 );
It could be a bit more clear to have a different message for
this one. e.g. "partition type " CONFIG_ENV_SCSI_PART_TYPE_GUID " not found".
Quoted 6 lines
env/scsi.c +5
-0+#elif defined(CONFIG_ENV_SCSI_PART_USE_UUID ) +env_set_default (CONFIG_ENV_SCSI_PART_UUID " partition not found" ,0 ); +#elif defined(CONFIG_ENV_SCSI_PART_USE_HW ) +env_set_default ("SCSI partition " CONFIG_ENV_SCSI_HW_PARTITION " not found" ,0 ); +#endif return -ENOENT ;
env/scsi.c static int env_scsi_load(void) · line 115
Quoted 10 lines
env/scsi.c +2
-5}if (blk_dread (ep->blk, ep->part.start, ep->count, &envbuf) != ep->count) { -if (CONFIG_ENV_SCSI_PART_UUID [0 ] =='\0' ) -env_set_default ("SCSI partition " CONFIG_ENV_SCSI_HW_PARTITION " read failed" ,0 ); -else -env_set_default (CONFIG_ENV_SCSI_PART_UUID " partition read failed" ,0 ); - +#if defined(CONFIG_ENV_SCSI_PART_USE_TYPE_GUID ) +env_set_default (CONFIG_ENV_SCSI_PART_TYPE_GUID " partition read failed" ,0 );
similar as above
Quoted 9 lines
env/scsi.c +5
-0+#elif defined(CONFIG_ENV_SCSI_PART_USE_UUID ) +env_set_default (CONFIG_ENV_SCSI_PART_UUID " partition read failed" ,0 ); +#elif defined(CONFIG_ENV_SCSI_PART_USE_HW ) +env_set_default ("SCSI partition " CONFIG_ENV_SCSI_HW_PARTITION " read failed" ,0 ); +#endif return -EIO ; }
PATCH v3 4/5 configs: Enable partition type GUID for QCM6490 and QCS615 boards
In reply to Balaji SelvanathanEnable CONFIG_PARTITION_TYPE_GUID and configure SCSI environment partition type GUID for QCM6490 and QCS615 board configurations. This allows these platforms to locate the environment partition using GPT type GUID instead of unique UUID.
---
Changes in v3:
- No changes
Changes in v2:
- Enable above new config in qcom_qcs615_defconfig and qcm6490_defconfig
--- configs/qcm6490_defconfig | 5 +++++ configs/qcom_qcs615_defconfig | 5 +++++ 2 files changed, 10 insertions(+)
configs/qcm6490_defconfig +5 -0
@@ -15,3 +15,8 @@ CONFIG_REMAKE_ELF=y CONFIG_DEFAULT_DEVICE_TREE="qcom/qcs6490-rb3gen2" CONFIG_FASTBOOT_BUF_ADDR=0xd8800000 + +CONFIG_ENV_IS_IN_SCSI=y +CONFIG_PARTITION_TYPE_GUID=y +CONFIG_ENV_SCSI_PART_USE_TYPE_GUID=y +CONFIG_ENV_SCSI_PART_TYPE_GUID="bc0330eb-3410-4951-a617-03898dbe3372"
configs/qcom_qcs615_defconfig +5 -0
@@ -22,3 +22,8 @@ CONFIG_REMAKE_ELF=y CONFIG_TEXT_BASE=0x9fc00000 CONFIG_FASTBOOT_BUF_ADDR=0xa1600000 + +CONFIG_ENV_IS_IN_SCSI=y +CONFIG_PARTITION_TYPE_GUID=y +CONFIG_ENV_SCSI_PART_USE_TYPE_GUID=y +CONFIG_ENV_SCSI_PART_TYPE_GUID="bc0330eb-3410-4951-a617-03898dbe3372"
Signature · 1 line
2.34.1
Re: [PATCH v3 4/5] configs: Enable partition type GUID for QCM6490 and QCS615 boards
Hi Balaji,
Quoted 7 lines · Balaji Selvanathan
configs: Enable partition type GUID for QCM6490 and QCS615 boards
Enable
CONFIG_PARTITION_TYPE_GUIDand configure SCSI environment partition type GUID for QCM6490 and QCS615 board configurations. This allows these platforms to locate the environment partition using GPT type GUID instead of unique UUID.
Quoted 5 lines
Signed-off-by Balaji Selvanathan <[email protected]>configs/qcm6490_defconfig | 5 +++++
configs/qcom_qcs615_defconfig | 5 +++++ 2 files changed, 10 insertions(+)
PATCH v3 5/5 test: dm: Add partition type GUID lookup test
In reply to Balaji SelvanathanAdd a unit test for the partition type GUID lookup functionality. The test verifies that partitions can be correctly identified by their type GUID, specifically testing the ChromeOS kernel partition lookup.
---
Changes in v3:
- Add unit test for the partition type GUID lookup functionality
--- test/dm/part.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+)
test/dm/part.c +48 -0
@@ -8,9 +8,13 @@#include <mmc.h> #include <part.h> #include <part_efi.h> +#include <asm/global_data.h> +#include <dm/lists.h> #include <dm/test.h> #include <test/ut.h> +DECLARE_GLOBAL_DATA_PTR ; +static int do_test (struct unit_test_state *uts,int expected,const char *part_str,bool whole) {
@@ -195,3 +199,47 @@ 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_type_guid (struct unit_test_state *uts) +{ +struct udevice *dev, *blk_dev; +struct blk_desc *desc; +struct disk_partition info; +ofnode root, node; +int partnum; + +if (!IS_ENABLED (CONFIG_PARTITION_TYPE_GUID )) +return -EOPNOTSUPP ; + +/* Bind the mmc5 node (ChromeOS image with type GUIDs) */ + root =oftree_root (oftree_default ()); + node =ofnode_find_subnode (root,"mmc5" ); +ut_assert (ofnode_valid (node)); +ut_assertok (lists_bind_fdt (gd->dm_root, node, &dev,NULL , false)); + +/* Get the MMC device (probes it), then walk MMC -> BLK parent link */ +ut_assertok (uclass_get_device_by_seq (UCLASS_MMC ,5 , &dev)); +ut_assertok (blk_get_from_parent (dev, &blk_dev)); + desc =dev_get_uclass_plat (blk_dev); +ut_assert (desc); + +/* +* Test: look up the first ChromeOS kernel partition by type GUID. +* In the ChromeOS image KERN_A is the first partition carrying the +* ChromeOS kernel type GUID (fe3a2a5d-...). +*/ + partnum =part_get_info_by_type_guid (desc, +"FE3A2A5D-4F32-41A7-B725-ACCC3285A309" , + &info); +ut_assert (partnum >0 ); + +/* Test: non-existent GUID must return -ENOENT */ +ut_asserteq (-ENOENT , +part_get_info_by_type_guid (desc, +"00000000-0000-0000-0000-000000000000" , + &info)); + +return 0 ; +} + +DM_TEST (dm_test_part_get_info_by_type_guid,UTF_SCAN_PDATA |UTF_SCAN_FDT );
Signature · 1 line
2.34.1
Re: [PATCH v3 5/5] test: dm: Add partition type GUID lookup test
Hi Balaji,
Quoted 13 lines · Balaji Selvanathan
test: dm: Add partition type GUID lookup test
Add a unit test for the partition type GUID lookup functionality. The test verifies that partitions can be correctly identified by their type GUID, specifically testing the ChromeOS kernel partition lookup.
Signed-off-by Balaji Selvanathan <[email protected]>
test/dm/part.c| 48 ++++++++++++++++++++++++++++++++++++++++++++++++1 file changed, 48 insertions(+)
test/dm/part.c static int dm_test_part_get_info_by_type(struct unit_test_state *uts) · line 200
Quoted 2 lines
test/dm/part.c +2
-0@@ -195,3 +199,47 @@ static int dm_test_part_get_info_by_type(struct unit_test_state *uts) +if (!IS_ENABLED (CONFIG_PARTITION_TYPE_GUID )) +return -EOPNOTSUPP ;
Please can you return -EAGAIN instead? The test framework uses -EAGAIN to indicate a test should be skipped (see test-main.c lines 486 and 492). Returning -EOPNOTSUPP will cause the test to fail rather than skip when the config is not enabled.
test/dm/part.c static int dm_test_part_get_info_by_type(struct unit_test_state *uts) · line 202
Quoted 6 lines
test/dm/part.c +4
-0@@ -195,3 +199,47 @@ static int dm_test_part_get_info_by_type(struct unit_test_state *uts) + partnum =part_get_info_by_type_guid (desc, +"FE3A2A5D-4F32-41A7-B725-ACCC3285A309" , + &info); +ut_assert (partnum >0 );
How about ut_asserteq(2, partnum) here, since the first ChromeOS kernel partition (KERN_A) is at partition 2 in the test image. This makes the test more precise and would catch regressions if the search order changes. Alternatively, you could verify the partition name using:
ut_asserteq_str("KERN_A", info.name)
Regards,
Simon
Quoted 5 lines · Balaji Selvanathan
This series adds support for locating partitions using GPT partition type GUID instead of unique partition UUID. This enables the saveenv command to work with partitions identified by their type rather than unique identifiers, providing flexibility for systems where partition UUIDs may vary across devices but types remain constant.
Why don't we rather rely on partition name/label instead? That can be common across platforms too. I would rather prefer a config fragment for eg. UFS based environment or eMMC based environment and so on.
-Sumit
Quoted 49 lines
Patch 1 adds
part_get_info_by_type_guid()function support Patch 2 addsscsi_get_blk_by_type_guid()function support Patch 3 adds support for partition type GUID based environment Patch 4 enables partition type GUID configs for QCM6490 and QCS615 Patch 5 adds unit test for the partition type GUID lookup functionalitySigned-off-by Balaji Selvanathan <[email protected]>---
Changes in v3:
- Addressed minor corrections in Patch 1 inpart_get_info_by_type_guidfunction
- Refactorenv_scsi_get_partandenv_scsi_loadfunctions based
on the choice configs in Patch 3
- Add unit test for the partition type GUID lookup functionality in Patch 5
- Link to v2: https://lore.kernel.org/u-boot/[email protected]/Changes in v2:
- Computeblk_find_max_devnum(UCLASS_SCSI)only once inscsi_get_blk_by_type_guid()
- Introduce aKconfigchoice config to select between UUID-based
and type GUID-based partition lookup methods.
- Enable above new config inqcom_qcs615_defconfigandqcm6490_defconfig
- Link to v1: https://lore.kernel.org/u-boot/[email protected]/---
Balaji Selvanathan (5):
disk: Add partition lookup by type GUID functionality
scsi: Add partition lookup by type GUID for SCSI devices
env: scsi: Add support for partition type GUID based environment
configs: Enable partition type GUID for QCM6490 and QCS615 boards
test: dm: Add partition type GUID lookup testconfigs/qcm6490_defconfig | 5 +++++ configs/qcom_qcs615_defconfig | 5 +++++ disk/part.c | 37 +++++++++++++++++++++++++++++++ drivers/scsi/scsi-uclass.c | 28 ++++++++++++++++++++++-- env/Kconfig | 51 ++++++++++++++++++++++++++++++++++++------- env/scsi.c | 45 +++++++++++++++++++++++--------------- include/part.h | 21 ++++++++++++++++++ include/scsi.h | 11 ++++++++++ test/dm/part.c | 48 ++++++++++++++++++++++++++++++++++++++++ 9 files changed, 223 insertions(+), 28 deletions(-)---
base-commit:e3405917a1806971d9e72a94186b299f05581e1a
change-id: 20260419-type-c6a48a1c273dBest regards,
Signature · 1 line
Balaji Selvanathan <[email protected]>
Quoted 11 lines · Sumit Garg
Quoted 5 lines · Balaji Selvanathan
This series adds support for locating partitions using GPT partition type GUID instead of unique partition UUID. This enables the saveenv command to work with partitions identified by their type rather than unique identifiers, providing flexibility for systems where partition UUIDs may vary across devices but types remain constant.
Why don't we rather rely on partition name/label instead? That can be common across platforms too. I would rather prefer a config fragment for eg. UFS based environment or eMMC based environment and so on.
-Sumit
Hi Sumit,
Using type GUIDs as they offer following advantages: they are standardized across vendors (e.g., ChromeOS kernel GUID, Linux filesystem GUID) unlike arbitrary partition names that vary by OEM or firmware version, they are immutable and set at partition creation, making them more robust than easily-modified partition names.
Regards,
Balaji
Quoted 49 lines
Quoted 49 lines
Patch 1 adds
part_get_info_by_type_guid()function support Patch 2 addsscsi_get_blk_by_type_guid()function support Patch 3 adds support for partition type GUID based environment Patch 4 enables partition type GUID configs for QCM6490 and QCS615 Patch 5 adds unit test for the partition type GUID lookup functionalitySigned-off-by Balaji Selvanathan <[email protected]>---
Changes in v3:
- Addressed minor corrections in Patch 1 inpart_get_info_by_type_guidfunction
- Refactorenv_scsi_get_partandenv_scsi_loadfunctions based
on the choice configs in Patch 3
- Add unit test for the partition type GUID lookup functionality in Patch 5
- Link to v2: https://lore.kernel.org/u-boot/[email protected]/Changes in v2:
- Computeblk_find_max_devnum(UCLASS_SCSI)only once inscsi_get_blk_by_type_guid()
- Introduce aKconfigchoice config to select between UUID-based
and type GUID-based partition lookup methods.
- Enable above new config inqcom_qcs615_defconfigandqcm6490_defconfig
- Link to v1: https://lore.kernel.org/u-boot/[email protected]/---
Balaji Selvanathan (5):
disk: Add partition lookup by type GUID functionality
scsi: Add partition lookup by type GUID for SCSI devices
env: scsi: Add support for partition type GUID based environment
configs: Enable partition type GUID for QCM6490 and QCS615 boards
test: dm: Add partition type GUID lookup testconfigs/qcm6490_defconfig | 5 +++++ configs/qcom_qcs615_defconfig | 5 +++++ disk/part.c | 37 +++++++++++++++++++++++++++++++ drivers/scsi/scsi-uclass.c | 28 ++++++++++++++++++++++-- env/Kconfig | 51 ++++++++++++++++++++++++++++++++++++------- env/scsi.c | 45 +++++++++++++++++++++++--------------- include/part.h | 21 ++++++++++++++++++ include/scsi.h | 11 ++++++++++ test/dm/part.c | 48 ++++++++++++++++++++++++++++++++++++++++ 9 files changed, 223 insertions(+), 28 deletions(-)---
base-commit:e3405917a1806971d9e72a94186b299f05581e1a
change-id: 20260419-type-c6a48a1c273dBest regards,
Signature · 1 line
Balaji Selvanathan <[email protected]>
Quoted 14 lines · Balaji Selvanathan
Quoted 11 lines · Sumit Garg
Quoted 5 lines · Balaji Selvanathan
This series adds support for locating partitions using GPT partition type GUID instead of unique partition UUID. This enables the saveenv command to work with partitions identified by their type rather than unique identifiers, providing flexibility for systems where partition UUIDs may vary across devices but types remain constant.
Why don't we rather rely on partition name/label instead? That can be common across platforms too. I would rather prefer a config fragment for eg. UFS based environment or eMMC based environment and so on.
-Sumit
Quoted 8 lines
Hi Sumit,
Using type GUIDs as they offer following advantages: they are standardized across vendors (e.g., ChromeOS kernel GUID, Linux filesystem GUID) unlike arbitrary partition names that vary by OEM or firmware version, they are immutable and set at partition creation, making them more robust than easily-modified partition names.
That's fair, let's at least document the partition name used for environment in the defconfig such that it's easier for users to know that.
-Sumit
Quoted 50 lines
Quoted 50 lines
Quoted 50 lines
Patch 1 adds
part_get_info_by_type_guid()function support Patch 2 addsscsi_get_blk_by_type_guid()function support Patch 3 adds support for partition type GUID based environment Patch 4 enables partition type GUID configs for QCM6490 and QCS615 Patch 5 adds unit test for the partition type GUID lookup functionalitySigned-off-by Balaji Selvanathan <[email protected]>---
Changes in v3:
- Addressed minor corrections in Patch 1 inpart_get_info_by_type_guidfunction
- Refactorenv_scsi_get_partandenv_scsi_loadfunctions based
on the choice configs in Patch 3
- Add unit test for the partition type GUID lookup functionality in Patch 5
- Link to v2: https://lore.kernel.org/u-boot/[email protected]/Changes in v2:
- Computeblk_find_max_devnum(UCLASS_SCSI)only once inscsi_get_blk_by_type_guid()
- Introduce aKconfigchoice config to select between UUID-based
and type GUID-based partition lookup methods.
- Enable above new config inqcom_qcs615_defconfigandqcm6490_defconfig
- Link to v1: https://lore.kernel.org/u-boot/[email protected]/---
Balaji Selvanathan (5):
disk: Add partition lookup by type GUID functionality
scsi: Add partition lookup by type GUID for SCSI devices
env: scsi: Add support for partition type GUID based environment
configs: Enable partition type GUID for QCM6490 and QCS615 boards
test: dm: Add partition type GUID lookup testconfigs/qcm6490_defconfig | 5 +++++ configs/qcom_qcs615_defconfig | 5 +++++ disk/part.c | 37 +++++++++++++++++++++++++++++++ drivers/scsi/scsi-uclass.c | 28 ++++++++++++++++++++++-- env/Kconfig | 51 ++++++++++++++++++++++++++++++++++++------- env/scsi.c | 45 +++++++++++++++++++++++--------------- include/part.h | 21 ++++++++++++++++++ include/scsi.h | 11 ++++++++++ test/dm/part.c | 48 ++++++++++++++++++++++++++++++++++++++++ 9 files changed, 223 insertions(+), 28 deletions(-)---
base-commit:e3405917a1806971d9e72a94186b299f05581e1a
change-id: 20260419-type-c6a48a1c273dBest regards,
Signature · 1 line
Balaji Selvanathan <[email protected]>