From: Detlev Zundel <dzu@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] U-boot env variables parsing
Date: Thu, 01 Apr 2010 14:15:03 +0200 [thread overview]
Message-ID: <m2d3yj74jc.fsf@ohwell.denx.de> (raw)
In-Reply-To: <553166.33158.qm@web50107.mail.re2.yahoo.com> (Nitin Mahajan's message of "Wed, 31 Mar 2010 22:27:29 -0700 (PDT)")
Hi Nitin,
> Hi!
>
> I am doing env settings some thing like this,
>
> ROOT1=/dev/mmcblk0p1
> ROOT2=/dev/mmcblk0p2
> ROOT=${ROOT1}
> bootargs1=console=ttyS0,115200n8 mem=256M noinitrd rw rootdelay=1 ${ROOT}
>
> when I say 'setenv bootargs ${bootargs1}', ${ROOT} gets resolved to 'ROOT1', it does not get completely resolved to '/dev/mmcblk0p1'.
>
> Is there something fundamentally wrong in setting the env variables
> this way?
There is nothing fundamentally wrong - it will simply not work ;) No,
seriously, you want U-Boot to do two evaluation passes over bootargs,
which we cannot do. In a regular shell this would be done by a separate
"eval" or backtick round, but we lack this.
What we usually do is something like this (example taken from an
arbitrary board):
nfsargs=setenv bootargs root=/dev/nfs rw nfsroot=${serverip}:${rootpath}
addip=setenv bootargs ${bootargs} ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}:${netdev}:off panic=1
addtty=setenv bootargs ${bootargs} console=tty0 console=${consdev},${baudrate}
addfb=setenv bootargs ${bootargs} fbcon=map:5 video=fslfb:800x480-32 at 60
flash_nfs=run nfsargs addip addtty addfb;bootm ${kernel_addr} - ${fdt_addr}
When "run flash_nfs" is executed, little "scripts" are called and they
assemble a full command line from different variables. So in this
example, one could simply change ${kernel_addr} and "run flash_nfs"
would boot the new kernel.
If you don't like such constructs, you can also get more funky and start
using "if ... then .. else .." construct in the hush shell parser.
> What would be the right way to achieve this, as I want ROOT to be
> ${ROOT1} sometimes and ${ROOT2} some times?
There is more than one way to do it ;)
Cheers
Detlev
--
Another helpful hint for successful MIME processing:
application/msword; rm -f %s; description="MS Word Text";
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de
next prev parent reply other threads:[~2010-04-01 12:15 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-01 5:27 [U-Boot] U-boot env variables parsing Nitin Mahajan
2010-04-01 12:15 ` Detlev Zundel [this message]
2010-04-01 12:31 ` Joakim Tjernlund
2010-04-01 12:47 ` Wolfgang Denk
2010-04-01 12:56 ` Joakim Tjernlund
2010-04-01 13:05 ` Wolfgang Denk
2010-04-01 13:11 ` Joakim Tjernlund
2010-04-01 14:56 ` Detlev Zundel
2010-04-01 17:13 ` Joakim Tjernlund
2010-04-01 18:27 ` Wolfgang Denk
2010-04-01 20:08 ` Joakim Tjernlund
2010-04-08 10:00 ` Detlev Zundel
2010-04-08 15:41 ` Joakim Tjernlund
2010-04-08 16:06 ` Detlev Zundel
2010-04-08 17:49 ` Joakim Tjernlund
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=m2d3yj74jc.fsf@ohwell.denx.de \
--to=dzu@denx.de \
--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