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