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>
50 #include <linux/stddef.h>
51 #include <asm/byteorder.h>
53 DECLARE_GLOBAL_DATA_PTR;
55 #if !defined(CONFIG_ENV_IS_IN_EEPROM) && \
56 !defined(CONFIG_ENV_IS_IN_FLASH) && \
57 !defined(CONFIG_ENV_IS_IN_DATAFLASH) && \
58 !defined(CONFIG_ENV_IS_IN_MMC) && \
59 !defined(CONFIG_ENV_IS_IN_FAT) && \
60 !defined(CONFIG_ENV_IS_IN_NAND) && \
61 !defined(CONFIG_ENV_IS_IN_NVRAM) && \
62 !defined(CONFIG_ENV_IS_IN_ONENAND) && \
63 !defined(CONFIG_ENV_IS_IN_SPI_FLASH) && \
64 !defined(CONFIG_ENV_IS_IN_REMOTE) && \
65 !defined(CONFIG_ENV_IS_NOWHERE)
66 # error Define one of CONFIG_ENV_IS_IN_{EEPROM|FLASH|DATAFLASH|ONENAND|\
67 SPI_FLASH|NVRAM|MMC|FAT|REMOTE} or CONFIG_ENV_IS_NOWHERE
71 * Maximum expected input data size for import command
73 #define MAX_ENV_SIZE (1 << 20) /* 1 MiB */
76 * This variable is incremented on each do_env_set(), so it can
77 * be used via get_env_id() as an indication, if the environment
78 * has changed or not. So it is possible to reread an environment
79 * variable only if the environment was changed ... done so for
80 * example in NetInitLoop()
82 static int env_id = 1;
89 #ifndef CONFIG_SPL_BUILD
91 * Command interface: print one or all environment variables
93 * Returns 0 in case of error, or length of printed string
95 static int env_print(char *name, int flag)
100 if (name) { /* print a single name */
105 hsearch_r(e, FIND, &ep, &env_htab, flag);
108 len = printf("%s=%s\n", ep->key, ep->data);
112 /* print whole list */
113 len = hexport_r(&env_htab, '\n', flag, &res, 0, 0, NULL);
121 /* should never happen */
125 static int do_env_print(cmd_tbl_t *cmdtp, int flag, int argc,
130 int env_flag = H_HIDE_DOT;
132 if (argc > 1 && argv[1][0] == '-' && argv[1][1] == 'a') {
135 env_flag &= ~H_HIDE_DOT;
139 /* print all env vars */
140 rcode = env_print(NULL, env_flag);
143 printf("\nEnvironment size: %d/%ld bytes\n",
144 rcode, (ulong)ENV_SIZE);
148 /* print selected env vars */
149 env_flag &= ~H_HIDE_DOT;
150 for (i = 1; i < argc; ++i) {
151 int rc = env_print(argv[i], env_flag);
153 printf("## Error: \"%s\" not defined\n", argv[i]);
161 #ifdef CONFIG_CMD_GREPENV
162 static int do_env_grep(cmd_tbl_t *cmdtp, int flag,
163 int argc, char * const argv[])
166 unsigned char matched[env_htab.size / 8];
167 int rcode = 1, arg = 1, idx;
170 return CMD_RET_USAGE;
172 memset(matched, 0, env_htab.size / 8);
174 while (arg <= argc) {
176 while ((idx = hstrstr_r(argv[arg], idx, &match, &env_htab))) {
177 if (!(matched[idx / 8] & (1 << (idx & 7)))) {
183 matched[idx / 8] |= 1 << (idx & 7);
192 #endif /* CONFIG_SPL_BUILD */
195 * Set a new environment variable,
196 * or replace or delete an existing one.
198 static int _do_env_set(int flag, int argc, char * const argv[])
201 char *name, *value, *s;
207 if (strchr(name, '=')) {
208 printf("## Error: illegal character '='"
209 "in variable name \"%s\"\n", name);
216 if (argc < 3 || argv[2] == NULL) {
217 int rc = hdelete_r(name, &env_htab, H_INTERACTIVE);
222 * Insert / replace new value
224 for (i = 2, len = 0; i < argc; ++i)
225 len += strlen(argv[i]) + 1;
229 printf("## Can't malloc %d bytes\n", len);
232 for (i = 2, s = value; i < argc; ++i) {
235 while ((*s++ = *v++) != '\0')
244 hsearch_r(e, ENTER, &ep, &env_htab, H_INTERACTIVE);
247 printf("## Error inserting \"%s\" variable, errno=%d\n",
255 int setenv(const char *varname, const char *varvalue)
257 const char * const argv[4] = { "setenv", varname, varvalue, NULL };
259 if (varvalue == NULL || varvalue[0] == '\0')
260 return _do_env_set(0, 2, (char * const *)argv);
262 return _do_env_set(0, 3, (char * const *)argv);
266 * Set an environment variable to an integer value
268 * @param varname Environmet variable to set
269 * @param value Value to set it to
270 * @return 0 if ok, 1 on error
272 int setenv_ulong(const char *varname, ulong value)
274 /* TODO: this should be unsigned */
275 char *str = simple_itoa(value);
277 return setenv(varname, str);
281 * Set an environment variable to an address in hex
283 * @param varname Environmet variable to set
284 * @param addr Value to set it to
285 * @return 0 if ok, 1 on error
287 int setenv_addr(const char *varname, const void *addr)
291 sprintf(str, "%lx", (uintptr_t)addr);
292 return setenv(varname, str);
295 #ifndef CONFIG_SPL_BUILD
296 static int do_env_set(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
299 return CMD_RET_USAGE;
301 return _do_env_set(flag, argc, argv);
305 * Prompt for environment variable
307 #if defined(CONFIG_CMD_ASKENV)
308 int do_env_ask(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
310 char message[CONFIG_SYS_CBSIZE];
311 int size = CONFIG_SYS_CBSIZE - 1;
315 local_args[0] = argv[0];
316 local_args[1] = argv[1];
317 local_args[2] = NULL;
318 local_args[3] = NULL;
320 /* Check the syntax */
323 return CMD_RET_USAGE;
325 case 2: /* env_ask envname */
326 sprintf(message, "Please enter '%s':", argv[1]);
329 case 3: /* env_ask envname size */
330 sprintf(message, "Please enter '%s':", argv[1]);
331 size = simple_strtoul(argv[2], NULL, 10);
334 default: /* env_ask envname message1 ... messagen size */
335 for (i = 2, pos = 0; i < argc - 1; i++) {
337 message[pos++] = ' ';
339 strcpy(message + pos, argv[i]);
340 pos += strlen(argv[i]);
344 size = simple_strtoul(argv[argc - 1], NULL, 10);
348 if (size >= CONFIG_SYS_CBSIZE)
349 size = CONFIG_SYS_CBSIZE - 1;
354 /* prompt for input */
355 len = readline(message);
358 console_buffer[size] = '\0';
361 if (console_buffer[0] != '\0') {
362 local_args[2] = console_buffer;
366 /* Continue calling setenv code */
367 return _do_env_set(flag, len, local_args);
371 #if defined(CONFIG_CMD_ENV_CALLBACK)
372 static int print_static_binding(const char *var_name, const char *callback_name)
374 printf("\t%-20s %-20s\n", var_name, callback_name);
379 static int print_active_callback(ENTRY *entry)
381 struct env_clbk_tbl *clbkp;
385 if (entry->callback == NULL)
388 /* look up the callback in the linker-list */
389 num_callbacks = ll_entry_count(struct env_clbk_tbl, env_clbk);
390 for (i = 0, clbkp = ll_entry_start(struct env_clbk_tbl, env_clbk);
393 #if defined(CONFIG_NEEDS_MANUAL_RELOC)
394 if (entry->callback == clbkp->callback + gd->reloc_off)
396 if (entry->callback == clbkp->callback)
401 if (i == num_callbacks)
402 /* this should probably never happen, but just in case... */
403 printf("\t%-20s %p\n", entry->key, entry->callback);
405 printf("\t%-20s %-20s\n", entry->key, clbkp->name);
411 * Print the callbacks available and what they are bound to
413 int do_env_callback(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
415 struct env_clbk_tbl *clbkp;
419 /* Print the available callbacks */
420 puts("Available callbacks:\n");
421 puts("\tCallback Name\n");
422 puts("\t-------------\n");
423 num_callbacks = ll_entry_count(struct env_clbk_tbl, env_clbk);
424 for (i = 0, clbkp = ll_entry_start(struct env_clbk_tbl, env_clbk);
427 printf("\t%s\n", clbkp->name);
430 /* Print the static bindings that may exist */
431 puts("Static callback bindings:\n");
432 printf("\t%-20s %-20s\n", "Variable Name", "Callback Name");
433 printf("\t%-20s %-20s\n", "-------------", "-------------");
434 env_attr_walk(ENV_CALLBACK_LIST_STATIC, print_static_binding);
437 /* walk through each variable and print the callback if it has one */
438 puts("Active callback bindings:\n");
439 printf("\t%-20s %-20s\n", "Variable Name", "Callback Name");
440 printf("\t%-20s %-20s\n", "-------------", "-------------");
441 hwalk_r(&env_htab, print_active_callback);
446 #if defined(CONFIG_CMD_ENV_FLAGS)
447 static int print_static_flags(const char *var_name, const char *flags)
449 enum env_flags_vartype type = env_flags_parse_vartype(flags);
451 printf("\t%-20s %-20s\n", var_name, env_flags_get_vartype_name(type));
456 static int print_active_flags(ENTRY *entry)
458 enum env_flags_vartype type;
460 if (entry->flags == 0)
463 type = (enum env_flags_vartype)
464 (entry->flags & ENV_FLAGS_VARTYPE_BIN_MASK);
465 printf("\t%-20s %-20s\n", entry->key, env_flags_get_vartype_name(type));
471 * Print the flags available and what variables have flags
473 int do_env_flags(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
475 /* Print the available variable types */
476 printf("Available variable type flags (position %d):\n",
477 ENV_FLAGS_VARTYPE_LOC);
478 puts("\tFlag\tVariable Type Name\n");
479 puts("\t----\t------------------\n");
480 env_flags_print_vartypes();
483 /* Print the static flags that may exist */
484 puts("Static flags:\n");
485 printf("\t%-20s %-20s\n", "Variable Name", "Variable Type");
486 printf("\t%-20s %-20s\n", "-------------", "-------------");
487 env_attr_walk(ENV_FLAGS_LIST_STATIC, print_static_flags);
490 /* walk through each variable and print the flags if non-default */
491 puts("Active flags:\n");
492 printf("\t%-20s %-20s\n", "Variable Name", "Variable Type");
493 printf("\t%-20s %-20s\n", "-------------", "-------------");
494 hwalk_r(&env_htab, print_active_flags);
500 * Interactively edit an environment variable
502 #if defined(CONFIG_CMD_EDITENV)
503 static int do_env_edit(cmd_tbl_t *cmdtp, int flag, int argc,
506 char buffer[CONFIG_SYS_CBSIZE];
510 return CMD_RET_USAGE;
512 /* Set read buffer to initial value or empty sting */
513 init_val = getenv(argv[1]);
515 sprintf(buffer, "%s", init_val);
519 readline_into_buffer("edit: ", buffer, 0);
521 return setenv(argv[1], buffer);
523 #endif /* CONFIG_CMD_EDITENV */
524 #endif /* CONFIG_SPL_BUILD */
527 * Look up variable from environment,
528 * return address of storage for that variable,
529 * or NULL if not found
531 char *getenv(const char *name)
533 if (gd->flags & GD_FLG_ENV_READY) { /* after import into hashtable */
540 hsearch_r(e, FIND, &ep, &env_htab, 0);
542 return ep ? ep->data : NULL;
545 /* restricted capabilities before import */
546 if (getenv_f(name, (char *)(gd->env_buf), sizeof(gd->env_buf)) > 0)
547 return (char *)(gd->env_buf);
553 * Look up variable from environment for restricted C runtime env.
555 int getenv_f(const char *name, char *buf, unsigned len)
559 for (i = 0; env_get_char(i) != '\0'; i = nxt + 1) {
562 for (nxt = i; env_get_char(nxt) != '\0'; ++nxt) {
563 if (nxt >= CONFIG_ENV_SIZE)
567 val = envmatch((uchar *)name, i);
571 /* found; copy out */
572 for (n = 0; n < len; ++n, ++buf) {
573 *buf = env_get_char(val++);
581 printf("env_buf [%d bytes] too small for value of \"%s\"\n",
591 * Decode the integer value of an environment variable and return it.
593 * @param name Name of environemnt variable
594 * @param base Number base to use (normally 10, or 16 for hex)
595 * @param default_val Default value to return if the variable is not
597 * @return the decoded value, or default_val if not found
599 ulong getenv_ulong(const char *name, int base, ulong default_val)
602 * We can use getenv() here, even before relocation, since the
603 * environment variable value is an integer and thus short.
605 const char *str = getenv(name);
607 return str ? simple_strtoul(str, NULL, base) : default_val;
610 #ifndef CONFIG_SPL_BUILD
611 #if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
612 static int do_env_save(cmd_tbl_t *cmdtp, int flag, int argc,
615 printf("Saving Environment to %s...\n", env_name_spec);
617 return saveenv() ? 1 : 0;
621 saveenv, 1, 0, do_env_save,
622 "save environment variables to persistent storage",
626 #endif /* CONFIG_SPL_BUILD */
630 * Match a name / name=value pair
632 * s1 is either a simple 'name', or a 'name=value' pair.
633 * i2 is the environment index for a 'name2=value2' pair.
634 * If the names match, return the index for the value2, else -1.
636 int envmatch(uchar *s1, int i2)
641 while (*s1 == env_get_char(i2++))
645 if (*s1 == '\0' && env_get_char(i2-1) == '=')
651 #ifndef CONFIG_SPL_BUILD
652 static int do_env_default(cmd_tbl_t *cmdtp, int __flag,
653 int argc, char * const argv[])
655 int all = 0, flag = 0;
657 debug("Initial value for argc=%d\n", argc);
658 while (--argc > 0 && **++argv == '-') {
663 case 'a': /* default all */
666 case 'f': /* force */
670 return cmd_usage(cmdtp);
674 debug("Final value for argc=%d\n", argc);
675 if (all && (argc == 0)) {
676 /* Reset the whole environment */
677 set_default_env("## Resetting to default environment\n");
680 if (!all && (argc > 0)) {
681 /* Reset individual variables */
682 set_default_vars(argc, argv);
686 return cmd_usage(cmdtp);
689 static int do_env_delete(cmd_tbl_t *cmdtp, int flag,
690 int argc, char * const argv[])
692 printf("Not implemented yet\n");
696 #ifdef CONFIG_CMD_EXPORTENV
698 * env export [-t | -b | -c] [-s size] addr [var ...]
699 * -t: export as text format; if size is given, data will be
700 * padded with '\0' bytes; if not, one terminating '\0'
701 * will be added (which is included in the "filesize"
702 * setting so you can for exmple copy this to flash and
703 * keep the termination).
704 * -b: export as binary format (name=value pairs separated by
705 * '\0', list end marked by double "\0\0")
706 * -c: export as checksum protected environment format as
707 * used for example by "saveenv" command
709 * size of output buffer
710 * addr: memory address where environment gets stored
711 * var... List of variable names that get included into the
712 * export. Without arguments, the whole environment gets
715 * With "-c" and size is NOT given, then the export command will
716 * format the data as currently used for the persistent storage,
717 * i. e. it will use CONFIG_ENV_SECT_SIZE as output block size and
718 * prepend a valid CRC32 checksum and, in case of resundant
719 * environment, a "current" redundancy flag. If size is given, this
720 * value will be used instead of CONFIG_ENV_SECT_SIZE; again, CRC32
721 * checksum and redundancy flag will be inserted.
723 * With "-b" and "-t", always only the real data (including a
724 * terminating '\0' byte) will be written; here the optional size
725 * argument will be used to make sure not to overflow the user
726 * provided buffer; the command will abort if the size is not
727 * sufficient. Any remainign space will be '\0' padded.
729 * On successful return, the variable "filesize" will be set.
730 * Note that filesize includes the trailing/terminating '\0' byte(s).
732 * Usage szenario: create a text snapshot/backup of the current settings:
734 * => env export -t 100000
735 * => era ${backup_addr} +${filesize}
736 * => cp.b 100000 ${backup_addr} ${filesize}
738 * Re-import this snapshot, deleting all other settings:
740 * => env import -d -t ${backup_addr}
742 static int do_env_export(cmd_tbl_t *cmdtp, int flag,
743 int argc, char * const argv[])
746 char *addr, *cmd, *res;
756 while (--argc > 0 && **++argv == '-') {
760 case 'b': /* raw binary format */
765 case 'c': /* external checksum format */
771 case 's': /* size given */
773 return cmd_usage(cmdtp);
774 size = simple_strtoul(*++argv, NULL, 16);
776 case 't': /* text format */
782 return CMD_RET_USAGE;
789 return CMD_RET_USAGE;
791 addr = (char *)simple_strtoul(argv[0], NULL, 16);
794 memset(addr, '\0', size);
799 if (sep) { /* export as text file */
800 len = hexport_r(&env_htab, sep, 0, &addr, size, argc, argv);
802 error("Cannot export environment: errno = %d\n", errno);
805 sprintf(buf, "%zX", (size_t)len);
806 setenv("filesize", buf);
811 envp = (env_t *)addr;
813 if (chk) /* export as checksum protected block */
814 res = (char *)envp->data;
815 else /* export as raw binary data */
818 len = hexport_r(&env_htab, '\0', 0, &res, ENV_SIZE, argc, argv);
820 error("Cannot export environment: errno = %d\n", errno);
825 envp->crc = crc32(0, envp->data, ENV_SIZE);
826 #ifdef CONFIG_ENV_ADDR_REDUND
827 envp->flags = ACTIVE_FLAG;
830 sprintf(buf, "%zX", (size_t)(len + offsetof(env_t, data)));
831 setenv("filesize", buf);
836 printf("## %s: only one of \"-b\", \"-c\" or \"-t\" allowed\n", cmd);
841 #ifdef CONFIG_CMD_IMPORTENV
843 * env import [-d] [-t | -b | -c] addr [size]
844 * -d: delete existing environment before importing;
845 * otherwise overwrite / append to existion definitions
846 * -t: assume text format; either "size" must be given or the
847 * text data must be '\0' terminated
848 * -b: assume binary format ('\0' separated, "\0\0" terminated)
849 * -c: assume checksum protected environment format
850 * addr: memory address to read from
851 * size: length of input data; if missing, proper '\0'
852 * termination is mandatory
854 static int do_env_import(cmd_tbl_t *cmdtp, int flag,
855 int argc, char * const argv[])
866 while (--argc > 0 && **++argv == '-') {
870 case 'b': /* raw binary format */
875 case 'c': /* external checksum format */
881 case 't': /* text format */
890 return CMD_RET_USAGE;
896 return CMD_RET_USAGE;
899 printf("## Warning: defaulting to text format\n");
901 addr = (char *)simple_strtoul(argv[0], NULL, 16);
904 size = simple_strtoul(argv[1], NULL, 16);
910 while (size < MAX_ENV_SIZE) {
911 if ((*s == sep) && (*(s+1) == '\0'))
916 if (size == MAX_ENV_SIZE) {
917 printf("## Warning: Input data exceeds %d bytes"
918 " - truncated\n", MAX_ENV_SIZE);
921 printf("## Info: input data size = %zu = 0x%zX\n", size, size);
926 env_t *ep = (env_t *)addr;
928 size -= offsetof(env_t, data);
929 memcpy(&crc, &ep->crc, sizeof(crc));
931 if (crc32(0, ep->data, size) != crc) {
932 puts("## Error: bad CRC, import failed\n");
935 addr = (char *)ep->data;
938 if (himport_r(&env_htab, addr, size, sep, del ? 0 : H_NOCLEAR,
940 error("Environment import failed: errno = %d\n", errno);
943 gd->flags |= GD_FLG_ENV_READY;
948 printf("## %s: only one of \"-b\", \"-c\" or \"-t\" allowed\n",
955 * New command line interface: "env" command with subcommands
957 static cmd_tbl_t cmd_env_sub[] = {
958 #if defined(CONFIG_CMD_ASKENV)
959 U_BOOT_CMD_MKENT(ask, CONFIG_SYS_MAXARGS, 1, do_env_ask, "", ""),
961 U_BOOT_CMD_MKENT(default, 1, 0, do_env_default, "", ""),
962 U_BOOT_CMD_MKENT(delete, 2, 0, do_env_delete, "", ""),
963 #if defined(CONFIG_CMD_EDITENV)
964 U_BOOT_CMD_MKENT(edit, 2, 0, do_env_edit, "", ""),
966 #if defined(CONFIG_CMD_ENV_CALLBACK)
967 U_BOOT_CMD_MKENT(callbacks, 1, 0, do_env_callback, "", ""),
969 #if defined(CONFIG_CMD_ENV_FLAGS)
970 U_BOOT_CMD_MKENT(flags, 1, 0, do_env_flags, "", ""),
972 #if defined(CONFIG_CMD_EXPORTENV)
973 U_BOOT_CMD_MKENT(export, 4, 0, do_env_export, "", ""),
975 #if defined(CONFIG_CMD_GREPENV)
976 U_BOOT_CMD_MKENT(grep, CONFIG_SYS_MAXARGS, 1, do_env_grep, "", ""),
978 #if defined(CONFIG_CMD_IMPORTENV)
979 U_BOOT_CMD_MKENT(import, 5, 0, do_env_import, "", ""),
981 U_BOOT_CMD_MKENT(print, CONFIG_SYS_MAXARGS, 1, do_env_print, "", ""),
982 #if defined(CONFIG_CMD_RUN)
983 U_BOOT_CMD_MKENT(run, CONFIG_SYS_MAXARGS, 1, do_run, "", ""),
985 #if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
986 U_BOOT_CMD_MKENT(save, 1, 0, do_env_save, "", ""),
988 U_BOOT_CMD_MKENT(set, CONFIG_SYS_MAXARGS, 0, do_env_set, "", ""),
991 #if defined(CONFIG_NEEDS_MANUAL_RELOC)
994 fixup_cmdtable(cmd_env_sub, ARRAY_SIZE(cmd_env_sub));
998 static int do_env(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
1003 return CMD_RET_USAGE;
1005 /* drop initial "env" arg */
1009 cp = find_cmd_tbl(argv[0], cmd_env_sub, ARRAY_SIZE(cmd_env_sub));
1012 return cp->cmd(cmdtp, flag, argc, argv);
1014 return CMD_RET_USAGE;
1017 #ifdef CONFIG_SYS_LONGHELP
1018 static char env_help_text[] =
1019 #if defined(CONFIG_CMD_ASKENV)
1020 "ask name [message] [size] - ask for environment variable\nenv "
1022 #if defined(CONFIG_CMD_ENV_CALLBACK)
1023 "callbacks - print callbacks and their associated variables\nenv "
1025 "default [-f] -a - [forcibly] reset default environment\n"
1026 "env default [-f] var [...] - [forcibly] reset variable(s) to their default values\n"
1027 #if defined(CONFIG_CMD_EDITENV)
1028 "env edit name - edit environment variable\n"
1030 #if defined(CONFIG_CMD_EXPORTENV)
1031 "env export [-t | -b | -c] [-s size] addr [var ...] - export environment\n"
1033 #if defined(CONFIG_CMD_ENV_FLAGS)
1034 "env flags - print variables that have non-default flags\n"
1036 #if defined(CONFIG_CMD_GREPENV)
1037 "env grep string [...] - search environment\n"
1039 #if defined(CONFIG_CMD_IMPORTENV)
1040 "env import [-d] [-t | -b | -c] addr [size] - import environment\n"
1042 "env print [-a | name ...] - print environment\n"
1043 #if defined(CONFIG_CMD_RUN)
1044 "env run var [...] - run commands in an environment variable\n"
1046 #if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
1047 "env save - save environment\n"
1049 "env set [-f] name [arg ...]\n";
1053 env, CONFIG_SYS_MAXARGS, 1, do_env,
1054 "environment handling commands", env_help_text
1058 * Old command line interface, kept for compatibility
1061 #if defined(CONFIG_CMD_EDITENV)
1062 U_BOOT_CMD_COMPLETE(
1063 editenv, 2, 0, do_env_edit,
1064 "edit environment variable",
1066 " - edit environment variable 'name'",
1071 U_BOOT_CMD_COMPLETE(
1072 printenv, CONFIG_SYS_MAXARGS, 1, do_env_print,
1073 "print environment variables",
1074 "[-a]\n - print [all] values of all environment variables\n"
1075 "printenv name ...\n"
1076 " - print value of environment variable 'name'",
1080 #ifdef CONFIG_CMD_GREPENV
1081 U_BOOT_CMD_COMPLETE(
1082 grepenv, CONFIG_SYS_MAXARGS, 0, do_env_grep,
1083 "search environment variables",
1085 " - list environment name=value pairs matching 'string'",
1090 U_BOOT_CMD_COMPLETE(
1091 setenv, CONFIG_SYS_MAXARGS, 0, do_env_set,
1092 "set environment variables",
1094 " - set environment variable 'name' to 'value ...'\n"
1096 " - delete environment variable 'name'",
1100 #if defined(CONFIG_CMD_ASKENV)
1103 askenv, CONFIG_SYS_MAXARGS, 1, do_env_ask,
1104 "get environment variables from stdin",
1105 "name [message] [size]\n"
1106 " - get environment variable 'name' from stdin (max 'size' chars)\n"
1108 " - get environment variable 'name' from stdin\n"
1109 "askenv name size\n"
1110 " - get environment variable 'name' from stdin (max 'size' chars)\n"
1111 "askenv name [message] size\n"
1112 " - display 'message' string and get environment variable 'name'"
1113 "from stdin (max 'size' chars)"
1117 #if defined(CONFIG_CMD_RUN)
1118 U_BOOT_CMD_COMPLETE(
1119 run, CONFIG_SYS_MAXARGS, 1, do_run,
1120 "run commands in an environment variable",
1122 " - run the commands in the environment variable(s) 'var'",
1126 #endif /* CONFIG_SPL_BUILD */