[U-Boot] How can I save U-Boot env vars to HUSH shell vars.

James Chargin
2014-04-09T21:09:00Z

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".

I'm working with U-Boot 2010.12. Changing to a newer version is not
possible at this time.

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.

I tried a few things and haven't found the right combination. I think
the following commands demonstrate my problem.

Given the U-Boot commands

=> setenv e "e ethaddr ipaddr rootpath"
=>
=> printenv e ethaddr ipaddr rootpath
e=e ethaddr ipaddr rootpath
ethaddr=00:00:17:88:09:36
ipaddr=10.3.134.80
rootpath=/home/anyuser/a/device/tr/rootfs
=>
=> for i in $e; do v_$i=$i; done
=>

What I get:

=> showvar
HUSH_VERSION=0.01
v_e=e
v_ethaddr=ethaddr
v_ipaddr=ipaddr
v_rootpath=rootpath
=>

What I want:

=> 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

Thanks for any help,
Jim

--
Jim Chargin
AJA Video Systems jimc at aja.com
(530) 271-3334 http://www.aja.com