Specifications
To modify the U-Boot environment you have to use the setenv command. When called with exactly one
argument, it will delete any variable of that name from U-Boot's environment, if such a variable exists. Any
storage occupied for such a variable will be automatically reclaimed:
=> setenv foo This is an example value.
=> printenv foo
foo=This is an example value.
=> setenv foo
=> printenv foo
## Error: "foo" not defined
=>
When called with more arguments, the first one will again be the name of the variable, and all following
arguments will (concatenated by single space characters) form the value that gets stored for this variable. New
variables will be automatically created, existing ones overwritten.
=> printenv bar
## Error: "bar" not defined
=> setenv bar This is a new example.
=> printenv bar
bar=This is a new example.
=>
Remember standard shell quoting rules when the value of a variable shall contain characters that have a
special meaning to the command line parser (like the $ character that is used for variable substitution or the
semicolon which separates commands). Use the backslash (\) character to escape such special characters, or
enclose the whole phrase in apstrophes ('). Use "${name}" for variable expansion (see 14.2.17. How the
Command Line Parsing Works for details).
=> setenv cons_opts 'console=tty0 console=ttyS0,${baudrate}'
=> printenv cons_opts
cons_opts=console=tty0 console=ttyS0,${baudrate}
=>
There is no restriction on the characters that can be used in a variable name except the restrictions imposed
by the command line parser (like using backslash for quoting, space and tab characters to separate arguments,
or semicolon and newline to separate commands). Even strange input like "=-/|()+=" is a perfectly legal
variable name in U-Boot.
A common mistake is to write
setenv name=value
instead of
setenv name value
There will be no error message, which lets you believe everything went OK, but it didn't: instead of setting the
variable name to the value value you tried to delete a variable with the name name=value - this is probably
not what you intended! Always remember that name and value have to be separated by space and/or tab
characters!
5.9.6.4. run - run commands in an environment variable
=> help run
run - run commands in an environment variable
Usage:
5.9.6.3. setenv - set environment variables 65