From: Eric Nelson <eric.nelson@boundarydevices.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] Add support for setting environment variable from RAM.
Date: Tue, 03 Feb 2009 11:56:46 -0700 [thread overview]
Message-ID: <4988936E.3070504@boundarydevices.com> (raw)
In-Reply-To: <1233676800.19784.1463.camel@localhost.localdomain>
Hello Peter,
Peter Tyser wrote:
> Hi Eric,
>
> On Tue, 2009-02-03 at 08:28 -0700, Eric Nelson (Boundary Devices) wrote:
>> /************************************************************************
>> + * Set a new environment variable from RAM.
>> + * Requires three arguments: the variable name, a memory address and a length.
>> + *
>> + * Deletes the environment variable if the length is zero.
>> + */
>> +int do_ramenv(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
>> +{
>> + unsigned long len, i;
>> + char *addr;
>> +
>> + if (argc != 4) {
>> + cmd_usage(cmdtp);
>> + return 1;
>> + }
>> + addr = (char *)simple_strtol(argv[2], NULL, 16);
>> + len = simple_strtol(argv[3], NULL, 16);
>> + if (!addr || !len) {
>> + cmd_usage(cmdtp);
>> + return 1;
>> + }
>> + addr[len] = '\0';
>> + for (i = 0; i < len; i++) {
>> + /* turn newlines into semicolon */
>> + if (addr[i] == '\n')
>> + addr[i] = ';'; /* ignore dos-style newlines */
>> + if (addr[i] == '\r')
>> + addr[i] = ' '; /* accept sh-comments and discard them */
>> + if (addr[i] == '#') {
>> + while (addr[i] && addr[i] != '\n')
>> + addr[i++] = ' ';
>> + i--;
>> + }
>> + }
>> + setenv(argv[1], addr);
>> + return 0;
>> +}
>> +
>> +/************************************************************************
>> * Look up variable from environment,
>> * return address of storage for that variable,
>> * or NULL if not found
>> @@ -605,6 +643,14 @@ U_BOOT_CMD(
>> " - delete environment variable 'name'\n"
>> );
>>
>> +U_BOOT_CMD(
>> + ramenv, 4, 0, do_ramenv,
>> + "ramenv - get environment variable from ram\n",
>
> The "ramenv - " and "\n" are no longer used in the above line.
>
Oops. Can you tell I started by implementing this on an older source tree?
Re-reading it, the comment should probably also say "set environment variable
from ram" instead of "get...".
If there's interest, I'll happily re-submit the patch.
>> + "name addr maxlen\n"
>> + " - set environment variable 'name' from addr 'addr'\n"
>> + " - delete environment variable if maxlen is 0\n"
>> +);
>> +
>> #if defined(CONFIG_CMD_ASKENV)
>>
>> U_BOOT_CMD(
>
> In the email thread you mentioned above, Detlev mentions 2 alternatives
> to the "ramenv" command - loading a uImage script and running it via
> autoscr, or modifying autoscr to be able to raw files (non-uImages).
> Both of these methods seem cleaner and more flexible at a glance. Is
> there a specific reason using autoscr wouldn't work for your setup?
>
The customer requesting this feature operates in a regulated environment with
pretty strict rules about separation of code and data. Autoscr is kind of
a big stick for what we're trying to achieve: (configuring an LCD with
settings from a file on SD card).
> For example, what is the process to load multiple environment variables
> with the ramenv command? If I understand correctly, in order to load 10
> environment variables you'd have to repeat the process of "load a file
> to RAM, run ramenv" 10 times? That seems much more difficult than
> loading 1 file with 10 environment variables and running autoscr once.
>
That's certainly true, although once you have an environment variable you
could use it for iteration...
Our particular need is just for a single environment variable, so the
update works pretty well. I started by updating our 'lcdpanel' U-Boot
command to read from file, but this is much more useful.
> Best,
> Peter
>
Regards,
Eric
next prev parent reply other threads:[~2009-02-03 18:56 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-03 15:28 [U-Boot] [PATCH] Add support for setting environment variable from RAM Eric Nelson
2009-02-03 16:00 ` Peter Tyser
2009-02-03 18:56 ` Eric Nelson [this message]
2009-02-03 20:16 ` Wolfgang Denk
2009-02-03 21:48 ` Eric Nelson
2009-02-03 22:08 ` Wolfgang Denk
-- strict thread matches above, loose matches on Subject: below --
2009-02-03 3:28 Eric Nelson
2009-02-05 19:30 ` Wolfgang Denk
2009-02-05 21:15 ` Eric Nelson
2009-02-05 21:26 ` Wolfgang Denk
2009-02-05 21:34 ` Eric Nelson
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=4988936E.3070504@boundarydevices.com \
--to=eric.nelson@boundarydevices.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.