Re: [PATCH] configs: rockchip: rock5b: enable environment

2024-03-05 Thread Jonas Karlman
On 2024-03-05 11:11, Quentin Schulz wrote:
> Hi all,
> 
> On 3/5/24 10:36, Christopher Obbard wrote:
>> [You don't often get email from chris.obb...@collabora.com. Learn why this 
>> is important at https://aka.ms/LearnAboutSenderIdentification ]
>>
>> Hi Jonas & Trevor,
>>
>> On Tue, 2024-03-05 at 10:31 +0100, Jonas Karlman wrote:
>>> Hi Trevor,
>>>
>>> On 2024-03-05 03:10, Trevor Woerner wrote:
 Following the pattern of other Rockchip devices, enable the U-Boot
 environment to be stored in MMC. This patch specifically assumes the
 environment will be stored on the SDcard.
>>>
>>> This board has SPI flash, so storing env in SPI flash is probably a
>>> better default.
>>
>> I agree with that.
>>
>>> However, preferably the env should be stored/loaded from
>>> the same device that TPL/SPL was loaded from.
>>
>> Do you know if there is some mechanism in U-Boot to do this already ?
>>
> 
> We do this for our Theobroma boards, though we use the same device that 
> U-Boot proper was loaded from, and not the one that TPL+SPL was loaded 
> from but the logic could be more or less the same.

Good catch, same as U-Boot proper may be more accurate and what I was
expecting, I typically expect TPL+SPL and FIT to be loaded from same
media so may see them as interchangeably.

My normal expectation will be that if FIT cannot be loaded from
same-as-spl we are in some kind of fallback and/or recovery mode.

Maybe a u-boot,env-load-order prop, similar to u-boot,spl-boot-order,
could be an option? with support for similar options, same-as-spl and
same-as-fit/proper/boot or node refs.

> 
> https://source.denx.de/u-boot/u-boot/-/blob/master/board/theobroma-systems/common/common.c?ref_type=heads#L92-L152
> 
> is what you need. The first function is to differentiate between SD card 
> and eMMC, the second actually returns the **kind** of medium the 
> environment is stored on (so MMC or SPI-flash for Theobroma boards).
> 
> Instead of 
> https://source.denx.de/u-boot/u-boot/-/blob/master/board/theobroma-systems/common/common.c?ref_type=heads#L94-L95
>  
> you probably want to use board_spl_was_booted_from().
> 
> Note that to you need the MMC and SPI controllers to be bound in U-Boot 
> proper **before relocation** for this to work. c.f. 
> https://lore.kernel.org/u-boot/20240221-jaguar-v3-15-1f256a822...@theobroma-systems.com/
> 
>> It could be useful to enable autodetection on many boards which can boot U-
>> Boot from either SPI flash / eMMC / SD card.
>>
> 
> There's been an attempt recently:
> 
> https://lore.kernel.org/u-boot/20240226011413.435713-2-benwolsief...@gmail.com/
> 
> though only for the MMC part of the equation.

I thought I noticed something related last few days/weeks, did not
manage to find anything when I went looking for it :-)

Regards,
Jonas

> 
> Cheers,
> Quentin



Re: [PATCH] configs: rockchip: rock5b: enable environment

2024-03-05 Thread Dragan Simic

Hello all,

On 2024-03-05 10:36, Christopher Obbard wrote:

On Tue, 2024-03-05 at 10:31 +0100, Jonas Karlman wrote:

On 2024-03-05 03:10, Trevor Woerner wrote:
> Following the pattern of other Rockchip devices, enable the U-Boot
> environment to be stored in MMC. This patch specifically assumes the
> environment will be stored on the SDcard.

This board has SPI flash, so storing env in SPI flash is probably a
better default.


I agree with that.


However, preferably the env should be stored/loaded from
the same device that TPL/SPL was loaded from.


Do you know if there is some mechanism in U-Boot to do this already ?

It could be useful to enable autodetection on many boards which can 
boot U-

Boot from either SPI flash / eMMC / SD card.


I agree that doing this on all Rockchip boards should be the way to go, 
or

perhaps to use the device that the U-Boot proper was loaded from.

Moreover, it would, for example, allow a microSD card to be used as a 
rescue

boot media for the users to recover from a borked environment.


Re: [PATCH] configs: rockchip: rock5b: enable environment

2024-03-05 Thread Quentin Schulz

Hi all,

On 3/5/24 10:36, Christopher Obbard wrote:

