Re: [PATCH v1 3/4] env: scsi: Add support for partition type GUID based environment
On Fri, Jan 09, 2026 at 02:21:28PM +0530, Balaji Selvanathan wrote:
> Hi Simon,
>
> On 1/8/2026 11:12 PM, Simon Glass wrote:
> > Hi Balaji,
> >
> > On Wed, 7 Jan 2026 at 23:50, Balaji Selvanathan
> > wrote:
> > > 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 CONFIG_SCSI_ENV_PART_TYPE_GUID configuration option that
> > > allows specifying a partition type GUID for environment storage.
> > > When enabled, the environment subsystem uses the new 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
> > > ---
> > > env/Kconfig | 7 +++
> > > env/scsi.c | 13 +
> > > 2 files changed, 20 insertions(+)
> > >
> > > diff --git a/env/Kconfig b/env/Kconfig
> > > index b312f9b5324..97cb3d05daf 100644
> > > --- a/env/Kconfig
> > > +++ b/env/Kconfig
> > > @@ -768,6 +768,13 @@ config SCSI_ENV_PART_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 ENV_IS_IN_SCSI
> > > + 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..6182ae26679 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_TYPE_GUID
> > > + if (scsi_get_blk_by_type_guid(CONFIG_SCSI_ENV_PART_TYPE_GUID,
> > > &ep->blk, &ep->part))
> > Can you use if IS_ENABLED(CONFIG_SCSI_ENV_PART_TYPE_GUID)
> >
> > (we try to avoid #ifdef)
> Thanks for the feedback.
>
> In this respin
> https://lore.kernel.org/u-boot/[email protected]/,
> I've introduced a choice statement in env/Kconfig to ensure mutual
> exclusivity between CONFIG_SCSI_ENV_PART_UUID and
> CONFIG_SCSI_ENV_PART_TYPE_GUID.
>
> Due to this choice-based configuration, only one of these string configs is
> defined at compile time. When I attempted to use `if (IS_ENABLED(...))` for
> the string concatenation cases, I encountered compilation errors because the
> compiler tries to evaluate both branches, but the undefined config macro
> causes an "undeclared identifier" error.
>
> For example:
>
> if (IS_ENABLED(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);
> // Error: CONFIG_SCSI_ENV_PART_UUID undeclared
>
> Given this constraint with mutually exclusive string configs, I've kept the
> #ifdef approach for these specific cases. I understand the preference for
> IS_ENABLED() for its compile-time checking benefits, but in this scenario
> with string concatenation, the preprocessor conditional appears to be
> necessary.
>
> Would this approach be acceptable, or would you prefer an alternative
> solution?
The way to solve this would be to wrap CONFIG_SCSI_ENV_PART_*UID with
CONFIG_VAL(...), but at that point we've also lost the readability
argument of avoiding #ifdef.
--
Tom
signature.asc
Description: PGP signature
Re: [PATCH v1 3/4] env: scsi: Add support for partition type GUID based environment
On Fri, Jan 09 2026, Balaji Selvanathan
wrote:
> Hi Simon,
>
> On 1/8/2026 11:12 PM, Simon Glass wrote:
>> Hi Balaji,
>>
>> On Wed, 7 Jan 2026 at 23:50, Balaji Selvanathan
>> wrote:
>>> 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 CONFIG_SCSI_ENV_PART_TYPE_GUID configuration option that
>>> allows specifying a partition type GUID for environment storage.
>>> When enabled, the environment subsystem uses the new 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
>>> ---
>>> env/Kconfig | 7 +++
>>> env/scsi.c | 13 +
>>> 2 files changed, 20 insertions(+)
>>>
>>> diff --git a/env/Kconfig b/env/Kconfig
>>> index b312f9b5324..97cb3d05daf 100644
>>> --- a/env/Kconfig
>>> +++ b/env/Kconfig
>>> @@ -768,6 +768,13 @@ config SCSI_ENV_PART_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 ENV_IS_IN_SCSI
>>> + 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..6182ae26679 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_TYPE_GUID
>>> + if (scsi_get_blk_by_type_guid(CONFIG_SCSI_ENV_PART_TYPE_GUID,
>>> &ep->blk, &ep->part))
>> Can you use if IS_ENABLED(CONFIG_SCSI_ENV_PART_TYPE_GUID)
>>
>> (we try to avoid #ifdef)
> Thanks for the feedback.
>
> In this respin
> https://lore.kernel.org/u-boot/[email protected]/,
> I've introduced a choice statement in env/Kconfig to ensure mutual
> exclusivity between CONFIG_SCSI_ENV_PART_UUID and
> CONFIG_SCSI_ENV_PART_TYPE_GUID.
>
> Due to this choice-based configuration, only one of these string
> configs is defined at compile time. When I attempted to use `if
> (IS_ENABLED(...))` for the string concatenation cases, I encountered
> compilation errors because the compiler tries to evaluate both
> branches, but the undefined config macro causes an "undeclared
> identifier" error.
>
I think you could do
config SCSI_ENV_PART_TYPE_GUID
string "SCSI partition type GUID for saving environment" if
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.
instead of
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.
Then the config symbol always exists, but is only visible/changable when
relevant.
Also, I suggest adding
default "3de21764-95bd-54bd-a5c3-4abe786f38a8"
There's really no reason everybody should come up with their own, and we
already have exactly that type guid defined to mean "partition
containing a u-boot environment".
Rasmus
Re: [PATCH v1 3/4] env: scsi: Add support for partition type GUID based environment
Hi Simon,
On 1/8/2026 11:12 PM, Simon Glass wrote:
Hi Balaji,
On Wed, 7 Jan 2026 at 23:50, Balaji Selvanathan
wrote:
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 CONFIG_SCSI_ENV_PART_TYPE_GUID configuration option that
allows specifying a partition type GUID for environment storage.
When enabled, the environment subsystem uses the new 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
---
env/Kconfig | 7 +++
env/scsi.c | 13 +
2 files changed, 20 insertions(+)
diff --git a/env/Kconfig b/env/Kconfig
index b312f9b5324..97cb3d05daf 100644
--- a/env/Kconfig
+++ b/env/Kconfig
@@ -768,6 +768,13 @@ config SCSI_ENV_PART_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 ENV_IS_IN_SCSI
+ 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..6182ae26679 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_TYPE_GUID
+ if (scsi_get_blk_by_type_guid(CONFIG_SCSI_ENV_PART_TYPE_GUID, &ep->blk,
&ep->part))
Can you use if IS_ENABLED(CONFIG_SCSI_ENV_PART_TYPE_GUID)
(we try to avoid #ifdef)
Thanks for the feedback.
In this respin
https://lore.kernel.org/u-boot/[email protected]/,
I've introduced a choice statement in env/Kconfig to ensure mutual
exclusivity between CONFIG_SCSI_ENV_PART_UUID and
CONFIG_SCSI_ENV_PART_TYPE_GUID.
Due to this choice-based configuration, only one of these string configs
is defined at compile time. When I attempted to use `if
(IS_ENABLED(...))` for the string concatenation cases, I encountered
compilation errors because the compiler tries to evaluate both branches,
but the undefined config macro causes an "undeclared identifier" error.
For example:
if (IS_ENABLED(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); // Error: CONFIG_SCSI_ENV_PART_UUID undeclared
Given this constraint with mutually exclusive string configs, I've kept
the #ifdef approach for these specific cases. I understand the
preference for IS_ENABLED() for its compile-time checking benefits, but
in this scenario with string concatenation, the preprocessor conditional
appears to be necessary.
Would this approach be acceptable, or would you prefer an alternative
solution?
Best regards,
Balaji
+ 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_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_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
Regards,
Simon
Re: [PATCH v1 3/4] env: scsi: Add support for partition type GUID based environment
Hi Tom, On 1/8/2026 8:02 PM, Tom Rini wrote: On Thu, Jan 08, 2026 at 03:11:37PM +0530, Varadarajan Narayanan wrote: On Thu, Jan 08, 2026 at 12:19:46PM +0530, Balaji Selvanathan wrote: 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 CONFIG_SCSI_ENV_PART_TYPE_GUID configuration option that allows specifying a partition type GUID for environment storage. When enabled, the environment subsystem uses the new 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 --- env/Kconfig | 7 +++ env/scsi.c | 13 + 2 files changed, 20 insertions(+) diff --git a/env/Kconfig b/env/Kconfig index b312f9b5324..97cb3d05daf 100644 --- a/env/Kconfig +++ b/env/Kconfig @@ -768,6 +768,13 @@ config SCSI_ENV_PART_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 ENV_IS_IN_SCSI Should we add depends on ENV_IS_IN_SCSI && !SCSI_ENV_PART_UUID and similarly vice versa in SCSI_ENV_PART_UUID since the code seems to handle them as mutually exclusive... If they're mutually exclusive it needs to be handled in a choice statement. Thanks for the feedback. Introduced a choice config as suggested in this respin: https://lore.kernel.org/u-boot/[email protected]/. Regards, Balaji
Re: [PATCH v1 3/4] env: scsi: Add support for partition type GUID based environment
Hi Varada, On 1/8/2026 3:11 PM, Varadarajan Narayanan wrote: On Thu, Jan 08, 2026 at 12:19:46PM +0530, Balaji Selvanathan wrote: 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 CONFIG_SCSI_ENV_PART_TYPE_GUID configuration option that allows specifying a partition type GUID for environment storage. When enabled, the environment subsystem uses the new 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 --- env/Kconfig | 7 +++ env/scsi.c | 13 + 2 files changed, 20 insertions(+) diff --git a/env/Kconfig b/env/Kconfig index b312f9b5324..97cb3d05daf 100644 --- a/env/Kconfig +++ b/env/Kconfig @@ -768,6 +768,13 @@ config SCSI_ENV_PART_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 ENV_IS_IN_SCSI Should we add depends on ENV_IS_IN_SCSI && !SCSI_ENV_PART_UUID and similarly vice versa in SCSI_ENV_PART_UUID since the code seems to handle them as mutually exclusive... -Varada Introduced a choice config (in this respin: https://lore.kernel.org/u-boot/[email protected]/) as suggested by Tom Rini. Regards, Balaji + 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..6182ae26679 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_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_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_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
Re: [PATCH v1 3/4] env: scsi: Add support for partition type GUID based environment
Hi Balaji,
On Wed, 7 Jan 2026 at 23:50, Balaji Selvanathan
wrote:
>
> 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 CONFIG_SCSI_ENV_PART_TYPE_GUID configuration option that
> allows specifying a partition type GUID for environment storage.
> When enabled, the environment subsystem uses the new 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
> ---
> env/Kconfig | 7 +++
> env/scsi.c | 13 +
> 2 files changed, 20 insertions(+)
>
> diff --git a/env/Kconfig b/env/Kconfig
> index b312f9b5324..97cb3d05daf 100644
> --- a/env/Kconfig
> +++ b/env/Kconfig
> @@ -768,6 +768,13 @@ config SCSI_ENV_PART_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 ENV_IS_IN_SCSI
> + 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..6182ae26679 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_TYPE_GUID
> + if (scsi_get_blk_by_type_guid(CONFIG_SCSI_ENV_PART_TYPE_GUID,
> &ep->blk, &ep->part))
Can you use if IS_ENABLED(CONFIG_SCSI_ENV_PART_TYPE_GUID)
(we try to avoid #ifdef)
> + 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_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_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
>
Regards,
Simon
Re: [PATCH v1 3/4] env: scsi: Add support for partition type GUID based environment
On Thu, Jan 08, 2026 at 03:11:37PM +0530, Varadarajan Narayanan wrote: > On Thu, Jan 08, 2026 at 12:19:46PM +0530, Balaji Selvanathan wrote: > > 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 CONFIG_SCSI_ENV_PART_TYPE_GUID configuration option that > > allows specifying a partition type GUID for environment storage. > > When enabled, the environment subsystem uses the new 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 > > --- > > env/Kconfig | 7 +++ > > env/scsi.c | 13 + > > 2 files changed, 20 insertions(+) > > > > diff --git a/env/Kconfig b/env/Kconfig > > index b312f9b5324..97cb3d05daf 100644 > > --- a/env/Kconfig > > +++ b/env/Kconfig > > @@ -768,6 +768,13 @@ config SCSI_ENV_PART_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 ENV_IS_IN_SCSI > > Should we add > > depends on ENV_IS_IN_SCSI && !SCSI_ENV_PART_UUID > > and similarly vice versa in SCSI_ENV_PART_UUID since the code seems to > handle them as mutually exclusive... If they're mutually exclusive it needs to be handled in a choice statement. -- Tom signature.asc Description: PGP signature
Re: [PATCH v1 3/4] env: scsi: Add support for partition type GUID based environment
On Thu, Jan 08, 2026 at 12:19:46PM +0530, Balaji Selvanathan wrote:
> 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 CONFIG_SCSI_ENV_PART_TYPE_GUID configuration option that
> allows specifying a partition type GUID for environment storage.
> When enabled, the environment subsystem uses the new 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
> ---
> env/Kconfig | 7 +++
> env/scsi.c | 13 +
> 2 files changed, 20 insertions(+)
>
> diff --git a/env/Kconfig b/env/Kconfig
> index b312f9b5324..97cb3d05daf 100644
> --- a/env/Kconfig
> +++ b/env/Kconfig
> @@ -768,6 +768,13 @@ config SCSI_ENV_PART_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 ENV_IS_IN_SCSI
Should we add
depends on ENV_IS_IN_SCSI && !SCSI_ENV_PART_UUID
and similarly vice versa in SCSI_ENV_PART_UUID since the code seems to
handle them as mutually exclusive...
-Varada
> + 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..6182ae26679 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_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_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_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
>

