1 .. SPDX-License-Identifier: GPL-2.0+
6 U-Boot supports user configuration using Environment Variables which
7 can be made persistent by saving to Flash memory.
9 Environment Variables are set using "setenv", printed using
10 "printenv", and saved to Flash using "saveenv". Using "setenv"
11 without a value can be used to delete a variable from the
12 environment. As long as you don't save the environment you are
13 working with an in-memory copy. In case the Flash area containing the
14 environment is erased by accident, a default environment is provided.
16 Some configuration options can be set using Environment Variables.
18 Text-based Environment
19 ----------------------
21 The default environment for a board is created using a `.env` environment file
22 using a simple text format. The base filename for this is defined by
23 `CONFIG_ENV_SOURCE_FILE`, or `CONFIG_SYS_BOARD` if that is empty.
25 The file must be in the board directory and have a .env extension, so
26 assuming that there is a board vendor, the resulting filename is therefore::
28 board/<vendor>/<board>/<CONFIG_ENV_SOURCE_FILE>.env
32 board/<vendor>/<board>/<CONFIG_SYS_BOARD>.env
34 This is a plain text file where you can type your environment variables in
35 the form `var=value`. Blank lines and multi-line variables are supported.
36 The conversion script looks for a line that starts in column 1 with a string
37 and has an equals sign immediately afterwards. Spaces before the = are not
38 permitted. It is a good idea to indent your scripts so that only the 'var='
39 appears at the start of a line.
41 To add additional text to a variable you can use `var+=value`. This text is
42 merged into the variable during the make process and made available as a
43 single value to U-Boot. Variables can contain `+` characters but in the unlikely
44 event that you want to have a variable name ending in plus, put a backslash
45 before the `+` so that the script knows you are not adding to an existing
46 variable but assigning to a new one::
50 This file can include C-style comments. Blank lines and multi-line
51 variables are supported, and you can use normal C preprocessor directives
52 and CONFIG defines from your board config also.
54 For example, for snapper9260 you would create a text file called
55 `board/bluewater/snapper9260.env` containing the environment text.
64 /* U-Boot script for booting */
66 if [ -z ${tftpserverip} ]; then
67 echo "Use 'setenv tftpserverip a.b.c.d' to set IP address."
70 usb start; setenv autoload n; bootp;
71 tftpboot ${tftpserverip}:
74 /* Print a message when boot fails */
75 echo CONFIG_SYS_BOARD boot failed - please check your image
76 echo Load address is CONFIG_SYS_LOAD_ADDR
78 If CONFIG_ENV_SOURCE_FILE is empty and the default filename is not present, then
79 the old-style C environment is used instead. See below.
81 Old-style C environment
82 -----------------------
84 Traditionally, the default environment is created in `include/env_default.h`,
85 and can be augmented by various `CONFIG` defines. See that file for details. In
86 particular you can define `CONFIG_EXTRA_ENV_SETTINGS` in your board file
87 to add environment variables.
89 Board maintainers are encouraged to migrate to the text-based environment as it
90 is easier to maintain. The distro-board script still requires the old-style
91 environment but work is underway to address this.
94 List of environment variables
95 -----------------------------
97 This is most-likely not complete:
106 see CONFIG_BOOTCOMMAND
109 Boot arguments when booting an RTOS image
112 Name of the image to load with TFTP
115 Memory range available for image processing in the bootm
116 command can be restricted. This variable is given as
117 a hexadecimal number and defines lowest address allowed
118 for use by the bootm command. See also "bootm_size"
119 environment variable. Address defined by "bootm_low" is
120 also the base of the initial memory mapping for the Linux
121 kernel -- see the description of CONFIG_SYS_BOOTMAPSZ and
125 Size of the initial memory mapping for the Linux kernel.
126 This variable is given as a hexadecimal number and it
127 defines the size of the memory region starting at base
128 address bootm_low that is accessible by the Linux kernel
129 during early boot. If unset, CONFIG_SYS_BOOTMAPSZ is used
130 as the default value if it is defined, and bootm_size is
134 Memory range available for image processing in the bootm
135 command can be restricted. This variable is given as
136 a hexadecimal number and defines the size of the region
137 allowed for use by the bootm command. See also "bootm_low"
138 environment variable.
140 bootstopkeysha256, bootdelaykey, bootstopkey
144 Location of the software update file on a TFTP server, used
145 by the automatic software update feature. Please refer to
146 documentation in doc/README.update for more details.
149 if set to "no" (any string beginning with 'n'),
150 "bootp" will just load perform a lookup of the
151 configuration from the BOOTP server, but not try to
152 load any image using TFTP
155 if set to "yes", an image loaded using the "bootp",
156 "rarpboot", "tftpboot" or "diskboot" commands will
157 be automatically started (by internally calling
160 If set to "no", a standalone image passed to the
161 "bootm" command will be copied to the load address
162 (and eventually uncompressed), but NOT be started.
163 This can be used to load and uncompress arbitrary
167 if set this restricts the maximum address that the
168 flattened device tree will be copied into upon boot.
169 For example, if you have a system with 1 GB memory
170 at physical address 0x10000000, while Linux kernel
171 only recognizes the first 704 MB as low memory, you
172 may need to set fdt_high as 0x3C000000 to have the
173 device tree blob be copied to the maximum address
174 of the 704 MB low memory, so that Linux kernel can
175 access it during the boot procedure.
177 If this is set to the special value 0xFFFFFFFF then
178 the fdt will not be copied at all on boot. For this
179 to work it must reside in writable memory, have
180 sufficient padding on the end of it for u-boot to
181 add the information it needs into it, and the memory
182 must be accessible by the kernel.
185 if set this is the address of the control flattened
186 device tree used by U-Boot when CONFIG_OF_CONTROL is
190 restrict positioning of initrd images:
191 If this variable is not set, initrd images will be
192 copied to the highest possible address in RAM; this
193 is usually what you want since it allows for
194 maximum initrd size. If for some reason you want to
195 make sure that the initrd image is loaded below the
196 CONFIG_SYS_BOOTMAPSZ limit, you can set this environment
197 variable to a value of "no" or "off" or "0".
198 Alternatively, you can set it to a maximum upper
199 address to use (U-Boot will still check that it
200 does not overwrite the U-Boot stack and data).
202 For instance, when you have a system with 16 MB
203 RAM, and want to reserve 4 MB from use by Linux,
204 you can do this by adding "mem=12M" to the value of
205 the "bootargs" variable. However, now you must make
206 sure that the initrd image is placed in the first
207 12 MB as well - this can be done with::
209 setenv initrd_high 00c00000
211 If you set initrd_high to 0xFFFFFFFF, this is an
212 indication to U-Boot that all addresses are legal
213 for the Linux kernel, including addresses in flash
214 memory. In this case U-Boot will NOT COPY the
215 ramdisk at all. This may be useful to reduce the
216 boot time on your system, but requires that this
217 feature is supported by your Linux kernel.
220 IP address; needed for tftpboot command
223 Default load address for commands like "bootp",
224 "rarpboot", "tftpboot", "loadb" or "diskboot"
227 see CONFIG_LOADS_ECHO
230 TFTP server IP address; needed for tftpboot command
233 see CONFIG_BOOT_RETRY_TIME
236 see CONFIG_AUTOBOOT_DELAY_STR
239 see CONFIG_AUTOBOOT_STOP_STR
242 controls which interface is used first.
245 controls which interface is currently active.
246 For example you can do the following::
249 => ping 192.168.0.1 # traffic sent on FEC
251 => ping 10.0.0.1 # traffic sent on SCC
254 When set to "no" U-Boot does not go through all
255 available network interfaces.
256 It just stays at the currently selected interface.
259 When set to "no" each network operation will
260 either succeed or fail without retrying.
261 When set to "once" the network operation will
262 fail when all the available network interfaces
263 are tried once without success.
264 Useful on scripts which control the retry operation
268 set load address for the NPE microcode
271 If set then Linux will be told to boot silently, by
272 changing the console to be empty. If "yes" it will be
273 made silent. If "no" it will not be made silent. If
274 unset, then it will be made silent if the U-Boot console
278 If this is set, the value is used for TFTP's
282 If this is set, the value is used for TFTP's UDP
283 destination port instead of the Well Know Port 69.
286 Block size to use for TFTP transfers; if not set,
287 we use the TFTP server's default block size
290 Retransmission timeout for TFTP packets (in milli-
291 seconds, minimum value is 1000 = 1 second). Defines
292 when a packet is considered to be lost so it has to
293 be retransmitted. The default is 5000 = 5 seconds.
294 Lowering this value may make downloads succeed
295 faster in networks with high packet loss rates or
296 with unreliable TFTP servers.
299 maximum count of TFTP timeouts (no
300 unit, minimum value = 0). Defines how many timeouts
301 can happen during a single file transfer before that
302 transfer is aborted. The default is 10, and 0 means
303 'no timeouts allowed'. Increasing this value may help
304 downloads succeed with high packet loss rates, or with
305 unreliable TFTP servers or client hardware.
308 if this is set, the value is used for TFTP's
309 window size as described by RFC 7440.
310 This means the count of blocks we can receive before
311 sending ack to server.
314 When set to a value < 4095 the traffic over
315 Ethernet is encapsulated/received over 802.1q
319 Period during which BOOTP/DHCP sends retries.
320 Unsigned value, in milliseconds. If not set, the period will
321 be either the default (28000), or a value based on
322 CONFIG_NET_RETRY_COUNT, if defined. This value has
323 precedence over the valu based on CONFIG_NET_RETRY_COUNT.
326 Number of matches found by the last 'ms' command, in hex
329 Address of the last match found by the 'ms' command, in hex,
333 Index position of the last match found by the 'ms' command,
334 in units of the size (.b, .w, .l) of the search
337 (x86 only) Base address of the bzImage 'setup' block
340 (x86 only) Address of the loaded bzImage, typically
341 BZIMAGE_LOAD_ADDR which is 0x100000
347 The following image location variables contain the location of images
348 used in booting. The "Image" column gives the role of the image and is
349 not an environment variable name. The other columns are environment
350 variable names. "File Name" gives the name of the file on a TFTP
351 server, "RAM Address" gives the location in RAM the image will be
352 loaded to, and "Flash Location" gives the image's address in NOR
353 flash or offset in NAND flash.
355 *Note* - these variables don't have to be defined for all boards, some
356 boards currently use other variables for these purposes, and some
357 boards use these variables for other purposes.
359 ================= ============== ================ ==============
360 Image File Name RAM Address Flash Location
361 ================= ============== ================ ==============
362 u-boot u-boot u-boot_addr_r u-boot_addr
363 Linux kernel bootfile kernel_addr_r kernel_addr
364 device tree blob fdtfile fdt_addr_r fdt_addr
365 ramdisk ramdiskfile ramdisk_addr_r ramdisk_addr
366 ================= ============== ================ ==============
369 Automatically updated variables
370 -------------------------------
372 The following environment variables may be used and automatically
373 updated by the network boot commands ("bootp" and "rarpboot"),
374 depending the information provided by your boot server:
376 ========= ===================================================
378 ========= ===================================================
380 dnsip IP address of your Domain Name Server
381 dnsip2 IP address of your secondary Domain Name Server
382 gatewayip IP address of the Gateway (Router) to use
383 hostname Target hostname
386 rootpath Pathname of the root filesystem on the NFS server
388 ========= ===================================================
391 Special environment variables
392 -----------------------------
394 There are two special Environment Variables:
397 contains hardware identification information such as type string and/or
402 These variables can be set only once (usually during manufacturing of
403 the board). U-Boot refuses to delete or overwrite these variables
404 once they have been set once.
409 Contains the U-Boot version string as printed
410 with the "version" command. This variable is
411 readonly (see CONFIG_VERSION_VARIABLE).
413 Please note that changes to some configuration parameters may take
414 only effect after the next boot (yes, that's just like Windoze :-).
417 Callback functions for environment variables
418 --------------------------------------------
420 For some environment variables, the behavior of u-boot needs to change
421 when their values are changed. This functionality allows functions to
422 be associated with arbitrary variables. On creation, overwrite, or
423 deletion, the callback will provide the opportunity for some side
424 effect to happen or for the change to be rejected.
426 The callbacks are named and associated with a function using the
427 U_BOOT_ENV_CALLBACK macro in your board or driver code.
429 These callbacks are associated with variables in one of two ways. The
430 static list can be added to by defining CONFIG_ENV_CALLBACK_LIST_STATIC
431 in the board configuration to a string that defines a list of
432 associations. The list must be in the following format::
434 entry = variable_name[:callback_name]
437 If the callback name is not specified, then the callback is deleted.
438 Spaces are also allowed anywhere in the list.
440 Callbacks can also be associated by defining the ".callbacks" variable
441 with the same list format above. Any association in ".callbacks" will
442 override any association in the static list. You can define
443 CONFIG_ENV_CALLBACK_LIST_DEFAULT to a list (string) to define the
444 ".callbacks" environment variable in the default or embedded environment.
446 If CONFIG_REGEX is defined, the variable_name above is evaluated as a
447 regular expression. This allows multiple variables to be connected to
448 the same callback without explicitly listing them all out.
450 The signature of the callback functions is::
452 int callback(const char *name, const char *value, enum env_op op, int flags)
454 * name - changed environment variable
455 * value - new value of the environment variable
456 * op - operation (create, overwrite, or delete)
457 * flags - attributes of the environment variable change, see flags H_* in
460 The return value is 0 if the variable change is accepted and 1 otherwise.