blob: 9629f97ffc4779d252a0c4ea6cecd20fc9073e42 [file] [log] [blame]
Patrick Delaunayaa5f43a2022-04-14 19:07:05 +02001.. SPDX-License-Identifier: GPL-2.0-or-later:
2
Heinrich Schuchardt1b0c3162024-01-14 14:53:13 +01003.. index::
4 single: env (command)
5
Patrick Delaunayaa5f43a2022-04-14 19:07:05 +02006env command
7===========
8
9Synopsis
10--------
11
12::
13
14 env ask name [message] [size]
15 env callbacks
16 env default [-f] (-a | var [...])
17 env delete [-f] var [...]
18 env edit name
Heinrich Schuchardtec84a3c2024-04-17 10:06:12 +020019 env erase
Patrick Delaunayaa5f43a2022-04-14 19:07:05 +020020 env exists name
21 env export [-t | -b | -c] [-s size] addr [var ...]
22 env flags
23 env grep [-e] [-n | -v | -b] string [...]
24 env import [-d] [-t [-r] | -b | -c] addr [size] [var ...]
25 env info [-d] [-p] [-q]
Heinrich Schuchardtec84a3c2024-04-17 10:06:12 +020026 env load
Patrick Delaunayaa5f43a2022-04-14 19:07:05 +020027 env print [-a | name ...]
28 env print -e [-guid guid] [-n] [name ...]
29 env run var [...]
30 env save
Patrick Delaunayaa5f43a2022-04-14 19:07:05 +020031 env select [target]
32 env set [-f] name [value]
33 env set -e [-nv][-bs][-rt][-at][-a][-i addr:size][-v] name [value]
34
35Description
36-----------
37
38The *env* commands is used to handle the U-Boot (:doc:`../environment`) or
39the UEFI variables.
40
41The next commands are kept as alias and for compatibility:
42
Heinrich Schuchardt4cdc1b12024-04-17 10:06:13 +020043+ :doc:`askenv <askenv>` = *env ask*
Patrick Delaunayaa5f43a2022-04-14 19:07:05 +020044+ *editenv* = *env edit*
45+ *grepenv* = *env grep*
Heinrich Schuchardt4cdc1b12024-04-17 10:06:13 +020046+ :doc:`printenv <printenv>` = *env print*
Patrick Delaunayaa5f43a2022-04-14 19:07:05 +020047+ *run* = *env run*
Heinrich Schuchardtec84a3c2024-04-17 10:06:12 +020048+ *setenv* = *env set*
Patrick Delaunayaa5f43a2022-04-14 19:07:05 +020049
50Ask
51~~~
52
53The *env ask* command asks for the new value of an environment variable
54(alias :doc:`askenv`).
55
56 name
57 name of the environment variable.
58
59 message
60 message to be displayed while the command waits for the value to be
61 entered from stdin. If no message is specified, a default message
62 "Please enter name:" will be displayed.
63
64 size
65 maximum number of characters that will be stored in the environment
66 variable name. This is in decimal number format (unlike in
67 other commands where size values are hexa-decimal). The default
68 value of size is 1023 (CONFIG_SYS_CBSIZE - 1).
69
70Callbacks
71~~~~~~~~~
72
73The *env callbacks* command prints callbacks and their associated variables.
74
75Default
76~~~~~~~
77
78The *env default* command resets the selected variables in the U-Boot
79environment to their default values.
80
81 var
82 list of variable name.
83 \-a
84 all U-Boot environment.
85 \-f
86 forcibly, overwrite read-only/write-once variables.
87
88Delete
89~~~~~~
90
91The *env delete* command deletes the selected variables from the U-Boot
92environment.
93
94 var
95 name of the variable to delete.
96 \-f
97 forcibly, overwrite read-only/write-once variables.
98
99Edit
100~~~~
101
102The *env edit* command edits an environment variable.
103
104 name
105 name of the variable.
106
Heinrich Schuchardtec84a3c2024-04-17 10:06:12 +0200107Erase
108~~~~~
109
110The *env erase* command erases the U-Boot environment.
111
Patrick Delaunayaa5f43a2022-04-14 19:07:05 +0200112Exists
113~~~~~~
114
115The *env exists* command tests for existence of variable.
116
117 name
118 name of the variable.
119
120Export
121~~~~~~
122
123The *env export* command exports the U-Boot environment in memory; on success,
124the variable $filesize will be set.
125
126 addr
127 memory address where environment gets stored.
128 var
129 list of variable names that get included into the export.
130 Without arguments, the whole environment gets exported.
131 \-b
132 export as binary format (name=value pairs separated by
133 list end marked by double "\0\0").
134 \-t
135 export as text format; if size is given, data will be
136 padded with '\0' bytes; if not, one terminating '\0'
137 will be added.
138 \-c
139 Export as checksum protected environment format as used by
140 'env save' command.
141 \-s size
142 size of output buffer.
143
144Flags
145~~~~~
146
147The *env flags* command prints variables that have non-default flags.
148
149Grep
150~~~~
151
152The *env grep* command searches environment, list environment name=value pairs
153matching the requested 'string'.
154
155 string
156 string to search in U-Boot environment.
157 \-e
158 enable regular expressions.
159 \-n
160 search string in variable names.
161 \-v
162 search string in vairable values.
163 \-b
164 search both names and values (default).
165
166Import
167~~~~~~
168
169The *env import* command imports environment from memory.
170
171 addr
172 memory address to read from.
173 size
174 length of input data; if missing, proper '\0' termination is mandatory
175 if var is set and size should be missing (i.e. '\0' termination),
176 set size to '-'.
177 var
178 List of the names of the only variables that get imported from
179 the environment at address 'addr'. Without arguments, the whole
180 environment gets imported.
181 \-d
182 delete existing environment before importing if no var is passed;
183 if vars are passed, if one var is in the current environment but not
184 in the environment at addr, delete var from current environment;
185 otherwise overwrite / append to existing definitions.
186 \-t
187 assume text format; either "size" must be given or the text data must
188 be '\0' terminated.
189 \-r
190 handle CRLF like LF, that means exported variables with a content which
191 ends with \r won't get imported. Used to import text files created with
192 editors which are using CRLF for line endings.
193 Only effective in addition to -t.
194 \-b
195 assume binary format ('\0' separated, "\0\0" terminated).
196 \-c
197 assume checksum protected environment format.
198
199Info
200~~~~
201
202The *env info* command displays (without argument) or evaluates the U-Boot
203environment information.
204
205 \-d
206 evaluate if the default environment is used.
207 \-p
208 evaluate if environment can be persisted.
209 \-q
210 quiet output, use only for command result, by example with
211 'test' command.
212
Heinrich Schuchardtec84a3c2024-04-17 10:06:12 +0200213Load
214~~~~
215
216The *env load* command loads the U-Boot environment from persistent storage.
217
Patrick Delaunayaa5f43a2022-04-14 19:07:05 +0200218Print
219~~~~~
220
221The *env print* command prints the selected variables in U-Boot environment or
222in UEFI variables.
223
224 name
225 list of variable name.
226 \-a
227 all U-Boot environment, when 'name' is absent.
228 \-e
Heinrich Schuchardt10b25f12024-04-22 22:00:56 +0200229 print UEFI variables, all by default if 'name' is not provided.
Patrick Delaunayaa5f43a2022-04-14 19:07:05 +0200230 \-guid guid
231 print only the UEFI variables matching this GUID (any by default)
232 with guid format = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".
233 \-n
234 suppress dumping variable's value for UEFI.
235
236Run
237~~~
238
239The *env run* command runs commands in an environment variable.
240
241 var
242 name of the variable.
243
244Save
245~~~~
246
247The *env save* command saves the U-Boot environment in persistent storage.
248
Patrick Delaunayaa5f43a2022-04-14 19:07:05 +0200249Select
250~~~~~~
251
252The *env select* command selects an U-Boot environment target, it is useful to
253overid the default location when several U-Boot environment backend are
254availables.
255
256 target
257 name of the U-Boot environment backend to select: EEPROM, EXT4, FAT,
258 Flash, MMC, NAND, nowhere, NVRAM, OneNAND, Remote, SATA, SPIFlash, UBI.
259
260
261Set
262~~~
263
264The *env set* command sets or delete (when 'value' or '-i' are absent)
265U-Boot variable in environment or UEFI variables (when -e is specified).
266
267 name
268 variable name to modify.
269 value
270 when present, set the environment variable 'name' to 'value'
271 when absent, delete the environment variable 'name'.
272 \-f
273 forcibly, overwrite read-only/write-once U-Boot variables.
274 \-e
275 update UEFI variables.
276 \-nv
277 set non-volatile attribute (UEFI).
278 \-bs
279 set boot-service attribute (UEFI).
280 \-rt
281 set runtime attribute (UEFI).
282 \-at
283 set time-based authentication attribute (UEFI).
284 \-a
285 append-write (UEFI).
286 \-i addr:size
287 use <addr,size> as variable's value (UEFI).
288 \-v
289 verbose message (UEFI).
290
291Example
292-------
293
294Print the U-Boot environment variables::
295
296 => env print -a
297 => env print bootcmd stdout
298
299Update environment variable in memory::
300
301 => env set bootcmd "run distro_bootcmd"
302 => env set stdout "serial,vidconsole"
303
304Delete environment variable in memory::
305
306 => env delete bootcmd
307 => env set bootcmd
308
309Reset environment variable to default value, in memory::
310
311 => env default bootcmd
312 => env default -a
313
314Save current environment in persistent storage::
315
316 => env save
317
318Restore the default environment in persistent storage::
319
320 => env erase
321
322Create a text snapshot/backup of the current settings in RAM
323(${filesize} can be use to save the snapshot in file)::
324
325 => env export -t ${backup_addr}
326
327Re-import this snapshot, deleting all other settings::
328
329 => env import -d -t ${backup_addr}
330
331Save environment if default enviromnent is used and persistent storage is
332selected::
333
334 => if env info -p -d -q; then env save; fi
335
336Configuration
337-------------
338
339The env command is always available but some sub-commands depend on
340configuration options:
341
342ask
343 CONFIG_CMD_ASKENV
344
345callback
346 CONFIG_CMD_ENV_CALLBACK
347
348edit
349 CONFIG_CMD_EDITENV
350
351exists
352 CONFIG_CMD_ENV_EXISTS
353
Patrick Delaunayaa5f43a2022-04-14 19:07:05 +0200354erase
355 CONFIG_CMD_ERASEENV
356
357export
358 CONFIG_CMD_EXPORTENV
359
Heinrich Schuchardtec84a3c2024-04-17 10:06:12 +0200360flags
361 CONFIG_CMD_ENV_FLAGS
362
Patrick Delaunayaa5f43a2022-04-14 19:07:05 +0200363grep
364 CONFIG_CMD_GREPENV, CONFIG_REGEX for '-e' option
365
366import
367 CONFIG_CMD_IMPORTENV
368
369info
370 CONFIG_CMD_NVEDIT_INFO
371
372load
373 CONFIG_CMD_NVEDIT_LOAD
374
Heinrich Schuchardt10b25f12024-04-22 22:00:56 +0200375print
376 CONFIG_CMD_NVEDIT_EFI for UEFI variables support ('-e' option),
377 additionally CONFIG_HEXDUMP to display content of UEFI variables
378
Patrick Delaunayaa5f43a2022-04-14 19:07:05 +0200379run
380 CONFIG_CMD_RUN
381
382save
383 CONFIG_CMD_SAVEENV
384
385select
386 CONFIG_CMD_NVEDIT_SELECT
387
Heinrich Schuchardt10b25f12024-04-22 22:00:56 +0200388set
389 CONFIG_CMD_NVEDIT_EFI for UEFI variables support ('-e' option)