public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Wolfgang Denk <wd@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] How can I save U-Boot env vars to HUSH shell vars.
Date: Thu, 10 Apr 2014 08:52:20 +0200	[thread overview]
Message-ID: <20140410065220.D43D73803C8@gemini.denx.de> (raw)
In-Reply-To: <5345D493.4080803@gmail.com>

Dear James,

In message <5345D493.4080803@gmail.com> you wrote:
> 
> > Heh.  As soon as you have to change _any_ code, you can as well
> > upgrade.
> 
> I was hoping (in vain perhaps) to do my work modifying only the environment.

Yes, I understand this.  But I have to admit that I don't see an easy
way.

Hm... thinking about it, you _can_ do this, but it's a bit ugly...

POC code:

	=> print ethaddr ipaddr serverip
	ethaddr=00:10:ec:01:08:84
	ipaddr=192.168.100.6
	serverip=192.168.1.1

	=> echo E=$foo_ethaddr I=$foo_ipaddr S=$foo_serverip
	E= I= S=

	=> setenv setvar 'setenv tmp "foo_$arg=$$arg"'

	=> for arg in ethaddr ipaddr serverip ; do
	> run setvar
	> run tmp
	> echo E=$foo_ethaddr I=$foo_ipaddr S=$foo_serverip
	> done
	E=00:10:ec:01:08:84 I= S=
	E=00:10:ec:01:08:84 I=192.168.100.6 S=
	E=00:10:ec:01:08:84 I=192.168.100.6 S=192.168.1.1

As you can see, I'm useing a two-step approach to first constuct a
command and then to run it.  This "consumes" 2 environment variables
("tmp" and "arg"), but this should be an acceptable price...

> This is a definite drawback to having an old U-Boot; I'm sure I would 
> benefit from the bug fixes and other enhancements.

Yes.

> Exporting a list of values sounds like a nice addition that would be 
> helpful to me.

The new env command allows for a lot of interesting features, like
maintaining a set of "user profiles", i. e. independent sets of
environment settings which can be loaded and restored as you lik,
including things like perfoming a "reset to factory defaults" (which
still can be changed, i. e. you can update the factory default
settings and are not limited to the fixed compiled in default env
values.

> I suppose, with my 2010.12, I could export everything to memory and then 
> parse through it to find the values I need then import them. Sounds 
> vaguely possible but it's probably more complex than doing the U-Boot 
> upgrade.

You don't have enough tools in the shell to do this parsing by any
scripts, so you would need code.  And if you add new code, you change
the binary anyway, so you could upgrade as well.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"I knew then (in 1970) that a 4-kbyte minicomputer would cost as much
as a house. So I reasoned  that  after  college,  I'd  have  to  live
cheaply in an apartment and put all my money into owning a computer."
      - Apple co-founder Steve Wozniak, EE Times, June 6, 1988, pg 45

  reply	other threads:[~2014-04-10  6:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-09 21:09 [U-Boot] How can I save U-Boot env vars to HUSH shell vars James Chargin
2014-04-09 21:50 ` Wolfgang Denk
2014-04-09 23:15   ` James Chargin
2014-04-10  6:52     ` Wolfgang Denk [this message]
2014-04-10 16:58       ` James Chargin
2014-04-10 18:46         ` Wolfgang Denk

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=20140410065220.D43D73803C8@gemini.denx.de \
    --to=wd@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