From: James Chargin <jimccrown@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] How can I save U-Boot env vars to HUSH shell vars.
Date: Wed, 09 Apr 2014 16:15:31 -0700 [thread overview]
Message-ID: <5345D493.4080803@gmail.com> (raw)
In-Reply-To: <20140409215018.88C95380407@gemini.denx.de>
Dear Wolfgang,
Thank you for your reply.
On 04/09/2014 02:50 PM, Wolfgang Denk wrote:
> Dear James,
>
> In message <5345B6EC.6050109@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 hadn't thought of exporting the environment to memory, excellent idea.
>
>> 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 was hoping (in vain perhaps) to do my work modifying only the environment.
>
>> 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).
>
This is a definite drawback to having an old U-Boot; I'm sure I would
benefit from the bug fixes and other enhancements.
Exporting a list of values sounds like a nice addition that would be
helpful to me.
>> => 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.
>
"eval" seemed to me also to be what I wanted. I'm aware it isn't present
in hush, but I was hoping for some magic from the community. :-)
> To me it seems the easiest way to get what you want is to use
> "env export ... ethaddr ipaddr rootpath" or similar.
>
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.
> Um... yes, this requires an update to more recent code.
Yes, update is on my to-do list, but schedules dictate that the upgrade
is not my first priority. The conclusion reached here adds to the
argument for doing it sooner rather than later.
>
> Best regards,
>
> Wolfgang Denk
>
Thank you again for you comments.
Jim
next prev parent reply other threads:[~2014-04-09 23:15 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 [this message]
2014-04-10 6:52 ` Wolfgang Denk
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=5345D493.4080803@gmail.com \
--to=jimccrown@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.