]>
Commit | Line | Data |
---|---|---|
a68d3ed0 WD |
1 | /* |
2 | * (C) Copyright 2000-2002 | |
3 | * Wolfgang Denk, DENX Software Engineering, [email protected]. | |
4 | * | |
5 | * (C) Copyright 2001 Sysgo Real-Time Solutions, GmbH <www.elinos.com> | |
6 | * Andreas Heppel <[email protected]> | |
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) && \ |
5779d8d9 WD |
60 | !defined(CFG_ENV_IS_NOWHERE) |
61 | # error Define one of CFG_ENV_IS_IN_{NVRAM|EEPROM|FLASH|DATAFLASH|NOWHERE} | |
a68d3ed0 WD |
62 | #endif |
63 | ||
64 | #define XMK_STR(x) #x | |
65 | #define MK_STR(x) XMK_STR(x) | |
66 | ||
67 | /************************************************************************ | |
68 | ************************************************************************/ | |
69 | ||
70 | /* Function that returns a character from the environment */ | |
71 | extern uchar (*env_get_char)(int); | |
72 | ||
73 | /* Function that returns a pointer to a value from the environment */ | |
74 | /* (Only memory version supported / needed). */ | |
75 | extern uchar *env_get_addr(int); | |
76 | ||
77 | /* Function that updates CRC of the enironment */ | |
78 | extern void env_crc_update (void); | |
79 | ||
80 | /************************************************************************ | |
81 | ************************************************************************/ | |
82 | ||
83 | static int envmatch (uchar *, int); | |
84 | ||
85 | /* | |
86 | * Table with supported baudrates (defined in config_xyz.h) | |
87 | */ | |
88 | static const unsigned long baudrate_table[] = CFG_BAUDRATE_TABLE; | |
89 | #define N_BAUDRATES (sizeof(baudrate_table) / sizeof(baudrate_table[0])) | |
90 | ||
91 | ||
92 | /************************************************************************ | |
93 | * Command interface: print one or all environment variables | |
94 | */ | |
95 | ||
96 | int do_printenv (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) | |
97 | { | |
98 | int i, j, k, nxt; | |
99 | int rcode = 0; | |
100 | ||
101 | if (argc == 1) { /* Print all env variables */ | |
102 | for (i=0; env_get_char(i) != '\0'; i=nxt+1) { | |
103 | for (nxt=i; env_get_char(nxt) != '\0'; ++nxt) | |
104 | ; | |
105 | for (k=i; k<nxt; ++k) | |
106 | putc(env_get_char(k)); | |
107 | putc ('\n'); | |
108 | ||
109 | if (ctrlc()) { | |
110 | puts ("\n ** Abort\n"); | |
111 | return 1; | |
112 | } | |
113 | } | |
114 | ||
115 | printf("\nEnvironment size: %d/%d bytes\n", i, ENV_SIZE); | |
116 | ||
117 | return 0; | |
118 | } | |
119 | ||
120 | for (i=1; i<argc; ++i) { /* print single env variables */ | |
121 | char *name = argv[i]; | |
122 | ||
123 | k = -1; | |
124 | ||
125 | for (j=0; env_get_char(j) != '\0'; j=nxt+1) { | |
126 | ||
127 | for (nxt=j; env_get_char(nxt) != '\0'; ++nxt) | |
128 | ; | |
77ddac94 | 129 | k = envmatch((uchar *)name, j); |
a68d3ed0 WD |
130 | if (k < 0) { |
131 | continue; | |
132 | } | |
133 | puts (name); | |
134 | putc ('='); | |
135 | while (k < nxt) | |
136 | putc(env_get_char(k++)); | |
137 | putc ('\n'); | |
138 | break; | |
139 | } | |
140 | if (k < 0) { | |
141 | printf ("## Error: \"%s\" not defined\n", name); | |
142 | rcode ++; | |
143 | } | |
144 | } | |
145 | return rcode; | |
146 | } | |
147 | ||
148 | /************************************************************************ | |
149 | * Set a new environment variable, | |
150 | * or replace or delete an existing one. | |
151 | * | |
152 | * This function will ONLY work with a in-RAM copy of the environment | |
153 | */ | |
154 | ||
155 | int _do_setenv (int flag, int argc, char *argv[]) | |
156 | { | |
a68d3ed0 WD |
157 | int i, len, oldval; |
158 | int console = -1; | |
159 | uchar *env, *nxt = NULL; | |
77ddac94 | 160 | char *name; |
a68d3ed0 WD |
161 | bd_t *bd = gd->bd; |
162 | ||
163 | uchar *env_data = env_get_addr(0); | |
164 | ||
165 | if (!env_data) /* need copy in RAM */ | |
166 | return 1; | |
167 | ||
168 | name = argv[1]; | |
169 | ||
471a7be7 WD |
170 | if (strchr(name, '=')) { |
171 | printf ("## Error: illegal character '=' in variable name \"%s\"\n", name); | |
172 | return 1; | |
173 | } | |
174 | ||
a68d3ed0 WD |
175 | /* |
176 | * search if variable with this name already exists | |
177 | */ | |
178 | oldval = -1; | |
179 | for (env=env_data; *env; env=nxt+1) { | |
180 | for (nxt=env; *nxt; ++nxt) | |
181 | ; | |
77ddac94 | 182 | if ((oldval = envmatch((uchar *)name, env-env_data)) >= 0) |
a68d3ed0 WD |
183 | break; |
184 | } | |
185 | ||
186 | /* | |
187 | * Delete any existing definition | |
188 | */ | |
189 | if (oldval >= 0) { | |
190 | #ifndef CONFIG_ENV_OVERWRITE | |
191 | ||
192 | /* | |
0587597c SR |
193 | * Ethernet Address and serial# can be set only once, |
194 | * ver is readonly. | |
a68d3ed0 | 195 | */ |
c74b2108 SK |
196 | #ifdef CONFIG_HAS_UID |
197 | /* Allow serial# forced overwrite with 0xdeaf4add flag */ | |
198 | if ( ((strcmp (name, "serial#") == 0) && (flag != 0xdeaf4add)) || | |
199 | #else | |
a68d3ed0 | 200 | if ( (strcmp (name, "serial#") == 0) || |
c74b2108 | 201 | #endif |
a68d3ed0 WD |
202 | ((strcmp (name, "ethaddr") == 0) |
203 | #if defined(CONFIG_OVERWRITE_ETHADDR_ONCE) && defined(CONFIG_ETHADDR) | |
77ddac94 | 204 | && (strcmp ((char *)env_get_addr(oldval),MK_STR(CONFIG_ETHADDR)) != 0) |
a68d3ed0 WD |
205 | #endif /* CONFIG_OVERWRITE_ETHADDR_ONCE && CONFIG_ETHADDR */ |
206 | ) ) { | |
207 | printf ("Can't overwrite \"%s\"\n", name); | |
208 | return 1; | |
209 | } | |
210 | #endif | |
211 | ||
212 | /* Check for console redirection */ | |
213 | if (strcmp(name,"stdin") == 0) { | |
214 | console = stdin; | |
215 | } else if (strcmp(name,"stdout") == 0) { | |
216 | console = stdout; | |
217 | } else if (strcmp(name,"stderr") == 0) { | |
218 | console = stderr; | |
219 | } | |
220 | ||
221 | if (console != -1) { | |
222 | if (argc < 3) { /* Cannot delete it! */ | |
223 | printf("Can't delete \"%s\"\n", name); | |
224 | return 1; | |
225 | } | |
226 | ||
227 | /* Try assigning specified device */ | |
228 | if (console_assign (console, argv[2]) < 0) | |
229 | return 1; | |
281e00a3 WD |
230 | |
231 | #ifdef CONFIG_SERIAL_MULTI | |
232 | if (serial_assign (argv[2]) < 0) | |
233 | return 1; | |
234 | #endif | |
a68d3ed0 WD |
235 | } |
236 | ||
237 | /* | |
238 | * Switch to new baudrate if new baudrate is supported | |
239 | */ | |
240 | if (strcmp(argv[1],"baudrate") == 0) { | |
241 | int baudrate = simple_strtoul(argv[2], NULL, 10); | |
242 | int i; | |
243 | for (i=0; i<N_BAUDRATES; ++i) { | |
244 | if (baudrate == baudrate_table[i]) | |
245 | break; | |
246 | } | |
247 | if (i == N_BAUDRATES) { | |
248 | printf ("## Baudrate %d bps not supported\n", | |
249 | baudrate); | |
250 | return 1; | |
251 | } | |
252 | printf ("## Switch baudrate to %d bps and press ENTER ...\n", | |
253 | baudrate); | |
254 | udelay(50000); | |
255 | gd->baudrate = baudrate; | |
c84bad0e | 256 | #if defined(CONFIG_PPC) || defined(CONFIG_MCF52x2) |
d0fb80c3 WD |
257 | gd->bd->bi_baudrate = baudrate; |
258 | #endif | |
259 | ||
a68d3ed0 WD |
260 | serial_setbrg (); |
261 | udelay(50000); | |
262 | for (;;) { | |
263 | if (getc() == '\r') | |
264 | break; | |
265 | } | |
266 | } | |
267 | ||
268 | if (*++nxt == '\0') { | |
269 | if (env > env_data) { | |
270 | env--; | |
271 | } else { | |
272 | *env = '\0'; | |
273 | } | |
274 | } else { | |
275 | for (;;) { | |
276 | *env = *nxt++; | |
277 | if ((*env == '\0') && (*nxt == '\0')) | |
278 | break; | |
279 | ++env; | |
280 | } | |
281 | } | |
282 | *++env = '\0'; | |
283 | } | |
284 | ||
285 | #ifdef CONFIG_NET_MULTI | |
286 | if (strncmp(name, "eth", 3) == 0) { | |
287 | char *end; | |
288 | int num = simple_strtoul(name+3, &end, 10); | |
289 | ||
290 | if (strcmp(end, "addr") == 0) { | |
291 | eth_set_enetaddr(num, argv[2]); | |
292 | } | |
293 | } | |
294 | #endif | |
295 | ||
296 | ||
297 | /* Delete only ? */ | |
298 | if ((argc < 3) || argv[2] == NULL) { | |
299 | env_crc_update (); | |
300 | return 0; | |
301 | } | |
302 | ||
303 | /* | |
304 | * Append new definition at the end | |
305 | */ | |
306 | for (env=env_data; *env || *(env+1); ++env) | |
307 | ; | |
308 | if (env > env_data) | |
309 | ++env; | |
310 | /* | |
311 | * Overflow when: | |
312 | * "name" + "=" + "val" +"\0\0" > ENV_SIZE - (env-env_data) | |
313 | */ | |
314 | len = strlen(name) + 2; | |
315 | /* add '=' for first arg, ' ' for all others */ | |
316 | for (i=2; i<argc; ++i) { | |
317 | len += strlen(argv[i]) + 1; | |
318 | } | |
319 | if (len > (&env_data[ENV_SIZE]-env)) { | |
320 | printf ("## Error: environment overflow, \"%s\" deleted\n", name); | |
321 | return 1; | |
322 | } | |
323 | while ((*env = *name++) != '\0') | |
324 | env++; | |
325 | for (i=2; i<argc; ++i) { | |
326 | char *val = argv[i]; | |
327 | ||
328 | *env = (i==2) ? '=' : ' '; | |
329 | while ((*++env = *val++) != '\0') | |
330 | ; | |
331 | } | |
332 | ||
333 | /* end is marked with double '\0' */ | |
334 | *++env = '\0'; | |
335 | ||
336 | /* Update CRC */ | |
337 | env_crc_update (); | |
338 | ||
339 | /* | |
340 | * Some variables should be updated when the corresponding | |
341 | * entry in the enviornment is changed | |
342 | */ | |
343 | ||
344 | if (strcmp(argv[1],"ethaddr") == 0) { | |
345 | char *s = argv[2]; /* always use only one arg */ | |
346 | char *e; | |
347 | for (i=0; i<6; ++i) { | |
348 | bd->bi_enetaddr[i] = s ? simple_strtoul(s, &e, 16) : 0; | |
349 | if (s) s = (*e) ? e+1 : e; | |
350 | } | |
351 | #ifdef CONFIG_NET_MULTI | |
352 | eth_set_enetaddr(0, argv[2]); | |
353 | #endif | |
354 | return 0; | |
355 | } | |
356 | ||
357 | if (strcmp(argv[1],"ipaddr") == 0) { | |
358 | char *s = argv[2]; /* always use only one arg */ | |
359 | char *e; | |
360 | unsigned long addr; | |
361 | bd->bi_ip_addr = 0; | |
362 | for (addr=0, i=0; i<4; ++i) { | |
363 | ulong val = s ? simple_strtoul(s, &e, 10) : 0; | |
364 | addr <<= 8; | |
365 | addr |= (val & 0xFF); | |
366 | if (s) s = (*e) ? e+1 : e; | |
367 | } | |
368 | bd->bi_ip_addr = htonl(addr); | |
369 | return 0; | |
370 | } | |
371 | if (strcmp(argv[1],"loadaddr") == 0) { | |
372 | load_addr = simple_strtoul(argv[2], NULL, 16); | |
373 | return 0; | |
374 | } | |
c76fe474 | 375 | #if defined(CONFIG_CMD_NET) |
a68d3ed0 WD |
376 | if (strcmp(argv[1],"bootfile") == 0) { |
377 | copy_filename (BootFile, argv[2], sizeof(BootFile)); | |
378 | return 0; | |
379 | } | |
90253178 | 380 | #endif |
c7de829c | 381 | |
0587597c | 382 | #ifdef CONFIG_AMIGAONEG3SE |
c7de829c WD |
383 | if (strcmp(argv[1], "vga_fg_color") == 0 || |
384 | strcmp(argv[1], "vga_bg_color") == 0 ) { | |
385 | extern void video_set_color(unsigned char attr); | |
386 | extern unsigned char video_get_attr(void); | |
387 | ||
388 | video_set_color(video_get_attr()); | |
389 | return 0; | |
390 | } | |
391 | #endif /* CONFIG_AMIGAONEG3SE */ | |
392 | ||
a68d3ed0 WD |
393 | return 0; |
394 | } | |
395 | ||
396 | void setenv (char *varname, char *varvalue) | |
397 | { | |
398 | char *argv[4] = { "setenv", varname, varvalue, NULL }; | |
9ffd451a JM |
399 | if (varvalue == NULL) |
400 | _do_setenv (0, 2, argv); | |
401 | else | |
402 | _do_setenv (0, 3, argv); | |
a68d3ed0 WD |
403 | } |
404 | ||
c74b2108 SK |
405 | #ifdef CONFIG_HAS_UID |
406 | void forceenv (char *varname, char *varvalue) | |
407 | { | |
408 | char *argv[4] = { "forceenv", varname, varvalue, NULL }; | |
409 | _do_setenv (0xdeaf4add, 3, argv); | |
410 | } | |
411 | #endif | |
412 | ||
413 | int do_setenv (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) | |
a68d3ed0 WD |
414 | { |
415 | if (argc < 2) { | |
416 | printf ("Usage:\n%s\n", cmdtp->usage); | |
417 | return 1; | |
418 | } | |
419 | ||
420 | return _do_setenv (flag, argc, argv); | |
421 | } | |
422 | ||
423 | /************************************************************************ | |
424 | * Prompt for environment variable | |
425 | */ | |
426 | ||
c76fe474 | 427 | #if defined(CONFIG_CMD_ASKENV) |
a68d3ed0 WD |
428 | int do_askenv ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
429 | { | |
430 | extern char console_buffer[CFG_CBSIZE]; | |
431 | char message[CFG_CBSIZE]; | |
432 | int size = CFG_CBSIZE - 1; | |
433 | int len; | |
434 | char *local_args[4]; | |
435 | ||
436 | local_args[0] = argv[0]; | |
437 | local_args[1] = argv[1]; | |
438 | local_args[2] = NULL; | |
439 | local_args[3] = NULL; | |
440 | ||
441 | if (argc < 2) { | |
442 | printf ("Usage:\n%s\n", cmdtp->usage); | |
443 | return 1; | |
444 | } | |
445 | /* Check the syntax */ | |
446 | switch (argc) { | |
447 | case 1: | |
448 | printf ("Usage:\n%s\n", cmdtp->usage); | |
449 | return 1; | |
450 | ||
451 | case 2: /* askenv envname */ | |
452 | sprintf (message, "Please enter '%s':", argv[1]); | |
453 | break; | |
454 | ||
455 | case 3: /* askenv envname size */ | |
456 | sprintf (message, "Please enter '%s':", argv[1]); | |
457 | size = simple_strtoul (argv[2], NULL, 10); | |
458 | break; | |
459 | ||
460 | default: /* askenv envname message1 ... messagen size */ | |
461 | { | |
462 | int i; | |
463 | int pos = 0; | |
464 | ||
465 | for (i = 2; i < argc - 1; i++) { | |
466 | if (pos) { | |
467 | message[pos++] = ' '; | |
468 | } | |
469 | strcpy (message+pos, argv[i]); | |
470 | pos += strlen(argv[i]); | |
471 | } | |
472 | message[pos] = '\0'; | |
473 | size = simple_strtoul (argv[argc - 1], NULL, 10); | |
474 | } | |
475 | break; | |
476 | } | |
477 | ||
478 | if (size >= CFG_CBSIZE) | |
479 | size = CFG_CBSIZE - 1; | |
480 | ||
481 | if (size <= 0) | |
482 | return 1; | |
483 | ||
484 | /* prompt for input */ | |
485 | len = readline (message); | |
486 | ||
487 | if (size < len) | |
488 | console_buffer[size] = '\0'; | |
489 | ||
490 | len = 2; | |
491 | if (console_buffer[0] != '\0') { | |
492 | local_args[2] = console_buffer; | |
493 | len = 3; | |
494 | } | |
495 | ||
496 | /* Continue calling setenv code */ | |
497 | return _do_setenv (flag, len, local_args); | |
498 | } | |
90253178 | 499 | #endif |
a68d3ed0 WD |
500 | |
501 | /************************************************************************ | |
502 | * Look up variable from environment, | |
503 | * return address of storage for that variable, | |
504 | * or NULL if not found | |
505 | */ | |
506 | ||
77ddac94 | 507 | char *getenv (char *name) |
a68d3ed0 WD |
508 | { |
509 | int i, nxt; | |
510 | ||
2a3cb020 WD |
511 | WATCHDOG_RESET(); |
512 | ||
a68d3ed0 WD |
513 | for (i=0; env_get_char(i) != '\0'; i=nxt+1) { |
514 | int val; | |
515 | ||
516 | for (nxt=i; env_get_char(nxt) != '\0'; ++nxt) { | |
517 | if (nxt >= CFG_ENV_SIZE) { | |
518 | return (NULL); | |
519 | } | |
520 | } | |
77ddac94 | 521 | if ((val=envmatch((uchar *)name, i)) < 0) |
a68d3ed0 | 522 | continue; |
77ddac94 | 523 | return ((char *)env_get_addr(val)); |
a68d3ed0 WD |
524 | } |
525 | ||
526 | return (NULL); | |
527 | } | |
528 | ||
77ddac94 | 529 | int getenv_r (char *name, char *buf, unsigned len) |
a68d3ed0 WD |
530 | { |
531 | int i, nxt; | |
532 | ||
533 | for (i=0; env_get_char(i) != '\0'; i=nxt+1) { | |
534 | int val, n; | |
535 | ||
536 | for (nxt=i; env_get_char(nxt) != '\0'; ++nxt) { | |
537 | if (nxt >= CFG_ENV_SIZE) { | |
538 | return (-1); | |
539 | } | |
540 | } | |
77ddac94 | 541 | if ((val=envmatch((uchar *)name, i)) < 0) |
a68d3ed0 WD |
542 | continue; |
543 | /* found; copy out */ | |
544 | n = 0; | |
545 | while ((len > n++) && (*buf++ = env_get_char(val++)) != '\0') | |
546 | ; | |
547 | if (len == n) | |
548 | *buf = '\0'; | |
549 | return (n); | |
550 | } | |
551 | return (-1); | |
552 | } | |
553 | ||
3865b1fb | 554 | #if defined(CFG_ENV_IS_IN_NVRAM) || defined(CFG_ENV_IS_IN_EEPROM) \ |
65c450b4 JL |
555 | || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_FLASH)) \ |
556 | || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_NAND)) | |
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 | ||
577 | static int | |
578 | envmatch (uchar *s1, int i2) | |
579 | { | |
580 | ||
581 | while (*s1 == env_get_char(i2++)) | |
582 | if (*s1++ == '=') | |
583 | return(i2); | |
584 | if (*s1 == '\0' && env_get_char(i2-1) == '=') | |
585 | return(i2); | |
586 | return(-1); | |
587 | } | |
8bde7f77 WD |
588 | |
589 | ||
590 | /**************************************************/ | |
591 | ||
0d498393 WD |
592 | U_BOOT_CMD( |
593 | printenv, CFG_MAXARGS, 1, do_printenv, | |
8bde7f77 WD |
594 | "printenv- print environment variables\n", |
595 | "\n - print values of all environment variables\n" | |
596 | "printenv name ...\n" | |
597 | " - print value of environment variable 'name'\n" | |
598 | ); | |
599 | ||
0d498393 WD |
600 | U_BOOT_CMD( |
601 | setenv, CFG_MAXARGS, 0, do_setenv, | |
8bde7f77 WD |
602 | "setenv - set environment variables\n", |
603 | "name value ...\n" | |
604 | " - set environment variable 'name' to 'value ...'\n" | |
605 | "setenv name\n" | |
606 | " - delete environment variable 'name'\n" | |
607 | ); | |
608 | ||
3865b1fb | 609 | #if defined(CFG_ENV_IS_IN_NVRAM) || defined(CFG_ENV_IS_IN_EEPROM) \ |
65c450b4 JL |
610 | || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_FLASH)) \ |
611 | || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_NAND)) | |
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 |