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 Kconfig choice statement to select between UUID-based and type GUID-based partition lookup methods. The choice provides two mutually exclusive options: SCSI_ENV_PART_USE_UUID (default) and SCSI_ENV_PART_USE_TYPE_GUID. The corresponding string configs SCSI_ENV_PART_UUID and SCSI_ENV_PART_TYPE_GUID depend on their respective selection method. Introduce CONFIG_SCSI_ENV_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. This change maintains backward compatibility with the existing UUID-based approach. Signed-off-by: Balaji Selvanathan <[email protected]> --- Changes in v2: - Introduce a Kconfig choice config to select between UUID-based and type GUID-based partition lookup methods. env/Kconfig | 31 ++++++++++++++++++++++++++++++- env/scsi.c | 13 +++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/env/Kconfig b/env/Kconfig index b312f9b5324..04bb6eeddf3 100644 --- a/env/Kconfig +++ b/env/Kconfig @@ -762,12 +762,41 @@ 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 SCSI_ENV_PART_USE_UUID + help + Select the method to identify the SCSI partition for environment storage. + +config SCSI_ENV_PART_USE_UUID + bool "Use partition UUID" + help + Use the partition's unique UUID to identify the SCSI partition + for environment storage. + +config SCSI_ENV_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. + +endchoice + config SCSI_ENV_PART_UUID string "SCSI partition UUID for saving environment" - depends on ENV_IS_IN_SCSI + depends on SCSI_ENV_PART_USE_UUID help UUID of the SCSI partition that you want to store the environment in. +config SCSI_ENV_PART_TYPE_GUID + string "SCSI partition type GUID for saving environment" + depends on SCSI_ENV_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_USE_DEFAULT_ENV_TEXT_FILE bool "Create default environment from file" depends on !COMPILE_TEST diff --git a/env/scsi.c b/env/scsi.c index 207717e17b1..88abf0d5945 100644 --- a/env/scsi.c +++ b/env/scsi.c @@ -35,8 +35,13 @@ static inline struct env_scsi_info *env_scsi_get_part(void) { struct env_scsi_info *ep = &env_part; +#ifdef CONFIG_SCSI_ENV_PART_USE_TYPE_GUID + if (scsi_get_blk_by_type_guid(CONFIG_SCSI_ENV_PART_TYPE_GUID, &ep->blk, &ep->part)) + return NULL; +#else if (scsi_get_blk_by_uuid(CONFIG_SCSI_ENV_PART_UUID, &ep->blk, &ep->part)) return NULL; +#endif ep->count = CONFIG_ENV_SIZE / ep->part.blksz; @@ -83,12 +88,20 @@ static int env_scsi_load(void) int ret; if (!ep) { +#ifdef CONFIG_SCSI_ENV_PART_USE_TYPE_GUID + env_set_default(CONFIG_SCSI_ENV_PART_TYPE_GUID " partition not found", 0); +#else env_set_default(CONFIG_SCSI_ENV_PART_UUID " partition not found", 0); +#endif return -ENOENT; } if (blk_dread(ep->blk, ep->part.start, ep->count, &envbuf) != ep->count) { +#ifdef CONFIG_SCSI_ENV_PART_USE_TYPE_GUID + env_set_default(CONFIG_SCSI_ENV_PART_TYPE_GUID " partition read failed", 0); +#else env_set_default(CONFIG_SCSI_ENV_PART_UUID " partition read failed", 0); +#endif return -EIO; } -- 2.34.1

