2 * (C) Copyright 2000-2010
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * (C) Copyright 2001 Sysgo Real-Time Solutions, GmbH <www.elinos.com>
6 * Andreas Heppel <aheppel@sysgo.de>
8 * Copyright 2011 Freescale Semiconductor, Inc.
10 * See file CREDITS for list of people who contributed to this
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License as
15 * published by the Free Software Foundation; either version 2 of
16 * the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
30 * Support for persistent environment data
32 * The "environment" is stored on external storage as a list of '\0'
33 * terminated "name=value" strings. The end of the list is marked by
34 * a double '\0'. The environment is preceeded by a 32 bit CRC over
35 * the data part and, in case of redundant environment, a byte of
38 * This linearized representation will also be used before
39 * relocation, i. e. as long as we don't have a full C runtime
40 * environment. After that, we use a hash table.
45 #include <environment.h>
51 #include <linux/stddef.h>
52 #include <asm/byteorder.h>
53 #if defined(CONFIG_CMD_NET)
57 DECLARE_GLOBAL_DATA_PTR;
59 #if !defined(CONFIG_ENV_IS_IN_EEPROM) && \
60 !defined(CONFIG_ENV_IS_IN_FLASH) && \
61 !defined(CONFIG_ENV_IS_IN_DATAFLASH) && \
62 !defined(CONFIG_ENV_IS_IN_MG_DISK) && \
63 !defined(CONFIG_ENV_IS_IN_MMC) && \
64 !defined(CONFIG_ENV_IS_IN_FAT) && \
65 !defined(CONFIG_ENV_IS_IN_NAND) && \
66 !defined(CONFIG_ENV_IS_IN_NVRAM) && \
67 !defined(CONFIG_ENV_IS_IN_ONENAND) && \
68 !defined(CONFIG_ENV_IS_IN_SPI_FLASH) && \
69 !defined(CONFIG_ENV_IS_IN_REMOTE) && \
70 !defined(CONFIG_ENV_IS_NOWHERE)
71 # error Define one of CONFIG_ENV_IS_IN_{EEPROM|FLASH|DATAFLASH|ONENAND|\
72 SPI_FLASH|MG_DISK|NVRAM|MMC|FAT|REMOTE} or CONFIG_ENV_IS_NOWHERE
76 #define MK_STR(x) XMK_STR(x)
79 * Maximum expected input data size for import command
81 #define MAX_ENV_SIZE (1 << 20) /* 1 MiB */
83 ulong load_addr = CONFIG_SYS_LOAD_ADDR; /* Default Load Address */
84 ulong save_addr; /* Default Save Address */
85 ulong save_size; /* Default Save Size (in bytes) */
88 * Table with supported baudrates (defined in config_xyz.h)
90 static const unsigned long baudrate_table[] = CONFIG_SYS_BAUDRATE_TABLE;
91 #define N_BAUDRATES (sizeof(baudrate_table) / sizeof(baudrate_table[0]))
94 * This variable is incremented on each do_env_set(), so it can
95 * be used via get_env_id() as an indication, if the environment
96 * has changed or not. So it is possible to reread an environment
97 * variable only if the environment was changed ... done so for
98 * example in NetInitLoop()
100 static int env_id = 1;
108 * Command interface: print one or all environment variables
110 * Returns 0 in case of error, or length of printed string
112 static int env_print(char *name)
117 if (name) { /* print a single name */
122 hsearch_r(e, FIND, &ep, &env_htab);
125 len = printf("%s=%s\n", ep->key, ep->data);
129 /* print whole list */
130 len = hexport_r(&env_htab, '\n', &res, 0, 0, NULL);
138 /* should never happen */
142 int do_env_print (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
148 /* print all env vars */
149 rcode = env_print(NULL);
152 printf("\nEnvironment size: %d/%ld bytes\n",
153 rcode, (ulong)ENV_SIZE);
157 /* print selected env vars */
158 for (i = 1; i < argc; ++i) {
159 int rc = env_print(argv[i]);
161 printf("## Error: \"%s\" not defined\n", argv[i]);
169 #ifdef CONFIG_CMD_GREPENV
170 static int do_env_grep(cmd_tbl_t *cmdtp, int flag,
171 int argc, char * const argv[])
174 unsigned char matched[env_htab.size / 8];
175 int rcode = 1, arg = 1, idx;
178 return CMD_RET_USAGE;
180 memset(matched, 0, env_htab.size / 8);
182 while (arg <= argc) {
184 while ((idx = hstrstr_r(argv[arg], idx, &match, &env_htab))) {
185 if (!(matched[idx / 8] & (1 << (idx & 7)))) {
191 matched[idx / 8] |= 1 << (idx & 7);
202 * Set a new environment variable,
203 * or replace or delete an existing one.
205 int _do_env_set(int flag, int argc, char * const argv[])
210 char *name, *value, *s;
215 if (strchr(name, '=')) {
216 printf("## Error: illegal character '=' in variable name"
223 * search if variable with this name already exists
227 hsearch_r(e, FIND, &ep, &env_htab);
229 /* Check for console redirection */
230 if (strcmp(name, "stdin") == 0)
232 else if (strcmp(name, "stdout") == 0)
234 else if (strcmp(name, "stderr") == 0)
238 if (argc < 3) { /* Cannot delete it! */
239 printf("Can't delete \"%s\"\n", name);
243 #ifdef CONFIG_CONSOLE_MUX
244 i = iomux_doenv(console, argv[2]);
248 /* Try assigning specified device */
249 if (console_assign(console, argv[2]) < 0)
252 #ifdef CONFIG_SERIAL_MULTI
253 if (serial_assign(argv[2]) < 0)
256 #endif /* CONFIG_CONSOLE_MUX */
260 * Some variables like "ethaddr" and "serial#" can be set only
261 * once and cannot be deleted; also, "ver" is readonly.
263 if (ep) { /* variable exists */
264 #ifndef CONFIG_ENV_OVERWRITE
265 if (strcmp(name, "serial#") == 0 ||
266 (strcmp(name, "ethaddr") == 0
267 #if defined(CONFIG_OVERWRITE_ETHADDR_ONCE) && defined(CONFIG_ETHADDR)
268 && strcmp(ep->data, MK_STR(CONFIG_ETHADDR)) != 0
269 #endif /* CONFIG_OVERWRITE_ETHADDR_ONCE && CONFIG_ETHADDR */
271 printf("Can't overwrite \"%s\"\n", name);
276 * Switch to new baudrate if new baudrate is supported
278 if (strcmp(name, "baudrate") == 0) {
279 int baudrate = simple_strtoul(argv[2], NULL, 10);
281 for (i = 0; i < N_BAUDRATES; ++i) {
282 if (baudrate == baudrate_table[i])
285 if (i == N_BAUDRATES) {
286 printf("## Baudrate %d bps not supported\n",
290 printf("## Switch baudrate to %d bps and"
291 "press ENTER ...\n", baudrate);
293 gd->baudrate = baudrate;
294 #if defined(CONFIG_PPC) || defined(CONFIG_MCF52x2)
295 gd->bd->bi_baudrate = baudrate;
300 while (getc() != '\r')
306 if (argc < 3 || argv[2] == NULL) {
307 int rc = hdelete_r(name, &env_htab);
312 * Insert / replace new value
314 for (i = 2, len = 0; i < argc; ++i)
315 len += strlen(argv[i]) + 1;
319 printf("## Can't malloc %d bytes\n", len);
322 for (i = 2, s = value; i < argc; ++i) {
325 while ((*s++ = *v++) != '\0')
334 hsearch_r(e, ENTER, &ep, &env_htab);
337 printf("## Error inserting \"%s\" variable, errno=%d\n",
343 * Some variables should be updated when the corresponding
344 * entry in the environment is changed
346 if (strcmp(name, "ipaddr") == 0) {
347 char *s = argv[2]; /* always use only one arg */
351 for (addr = 0, i = 0; i < 4; ++i) {
352 ulong val = s ? simple_strtoul(s, &e, 10) : 0;
358 bd->bi_ip_addr = htonl(addr);
360 } else if (strcmp(argv[1], "loadaddr") == 0) {
361 load_addr = simple_strtoul(argv[2], NULL, 16);
364 #if defined(CONFIG_CMD_NET)
365 else if (strcmp(argv[1], "bootfile") == 0) {
366 copy_filename(BootFile, argv[2], sizeof(BootFile));
373 int setenv(const char *varname, const char *varvalue)
375 const char * const argv[4] = { "setenv", varname, varvalue, NULL };
377 if (varvalue == NULL || varvalue[0] == '\0')
378 return _do_env_set(0, 2, (char * const *)argv);
380 return _do_env_set(0, 3, (char * const *)argv);
384 * Set an environment variable to an integer value
386 * @param varname Environmet variable to set
387 * @param value Value to set it to
388 * @return 0 if ok, 1 on error
390 int setenv_ulong(const char *varname, ulong value)
392 /* TODO: this should be unsigned */
393 char *str = simple_itoa(value);
395 return setenv(varname, str);
399 * Set an environment variable to an address in hex
401 * @param varname Environmet variable to set
402 * @param addr Value to set it to
403 * @return 0 if ok, 1 on error
405 int setenv_addr(const char *varname, const void *addr)
409 sprintf(str, "%lx", (uintptr_t)addr);
410 return setenv(varname, str);
413 int do_env_set(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
416 return CMD_RET_USAGE;
418 return _do_env_set(flag, argc, argv);
422 * Prompt for environment variable
424 #if defined(CONFIG_CMD_ASKENV)
425 int do_env_ask(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
427 char message[CONFIG_SYS_CBSIZE];
428 int size = CONFIG_SYS_CBSIZE - 1;
432 local_args[0] = argv[0];
433 local_args[1] = argv[1];
434 local_args[2] = NULL;
435 local_args[3] = NULL;
437 /* Check the syntax */
440 return CMD_RET_USAGE;
442 case 2: /* env_ask envname */
443 sprintf(message, "Please enter '%s':", argv[1]);
446 case 3: /* env_ask envname size */
447 sprintf(message, "Please enter '%s':", argv[1]);
448 size = simple_strtoul(argv[2], NULL, 10);
451 default: /* env_ask envname message1 ... messagen size */
452 for (i = 2, pos = 0; i < argc - 1; i++) {
454 message[pos++] = ' ';
456 strcpy(message + pos, argv[i]);
457 pos += strlen(argv[i]);
461 size = simple_strtoul(argv[argc - 1], NULL, 10);
465 if (size >= CONFIG_SYS_CBSIZE)
466 size = CONFIG_SYS_CBSIZE - 1;
471 /* prompt for input */
472 len = readline(message);
475 console_buffer[size] = '\0';
478 if (console_buffer[0] != '\0') {
479 local_args[2] = console_buffer;
483 /* Continue calling setenv code */
484 return _do_env_set(flag, len, local_args);
489 * Interactively edit an environment variable
491 #if defined(CONFIG_CMD_EDITENV)
492 int do_env_edit(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
494 char buffer[CONFIG_SYS_CBSIZE];
498 return CMD_RET_USAGE;
500 /* Set read buffer to initial value or empty sting */
501 init_val = getenv(argv[1]);
503 sprintf(buffer, "%s", init_val);
507 readline_into_buffer("edit: ", buffer, 0);
509 return setenv(argv[1], buffer);
511 #endif /* CONFIG_CMD_EDITENV */
514 * Look up variable from environment,
515 * return address of storage for that variable,
516 * or NULL if not found
518 char *getenv(const char *name)
520 if (gd->flags & GD_FLG_ENV_READY) { /* after import into hashtable */
527 hsearch_r(e, FIND, &ep, &env_htab);
529 return ep ? ep->data : NULL;
532 /* restricted capabilities before import */
533 if (getenv_f(name, (char *)(gd->env_buf), sizeof(gd->env_buf)) > 0)
534 return (char *)(gd->env_buf);
540 * Look up variable from environment for restricted C runtime env.
542 int getenv_f(const char *name, char *buf, unsigned len)
546 for (i = 0; env_get_char(i) != '\0'; i = nxt + 1) {
549 for (nxt = i; env_get_char(nxt) != '\0'; ++nxt) {
550 if (nxt >= CONFIG_ENV_SIZE)
554 val = envmatch((uchar *)name, i);
558 /* found; copy out */
559 for (n = 0; n < len; ++n, ++buf) {
560 *buf = env_get_char(val++);
568 printf("env_buf [%d bytes] too small for value of \"%s\"\n",
578 * Decode the integer value of an environment variable and return it.
580 * @param name Name of environemnt variable
581 * @param base Number base to use (normally 10, or 16 for hex)
582 * @param default_val Default value to return if the variable is not
584 * @return the decoded value, or default_val if not found
586 ulong getenv_ulong(const char *name, int base, ulong default_val)
589 * We can use getenv() here, even before relocation, since the
590 * environment variable value is an integer and thus short.
592 const char *str = getenv(name);
594 return str ? simple_strtoul(str, NULL, base) : default_val;
597 #if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
598 int do_env_save(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
600 printf("Saving Environment to %s...\n", env_name_spec);
602 return saveenv() ? 1 : 0;
606 saveenv, 1, 0, do_env_save,
607 "save environment variables to persistent storage",
614 * Match a name / name=value pair
616 * s1 is either a simple 'name', or a 'name=value' pair.
617 * i2 is the environment index for a 'name2=value2' pair.
618 * If the names match, return the index for the value2, else -1.
620 int envmatch(uchar *s1, int i2)
622 while (*s1 == env_get_char(i2++))
626 if (*s1 == '\0' && env_get_char(i2-1) == '=')
632 static int do_env_default(cmd_tbl_t *cmdtp, int flag,
633 int argc, char * const argv[])
635 if (argc != 2 || strcmp(argv[1], "-f") != 0)
636 return CMD_RET_USAGE;
638 set_default_env("## Resetting to default environment\n");
642 static int do_env_delete(cmd_tbl_t *cmdtp, int flag,
643 int argc, char * const argv[])
645 printf("Not implemented yet\n");
649 #ifdef CONFIG_CMD_EXPORTENV
651 * env export [-t | -b | -c] [-s size] addr [var ...]
652 * -t: export as text format; if size is given, data will be
653 * padded with '\0' bytes; if not, one terminating '\0'
654 * will be added (which is included in the "filesize"
655 * setting so you can for exmple copy this to flash and
656 * keep the termination).
657 * -b: export as binary format (name=value pairs separated by
658 * '\0', list end marked by double "\0\0")
659 * -c: export as checksum protected environment format as
660 * used for example by "saveenv" command
662 * size of output buffer
663 * addr: memory address where environment gets stored
664 * var... List of variable names that get included into the
665 * export. Without arguments, the whole environment gets
668 * With "-c" and size is NOT given, then the export command will
669 * format the data as currently used for the persistent storage,
670 * i. e. it will use CONFIG_ENV_SECT_SIZE as output block size and
671 * prepend a valid CRC32 checksum and, in case of resundant
672 * environment, a "current" redundancy flag. If size is given, this
673 * value will be used instead of CONFIG_ENV_SECT_SIZE; again, CRC32
674 * checksum and redundancy flag will be inserted.
676 * With "-b" and "-t", always only the real data (including a
677 * terminating '\0' byte) will be written; here the optional size
678 * argument will be used to make sure not to overflow the user
679 * provided buffer; the command will abort if the size is not
680 * sufficient. Any remainign space will be '\0' padded.
682 * On successful return, the variable "filesize" will be set.
683 * Note that filesize includes the trailing/terminating '\0' byte(s).
685 * Usage szenario: create a text snapshot/backup of the current settings:
687 * => env export -t 100000
688 * => era ${backup_addr} +${filesize}
689 * => cp.b 100000 ${backup_addr} ${filesize}
691 * Re-import this snapshot, deleting all other settings:
693 * => env import -d -t ${backup_addr}
695 static int do_env_export(cmd_tbl_t *cmdtp, int flag,
696 int argc, char * const argv[])
699 char *addr, *cmd, *res;
709 while (--argc > 0 && **++argv == '-') {
713 case 'b': /* raw binary format */
718 case 'c': /* external checksum format */
724 case 's': /* size given */
726 return cmd_usage(cmdtp);
727 size = simple_strtoul(*++argv, NULL, 16);
729 case 't': /* text format */
735 return CMD_RET_USAGE;
742 return CMD_RET_USAGE;
744 addr = (char *)simple_strtoul(argv[0], NULL, 16);
747 memset(addr, '\0', size);
752 if (sep) { /* export as text file */
753 len = hexport_r(&env_htab, sep, &addr, size, argc, argv);
755 error("Cannot export environment: errno = %d\n", errno);
758 sprintf(buf, "%zX", (size_t)len);
759 setenv("filesize", buf);
764 envp = (env_t *)addr;
766 if (chk) /* export as checksum protected block */
767 res = (char *)envp->data;
768 else /* export as raw binary data */
771 len = hexport_r(&env_htab, '\0', &res, ENV_SIZE, argc, argv);
773 error("Cannot export environment: errno = %d\n", errno);
778 envp->crc = crc32(0, envp->data, ENV_SIZE);
779 #ifdef CONFIG_ENV_ADDR_REDUND
780 envp->flags = ACTIVE_FLAG;
783 sprintf(buf, "%zX", (size_t)(len + offsetof(env_t, data)));
784 setenv("filesize", buf);
789 printf("## %s: only one of \"-b\", \"-c\" or \"-t\" allowed\n", cmd);
794 #ifdef CONFIG_CMD_IMPORTENV
796 * env import [-d] [-t | -b | -c] addr [size]
797 * -d: delete existing environment before importing;
798 * otherwise overwrite / append to existion definitions
799 * -t: assume text format; either "size" must be given or the
800 * text data must be '\0' terminated
801 * -b: assume binary format ('\0' separated, "\0\0" terminated)
802 * -c: assume checksum protected environment format
803 * addr: memory address to read from
804 * size: length of input data; if missing, proper '\0'
805 * termination is mandatory
807 static int do_env_import(cmd_tbl_t *cmdtp, int flag,
808 int argc, char * const argv[])
819 while (--argc > 0 && **++argv == '-') {
823 case 'b': /* raw binary format */
828 case 'c': /* external checksum format */
834 case 't': /* text format */
843 return CMD_RET_USAGE;
849 return CMD_RET_USAGE;
852 printf("## Warning: defaulting to text format\n");
854 addr = (char *)simple_strtoul(argv[0], NULL, 16);
857 size = simple_strtoul(argv[1], NULL, 16);
863 while (size < MAX_ENV_SIZE) {
864 if ((*s == sep) && (*(s+1) == '\0'))
869 if (size == MAX_ENV_SIZE) {
870 printf("## Warning: Input data exceeds %d bytes"
871 " - truncated\n", MAX_ENV_SIZE);
874 printf("## Info: input data size = %zu = 0x%zX\n", size, size);
879 env_t *ep = (env_t *)addr;
881 size -= offsetof(env_t, data);
882 memcpy(&crc, &ep->crc, sizeof(crc));
884 if (crc32(0, ep->data, size) != crc) {
885 puts("## Error: bad CRC, import failed\n");
888 addr = (char *)ep->data;
891 if (himport_r(&env_htab, addr, size, sep, del ? 0 : H_NOCLEAR) == 0) {
892 error("Environment import failed: errno = %d\n", errno);
895 gd->flags |= GD_FLG_ENV_READY;
900 printf("## %s: only one of \"-b\", \"-c\" or \"-t\" allowed\n",
907 * New command line interface: "env" command with subcommands
909 static cmd_tbl_t cmd_env_sub[] = {
910 #if defined(CONFIG_CMD_ASKENV)
911 U_BOOT_CMD_MKENT(ask, CONFIG_SYS_MAXARGS, 1, do_env_ask, "", ""),
913 U_BOOT_CMD_MKENT(default, 1, 0, do_env_default, "", ""),
914 U_BOOT_CMD_MKENT(delete, 2, 0, do_env_delete, "", ""),
915 #if defined(CONFIG_CMD_EDITENV)
916 U_BOOT_CMD_MKENT(edit, 2, 0, do_env_edit, "", ""),
918 #if defined(CONFIG_CMD_EXPORTENV)
919 U_BOOT_CMD_MKENT(export, 4, 0, do_env_export, "", ""),
921 #if defined(CONFIG_CMD_GREPENV)
922 U_BOOT_CMD_MKENT(grep, CONFIG_SYS_MAXARGS, 1, do_env_grep, "", ""),
924 #if defined(CONFIG_CMD_IMPORTENV)
925 U_BOOT_CMD_MKENT(import, 5, 0, do_env_import, "", ""),
927 U_BOOT_CMD_MKENT(print, CONFIG_SYS_MAXARGS, 1, do_env_print, "", ""),
928 #if defined(CONFIG_CMD_RUN)
929 U_BOOT_CMD_MKENT(run, CONFIG_SYS_MAXARGS, 1, do_run, "", ""),
931 #if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
932 U_BOOT_CMD_MKENT(save, 1, 0, do_env_save, "", ""),
934 U_BOOT_CMD_MKENT(set, CONFIG_SYS_MAXARGS, 0, do_env_set, "", ""),
937 #if defined(CONFIG_NEEDS_MANUAL_RELOC)
940 fixup_cmdtable(cmd_env_sub, ARRAY_SIZE(cmd_env_sub));
944 static int do_env(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
949 return CMD_RET_USAGE;
951 /* drop initial "env" arg */
955 cp = find_cmd_tbl(argv[0], cmd_env_sub, ARRAY_SIZE(cmd_env_sub));
958 return cp->cmd(cmdtp, flag, argc, argv);
960 return CMD_RET_USAGE;
964 env, CONFIG_SYS_MAXARGS, 1, do_env,
965 "environment handling commands",
966 #if defined(CONFIG_CMD_ASKENV)
967 "ask name [message] [size] - ask for environment variable\nenv "
969 "default -f - reset default environment\n"
970 #if defined(CONFIG_CMD_EDITENV)
971 "env edit name - edit environment variable\n"
973 "env export [-t | -b | -c] [-s size] addr [var ...] - export environment\n"
974 #if defined(CONFIG_CMD_GREPENV)
975 "env grep string [...] - search environment\n"
977 "env import [-d] [-t | -b | -c] addr [size] - import environment\n"
978 "env print [name ...] - print environment\n"
979 #if defined(CONFIG_CMD_RUN)
980 "env run var [...] - run commands in an environment variable\n"
982 #if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
983 "env save - save environment\n"
985 "env set [-f] name [arg ...]\n"
989 * Old command line interface, kept for compatibility
992 #if defined(CONFIG_CMD_EDITENV)
994 editenv, 2, 0, do_env_edit,
995 "edit environment variable",
997 " - edit environment variable 'name'",
1002 U_BOOT_CMD_COMPLETE(
1003 printenv, CONFIG_SYS_MAXARGS, 1, do_env_print,
1004 "print environment variables",
1005 "\n - print values of all environment variables\n"
1006 "printenv name ...\n"
1007 " - print value of environment variable 'name'",
1011 #ifdef CONFIG_CMD_GREPENV
1012 U_BOOT_CMD_COMPLETE(
1013 grepenv, CONFIG_SYS_MAXARGS, 0, do_env_grep,
1014 "search environment variables",
1016 " - list environment name=value pairs matching 'string'",
1021 U_BOOT_CMD_COMPLETE(
1022 setenv, CONFIG_SYS_MAXARGS, 0, do_env_set,
1023 "set environment variables",
1025 " - set environment variable 'name' to 'value ...'\n"
1027 " - delete environment variable 'name'",
1031 #if defined(CONFIG_CMD_ASKENV)
1034 askenv, CONFIG_SYS_MAXARGS, 1, do_env_ask,
1035 "get environment variables from stdin",
1036 "name [message] [size]\n"
1037 " - get environment variable 'name' from stdin (max 'size' chars)\n"
1039 " - get environment variable 'name' from stdin\n"
1040 "askenv name size\n"
1041 " - get environment variable 'name' from stdin (max 'size' chars)\n"
1042 "askenv name [message] size\n"
1043 " - display 'message' string and get environment variable 'name'"
1044 "from stdin (max 'size' chars)"
1048 #if defined(CONFIG_CMD_RUN)
1049 U_BOOT_CMD_COMPLETE(
1050 run, CONFIG_SYS_MAXARGS, 1, do_run,
1051 "run commands in an environment variable",
1053 " - run the commands in the environment variable(s) 'var'",