From: Alessandro Rubini <rubini-list@gnudd.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] Reading memory into environment variable
Date: Fri, 4 Jul 2008 16:51:12 +0200 [thread overview]
Message-ID: <20080704145112.GA8227@mail.gnudd.com> (raw)
In-Reply-To: <m2skupu36n.fsf@ohwell.denx.de>
>> 1. Read disk file into RAM
>> 2. Implement custom "mem2env" command to read memory into environment
>> variable, with destination variable as ${bootargs}
I've done the same (on u-boot-1.2.0) to read an upgrade script from a
network file or usb pen. I called the command "setenvram" (bad choice,
Wolfgang would refuse it). I'm sure later I found something similar
in mainline, but now I can't find it any more. I may have overlooked
another command.
Although it's not ready for prime time, I paste it here.
If useful I can make a proper patch against current git.
/* set environment variable from ram -- ARub */
int do_setenvram(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
unsigned long len, i;
char *addr;
if (argc != 4) {
printf ("Usage:\n%s\n", cmdtp->usage);
return 1;
}
addr = (char *)simple_strtol(argv[2], NULL, 16);
len = simple_strtol(argv[3], NULL, 16);
if (!addr || !len) {
printf ("Usage:\n%s\n", cmdtp->usage);
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;
}
U_BOOT_CMD(
setenvram, 4, 0, do_setenvram,
"setenvram - get environment variable from ram\n",
"name addr maxlen\n"
" - set environment variable 'name' from addr 'addr'\n"
);
next prev parent reply other threads:[~2008-07-04 14:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-04 10:03 [U-Boot-Users] Reading memory into environment variable mcj00_rubbish at f-m.fm
2008-07-04 14:36 ` Detlev Zundel
2008-07-04 14:51 ` Alessandro Rubini [this message]
2008-07-04 15:39 ` mcj00_rubbish at f-m.fm
2008-07-04 17:02 ` Alessandro Rubini
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=20080704145112.GA8227@mail.gnudd.com \
--to=rubini-list@gnudd.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox