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