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 * Perform consistency checking before setting, replacing, or deleting an
196 * environment variable, then (if successful) apply the changes to internals so
197 * to make them effective. Code for this function was taken out of
198 * _do_env_set(), which now calls it instead.
199 * Also called as a callback function by himport_r().
200 * Returns 0 in case of success, 1 in case of failure.
201 * When (flag & H_FORCE) is set, do not print out any error message and force
202 * overwriting of write-once variables.
205 int env_change_ok(const ENTRY *item, const char *newval, enum env_op op,
208 #ifndef CONFIG_ENV_OVERWRITE
210 #if defined(CONFIG_OVERWRITE_ETHADDR_ONCE) && defined(CONFIG_ETHADDR)
211 const char *oldval = NULL;
213 if (op != env_op_create)
220 #ifndef CONFIG_ENV_OVERWRITE
222 * Some variables like "ethaddr" and "serial#" can be set only once and
223 * cannot be deleted, unless CONFIG_ENV_OVERWRITE is defined.
225 if (op != env_op_create && /* variable exists */
226 (flag & H_FORCE) == 0) { /* and we are not forced */
227 if (strcmp(name, "serial#") == 0 ||
228 (strcmp(name, "ethaddr") == 0
229 #if defined(CONFIG_OVERWRITE_ETHADDR_ONCE) && defined(CONFIG_ETHADDR)
230 && strcmp(oldval, __stringify(CONFIG_ETHADDR)) != 0
231 #endif /* CONFIG_OVERWRITE_ETHADDR_ONCE && CONFIG_ETHADDR */
233 printf("Can't overwrite \"%s\"\n", name);
243 * Set a new environment variable,
244 * or replace or delete an existing one.
246 static int _do_env_set(int flag, int argc, char * const argv[])
249 char *name, *value, *s;
255 if (strchr(name, '=')) {
256 printf("## Error: illegal character '='"
257 "in variable name \"%s\"\n", name);
264 if (argc < 3 || argv[2] == NULL) {
265 int rc = hdelete_r(name, &env_htab, H_INTERACTIVE);
270 * Insert / replace new value
272 for (i = 2, len = 0; i < argc; ++i)
273 len += strlen(argv[i]) + 1;
277 printf("## Can't malloc %d bytes\n", len);
280 for (i = 2, s = value; i < argc; ++i) {
283 while ((*s++ = *v++) != '\0')
292 hsearch_r(e, ENTER, &ep, &env_htab, H_INTERACTIVE);
295 printf("## Error inserting \"%s\" variable, errno=%d\n",
303 int setenv(const char *varname, const char *varvalue)
305 const char * const argv[4] = { "setenv", varname, varvalue, NULL };
307 if (varvalue == NULL || varvalue[0] == '\0')
308 return _do_env_set(0, 2, (char * const *)argv);
310 return _do_env_set(0, 3, (char * const *)argv);
314 * Set an environment variable to an integer value
316 * @param varname Environmet variable to set
317 * @param value Value to set it to
318 * @return 0 if ok, 1 on error
320 int setenv_ulong(const char *varname, ulong value)
322 /* TODO: this should be unsigned */
323 char *str = simple_itoa(value);
325 return setenv(varname, str);
329 * Set an environment variable to an address in hex
331 * @param varname Environmet variable to set
332 * @param addr Value to set it to
333 * @return 0 if ok, 1 on error
335 int setenv_addr(const char *varname, const void *addr)
339 sprintf(str, "%lx", (uintptr_t)addr);
340 return setenv(varname, str);
343 #ifndef CONFIG_SPL_BUILD
344 static int do_env_set(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
347 return CMD_RET_USAGE;
349 return _do_env_set(flag, argc, argv);
353 * Prompt for environment variable
355 #if defined(CONFIG_CMD_ASKENV)
356 int do_env_ask(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
358 char message[CONFIG_SYS_CBSIZE];
359 int size = CONFIG_SYS_CBSIZE - 1;
363 local_args[0] = argv[0];
364 local_args[1] = argv[1];
365 local_args[2] = NULL;
366 local_args[3] = NULL;
368 /* Check the syntax */
371 return CMD_RET_USAGE;
373 case 2: /* env_ask envname */
374 sprintf(message, "Please enter '%s':", argv[1]);
377 case 3: /* env_ask envname size */
378 sprintf(message, "Please enter '%s':", argv[1]);
379 size = simple_strtoul(argv[2], NULL, 10);
382 default: /* env_ask envname message1 ... messagen size */
383 for (i = 2, pos = 0; i < argc - 1; i++) {
385 message[pos++] = ' ';
387 strcpy(message + pos, argv[i]);
388 pos += strlen(argv[i]);
392 size = simple_strtoul(argv[argc - 1], NULL, 10);
396 if (size >= CONFIG_SYS_CBSIZE)
397 size = CONFIG_SYS_CBSIZE - 1;
402 /* prompt for input */
403 len = readline(message);
406 console_buffer[size] = '\0';
409 if (console_buffer[0] != '\0') {
410 local_args[2] = console_buffer;
414 /* Continue calling setenv code */
415 return _do_env_set(flag, len, local_args);
419 #if defined(CONFIG_CMD_ENV_CALLBACK)
420 static int print_static_binding(const char *var_name, const char *callback_name)
422 printf("\t%-20s %-20s\n", var_name, callback_name);
427 static int print_active_callback(ENTRY *entry)
429 struct env_clbk_tbl *clbkp;
433 if (entry->callback == NULL)
436 /* look up the callback in the linker-list */
437 num_callbacks = ll_entry_count(struct env_clbk_tbl, env_clbk);
438 for (i = 0, clbkp = ll_entry_start(struct env_clbk_tbl, env_clbk);
441 #if defined(CONFIG_NEEDS_MANUAL_RELOC)
442 if (entry->callback == clbkp->callback + gd->reloc_off)
444 if (entry->callback == clbkp->callback)
449 if (i == num_callbacks)
450 /* this should probably never happen, but just in case... */
451 printf("\t%-20s %p\n", entry->key, entry->callback);
453 printf("\t%-20s %-20s\n", entry->key, clbkp->name);
459 * Print the callbacks available and what they are bound to
461 int do_env_callback(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
463 struct env_clbk_tbl *clbkp;
467 /* Print the available callbacks */
468 puts("Available callbacks:\n");
469 puts("\tCallback Name\n");
470 puts("\t-------------\n");
471 num_callbacks = ll_entry_count(struct env_clbk_tbl, env_clbk);
472 for (i = 0, clbkp = ll_entry_start(struct env_clbk_tbl, env_clbk);
475 printf("\t%s\n", clbkp->name);
478 /* Print the static bindings that may exist */
479 puts("Static callback bindings:\n");
480 printf("\t%-20s %-20s\n", "Variable Name", "Callback Name");
481 printf("\t%-20s %-20s\n", "-------------", "-------------");
482 env_attr_walk(ENV_CALLBACK_LIST_STATIC, print_static_binding);
485 /* walk through each variable and print the callback if it has one */
486 puts("Active callback bindings:\n");
487 printf("\t%-20s %-20s\n", "Variable Name", "Callback Name");
488 printf("\t%-20s %-20s\n", "-------------", "-------------");
489 hwalk_r(&env_htab, print_active_callback);
495 * Interactively edit an environment variable
497 #if defined(CONFIG_CMD_EDITENV)
498 static int do_env_edit(cmd_tbl_t *cmdtp, int flag, int argc,
501 char buffer[CONFIG_SYS_CBSIZE];
505 return CMD_RET_USAGE;
507 /* Set read buffer to initial value or empty sting */
508 init_val = getenv(argv[1]);
510 sprintf(buffer, "%s", init_val);
514 readline_into_buffer("edit: ", buffer, 0);
516 return setenv(argv[1], buffer);
518 #endif /* CONFIG_CMD_EDITENV */
519 #endif /* CONFIG_SPL_BUILD */
522 * Look up variable from environment,
523 * return address of storage for that variable,
524 * or NULL if not found
526 char *getenv(const char *name)
528 if (gd->flags & GD_FLG_ENV_READY) { /* after import into hashtable */
535 hsearch_r(e, FIND, &ep, &env_htab, 0);
537 return ep ? ep->data : NULL;
540 /* restricted capabilities before import */
541 if (getenv_f(name, (char *)(gd->env_buf), sizeof(gd->env_buf)) > 0)
542 return (char *)(gd->env_buf);
548 * Look up variable from environment for restricted C runtime env.
550 int getenv_f(const char *name, char *buf, unsigned len)
554 for (i = 0; env_get_char(i) != '\0'; i = nxt + 1) {
557 for (nxt = i; env_get_char(nxt) != '\0'; ++nxt) {
558 if (nxt >= CONFIG_ENV_SIZE)
562 val = envmatch((uchar *)name, i);
566 /* found; copy out */
567 for (n = 0; n < len; ++n, ++buf) {
568 *buf = env_get_char(val++);
576 printf("env_buf [%d bytes] too small for value of \"%s\"\n",
586 * Decode the integer value of an environment variable and return it.
588 * @param name Name of environemnt variable
589 * @param base Number base to use (normally 10, or 16 for hex)
590 * @param default_val Default value to return if the variable is not
592 * @return the decoded value, or default_val if not found
594 ulong getenv_ulong(const char *name, int base, ulong default_val)
597 * We can use getenv() here, even before relocation, since the
598 * environment variable value is an integer and thus short.
600 const char *str = getenv(name);
602 return str ? simple_strtoul(str, NULL, base) : default_val;
605 #ifndef CONFIG_SPL_BUILD
606 #if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
607 static int do_env_save(cmd_tbl_t *cmdtp, int flag, int argc,
610 printf("Saving Environment to %s...\n", env_name_spec);
612 return saveenv() ? 1 : 0;
616 saveenv, 1, 0, do_env_save,
617 "save environment variables to persistent storage",
621 #endif /* CONFIG_SPL_BUILD */
625 * Match a name / name=value pair
627 * s1 is either a simple 'name', or a 'name=value' pair.
628 * i2 is the environment index for a 'name2=value2' pair.
629 * If the names match, return the index for the value2, else -1.
631 int envmatch(uchar *s1, int i2)
636 while (*s1 == env_get_char(i2++))
640 if (*s1 == '\0' && env_get_char(i2-1) == '=')
646 #ifndef CONFIG_SPL_BUILD
647 static int do_env_default(cmd_tbl_t *cmdtp, int __flag,
648 int argc, char * const argv[])
650 int all = 0, flag = 0;
652 debug("Initial value for argc=%d\n", argc);
653 while (--argc > 0 && **++argv == '-') {
658 case 'a': /* default all */
661 case 'f': /* force */
665 return cmd_usage(cmdtp);
669 debug("Final value for argc=%d\n", argc);
670 if (all && (argc == 0)) {
671 /* Reset the whole environment */
672 set_default_env("## Resetting to default environment\n");
675 if (!all && (argc > 0)) {
676 /* Reset individual variables */
677 set_default_vars(argc, argv);
681 return cmd_usage(cmdtp);
684 static int do_env_delete(cmd_tbl_t *cmdtp, int flag,
685 int argc, char * const argv[])
687 printf("Not implemented yet\n");
691 #ifdef CONFIG_CMD_EXPORTENV
693 * env export [-t | -b | -c] [-s size] addr [var ...]
694 * -t: export as text format; if size is given, data will be
695 * padded with '\0' bytes; if not, one terminating '\0'
696 * will be added (which is included in the "filesize"
697 * setting so you can for exmple copy this to flash and
698 * keep the termination).
699 * -b: export as binary format (name=value pairs separated by
700 * '\0', list end marked by double "\0\0")
701 * -c: export as checksum protected environment format as
702 * used for example by "saveenv" command
704 * size of output buffer
705 * addr: memory address where environment gets stored
706 * var... List of variable names that get included into the
707 * export. Without arguments, the whole environment gets
710 * With "-c" and size is NOT given, then the export command will
711 * format the data as currently used for the persistent storage,
712 * i. e. it will use CONFIG_ENV_SECT_SIZE as output block size and
713 * prepend a valid CRC32 checksum and, in case of resundant
714 * environment, a "current" redundancy flag. If size is given, this
715 * value will be used instead of CONFIG_ENV_SECT_SIZE; again, CRC32
716 * checksum and redundancy flag will be inserted.
718 * With "-b" and "-t", always only the real data (including a
719 * terminating '\0' byte) will be written; here the optional size
720 * argument will be used to make sure not to overflow the user
721 * provided buffer; the command will abort if the size is not
722 * sufficient. Any remainign space will be '\0' padded.
724 * On successful return, the variable "filesize" will be set.
725 * Note that filesize includes the trailing/terminating '\0' byte(s).
727 * Usage szenario: create a text snapshot/backup of the current settings:
729 * => env export -t 100000
730 * => era ${backup_addr} +${filesize}
731 * => cp.b 100000 ${backup_addr} ${filesize}
733 * Re-import this snapshot, deleting all other settings:
735 * => env import -d -t ${backup_addr}
737 static int do_env_export(cmd_tbl_t *cmdtp, int flag,
738 int argc, char * const argv[])
741 char *addr, *cmd, *res;
751 while (--argc > 0 && **++argv == '-') {
755 case 'b': /* raw binary format */
760 case 'c': /* external checksum format */
766 case 's': /* size given */
768 return cmd_usage(cmdtp);
769 size = simple_strtoul(*++argv, NULL, 16);
771 case 't': /* text format */
777 return CMD_RET_USAGE;
784 return CMD_RET_USAGE;
786 addr = (char *)simple_strtoul(argv[0], NULL, 16);
789 memset(addr, '\0', size);
794 if (sep) { /* export as text file */
795 len = hexport_r(&env_htab, sep, 0, &addr, size, argc, argv);
797 error("Cannot export environment: errno = %d\n", errno);
800 sprintf(buf, "%zX", (size_t)len);
801 setenv("filesize", buf);
806 envp = (env_t *)addr;
808 if (chk) /* export as checksum protected block */
809 res = (char *)envp->data;
810 else /* export as raw binary data */
813 len = hexport_r(&env_htab, '\0', 0, &res, ENV_SIZE, argc, argv);
815 error("Cannot export environment: errno = %d\n", errno);
820 envp->crc = crc32(0, envp->data, ENV_SIZE);
821 #ifdef CONFIG_ENV_ADDR_REDUND
822 envp->flags = ACTIVE_FLAG;
825 sprintf(buf, "%zX", (size_t)(len + offsetof(env_t, data)));
826 setenv("filesize", buf);
831 printf("## %s: only one of \"-b\", \"-c\" or \"-t\" allowed\n", cmd);
836 #ifdef CONFIG_CMD_IMPORTENV
838 * env import [-d] [-t | -b | -c] addr [size]
839 * -d: delete existing environment before importing;
840 * otherwise overwrite / append to existion definitions
841 * -t: assume text format; either "size" must be given or the
842 * text data must be '\0' terminated
843 * -b: assume binary format ('\0' separated, "\0\0" terminated)
844 * -c: assume checksum protected environment format
845 * addr: memory address to read from
846 * size: length of input data; if missing, proper '\0'
847 * termination is mandatory
849 static int do_env_import(cmd_tbl_t *cmdtp, int flag,
850 int argc, char * const argv[])
861 while (--argc > 0 && **++argv == '-') {
865 case 'b': /* raw binary format */
870 case 'c': /* external checksum format */
876 case 't': /* text format */
885 return CMD_RET_USAGE;
891 return CMD_RET_USAGE;
894 printf("## Warning: defaulting to text format\n");
896 addr = (char *)simple_strtoul(argv[0], NULL, 16);
899 size = simple_strtoul(argv[1], NULL, 16);
905 while (size < MAX_ENV_SIZE) {
906 if ((*s == sep) && (*(s+1) == '\0'))
911 if (size == MAX_ENV_SIZE) {
912 printf("## Warning: Input data exceeds %d bytes"
913 " - truncated\n", MAX_ENV_SIZE);
916 printf("## Info: input data size = %zu = 0x%zX\n", size, size);
921 env_t *ep = (env_t *)addr;
923 size -= offsetof(env_t, data);
924 memcpy(&crc, &ep->crc, sizeof(crc));
926 if (crc32(0, ep->data, size) != crc) {
927 puts("## Error: bad CRC, import failed\n");
930 addr = (char *)ep->data;
933 if (himport_r(&env_htab, addr, size, sep, del ? 0 : H_NOCLEAR,
935 error("Environment import failed: errno = %d\n", errno);
938 gd->flags |= GD_FLG_ENV_READY;
943 printf("## %s: only one of \"-b\", \"-c\" or \"-t\" allowed\n",
950 * New command line interface: "env" command with subcommands
952 static cmd_tbl_t cmd_env_sub[] = {
953 #if defined(CONFIG_CMD_ASKENV)
954 U_BOOT_CMD_MKENT(ask, CONFIG_SYS_MAXARGS, 1, do_env_ask, "", ""),
956 U_BOOT_CMD_MKENT(default, 1, 0, do_env_default, "", ""),
957 U_BOOT_CMD_MKENT(delete, 2, 0, do_env_delete, "", ""),
958 #if defined(CONFIG_CMD_EDITENV)
959 U_BOOT_CMD_MKENT(edit, 2, 0, do_env_edit, "", ""),
961 #if defined(CONFIG_CMD_ENV_CALLBACK)
962 U_BOOT_CMD_MKENT(callbacks, 1, 0, do_env_callback, "", ""),
964 #if defined(CONFIG_CMD_EXPORTENV)
965 U_BOOT_CMD_MKENT(export, 4, 0, do_env_export, "", ""),
967 #if defined(CONFIG_CMD_GREPENV)
968 U_BOOT_CMD_MKENT(grep, CONFIG_SYS_MAXARGS, 1, do_env_grep, "", ""),
970 #if defined(CONFIG_CMD_IMPORTENV)
971 U_BOOT_CMD_MKENT(import, 5, 0, do_env_import, "", ""),
973 U_BOOT_CMD_MKENT(print, CONFIG_SYS_MAXARGS, 1, do_env_print, "", ""),
974 #if defined(CONFIG_CMD_RUN)
975 U_BOOT_CMD_MKENT(run, CONFIG_SYS_MAXARGS, 1, do_run, "", ""),
977 #if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
978 U_BOOT_CMD_MKENT(save, 1, 0, do_env_save, "", ""),
980 U_BOOT_CMD_MKENT(set, CONFIG_SYS_MAXARGS, 0, do_env_set, "", ""),
983 #if defined(CONFIG_NEEDS_MANUAL_RELOC)
986 fixup_cmdtable(cmd_env_sub, ARRAY_SIZE(cmd_env_sub));
990 static int do_env(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
995 return CMD_RET_USAGE;
997 /* drop initial "env" arg */
1001 cp = find_cmd_tbl(argv[0], cmd_env_sub, ARRAY_SIZE(cmd_env_sub));
1004 return cp->cmd(cmdtp, flag, argc, argv);
1006 return CMD_RET_USAGE;
1009 #ifdef CONFIG_SYS_LONGHELP
1010 static char env_help_text[] =
1011 #if defined(CONFIG_CMD_ASKENV)
1012 "ask name [message] [size] - ask for environment variable\nenv "
1014 #if defined(CONFIG_CMD_ENV_CALLBACK)
1015 "callbacks - print callbacks and their associated variables\nenv "
1017 "default [-f] -a - [forcibly] reset default environment\n"
1018 "env default [-f] var [...] - [forcibly] reset variable(s) to their default values\n"
1019 #if defined(CONFIG_CMD_EDITENV)
1020 "env edit name - edit environment variable\n"
1022 #if defined(CONFIG_CMD_EXPORTENV)
1023 "env export [-t | -b | -c] [-s size] addr [var ...] - export environment\n"
1025 #if defined(CONFIG_CMD_GREPENV)
1026 "env grep string [...] - search environment\n"
1028 #if defined(CONFIG_CMD_IMPORTENV)
1029 "env import [-d] [-t | -b | -c] addr [size] - import environment\n"
1031 "env print [-a | name ...] - print environment\n"
1032 #if defined(CONFIG_CMD_RUN)
1033 "env run var [...] - run commands in an environment variable\n"
1035 #if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
1036 "env save - save environment\n"
1038 "env set [-f] name [arg ...]\n";
1042 env, CONFIG_SYS_MAXARGS, 1, do_env,
1043 "environment handling commands", env_help_text
1047 * Old command line interface, kept for compatibility
1050 #if defined(CONFIG_CMD_EDITENV)
1051 U_BOOT_CMD_COMPLETE(
1052 editenv, 2, 0, do_env_edit,
1053 "edit environment variable",
1055 " - edit environment variable 'name'",
1060 U_BOOT_CMD_COMPLETE(
1061 printenv, CONFIG_SYS_MAXARGS, 1, do_env_print,
1062 "print environment variables",
1063 "[-a]\n - print [all] values of all environment variables\n"
1064 "printenv name ...\n"
1065 " - print value of environment variable 'name'",
1069 #ifdef CONFIG_CMD_GREPENV
1070 U_BOOT_CMD_COMPLETE(
1071 grepenv, CONFIG_SYS_MAXARGS, 0, do_env_grep,
1072 "search environment variables",
1074 " - list environment name=value pairs matching 'string'",
1079 U_BOOT_CMD_COMPLETE(
1080 setenv, CONFIG_SYS_MAXARGS, 0, do_env_set,
1081 "set environment variables",
1083 " - set environment variable 'name' to 'value ...'\n"
1085 " - delete environment variable 'name'",
1089 #if defined(CONFIG_CMD_ASKENV)
1092 askenv, CONFIG_SYS_MAXARGS, 1, do_env_ask,
1093 "get environment variables from stdin",
1094 "name [message] [size]\n"
1095 " - get environment variable 'name' from stdin (max 'size' chars)\n"
1097 " - get environment variable 'name' from stdin\n"
1098 "askenv name size\n"
1099 " - get environment variable 'name' from stdin (max 'size' chars)\n"
1100 "askenv name [message] size\n"
1101 " - display 'message' string and get environment variable 'name'"
1102 "from stdin (max 'size' chars)"
1106 #if defined(CONFIG_CMD_RUN)
1107 U_BOOT_CMD_COMPLETE(
1108 run, CONFIG_SYS_MAXARGS, 1, do_run,
1109 "run commands in an environment variable",
1111 " - run the commands in the environment variable(s) 'var'",
1115 #endif /* CONFIG_SPL_BUILD */