[U-Boot] How can I save U-Boot env vars to HUSH shell vars.
Wolfgang Denk
wd at denx.de
Wed Apr 9 23:50:18 CEST 2014
Dear James,
In message <5345B6EC.6050109 at gmail.com> you wrote:
> I'd like to store the values of environment variables in HUSH shell
> variables and then restore them later. My ultimate goal is to preserve a
> few environment variables through a "env default -f".
It is probably easier to use "env export" to store this set of
variables to some area in memory. You could even make this permanent
by writing it to flash or some storage device.
> I'm working with U-Boot 2010.12. Changing to a newer version is not
> possible at this time.
Heh. As soon as you have to change _any_ code, you can as well
upgrade.
> I realize this is a very old U-Boot. I'm hoping that the relevant parts
> of U-Boot have not changed between that old version and versions you
> might provide help for.
Well, a ton of bug fixes and improvements have been added since. One
of the extensions you want and which has been added only after
v2010.12 is the capability to export only a sub-set of the environment
(i. e. a list of variables passed on the command line).
> => for i in $e; do v_$i=$i; done
...
> What I get:
...is exactly what you coded. You would get the same in any other
shell, too.
> => showvar
> HUSH_VERSION=0.01
> v_e=e ethaddr ipaddr rootpath
> v_ethaddr=00:00:17:88:09:36
> v_ipaddr=10.3.134.80
> v_rootpath=/home/anyuser/a/device/tr/rootfs
> =>
>
> So, how do I re-write the for loop to get the desired results
This would require an "eval" or command substitution, which we do not
have in our implementation of the hush shell.
To me it seems the easiest way to get what you want is to use
"env export ... ethaddr ipaddr rootpath" or similar.
Um... yes, this requires an update to more recent code.
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
Of course there's no reason for it, it's just our policy.
More information about the U-Boot
mailing list