blob: d295cc898785961298c3bd2cac9f97a7d038450d [file] [log] [blame]
Simon Glassaef523a2021-10-21 21:08:45 -06001.. SPDX-License-Identifier: GPL-2.0+
2
3Environment Variables
4=====================
5
Simon Glass420febd2021-10-21 21:08:50 -06006U-Boot supports user configuration using environment variables which
Simon Glass341c7ea2021-10-21 21:08:49 -06007can be made persistent by saving to persistent storage, for example flash
8memory.
Simon Glassaef523a2021-10-21 21:08:45 -06009
Simon Glass420febd2021-10-21 21:08:50 -060010Environment variables are set using "env set" (alias "setenv"), printed using
Simon Glass341c7ea2021-10-21 21:08:49 -060011"env print" (alias "printenv"), and saved to persistent storage using
12"env save" (alias "saveenv"). Using "env set"
Simon Glassaef523a2021-10-21 21:08:45 -060013without a value can be used to delete a variable from the
Simon Glass341c7ea2021-10-21 21:08:49 -060014environment. As long as you don't save the environment, you are
Simon Glassaef523a2021-10-21 21:08:45 -060015working with an in-memory copy. In case the Flash area containing the
16environment is erased by accident, a default environment is provided.
17
Simon Glass341c7ea2021-10-21 21:08:49 -060018Some configuration is controlled by Environment Variables, so that setting the
19variable can adjust the behaviour of U-Boot (e.g. autoboot delay, autoloading
20from tftp).
Simon Glassaef523a2021-10-21 21:08:45 -060021
Simon Glass7327fe72021-10-21 21:08:46 -060022Text-based Environment
23----------------------
24
25The default environment for a board is created using a `.env` environment file
26using a simple text format. The base filename for this is defined by
27`CONFIG_ENV_SOURCE_FILE`, or `CONFIG_SYS_BOARD` if that is empty.
28
29The file must be in the board directory and have a .env extension, so
30assuming that there is a board vendor, the resulting filename is therefore::
31
32 board/<vendor>/<board>/<CONFIG_ENV_SOURCE_FILE>.env
33
34or::
35
36 board/<vendor>/<board>/<CONFIG_SYS_BOARD>.env
37
38This is a plain text file where you can type your environment variables in
39the form `var=value`. Blank lines and multi-line variables are supported.
40The conversion script looks for a line that starts in column 1 with a string
41and has an equals sign immediately afterwards. Spaces before the = are not
42permitted. It is a good idea to indent your scripts so that only the 'var='
43appears at the start of a line.
44
45To add additional text to a variable you can use `var+=value`. This text is
46merged into the variable during the make process and made available as a
47single value to U-Boot. Variables can contain `+` characters but in the unlikely
48event that you want to have a variable name ending in plus, put a backslash
49before the `+` so that the script knows you are not adding to an existing
50variable but assigning to a new one::
51
52 maximum\+=value
53
54This file can include C-style comments. Blank lines and multi-line
55variables are supported, and you can use normal C preprocessor directives
56and CONFIG defines from your board config also.
57
58For example, for snapper9260 you would create a text file called
59`board/bluewater/snapper9260.env` containing the environment text.
60
61Example::
62
63 stdout=serial
64 #ifdef CONFIG_LCD
65 stdout+=,lcd
66 #endif
67 bootcmd=
68 /* U-Boot script for booting */
69
70 if [ -z ${tftpserverip} ]; then
71 echo "Use 'setenv tftpserverip a.b.c.d' to set IP address."
72 fi
73
74 usb start; setenv autoload n; bootp;
75 tftpboot ${tftpserverip}:
76 bootm
77 failed=
78 /* Print a message when boot fails */
79 echo CONFIG_SYS_BOARD boot failed - please check your image
80 echo Load address is CONFIG_SYS_LOAD_ADDR
81
82If CONFIG_ENV_SOURCE_FILE is empty and the default filename is not present, then
83the old-style C environment is used instead. See below.
84
85Old-style C environment
86-----------------------
87
88Traditionally, the default environment is created in `include/env_default.h`,
89and can be augmented by various `CONFIG` defines. See that file for details. In
90particular you can define `CONFIG_EXTRA_ENV_SETTINGS` in your board file
91to add environment variables.
92
93Board maintainers are encouraged to migrate to the text-based environment as it
94is easier to maintain. The distro-board script still requires the old-style
95environment but work is underway to address this.
96
97
98List of environment variables
99-----------------------------
100
Simon Glass420febd2021-10-21 21:08:50 -0600101Some device configuration options can be set using environment variables. In
102many cases the value in the default environment comes from a CONFIG option - see
Simon Glass341c7ea2021-10-21 21:08:49 -0600103`include/env_default.h`) for this.
104
Simon Glass7327fe72021-10-21 21:08:46 -0600105This is most-likely not complete:
Simon Glassaef523a2021-10-21 21:08:45 -0600106
107baudrate
Simon Glass420febd2021-10-21 21:08:50 -0600108 Used to set the baudrate of the UART - it defaults to CONFIG_BAUDRATE (which
109 defaults to 115200).
Simon Glassaef523a2021-10-21 21:08:45 -0600110
111bootdelay
Simon Glass420febd2021-10-21 21:08:50 -0600112 Delay before automatically running bootcmd. During this time the user
113 can choose to enter the shell (or the boot menu if
114 CONFIG_AUTOBOOT_MENU_SHOW=y):
115
116 - 0 to autoboot with no delay, but you can stop it by key input.
117 - -1 to disable autoboot.
118 - -2 to autoboot with no delay and not check for abort
119
120 The default value is defined by CONFIG_BOOTDELAY.
121 The value of 'bootdelay' is overridden by the /config/bootdelay value in
122 the device-tree if CONFIG_OF_CONTROL=y.
123 Does it really make sense that the devicetree overrides the user setting?
Simon Glassaef523a2021-10-21 21:08:45 -0600124
125bootcmd
Simon Glass420febd2021-10-21 21:08:50 -0600126 The command that is run if the user does not enter the shell during the
127 boot delay.
Simon Glassaef523a2021-10-21 21:08:45 -0600128
129bootargs
Simon Glass420febd2021-10-21 21:08:50 -0600130 Command line arguments passed when booting an operating system or binary
131 image
Simon Glassaef523a2021-10-21 21:08:45 -0600132
133bootfile
134 Name of the image to load with TFTP
135
136bootm_low
137 Memory range available for image processing in the bootm
138 command can be restricted. This variable is given as
139 a hexadecimal number and defines lowest address allowed
140 for use by the bootm command. See also "bootm_size"
141 environment variable. Address defined by "bootm_low" is
142 also the base of the initial memory mapping for the Linux
143 kernel -- see the description of CONFIG_SYS_BOOTMAPSZ and
144 bootm_mapsize.
145
146bootm_mapsize
147 Size of the initial memory mapping for the Linux kernel.
148 This variable is given as a hexadecimal number and it
149 defines the size of the memory region starting at base
150 address bootm_low that is accessible by the Linux kernel
151 during early boot. If unset, CONFIG_SYS_BOOTMAPSZ is used
152 as the default value if it is defined, and bootm_size is
153 used otherwise.
154
155bootm_size
156 Memory range available for image processing in the bootm
157 command can be restricted. This variable is given as
158 a hexadecimal number and defines the size of the region
159 allowed for use by the bootm command. See also "bootm_low"
160 environment variable.
161
162bootstopkeysha256, bootdelaykey, bootstopkey
163 See README.autoboot
164
165updatefile
166 Location of the software update file on a TFTP server, used
167 by the automatic software update feature. Please refer to
168 documentation in doc/README.update for more details.
169
170autoload
171 if set to "no" (any string beginning with 'n'),
Simon Glass420febd2021-10-21 21:08:50 -0600172 "bootp" and "dhcp" will just load perform a lookup of the
Simon Glassaef523a2021-10-21 21:08:45 -0600173 configuration from the BOOTP server, but not try to
Simon Glass341c7ea2021-10-21 21:08:49 -0600174 load any image using TFTP or DHCP.
Simon Glassaef523a2021-10-21 21:08:45 -0600175
176autostart
Simon Glass420febd2021-10-21 21:08:50 -0600177 if set to "yes", an image loaded using the "bootp", "dhcp",
Simon Glassaef523a2021-10-21 21:08:45 -0600178 "rarpboot", "tftpboot" or "diskboot" commands will
179 be automatically started (by internally calling
180 "bootm")
181
Simon Glass46b530a2021-10-21 21:08:52 -0600182 If unset, or set to "1"/"yes"/"true" (case insensitive, just the first
183 character is enough), a standalone image
184 passed to the "bootm" command will be copied to the load address
Simon Glassaef523a2021-10-21 21:08:45 -0600185 (and eventually uncompressed), but NOT be started.
186 This can be used to load and uncompress arbitrary
187 data.
188
189fdt_high
190 if set this restricts the maximum address that the
191 flattened device tree will be copied into upon boot.
192 For example, if you have a system with 1 GB memory
193 at physical address 0x10000000, while Linux kernel
194 only recognizes the first 704 MB as low memory, you
195 may need to set fdt_high as 0x3C000000 to have the
196 device tree blob be copied to the maximum address
197 of the 704 MB low memory, so that Linux kernel can
198 access it during the boot procedure.
199
Simon Glass420febd2021-10-21 21:08:50 -0600200 If this is set to the special value 0xffffffff (32-bit machines) or
201 0xffffffffffffffff (64-bit machines) then
Simon Glassaef523a2021-10-21 21:08:45 -0600202 the fdt will not be copied at all on boot. For this
203 to work it must reside in writable memory, have
204 sufficient padding on the end of it for u-boot to
205 add the information it needs into it, and the memory
206 must be accessible by the kernel.
207
208fdtcontroladdr
209 if set this is the address of the control flattened
210 device tree used by U-Boot when CONFIG_OF_CONTROL is
211 defined.
212
213initrd_high
214 restrict positioning of initrd images:
215 If this variable is not set, initrd images will be
216 copied to the highest possible address in RAM; this
217 is usually what you want since it allows for
218 maximum initrd size. If for some reason you want to
219 make sure that the initrd image is loaded below the
220 CONFIG_SYS_BOOTMAPSZ limit, you can set this environment
221 variable to a value of "no" or "off" or "0".
222 Alternatively, you can set it to a maximum upper
223 address to use (U-Boot will still check that it
224 does not overwrite the U-Boot stack and data).
225
226 For instance, when you have a system with 16 MB
227 RAM, and want to reserve 4 MB from use by Linux,
228 you can do this by adding "mem=12M" to the value of
229 the "bootargs" variable. However, now you must make
230 sure that the initrd image is placed in the first
231 12 MB as well - this can be done with::
232
233 setenv initrd_high 00c00000
234
Simon Glass420febd2021-10-21 21:08:50 -0600235 If you set initrd_high to 0xffffffff (32-bit machines) or
236 0xffffffffffffffff (64-bit machines), this is an
Simon Glassaef523a2021-10-21 21:08:45 -0600237 indication to U-Boot that all addresses are legal
238 for the Linux kernel, including addresses in flash
239 memory. In this case U-Boot will NOT COPY the
240 ramdisk at all. This may be useful to reduce the
241 boot time on your system, but requires that this
242 feature is supported by your Linux kernel.
243
244ipaddr
245 IP address; needed for tftpboot command
246
247loadaddr
248 Default load address for commands like "bootp",
249 "rarpboot", "tftpboot", "loadb" or "diskboot"
250
251loads_echo
252 see CONFIG_LOADS_ECHO
253
254serverip
255 TFTP server IP address; needed for tftpboot command
256
257bootretry
258 see CONFIG_BOOT_RETRY_TIME
259
260bootdelaykey
261 see CONFIG_AUTOBOOT_DELAY_STR
262
263bootstopkey
264 see CONFIG_AUTOBOOT_STOP_STR
265
266ethprime
Simon Glass420febd2021-10-21 21:08:50 -0600267 controls which network interface is used first.
Simon Glassaef523a2021-10-21 21:08:45 -0600268
269ethact
270 controls which interface is currently active.
271 For example you can do the following::
272
273 => setenv ethact FEC
274 => ping 192.168.0.1 # traffic sent on FEC
275 => setenv ethact SCC
276 => ping 10.0.0.1 # traffic sent on SCC
277
278ethrotate
279 When set to "no" U-Boot does not go through all
280 available network interfaces.
Simon Glass420febd2021-10-21 21:08:50 -0600281 It just stays at the currently selected interface. When unset or set to
282 anything other than "no", U-Boot does go through all
283 available network interfaces.
Simon Glassaef523a2021-10-21 21:08:45 -0600284
285netretry
286 When set to "no" each network operation will
287 either succeed or fail without retrying.
288 When set to "once" the network operation will
289 fail when all the available network interfaces
290 are tried once without success.
291 Useful on scripts which control the retry operation
292 themselves.
293
Simon Glassaef523a2021-10-21 21:08:45 -0600294silent_linux
295 If set then Linux will be told to boot silently, by
Simon Glass420febd2021-10-21 21:08:50 -0600296 adding 'console=' to its command line. If "yes" it will be
Simon Glassaef523a2021-10-21 21:08:45 -0600297 made silent. If "no" it will not be made silent. If
298 unset, then it will be made silent if the U-Boot console
299 is silent.
300
301tftpsrcp
302 If this is set, the value is used for TFTP's
303 UDP source port.
304
305tftpdstp
306 If this is set, the value is used for TFTP's UDP
Simon Glass420febd2021-10-21 21:08:50 -0600307 destination port instead of the default port 69.
Simon Glassaef523a2021-10-21 21:08:45 -0600308
309tftpblocksize
310 Block size to use for TFTP transfers; if not set,
311 we use the TFTP server's default block size
312
313tftptimeout
314 Retransmission timeout for TFTP packets (in milli-
315 seconds, minimum value is 1000 = 1 second). Defines
316 when a packet is considered to be lost so it has to
317 be retransmitted. The default is 5000 = 5 seconds.
318 Lowering this value may make downloads succeed
319 faster in networks with high packet loss rates or
320 with unreliable TFTP servers.
321
322tftptimeoutcountmax
323 maximum count of TFTP timeouts (no
324 unit, minimum value = 0). Defines how many timeouts
325 can happen during a single file transfer before that
326 transfer is aborted. The default is 10, and 0 means
327 'no timeouts allowed'. Increasing this value may help
328 downloads succeed with high packet loss rates, or with
329 unreliable TFTP servers or client hardware.
330
331tftpwindowsize
332 if this is set, the value is used for TFTP's
333 window size as described by RFC 7440.
334 This means the count of blocks we can receive before
335 sending ack to server.
336
337vlan
338 When set to a value < 4095 the traffic over
339 Ethernet is encapsulated/received over 802.1q
340 VLAN tagged frames.
341
Simon Glass341c7ea2021-10-21 21:08:49 -0600342 Note: This appears not to be used in U-Boot. See `README.VLAN`.
343
Simon Glassaef523a2021-10-21 21:08:45 -0600344bootpretryperiod
345 Period during which BOOTP/DHCP sends retries.
346 Unsigned value, in milliseconds. If not set, the period will
347 be either the default (28000), or a value based on
348 CONFIG_NET_RETRY_COUNT, if defined. This value has
349 precedence over the valu based on CONFIG_NET_RETRY_COUNT.
350
351memmatches
352 Number of matches found by the last 'ms' command, in hex
353
354memaddr
355 Address of the last match found by the 'ms' command, in hex,
356 or 0 if none
357
358mempos
359 Index position of the last match found by the 'ms' command,
360 in units of the size (.b, .w, .l) of the search
361
362zbootbase
363 (x86 only) Base address of the bzImage 'setup' block
364
365zbootaddr
366 (x86 only) Address of the loaded bzImage, typically
367 BZIMAGE_LOAD_ADDR which is 0x100000
368
369
370Image locations
371---------------
372
373The following image location variables contain the location of images
374used in booting. The "Image" column gives the role of the image and is
375not an environment variable name. The other columns are environment
376variable names. "File Name" gives the name of the file on a TFTP
377server, "RAM Address" gives the location in RAM the image will be
378loaded to, and "Flash Location" gives the image's address in NOR
379flash or offset in NAND flash.
380
381*Note* - these variables don't have to be defined for all boards, some
382boards currently use other variables for these purposes, and some
383boards use these variables for other purposes.
384
Simon Glass341c7ea2021-10-21 21:08:49 -0600385Also note that most of these variables are just a commonly used set of variable
386names, used in some other variable definitions, but are not hard-coded anywhere
387in U-Boot code.
388
Simon Glassaef523a2021-10-21 21:08:45 -0600389================= ============== ================ ==============
390Image File Name RAM Address Flash Location
391================= ============== ================ ==============
392u-boot u-boot u-boot_addr_r u-boot_addr
393Linux kernel bootfile kernel_addr_r kernel_addr
394device tree blob fdtfile fdt_addr_r fdt_addr
395ramdisk ramdiskfile ramdisk_addr_r ramdisk_addr
396================= ============== ================ ==============
397
398
399Automatically updated variables
400-------------------------------
401
402The following environment variables may be used and automatically
403updated by the network boot commands ("bootp" and "rarpboot"),
404depending the information provided by your boot server:
405
406========= ===================================================
407Variable Notes
408========= ===================================================
409bootfile see above
410dnsip IP address of your Domain Name Server
411dnsip2 IP address of your secondary Domain Name Server
412gatewayip IP address of the Gateway (Router) to use
413hostname Target hostname
414ipaddr See above
415netmask Subnet Mask
416rootpath Pathname of the root filesystem on the NFS server
417serverip see above
418========= ===================================================
419
420
421Special environment variables
422-----------------------------
423
424There are two special Environment Variables:
425
426serial#
427 contains hardware identification information such as type string and/or
428 serial number
429ethaddr
Simon Glass420febd2021-10-21 21:08:50 -0600430 Ethernet address. If CONFIG_REGEX=y, also eth*addr (where * is an integer).
Simon Glassaef523a2021-10-21 21:08:45 -0600431
432These variables can be set only once (usually during manufacturing of
433the board). U-Boot refuses to delete or overwrite these variables
Simon Glass420febd2021-10-21 21:08:50 -0600434once they have been set, unless CONFIG_ENV_OVERWRITE is enabled in the board
435configuration.
Simon Glassaef523a2021-10-21 21:08:45 -0600436
437Also:
438
439ver
440 Contains the U-Boot version string as printed
441 with the "version" command. This variable is
442 readonly (see CONFIG_VERSION_VARIABLE).
443
444Please note that changes to some configuration parameters may take
Simon Glass420febd2021-10-21 21:08:50 -0600445only effect after the next boot (yes, that's just like Windows).
Simon Glassaef523a2021-10-21 21:08:45 -0600446
Simon Glass9f3a7bf2021-10-21 21:08:48 -0600447
448External environment file
449-------------------------
450
451The `CONFIG_USE_DEFAULT_ENV_FILE` option provides a way to bypass the
452environment generation in U-Boot. If enabled, then `CONFIG_DEFAULT_ENV_FILE`
453provides the name of a file which is converted into the environment,
454completely bypassing the standard environment variables in `env_default.h`.
455
456The format is the same as accepted by the mkenvimage tool, with lines containing
457key=value pairs. Blank lines and lines beginning with # are ignored.
458
459Future work may unify this feature with the text-based environment, perhaps
460moving the contents of `env_default.h` to a text file.
Simon Glass420febd2021-10-21 21:08:50 -0600461
462Implementation
463--------------
464
465See :doc:`../develop/environment` for internal development details.