From: Michal Simek <michal.simek@xilinx.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] env: Setup GD_FLG_ENV_DEFAULT flag when default environment are used
Date: Tue, 31 May 2016 07:04:57 +0200 [thread overview]
Message-ID: <574D1B79.7090308@xilinx.com> (raw)
In-Reply-To: <574C962B.2090503@suse.de>
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 }
next prev parent reply other threads:[~2016-05-31 5:04 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=574D1B79.7090308@xilinx.com \
--to=michal.simek@xilinx.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox