]>
Commit | Line | Data |
---|---|---|
a68d3ed0 WD |
1 | /* |
2 | * (C) Copyright 2000-2002 | |
3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. | |
4 | * | |
5 | * (C) Copyright 2001 Sysgo Real-Time Solutions, GmbH <www.elinos.com> | |
6 | * Andreas Heppel <aheppel@sysgo.de> | |
7 | ||
8 | * See file CREDITS for list of people who contributed to this | |
9 | * project. | |
10 | * | |
11 | * This program is free software; you can redistribute it and/or | |
12 | * modify it under the terms of the GNU General Public License as | |
13 | * published by the Free Software Foundation; either version 2 of | |
14 | * the License, or (at your option) any later version. | |
15 | * | |
16 | * This program is distributed in the hope that it will be useful, | |
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 | * GNU General Public License for more details. | |
20 | * | |
21 | * You should have received a copy of the GNU General Public License | |
22 | * along with this program; if not, write to the Free Software | |
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | |
24 | * MA 02111-1307 USA | |
25 | */ | |
26 | ||
27 | /************************************************************************** | |
28 | * | |
29 | * Support for persistent environment data | |
30 | * | |
31 | * The "environment" is stored as a list of '\0' terminated | |
32 | * "name=value" strings. The end of the list is marked by a double | |
33 | * '\0'. New entries are always added at the end. Deleting an entry | |
34 | * shifts the remaining entries to the front. Replacing an entry is a | |
35 | * combination of deleting the old value and adding the new one. | |
36 | * | |
37 | * The environment is preceeded by a 32 bit CRC over the data part. | |
38 | * | |
39 | ************************************************************************** | |
40 | */ | |
41 | ||
42 | #include <common.h> | |
43 | #include <command.h> | |
44 | #include <environment.h> | |
2a3cb020 | 45 | #include <watchdog.h> |
281e00a3 | 46 | #include <serial.h> |
a68d3ed0 WD |
47 | #include <linux/stddef.h> |
48 | #include <asm/byteorder.h> | |
c76fe474 | 49 | #if defined(CONFIG_CMD_NET) |
a68d3ed0 WD |
50 | #include <net.h> |
51 | #endif | |
52 | ||
d87080b7 WD |
53 | DECLARE_GLOBAL_DATA_PTR; |
54 | ||
5779d8d9 WD |
55 | #if !defined(CFG_ENV_IS_IN_NVRAM) && \ |
56 | !defined(CFG_ENV_IS_IN_EEPROM) && \ | |
57 | !defined(CFG_ENV_IS_IN_FLASH) && \ | |
58 | !defined(CFG_ENV_IS_IN_DATAFLASH) && \ | |
13a5695b | 59 | !defined(CFG_ENV_IS_IN_NAND) && \ |
d7e8ce10 | 60 | !defined(CFG_ENV_IS_IN_ONENAND) && \ |
5779d8d9 | 61 | !defined(CFG_ENV_IS_NOWHERE) |
d7e8ce10 | 62 | # error Define one of CFG_ENV_IS_IN_{NVRAM|EEPROM|FLASH|DATAFLASH|ONENAND|NOWHERE} |
a68d3ed0 WD |
63 | #endif |
64 | ||
65 | #define XMK_STR(x) #x | |
66 | #define MK_STR(x) XMK_STR(x) | |
67 | ||
68 | /************************************************************************ | |
69 | ************************************************************************/ | |
70 | ||
71 | /* Function that returns a character from the environment */ | |
72 | extern uchar (*env_get_char)(int); | |
73 | ||
74 | /* Function that returns a pointer to a value from the environment */ | |
75 | /* (Only memory version supported / needed). */ | |
76 | extern uchar *env_get_addr(int); | |
77 | ||
78 | /* Function that updates CRC of the enironment */ | |
79 | extern void env_crc_update (void); | |
80 | ||
81 | /************************************************************************ | |
82 | ************************************************************************/ | |
83 | ||
a68d3ed0 WD |
84 | /* |
85 | * Table with supported baudrates (defined in config_xyz.h) | |
86 | */ | |
87 | static const unsigned long baudrate_table[] = CFG_BAUDRATE_TABLE; | |
88 | #define N_BAUDRATES (sizeof(baudrate_table) / sizeof(baudrate_table[0])) | |
89 | ||
90 | ||
91 | /************************************************************************ | |
92 | * Command interface: print one or all environment variables | |
93 | */ | |
94 | ||
95 | int do_printenv (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) | |
96 | { | |
97 | int i, j, k, nxt; | |
98 | int rcode = 0; | |
99 | ||
100 | if (argc == 1) { /* Print all env variables */ | |
101 | for (i=0; env_get_char(i) != '\0'; i=nxt+1) { | |
102 | for (nxt=i; env_get_char(nxt) != '\0'; ++nxt) | |
103 | ; | |
104 | for (k=i; k<nxt; ++k) | |
105 | putc(env_get_char(k)); | |
106 | putc ('\n'); | |
107 | ||
108 | if (ctrlc()) { | |
109 | puts ("\n ** Abort\n"); | |
110 | return 1; | |
111 | } | |
112 | } | |
113 | ||
114 | printf("\nEnvironment size: %d/%d bytes\n", i, ENV_SIZE); | |
115 | ||
116 | return 0; | |
117 | } | |
118 | ||
119 | for (i=1; i<argc; ++i) { /* print single env variables */ | |
120 | char *name = argv[i]; | |
121 | ||
122 | k = -1; | |
123 | ||
124 | for (j=0; env_get_char(j) != '\0'; j=nxt+1) { | |
125 | ||
126 | for (nxt=j; env_get_char(nxt) != '\0'; ++nxt) | |
127 | ; | |
77ddac94 | 128 | k = envmatch((uchar *)name, j); |
a68d3ed0 WD |
129 | if (k < 0) { |
130 | continue; | |
131 | } | |
132 | puts (name); | |
133 | putc ('='); | |
134 | while (k < nxt) | |
135 | putc(env_get_char(k++)); | |
136 | putc ('\n'); | |
137 | break; | |
138 | } | |
139 | if (k < 0) { | |
140 | printf ("## Error: \"%s\" not defined\n", name); | |
141 | rcode ++; | |
142 | } | |
143 | } | |
144 | return rcode; | |
145 | } | |
146 | ||
147 | /************************************************************************ | |
148 | * Set a new environment variable, | |
149 | * or replace or delete an existing one. | |
150 | * | |
151 | * This function will ONLY work with a in-RAM copy of the environment | |
152 | */ | |
153 | ||
154 | int _do_setenv (int flag, int argc, char *argv[]) | |
155 | { | |
a68d3ed0 WD |
156 | int i, len, oldval; |
157 | int console = -1; | |
158 | uchar *env, *nxt = NULL; | |
77ddac94 | 159 | char *name; |
a68d3ed0 WD |
160 | bd_t *bd = gd->bd; |
161 | ||
162 | uchar *env_data = env_get_addr(0); | |
163 | ||
164 | if (!env_data) /* need copy in RAM */ | |
165 | return 1; | |
166 | ||
167 | name = argv[1]; | |
168 | ||
471a7be7 WD |
169 | if (strchr(name, '=')) { |
170 | printf ("## Error: illegal character '=' in variable name \"%s\"\n", name); | |
171 | return 1; | |
172 | } | |
173 | ||
a68d3ed0 WD |
174 | /* |
175 | * search if variable with this name already exists | |
176 | */ | |
177 | oldval = -1; | |
178 | for (env=env_data; *env; env=nxt+1) { | |
179 | for (nxt=env; *nxt; ++nxt) | |
180 | ; | |
77ddac94 | 181 | if ((oldval = envmatch((uchar *)name, env-env_data)) >= 0) |
a68d3ed0 WD |
182 | break; |
183 | } | |
184 | ||
185 | /* | |
186 | * Delete any existing definition | |
187 | */ | |
188 | if (oldval >= 0) { | |
189 | #ifndef CONFIG_ENV_OVERWRITE | |
190 | ||
191 | /* | |
0587597c SR |
192 | * Ethernet Address and serial# can be set only once, |
193 | * ver is readonly. | |
a68d3ed0 | 194 | */ |
c74b2108 SK |
195 | #ifdef CONFIG_HAS_UID |
196 | /* Allow serial# forced overwrite with 0xdeaf4add flag */ | |
197 | if ( ((strcmp (name, "serial#") == 0) && (flag != 0xdeaf4add)) || | |
198 | #else | |
a68d3ed0 | 199 | if ( (strcmp (name, "serial#") == 0) || |
c74b2108 | 200 | #endif |
a68d3ed0 WD |
201 | ((strcmp (name, "ethaddr") == 0) |
202 | #if defined(CONFIG_OVERWRITE_ETHADDR_ONCE) && defined(CONFIG_ETHADDR) | |
77ddac94 | 203 | && (strcmp ((char *)env_get_addr(oldval),MK_STR(CONFIG_ETHADDR)) != 0) |
a68d3ed0 WD |
204 | #endif /* CONFIG_OVERWRITE_ETHADDR_ONCE && CONFIG_ETHADDR */ |
205 | ) ) { | |
206 | printf ("Can't overwrite \"%s\"\n", name); | |
207 | return 1; | |
208 | } | |
209 | #endif | |
210 | ||
211 | /* Check for console redirection */ | |
212 | if (strcmp(name,"stdin") == 0) { | |
213 | console = stdin; | |
214 | } else if (strcmp(name,"stdout") == 0) { | |
215 | console = stdout; | |
216 | } else if (strcmp(name,"stderr") == 0) { | |
217 | console = stderr; | |
218 | } | |
219 | ||
220 | if (console != -1) { | |
221 | if (argc < 3) { /* Cannot delete it! */ | |
222 | printf("Can't delete \"%s\"\n", name); | |
223 | return 1; | |
224 | } | |
225 | ||
226 | /* Try assigning specified device */ | |
227 | if (console_assign (console, argv[2]) < 0) | |
228 | return 1; | |
281e00a3 WD |
229 | |
230 | #ifdef CONFIG_SERIAL_MULTI | |
231 | if (serial_assign (argv[2]) < 0) | |
232 | return 1; | |
233 | #endif | |
a68d3ed0 WD |
234 | } |
235 | ||
236 | /* | |
237 | * Switch to new baudrate if new baudrate is supported | |
238 | */ | |
239 | if (strcmp(argv[1],"baudrate") == 0) { | |
240 | int baudrate = simple_strtoul(argv[2], NULL, 10); | |
241 | int i; | |
242 | for (i=0; i<N_BAUDRATES; ++i) { | |
243 | if (baudrate == baudrate_table[i]) | |
244 | break; | |
245 | } | |
246 | if (i == N_BAUDRATES) { | |
247 | printf ("## Baudrate %d bps not supported\n", | |
248 | baudrate); | |
249 | return 1; | |
250 | } | |
251 | printf ("## Switch baudrate to %d bps and press ENTER ...\n", | |
252 | baudrate); | |
253 | udelay(50000); | |
254 | gd->baudrate = baudrate; | |
c84bad0e | 255 | #if defined(CONFIG_PPC) || defined(CONFIG_MCF52x2) |
d0fb80c3 WD |
256 | gd->bd->bi_baudrate = baudrate; |
257 | #endif | |
258 | ||
a68d3ed0 WD |
259 | serial_setbrg (); |
260 | udelay(50000); | |
261 | for (;;) { | |
262 | if (getc() == '\r') | |
263 | break; | |
264 | } | |
265 | } | |
266 | ||
267 | if (*++nxt == '\0') { | |
268 | if (env > env_data) { | |
269 | env--; | |
270 | } else { | |
271 | *env = '\0'; | |
272 | } | |
273 | } else { | |
274 | for (;;) { | |
275 | *env = *nxt++; | |
276 | if ((*env == '\0') && (*nxt == '\0')) | |
277 | break; | |
278 | ++env; | |
279 | } | |
280 | } | |
281 | *++env = '\0'; | |
282 | } | |
283 | ||
284 | #ifdef CONFIG_NET_MULTI | |
285 | if (strncmp(name, "eth", 3) == 0) { | |
286 | char *end; | |
287 | int num = simple_strtoul(name+3, &end, 10); | |
288 | ||
289 | if (strcmp(end, "addr") == 0) { | |
290 | eth_set_enetaddr(num, argv[2]); | |
291 | } | |
292 | } | |
293 | #endif | |
294 | ||
295 | ||
296 | /* Delete only ? */ | |
297 | if ((argc < 3) || argv[2] == NULL) { | |
298 | env_crc_update (); | |
299 | return 0; | |
300 | } | |
301 | ||
302 | /* | |
303 | * Append new definition at the end | |
304 | */ | |
305 | for (env=env_data; *env || *(env+1); ++env) | |
306 | ; | |
307 | if (env > env_data) | |
308 | ++env; | |
309 | /* | |
310 | * Overflow when: | |
311 | * "name" + "=" + "val" +"\0\0" > ENV_SIZE - (env-env_data) | |
312 | */ | |
313 | len = strlen(name) + 2; | |
314 | /* add '=' for first arg, ' ' for all others */ | |
315 | for (i=2; i<argc; ++i) { | |
316 | len += strlen(argv[i]) + 1; | |
317 | } | |
318 | if (len > (&env_data[ENV_SIZE]-env)) { | |
319 | printf ("## Error: environment overflow, \"%s\" deleted\n", name); | |
320 | return 1; | |
321 | } | |
322 | while ((*env = *name++) != '\0') | |
323 | env++; | |
324 | for (i=2; i<argc; ++i) { | |
325 | char *val = argv[i]; | |
326 | ||
327 | *env = (i==2) ? '=' : ' '; | |
328 | while ((*++env = *val++) != '\0') | |
329 | ; | |
330 | } | |
331 | ||
332 | /* end is marked with double '\0' */ | |
333 | *++env = '\0'; | |
334 | ||
335 | /* Update CRC */ | |
336 | env_crc_update (); | |
337 | ||
338 | /* | |
339 | * Some variables should be updated when the corresponding | |
340 | * entry in the enviornment is changed | |
341 | */ | |
342 | ||
343 | if (strcmp(argv[1],"ethaddr") == 0) { | |
344 | char *s = argv[2]; /* always use only one arg */ | |
345 | char *e; | |
346 | for (i=0; i<6; ++i) { | |
347 | bd->bi_enetaddr[i] = s ? simple_strtoul(s, &e, 16) : 0; | |
348 | if (s) s = (*e) ? e+1 : e; | |
349 | } | |
350 | #ifdef CONFIG_NET_MULTI | |
351 | eth_set_enetaddr(0, argv[2]); | |
352 | #endif | |
353 | return 0; | |
354 | } | |
355 | ||
356 | if (strcmp(argv[1],"ipaddr") == 0) { | |
357 | char *s = argv[2]; /* always use only one arg */ | |
358 | char *e; | |
359 | unsigned long addr; | |
360 | bd->bi_ip_addr = 0; | |
361 | for (addr=0, i=0; i<4; ++i) { | |
362 | ulong val = s ? simple_strtoul(s, &e, 10) : 0; | |
363 | addr <<= 8; | |
364 | addr |= (val & 0xFF); | |
365 | if (s) s = (*e) ? e+1 : e; | |
366 | } | |
367 | bd->bi_ip_addr = htonl(addr); | |
368 | return 0; | |
369 | } | |
370 | if (strcmp(argv[1],"loadaddr") == 0) { | |
371 | load_addr = simple_strtoul(argv[2], NULL, 16); | |
372 | return 0; | |
373 | } | |
c76fe474 | 374 | #if defined(CONFIG_CMD_NET) |
a68d3ed0 WD |
375 | if (strcmp(argv[1],"bootfile") == 0) { |
376 | copy_filename (BootFile, argv[2], sizeof(BootFile)); | |
377 | return 0; | |
378 | } | |
90253178 | 379 | #endif |
c7de829c | 380 | |
0587597c | 381 | #ifdef CONFIG_AMIGAONEG3SE |
c7de829c WD |
382 | if (strcmp(argv[1], "vga_fg_color") == 0 || |
383 | strcmp(argv[1], "vga_bg_color") == 0 ) { | |
384 | extern void video_set_color(unsigned char attr); | |
385 | extern unsigned char video_get_attr(void); | |
386 | ||
387 | video_set_color(video_get_attr()); | |
388 | return 0; | |
389 | } | |
390 | #endif /* CONFIG_AMIGAONEG3SE */ | |
391 | ||
a68d3ed0 WD |
392 | return 0; |
393 | } | |
394 | ||
395 | void setenv (char *varname, char *varvalue) | |
396 | { | |
397 | char *argv[4] = { "setenv", varname, varvalue, NULL }; | |
9ffd451a JM |
398 | if (varvalue == NULL) |
399 | _do_setenv (0, 2, argv); | |
400 | else | |
401 | _do_setenv (0, 3, argv); | |
a68d3ed0 WD |
402 | } |
403 | ||
c74b2108 SK |
404 | #ifdef CONFIG_HAS_UID |
405 | void forceenv (char *varname, char *varvalue) | |
406 | { | |
407 | char *argv[4] = { "forceenv", varname, varvalue, NULL }; | |
408 | _do_setenv (0xdeaf4add, 3, argv); | |
409 | } | |
410 | #endif | |
411 | ||
412 | int do_setenv (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) | |
a68d3ed0 WD |
413 | { |
414 | if (argc < 2) { | |
415 | printf ("Usage:\n%s\n", cmdtp->usage); | |
416 | return 1; | |
417 | } | |
418 | ||
419 | return _do_setenv (flag, argc, argv); | |
420 | } | |
421 | ||
422 | /************************************************************************ | |
423 | * Prompt for environment variable | |
424 | */ | |
425 | ||
c76fe474 | 426 | #if defined(CONFIG_CMD_ASKENV) |
a68d3ed0 WD |
427 | int do_askenv ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
428 | { | |
429 | extern char console_buffer[CFG_CBSIZE]; | |
430 | char message[CFG_CBSIZE]; | |
431 | int size = CFG_CBSIZE - 1; | |
432 | int len; | |
433 | char *local_args[4]; | |
434 | ||
435 | local_args[0] = argv[0]; | |
436 | local_args[1] = argv[1]; | |
437 | local_args[2] = NULL; | |
438 | local_args[3] = NULL; | |
439 | ||
440 | if (argc < 2) { | |
441 | printf ("Usage:\n%s\n", cmdtp->usage); | |
442 | return 1; | |
443 | } | |
444 | /* Check the syntax */ | |
445 | switch (argc) { | |
446 | case 1: | |
447 | printf ("Usage:\n%s\n", cmdtp->usage); | |
448 | return 1; | |
449 | ||
450 | case 2: /* askenv envname */ | |
451 | sprintf (message, "Please enter '%s':", argv[1]); | |
452 | break; | |
453 | ||
454 | case 3: /* askenv envname size */ | |
455 | sprintf (message, "Please enter '%s':", argv[1]); | |
456 | size = simple_strtoul (argv[2], NULL, 10); | |
457 | break; | |
458 | ||
459 | default: /* askenv envname message1 ... messagen size */ | |
460 | { | |
461 | int i; | |
462 | int pos = 0; | |
463 | ||
464 | for (i = 2; i < argc - 1; i++) { | |
465 | if (pos) { | |
466 | message[pos++] = ' '; | |
467 | } | |
468 | strcpy (message+pos, argv[i]); | |
469 | pos += strlen(argv[i]); | |
470 | } | |
471 | message[pos] = '\0'; | |
472 | size = simple_strtoul (argv[argc - 1], NULL, 10); | |
473 | } | |
474 | break; | |
475 | } | |
476 | ||
477 | if (size >= CFG_CBSIZE) | |
478 | size = CFG_CBSIZE - 1; | |
479 | ||
480 | if (size <= 0) | |
481 | return 1; | |
482 | ||
483 | /* prompt for input */ | |
484 | len = readline (message); | |
485 | ||
486 | if (size < len) | |
487 | console_buffer[size] = '\0'; | |
488 | ||
489 | len = 2; | |
490 | if (console_buffer[0] != '\0') { | |
491 | local_args[2] = console_buffer; | |
492 | len = 3; | |
493 | } | |
494 | ||
495 | /* Continue calling setenv code */ | |
496 | return _do_setenv (flag, len, local_args); | |
497 | } | |
90253178 | 498 | #endif |
a68d3ed0 WD |
499 | |
500 | /************************************************************************ | |
501 | * Look up variable from environment, | |
502 | * return address of storage for that variable, | |
503 | * or NULL if not found | |
504 | */ | |
505 | ||
77ddac94 | 506 | char *getenv (char *name) |
a68d3ed0 WD |
507 | { |
508 | int i, nxt; | |
509 | ||
2a3cb020 WD |
510 | WATCHDOG_RESET(); |
511 | ||
a68d3ed0 WD |
512 | for (i=0; env_get_char(i) != '\0'; i=nxt+1) { |
513 | int val; | |
514 | ||
515 | for (nxt=i; env_get_char(nxt) != '\0'; ++nxt) { | |
516 | if (nxt >= CFG_ENV_SIZE) { | |
517 | return (NULL); | |
518 | } | |
519 | } | |
77ddac94 | 520 | if ((val=envmatch((uchar *)name, i)) < 0) |
a68d3ed0 | 521 | continue; |
77ddac94 | 522 | return ((char *)env_get_addr(val)); |
a68d3ed0 WD |
523 | } |
524 | ||
525 | return (NULL); | |
526 | } | |
527 | ||
77ddac94 | 528 | int getenv_r (char *name, char *buf, unsigned len) |
a68d3ed0 WD |
529 | { |
530 | int i, nxt; | |
531 | ||
532 | for (i=0; env_get_char(i) != '\0'; i=nxt+1) { | |
533 | int val, n; | |
534 | ||
535 | for (nxt=i; env_get_char(nxt) != '\0'; ++nxt) { | |
536 | if (nxt >= CFG_ENV_SIZE) { | |
537 | return (-1); | |
538 | } | |
539 | } | |
77ddac94 | 540 | if ((val=envmatch((uchar *)name, i)) < 0) |
a68d3ed0 WD |
541 | continue; |
542 | /* found; copy out */ | |
543 | n = 0; | |
544 | while ((len > n++) && (*buf++ = env_get_char(val++)) != '\0') | |
545 | ; | |
546 | if (len == n) | |
547 | *buf = '\0'; | |
548 | return (n); | |
549 | } | |
550 | return (-1); | |
551 | } | |
552 | ||
3865b1fb | 553 | #if defined(CFG_ENV_IS_IN_NVRAM) || defined(CFG_ENV_IS_IN_EEPROM) \ |
65c450b4 | 554 | || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_FLASH)) \ |
d7e8ce10 KP |
555 | || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_NAND)) \ |
556 | || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_ONENAND)) | |
a68d3ed0 WD |
557 | int do_saveenv (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
558 | { | |
559 | extern char * env_name_spec; | |
560 | ||
561 | printf ("Saving Environment to %s...\n", env_name_spec); | |
562 | ||
563 | return (saveenv() ? 1 : 0); | |
564 | } | |
8bde7f77 | 565 | |
a68d3ed0 WD |
566 | #endif |
567 | ||
568 | ||
569 | /************************************************************************ | |
570 | * Match a name / name=value pair | |
571 | * | |
572 | * s1 is either a simple 'name', or a 'name=value' pair. | |
573 | * i2 is the environment index for a 'name2=value2' pair. | |
574 | * If the names match, return the index for the value2, else NULL. | |
575 | */ | |
576 | ||
26a41790 | 577 | int envmatch (uchar *s1, int i2) |
a68d3ed0 WD |
578 | { |
579 | ||
580 | while (*s1 == env_get_char(i2++)) | |
581 | if (*s1++ == '=') | |
582 | return(i2); | |
583 | if (*s1 == '\0' && env_get_char(i2-1) == '=') | |
584 | return(i2); | |
585 | return(-1); | |
586 | } | |
8bde7f77 WD |
587 | |
588 | ||
589 | /**************************************************/ | |
590 | ||
0d498393 WD |
591 | U_BOOT_CMD( |
592 | printenv, CFG_MAXARGS, 1, do_printenv, | |
8bde7f77 WD |
593 | "printenv- print environment variables\n", |
594 | "\n - print values of all environment variables\n" | |
595 | "printenv name ...\n" | |
596 | " - print value of environment variable 'name'\n" | |
597 | ); | |
598 | ||
0d498393 WD |
599 | U_BOOT_CMD( |
600 | setenv, CFG_MAXARGS, 0, do_setenv, | |
8bde7f77 WD |
601 | "setenv - set environment variables\n", |
602 | "name value ...\n" | |
603 | " - set environment variable 'name' to 'value ...'\n" | |
604 | "setenv name\n" | |
605 | " - delete environment variable 'name'\n" | |
606 | ); | |
607 | ||
3865b1fb | 608 | #if defined(CFG_ENV_IS_IN_NVRAM) || defined(CFG_ENV_IS_IN_EEPROM) \ |
65c450b4 | 609 | || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_FLASH)) \ |
d7e8ce10 KP |
610 | || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_NAND)) \ |
611 | || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_ONENAND)) | |
0d498393 WD |
612 | U_BOOT_CMD( |
613 | saveenv, 1, 0, do_saveenv, | |
8bde7f77 WD |
614 | "saveenv - save environment variables to persistent storage\n", |
615 | NULL | |
616 | ); | |
617 | ||
90253178 | 618 | #endif |
8bde7f77 | 619 | |
c76fe474 | 620 | #if defined(CONFIG_CMD_ASKENV) |
8bde7f77 | 621 | |
0d498393 WD |
622 | U_BOOT_CMD( |
623 | askenv, CFG_MAXARGS, 1, do_askenv, | |
8bde7f77 WD |
624 | "askenv - get environment variables from stdin\n", |
625 | "name [message] [size]\n" | |
626 | " - get environment variable 'name' from stdin (max 'size' chars)\n" | |
627 | "askenv name\n" | |
628 | " - get environment variable 'name' from stdin\n" | |
629 | "askenv name size\n" | |
630 | " - get environment variable 'name' from stdin (max 'size' chars)\n" | |
631 | "askenv name [message] size\n" | |
632 | " - display 'message' string and get environment variable 'name'" | |
633 | "from stdin (max 'size' chars)\n" | |
634 | ); | |
90253178 | 635 | #endif |
8bde7f77 | 636 | |
c76fe474 | 637 | #if defined(CONFIG_CMD_RUN) |
8bde7f77 | 638 | int do_run (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); |
0d498393 WD |
639 | U_BOOT_CMD( |
640 | run, CFG_MAXARGS, 1, do_run, | |
8bde7f77 WD |
641 | "run - run commands in an environment variable\n", |
642 | "var [...]\n" | |
643 | " - run the commands in the environment variable(s) 'var'\n" | |
644 | ); | |
90253178 | 645 | #endif |