* [U-Boot] [PATCH] env: Setup GD_FLG_ENV_DEFAULT flag when default environment are used
@ 2016-05-30 14:11 Michal Simek
2016-05-30 19:36 ` Alexander Graf
2016-06-06 21:28 ` [U-Boot] " Tom Rini
0 siblings, 2 replies; 10+ messages in thread
From: Michal Simek @ 2016-05-30 14:11 UTC (permalink / raw)
To: u-boot
Setup flag when default environment are used to be able to
rewrite default distro boot variables based on SoC boot mode.
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---
I didn't find any way how to detect that default or saved variables are
used. I want to have a flag to be able to rewrite boot_targets variable
based on boot mode. Especially when SD boot mode is setup than SD should
be primary boot devices, etc.
When variables are saved boot_targets will be restored and SoC boot mode
will be ignored.
If you know better way how to do it, please let me know.
---
common/env_common.c | 1 +
include/asm-generic/global_data.h | 1 +
2 files changed, 2 insertions(+)
diff --git a/common/env_common.c b/common/env_common.c
index af59c72e1fd7..13db7dc3f755 100644
--- a/common/env_common.c
+++ b/common/env_common.c
@@ -123,6 +123,7 @@ void set_default_env(const char *s)
error("Environment import failed: errno = %d\n", errno);
gd->flags |= GD_FLG_ENV_READY;
+ gd->flags |= GD_FLG_ENV_DEFAULT;
}
diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h
index f2810a1bd75f..0abcbe4c0b3a 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -141,5 +141,6 @@ typedef struct global_data {
#define GD_FLG_SPL_INIT 0x00400 /* spl_init() has been called */
#define GD_FLG_SKIP_RELOC 0x00800 /* Don't relocate */
#define GD_FLG_RECORD 0x01000 /* Record console */
+#define GD_FLG_ENV_DEFAULT 0x02000 /* Default variable flag */
#endif /* __ASM_GENERIC_GBL_DATA_H */
--
1.9.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH] env: Setup GD_FLG_ENV_DEFAULT flag when default environment are used
2016-05-30 14:11 [U-Boot] [PATCH] env: Setup GD_FLG_ENV_DEFAULT flag when default environment are used Michal Simek
@ 2016-05-30 19:36 ` Alexander Graf
2016-05-31 5:04 ` Michal Simek
2016-06-06 21:28 ` [U-Boot] " Tom Rini
1 sibling, 1 reply; 10+ messages in thread
From: Alexander Graf @ 2016-05-30 19:36 UTC (permalink / raw)
To: u-boot
On 05/30/2016 04:11 PM, Michal Simek wrote:
> Setup flag when default environment are used to be able to
> rewrite default distro boot variables based on SoC boot mode.
>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
>
> I didn't find any way how to detect that default or saved variables are
> used. I want to have a flag to be able to rewrite boot_targets variable
> based on boot mode. Especially when SD boot mode is setup than SD should
> be primary boot devices, etc.
> When variables are saved boot_targets will be restored and SoC boot mode
> will be ignored.
> If you know better way how to do it, please let me know.
You may want to be able to do the same from inside a script, so I guess
we should better have this as an environment variable itself again.
There was a way to have environment variable reads return a value
directly from code rather than go via environment storage. I guess we
could expose the flag through that?
Or add an environment variable that we set in set_default_env() and
ignore that variable on saveenv. I'm not sure I like that option better
than your current one though.
Alex
>
> ---
> common/env_common.c | 1 +
> include/asm-generic/global_data.h | 1 +
> 2 files changed, 2 insertions(+)
>
> diff --git a/common/env_common.c b/common/env_common.c
> index af59c72e1fd7..13db7dc3f755 100644
> --- a/common/env_common.c
> +++ b/common/env_common.c
> @@ -123,6 +123,7 @@ void set_default_env(const char *s)
> error("Environment import failed: errno = %d\n", errno);
>
> gd->flags |= GD_FLG_ENV_READY;
> + gd->flags |= GD_FLG_ENV_DEFAULT;
> }
>
>
> diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h
> index f2810a1bd75f..0abcbe4c0b3a 100644
> --- a/include/asm-generic/global_data.h
> +++ b/include/asm-generic/global_data.h
> @@ -141,5 +141,6 @@ typedef struct global_data {
> #define GD_FLG_SPL_INIT 0x00400 /* spl_init() has been called */
> #define GD_FLG_SKIP_RELOC 0x00800 /* Don't relocate */
> #define GD_FLG_RECORD 0x01000 /* Record console */
> +#define GD_FLG_ENV_DEFAULT 0x02000 /* Default variable flag */
>
> #endif /* __ASM_GENERIC_GBL_DATA_H */
^ permalink raw reply [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH] env: Setup GD_FLG_ENV_DEFAULT flag when default environment are used
2016-05-30 19:36 ` Alexander Graf
@ 2016-05-31 5:04 ` Michal Simek
2016-05-31 6:39 ` Alexander Graf
0 siblings, 1 reply; 10+ messages in thread
From: Michal Simek @ 2016-05-31 5:04 UTC (permalink / raw)
To: u-boot
On 30.5.2016 21:36, Alexander Graf wrote:
>
>
> On 05/30/2016 04:11 PM, Michal Simek wrote:
>> Setup flag when default environment are used to be able to
>> rewrite default distro boot variables based on SoC boot mode.
>>
>> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
>> ---
>>
>> I didn't find any way how to detect that default or saved variables are
>> used. I want to have a flag to be able to rewrite boot_targets variable
>> based on boot mode. Especially when SD boot mode is setup than SD should
>> be primary boot devices, etc.
>> When variables are saved boot_targets will be restored and SoC boot mode
>> will be ignored.
>> If you know better way how to do it, please let me know.
>
> You may want to be able to do the same from inside a script, so I guess
> we should better have this as an environment variable itself again.
Was there any environment in past?
>
> There was a way to have environment variable reads return a value
> directly from code rather than go via environment storage. I guess we
> could expose the flag through that?
If you expose environment variable and then run saveenv this variable
will be saved and restored again and your script behaves the same.
>
> Or add an environment variable that we set in set_default_env() and
> ignore that variable on saveenv. I'm not sure I like that option better
> than your current one though.
Yes this should work but sounds pretty hacky.
Just and example of usage which I have tested on ZynqMP.
Based on bootmode different boot_targets are setup and this setting is
blocked for saved environment detected via this flag.
Thanks,
Michal
224 int board_late_init(void)
225 {
226 u32 reg = 0;
227 u8 bootmode;
228
229 if (!(gd->flags & GD_FLG_ENV_DEFAULT)) {
230 debug("Saved variables - Skipping\n");
231 return 0;
232 }
233
234 reg = readl(&crlapb_base->boot_mode);
235 bootmode = reg & BOOT_MODES_MASK;
236
237 puts("Bootmode: ");
238 switch (bootmode) {
239 case JTAG_MODE:
240 puts("JTAG_MODE\n");
241 setenv("boot_targets", "pxe dhcp");
242 break;
243 case QSPI_MODE_24BIT:
244 case QSPI_MODE_32BIT:
245 setenv("boot_targets", "qspi0");
246 puts("QSPI_MODE\n");
247 break;
248 case EMMC_MODE:
249 puts("EMMC_MODE\n");
250 setenv("boot_targets", "mmc0 mmc1");
251 break;
252 case SD_MODE:
253 puts("SD_MODE\n");
254 setenv("boot_targets", "mmc0 mmc1");
255 break;
256 case SD_MODE1:
257 puts("SD_MODE1\n");
258 setenv("boot_targets", "mmc0 mmc1");
259 break;
260 case NAND_MODE:
261 puts("NAND_MODE\n");
262 setenv("boot_targets", "nand0");
263 break;
264 default:
265 printf("Invalid Boot Mode:0x%x\n", bootmode);
266 break;
267 }
268
269 return 0;
270 }
^ permalink raw reply [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH] env: Setup GD_FLG_ENV_DEFAULT flag when default environment are used
2016-05-31 5:04 ` Michal Simek
@ 2016-05-31 6:39 ` Alexander Graf
2016-05-31 7:40 ` Michal Simek
0 siblings, 1 reply; 10+ messages in thread
From: Alexander Graf @ 2016-05-31 6:39 UTC (permalink / raw)
To: u-boot
> Am 31.05.2016 um 07:04 schrieb Michal Simek <michal.simek@xilinx.com>:
>
>> On 30.5.2016 21:36, Alexander Graf wrote:
>>
>>
>>> On 05/30/2016 04:11 PM, Michal Simek wrote:
>>> Setup flag when default environment are used to be able to
>>> rewrite default distro boot variables based on SoC boot mode.
>>>
>>> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
>>> ---
>>>
>>> I didn't find any way how to detect that default or saved variables are
>>> used. I want to have a flag to be able to rewrite boot_targets variable
>>> based on boot mode. Especially when SD boot mode is setup than SD should
>>> be primary boot devices, etc.
>>> When variables are saved boot_targets will be restored and SoC boot mode
>>> will be ignored.
>>> If you know better way how to do it, please let me know.
>>
>> You may want to be able to do the same from inside a script, so I guess
>> we should better have this as an environment variable itself again.
>
> Was there any environment in past?
With again I meant "from C as well as from script".
>>
>> There was a way to have environment variable reads return a value
>> directly from code rather than go via environment storage. I guess we
>> could expose the flag through that?
>
> If you expose environment variable and then run saveenv this variable
> will be saved and restored again and your script behaves the same.
Not if we declare the environment variable read as callback ;).
Alex
^ permalink raw reply [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH] env: Setup GD_FLG_ENV_DEFAULT flag when default environment are used
2016-05-31 6:39 ` Alexander Graf
@ 2016-05-31 7:40 ` Michal Simek
2016-06-01 14:16 ` Alexander Graf
0 siblings, 1 reply; 10+ messages in thread
From: Michal Simek @ 2016-05-31 7:40 UTC (permalink / raw)
To: u-boot
On 31.5.2016 08:39, Alexander Graf wrote:
>
>
>> Am 31.05.2016 um 07:04 schrieb Michal Simek <michal.simek@xilinx.com>:
>>
>>> On 30.5.2016 21:36, Alexander Graf wrote:
>>>
>>>
>>>> On 05/30/2016 04:11 PM, Michal Simek wrote:
>>>> Setup flag when default environment are used to be able to
>>>> rewrite default distro boot variables based on SoC boot mode.
>>>>
>>>> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
>>>> ---
>>>>
>>>> I didn't find any way how to detect that default or saved variables are
>>>> used. I want to have a flag to be able to rewrite boot_targets variable
>>>> based on boot mode. Especially when SD boot mode is setup than SD should
>>>> be primary boot devices, etc.
>>>> When variables are saved boot_targets will be restored and SoC boot mode
>>>> will be ignored.
>>>> If you know better way how to do it, please let me know.
>>>
>>> You may want to be able to do the same from inside a script, so I guess
>>> we should better have this as an environment variable itself again.
>>
>> Was there any environment in past?
>
> With again I meant "from C as well as from script".
>
>>>
>>> There was a way to have environment variable reads return a value
>>> directly from code rather than go via environment storage. I guess we
>>> could expose the flag through that?
>>
>> If you expose environment variable and then run saveenv this variable
>> will be saved and restored again and your script behaves the same.
>
> Not if we declare the environment variable read as callback ;).
What do you mean?
It is kind of interesting that this is not done already for others SoCs
when you want to use distro config. :-)
Cheers,
Michal
^ permalink raw reply [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH] env: Setup GD_FLG_ENV_DEFAULT flag when default environment are used
2016-05-31 7:40 ` Michal Simek
@ 2016-06-01 14:16 ` Alexander Graf
2016-06-01 14:21 ` Michal Simek
0 siblings, 1 reply; 10+ messages in thread
From: Alexander Graf @ 2016-06-01 14:16 UTC (permalink / raw)
To: u-boot
On 31.05.16 09:40, Michal Simek wrote:
> On 31.5.2016 08:39, Alexander Graf wrote:
>>
>>
>>> Am 31.05.2016 um 07:04 schrieb Michal Simek <michal.simek@xilinx.com>:
>>>
>>>> On 30.5.2016 21:36, Alexander Graf wrote:
>>>>
>>>>
>>>>> On 05/30/2016 04:11 PM, Michal Simek wrote:
>>>>> Setup flag when default environment are used to be able to
>>>>> rewrite default distro boot variables based on SoC boot mode.
>>>>>
>>>>> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
>>>>> ---
>>>>>
>>>>> I didn't find any way how to detect that default or saved variables are
>>>>> used. I want to have a flag to be able to rewrite boot_targets variable
>>>>> based on boot mode. Especially when SD boot mode is setup than SD should
>>>>> be primary boot devices, etc.
>>>>> When variables are saved boot_targets will be restored and SoC boot mode
>>>>> will be ignored.
>>>>> If you know better way how to do it, please let me know.
>>>>
>>>> You may want to be able to do the same from inside a script, so I guess
>>>> we should better have this as an environment variable itself again.
>>>
>>> Was there any environment in past?
>>
>> With again I meant "from C as well as from script".
>>
>>>>
>>>> There was a way to have environment variable reads return a value
>>>> directly from code rather than go via environment storage. I guess we
>>>> could expose the flag through that?
>>>
>>> If you expose environment variable and then run saveenv this variable
>>> will be saved and restored again and your script behaves the same.
>>
>> Not if we declare the environment variable read as callback ;).
>
> What do you mean?
Meh, apparently I misremembered.
> It is kind of interesting that this is not done already for others SoCs
> when you want to use distro config. :-)
Well, there's always a first :).
Either way, I guess your patch is perfectly fine as a first step. It
would be nice to also introduce some way for scripts to evaluate whether
the environment is the default environment, but we can always add that
later.
Alex
^ permalink raw reply [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH] env: Setup GD_FLG_ENV_DEFAULT flag when default environment are used
2016-06-01 14:16 ` Alexander Graf
@ 2016-06-01 14:21 ` Michal Simek
2016-06-01 14:24 ` Alexander Graf
0 siblings, 1 reply; 10+ messages in thread
From: Michal Simek @ 2016-06-01 14:21 UTC (permalink / raw)
To: u-boot
On 1.6.2016 16:16, Alexander Graf wrote:
>
>
> On 31.05.16 09:40, Michal Simek wrote:
>> On 31.5.2016 08:39, Alexander Graf wrote:
>>>
>>>
>>>> Am 31.05.2016 um 07:04 schrieb Michal Simek <michal.simek@xilinx.com>:
>>>>
>>>>> On 30.5.2016 21:36, Alexander Graf wrote:
>>>>>
>>>>>
>>>>>> On 05/30/2016 04:11 PM, Michal Simek wrote:
>>>>>> Setup flag when default environment are used to be able to
>>>>>> rewrite default distro boot variables based on SoC boot mode.
>>>>>>
>>>>>> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
>>>>>> ---
>>>>>>
>>>>>> I didn't find any way how to detect that default or saved variables are
>>>>>> used. I want to have a flag to be able to rewrite boot_targets variable
>>>>>> based on boot mode. Especially when SD boot mode is setup than SD should
>>>>>> be primary boot devices, etc.
>>>>>> When variables are saved boot_targets will be restored and SoC boot mode
>>>>>> will be ignored.
>>>>>> If you know better way how to do it, please let me know.
>>>>>
>>>>> You may want to be able to do the same from inside a script, so I guess
>>>>> we should better have this as an environment variable itself again.
>>>>
>>>> Was there any environment in past?
>>>
>>> With again I meant "from C as well as from script".
>>>
>>>>>
>>>>> There was a way to have environment variable reads return a value
>>>>> directly from code rather than go via environment storage. I guess we
>>>>> could expose the flag through that?
>>>>
>>>> If you expose environment variable and then run saveenv this variable
>>>> will be saved and restored again and your script behaves the same.
>>>
>>> Not if we declare the environment variable read as callback ;).
>>
>> What do you mean?
>
> Meh, apparently I misremembered.
>
>> It is kind of interesting that this is not done already for others SoCs
>> when you want to use distro config. :-)
>
> Well, there's always a first :).
>
> Either way, I guess your patch is perfectly fine as a first step. It
> would be nice to also introduce some way for scripts to evaluate whether
> the environment is the default environment, but we can always add that
> later.
Does this mean your Acked-by line?
Cheers,
Michal
^ permalink raw reply [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH] env: Setup GD_FLG_ENV_DEFAULT flag when default environment are used
2016-06-01 14:21 ` Michal Simek
@ 2016-06-01 14:24 ` Alexander Graf
0 siblings, 0 replies; 10+ messages in thread
From: Alexander Graf @ 2016-06-01 14:24 UTC (permalink / raw)
To: u-boot
On 01.06.16 16:21, Michal Simek wrote:
> On 1.6.2016 16:16, Alexander Graf wrote:
>>
>>
>> On 31.05.16 09:40, Michal Simek wrote:
>>> On 31.5.2016 08:39, Alexander Graf wrote:
>>>>
>>>>
>>>>> Am 31.05.2016 um 07:04 schrieb Michal Simek <michal.simek@xilinx.com>:
>>>>>
>>>>>> On 30.5.2016 21:36, Alexander Graf wrote:
>>>>>>
>>>>>>
>>>>>>> On 05/30/2016 04:11 PM, Michal Simek wrote:
>>>>>>> Setup flag when default environment are used to be able to
>>>>>>> rewrite default distro boot variables based on SoC boot mode.
>>>>>>>
>>>>>>> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
>>>>>>> ---
>>>>>>>
>>>>>>> I didn't find any way how to detect that default or saved variables are
>>>>>>> used. I want to have a flag to be able to rewrite boot_targets variable
>>>>>>> based on boot mode. Especially when SD boot mode is setup than SD should
>>>>>>> be primary boot devices, etc.
>>>>>>> When variables are saved boot_targets will be restored and SoC boot mode
>>>>>>> will be ignored.
>>>>>>> If you know better way how to do it, please let me know.
>>>>>>
>>>>>> You may want to be able to do the same from inside a script, so I guess
>>>>>> we should better have this as an environment variable itself again.
>>>>>
>>>>> Was there any environment in past?
>>>>
>>>> With again I meant "from C as well as from script".
>>>>
>>>>>>
>>>>>> There was a way to have environment variable reads return a value
>>>>>> directly from code rather than go via environment storage. I guess we
>>>>>> could expose the flag through that?
>>>>>
>>>>> If you expose environment variable and then run saveenv this variable
>>>>> will be saved and restored again and your script behaves the same.
>>>>
>>>> Not if we declare the environment variable read as callback ;).
>>>
>>> What do you mean?
>>
>> Meh, apparently I misremembered.
>>
>>> It is kind of interesting that this is not done already for others SoCs
>>> when you want to use distro config. :-)
>>
>> Well, there's always a first :).
>>
>> Either way, I guess your patch is perfectly fine as a first step. It
>> would be nice to also introduce some way for scripts to evaluate whether
>> the environment is the default environment, but we can always add that
>> later.
>
> Does this mean your Acked-by line?
>
Reviewed-by: Alexander Graf <agraf@suse.de>
(IIRC Reviewed-by is stronger than Acked-by)
Alex
^ permalink raw reply [flat|nested] 10+ messages in thread
* [U-Boot] env: Setup GD_FLG_ENV_DEFAULT flag when default environment are used
2016-05-30 14:11 [U-Boot] [PATCH] env: Setup GD_FLG_ENV_DEFAULT flag when default environment are used Michal Simek
2016-05-30 19:36 ` Alexander Graf
@ 2016-06-06 21:28 ` Tom Rini
2016-06-06 21:34 ` Tom Rini
1 sibling, 1 reply; 10+ messages in thread
From: Tom Rini @ 2016-06-06 21:28 UTC (permalink / raw)
To: u-boot
On Mon, May 30, 2016 at 04:11:53PM +0200, Michal Simek wrote:
> Setup flag when default environment are used to be able to
> rewrite default distro boot variables based on SoC boot mode.
>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> Reviewed-by: Alexander Graf <agraf@suse.de>
Applied to u-boot/master, thanks!
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160606/d08d081d/attachment.sig>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [U-Boot] env: Setup GD_FLG_ENV_DEFAULT flag when default environment are used
2016-06-06 21:28 ` [U-Boot] " Tom Rini
@ 2016-06-06 21:34 ` Tom Rini
0 siblings, 0 replies; 10+ messages in thread
From: Tom Rini @ 2016-06-06 21:34 UTC (permalink / raw)
To: u-boot
On Mon, Jun 06, 2016 at 05:28:33PM -0400, Tom Rini wrote:
> On Mon, May 30, 2016 at 04:11:53PM +0200, Michal Simek wrote:
>
> > Setup flag when default environment are used to be able to
> > rewrite default distro boot variables based on SoC boot mode.
> >
> > Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> > Reviewed-by: Alexander Graf <agraf@suse.de>
>
> Applied to u-boot/master, thanks!
... yes, this was already in via Michal's tree, it didn't get applied
twice, I just didn't delete it from my bundle.
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160606/8096b52e/attachment.sig>
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2016-06-06 21:34 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-30 14:11 [U-Boot] [PATCH] env: Setup GD_FLG_ENV_DEFAULT flag when default environment are used Michal Simek
2016-05-30 19:36 ` Alexander Graf
2016-05-31 5:04 ` Michal Simek
2016-05-31 6:39 ` Alexander Graf
2016-05-31 7:40 ` Michal Simek
2016-06-01 14:16 ` Alexander Graf
2016-06-01 14:21 ` Michal Simek
2016-06-01 14:24 ` Alexander Graf
2016-06-06 21:28 ` [U-Boot] " Tom Rini
2016-06-06 21:34 ` Tom Rini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox