I wish to read the kernel command line parameters in from a disk file
located e.g. on a FAT file system. My current idea is to implement it
like this:
1. Read disk file into RAM
2. Implement custom "mem2env" command to read memory into environment
variable, with destination variable as ${bootargs}
As far as I can see, I am not reinventing any wheels by doing this, but
does anyone know a better way?
Thanks & regards,
Martin
-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
U-Boot-Users mailing list
U-Boot...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/u-boot-users
> I wish to read the kernel command line parameters in from a disk file
> located e.g. on a FAT file system. My current idea is to implement it
> like this:
>
> 1. Read disk file into RAM
> 2. Implement custom "mem2env" command to read memory into environment
> variable, with destination variable as ${bootargs}
>
> As far as I can see, I am not reinventing any wheels by doing this, but
> does anyone know a better way?
I've seen the dbox guys doing something similar, although IIRC that
solution wasn't quite generic and was hacked into board specific code.
Thinking about it some more, if you can use mkimage somewhere in
userspace, you could create a script file, load that to ram and execute
it. This is very generic and not limited to setting environment
variables.
Thinking about that some more, maybe we could teach "autoscr" also to
run commands from a memory address without it being wrapped with
mkimage. This is also very generic but prone to errors...
Cheers
Detlev
--
0x2B | ~0x2B
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: d...@denx.de
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"
);
Using a proper U-Boot payload script would also be my preferred way, as
suggested by Detlev. However, this isn't my choice to make, it's an
accepted way of doing it already at my company :(
This patch looks about exactly like what I need. In fact I am using
U-Boot 1.2.0, so it's just perfect!
I am somewhat new to U-Boot development. What further work would be
required to bring this up to mainline U-Boot standard?
Thanks & regards,
Martin
Well, someone must cook it up as a patch, with proper indentation,
based on current tree, add some documentation, and hope it's
considered useful.
I might try next week, I have to study a little git first
/alessandro