[You don't often get email from chris.obb...@collabora.com. Learn why this is 
important at https://aka.ms/LearnAboutSenderIdentification ]

Hi Jonas & Trevor,

On Tue, 2024-03-05 at 10:31 +0100, Jonas Karlman wrote:

Hi Trevor,

On 2024-03-05 03:10, Trevor Woerner wrote:

Following the pattern of other Rockchip devices, enable the U-Boot
environment to be stored in MMC. This patch specifically assumes the
environment will be stored on the SDcard.


This board has SPI flash, so storing env in SPI flash is probably a
better default.


I agree with that.


However, preferably the env should be stored/loaded from
the same device that TPL/SPL was loaded from.


Do you know if there is some mechanism in U-Boot to do this already ?



We do this for our Theobroma boards, though we use the same device that 
U-Boot proper was loaded from, and not the one that TPL+SPL was loaded 
from but the logic could be more or less the same.


https://source.denx.de/u-boot/u-boot/-/blob/master/board/theobroma-systems/common/common.c?ref_type=heads#L92-L152

is what you need. The first function is to differentiate between SD card 
and eMMC, the second actually returns the **kind** of medium the 
environment is stored on (so MMC or SPI-flash for Theobroma boards).


Instead of 
https://source.denx.de/u-boot/u-boot/-/blob/master/board/theobroma-systems/common/common.c?ref_type=heads#L94-L95 
you probably want to use board_spl_was_booted_from().


Note that to you need the MMC and SPI controllers to be bound in U-Boot 
proper **before relocation** for this to work. c.f. 
https://lore.kernel.org/u-boot/20240221-jaguar-v3-15-1f256a822...@theobroma-systems.com/



It could be useful to enable autodetection on many boards which can boot U-
Boot from either SPI flash / eMMC / SD card.



There's been an attempt recently:

https://lore.kernel.org/u-boot/20240226011413.435713-2-benwolsief...@gmail.com/

though only for the MMC part of the equation.

Cheers,
Quentin


Re: [PATCH] configs: rockchip: rock5b: enable environment

2024-03-05 Thread Jonas Karlman
Hi Christopher,

On 2024-03-05 10:36, Christopher Obbard wrote:
> Hi Jonas & Trevor,
> 
> On Tue, 2024-03-05 at 10:31 +0100, Jonas Karlman wrote:
>> Hi Trevor,
>>
>> On 2024-03-05 03:10, Trevor Woerner wrote:
>>> Following the pattern of other Rockchip devices, enable the U-Boot
>>> environment to be stored in MMC. This patch specifically assumes the
>>> environment will be stored on the SDcard.
>>
>> This board has SPI flash, so storing env in SPI flash is probably a
>> better default.
> 
> I agree with that.
> 
>> However, preferably the env should be stored/loaded from
>> the same device that TPL/SPL was loaded from.
> 
> Do you know if there is some mechanism in U-Boot to do this already ?
> 
> It could be useful to enable autodetection on many boards which can boot U-
> Boot from either SPI flash / eMMC / SD card.
> 

I think it should be possible with a combo of env_get_location(),
arch_env_get_location() and mmc_get_env_dev().

board/theobroma-systems/common/common.c does something like this already,
other arch also have these functions defined, for inspiration.

Regards,
Jonas

> 
> Cheers!
> 
> Chris
> 
>>
>> Regards,
>> Jonas
>>
>>>
>>> Signed-off-by: Trevor Woerner 
>>> ---
>>>  configs/rock5b-rk3588_defconfig | 2 ++
>>>  1 file changed, 2 insertions(+)
>>>
>>> diff --git a/configs/rock5b-rk3588_defconfig b/configs/rock5b-
>>> rk3588_defconfig
>>> index 0595325e8107..64a242003aa1 100644
>>> --- a/configs/rock5b-rk3588_defconfig
>>> +++ b/configs/rock5b-rk3588_defconfig
>>> @@ -60,6 +60,8 @@ CONFIG_CMD_REGULATOR=y
>>>  CONFIG_SPL_OF_CONTROL=y
>>>  CONFIG_OF_LIVE=y
>>>  CONFIG_OF_SPL_REMOVE_PROPS="clock-names interrupt-parent assigned-clocks
>>> assigned-clock-rates assigned-clock-parents"
>>> +CONFIG_ENV_IS_IN_MMC=y
>>> +CONFIG_SYS_MMC_ENV_DEV=1
>>>  CONFIG_SPL_DM_SEQ_ALIAS=y
>>>  CONFIG_SPL_REGMAP=y
>>>  CONFIG_SPL_SYSCON=y
>>



Re: [PATCH] configs: rockchip: rock5b: enable environment

2024-03-05 Thread Christopher Obbard
Hi Jonas & Trevor,

On Tue, 2024-03-05 at 10:31 +0100, Jonas Karlman wrote:
> Hi Trevor,
> 
> On 2024-03-05 03:10, Trevor Woerner wrote:
> > Following the pattern of other Rockchip devices, enable the U-Boot
> > environment to be stored in MMC. This patch specifically assumes the
> > environment will be stored on the SDcard.
> 
> This board has SPI flash, so storing env in SPI flash is probably a
> better default.

I agree with that.

> However, preferably the env should be stored/loaded from
> the same device that TPL/SPL was loaded from.

Do you know if there is some mechanism in U-Boot to do this already ?

It could be useful to enable autodetection on many boards which can boot U-
Boot from either SPI flash / eMMC / SD card.


Cheers!

Chris

> 
> Regards,
> Jonas
> 
> > 
> > Signed-off-by: Trevor Woerner 
> > ---
> >  configs/rock5b-rk3588_defconfig | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/configs/rock5b-rk3588_defconfig b/configs/rock5b-
> > rk3588_defconfig
> > index 0595325e8107..64a242003aa1 100644
> > --- a/configs/rock5b-rk3588_defconfig
> > +++ b/configs/rock5b-rk3588_defconfig
> > @@ -60,6 +60,8 @@ CONFIG_CMD_REGULATOR=y
> >  CONFIG_SPL_OF_CONTROL=y
> >  CONFIG_OF_LIVE=y
> >  CONFIG_OF_SPL_REMOVE_PROPS="clock-names interrupt-parent assigned-clocks
> > assigned-clock-rates assigned-clock-parents"
> > +CONFIG_ENV_IS_IN_MMC=y
> > +CONFIG_SYS_MMC_ENV_DEV=1
> >  CONFIG_SPL_DM_SEQ_ALIAS=y
> >  CONFIG_SPL_REGMAP=y
> >  CONFIG_SPL_SYSCON=y
> 


Re: [PATCH] configs: rockchip: rock5b: enable environment

2024-03-05 Thread Jonas Karlman
Hi Trevor,

On 2024-03-05 03:10, Trevor Woerner wrote:
> Following the pattern of other Rockchip devices, enable the U-Boot
> environment to be stored in MMC. This patch specifically assumes the
> environment will be stored on the SDcard.

This board has SPI flash, so storing env in SPI flash is probably a
better default. However, preferably the env should be stored/loaded from
the same device that TPL/SPL was loaded from.

Regards,
Jonas

> 
> Signed-off-by: Trevor Woerner 
> ---
>  configs/rock5b-rk3588_defconfig | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/configs/rock5b-rk3588_defconfig b/configs/rock5b-rk3588_defconfig
> index 0595325e8107..64a242003aa1 100644
> --- a/configs/rock5b-rk3588_defconfig
> +++ b/configs/rock5b-rk3588_defconfig
> @@ -60,6 +60,8 @@ CONFIG_CMD_REGULATOR=y
>  CONFIG_SPL_OF_CONTROL=y
>  CONFIG_OF_LIVE=y
>  CONFIG_OF_SPL_REMOVE_PROPS="clock-names interrupt-parent assigned-clocks 
> assigned-clock-rates assigned-clock-parents"
> +CONFIG_ENV_IS_IN_MMC=y
> +CONFIG_SYS_MMC_ENV_DEV=1
>  CONFIG_SPL_DM_SEQ_ALIAS=y
>  CONFIG_SPL_REGMAP=y
>  CONFIG_SPL_SYSCON=y



[PATCH] configs: rockchip: rock5b: enable environment

2024-03-04 Thread Trevor Woerner
Following the pattern of other Rockchip devices, enable the U-Boot
environment to be stored in MMC. This patch specifically assumes the
environment will be stored on the SDcard.

Signed-off-by: Trevor Woerner 
---
 configs/rock5b-rk3588_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/configs/rock5b-rk3588_defconfig b/configs/rock5b-rk3588_defconfig
index 0595325e8107..64a242003aa1 100644
--- a/configs/rock5b-rk3588_defconfig
+++ b/configs/rock5b-rk3588_defconfig
@@ -60,6 +60,8 @@ CONFIG_CMD_REGULATOR=y
 CONFIG_SPL_OF_CONTROL=y
 CONFIG_OF_LIVE=y
 CONFIG_OF_SPL_REMOVE_PROPS="clock-names interrupt-parent assigned-clocks 
assigned-clock-rates assigned-clock-parents"
+CONFIG_ENV_IS_IN_MMC=y
+CONFIG_SYS_MMC_ENV_DEV=1
 CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_SPL_REGMAP=y
 CONFIG_SPL_SYSCON=y
-- 
2.43.0.76.g1a87c842ece3