Patrick Delaunay | aa5f43a | 2022-04-14 19:07:05 +0200 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0-or-later: |
| 2 | |
Heinrich Schuchardt | 1b0c316 | 2024-01-14 14:53:13 +0100 | [diff] [blame] | 3 | .. index:: |
| 4 | single: env (command) |
| 5 | |
Patrick Delaunay | aa5f43a | 2022-04-14 19:07:05 +0200 | [diff] [blame] | 6 | env command |
| 7 | =========== |
| 8 | |
| 9 | Synopsis |
| 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 Schuchardt | ec84a3c | 2024-04-17 10:06:12 +0200 | [diff] [blame^] | 19 | env erase |
Patrick Delaunay | aa5f43a | 2022-04-14 19:07:05 +0200 | [diff] [blame] | 20 | 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 Schuchardt | ec84a3c | 2024-04-17 10:06:12 +0200 | [diff] [blame^] | 26 | env load |
Patrick Delaunay | aa5f43a | 2022-04-14 19:07:05 +0200 | [diff] [blame] | 27 | env print [-a | name ...] |
| 28 | env print -e [-guid guid] [-n] [name ...] |
| 29 | env run var [...] |
| 30 | env save |
Patrick Delaunay | aa5f43a | 2022-04-14 19:07:05 +0200 | [diff] [blame] | 31 | 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 | |
| 35 | Description |
| 36 | ----------- |
| 37 | |
| 38 | The *env* commands is used to handle the U-Boot (:doc:`../environment`) or |
| 39 | the UEFI variables. |
| 40 | |
| 41 | The next commands are kept as alias and for compatibility: |
| 42 | |
Heinrich Schuchardt | ec84a3c | 2024-04-17 10:06:12 +0200 | [diff] [blame^] | 43 | + *askenv* = *env ask* |
Patrick Delaunay | aa5f43a | 2022-04-14 19:07:05 +0200 | [diff] [blame] | 44 | + *editenv* = *env edit* |
| 45 | + *grepenv* = *env grep* |
Patrick Delaunay | aa5f43a | 2022-04-14 19:07:05 +0200 | [diff] [blame] | 46 | + *run* = *env run* |
Heinrich Schuchardt | ec84a3c | 2024-04-17 10:06:12 +0200 | [diff] [blame^] | 47 | + *setenv* = *env set* |
Patrick Delaunay | aa5f43a | 2022-04-14 19:07:05 +0200 | [diff] [blame] | 48 | |
| 49 | Ask |
| 50 | ~~~ |
| 51 | |
| 52 | The *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 | |
| 69 | Callbacks |
| 70 | ~~~~~~~~~ |
| 71 | |
| 72 | The *env callbacks* command prints callbacks and their associated variables. |
| 73 | |
| 74 | Default |
| 75 | ~~~~~~~ |
| 76 | |
| 77 | The *env default* command resets the selected variables in the U-Boot |
| 78 | environment 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 | |
| 87 | Delete |
| 88 | ~~~~~~ |
| 89 | |
| 90 | The *env delete* command deletes the selected variables from the U-Boot |
| 91 | environment. |
| 92 | |
| 93 | var |
| 94 | name of the variable to delete. |
| 95 | \-f |
| 96 | forcibly, overwrite read-only/write-once variables. |
| 97 | |
| 98 | Edit |
| 99 | ~~~~ |
| 100 | |
| 101 | The *env edit* command edits an environment variable. |
| 102 | |
| 103 | name |
| 104 | name of the variable. |
| 105 | |
Heinrich Schuchardt | ec84a3c | 2024-04-17 10:06:12 +0200 | [diff] [blame^] | 106 | Erase |
| 107 | ~~~~~ |
| 108 | |
| 109 | The *env erase* command erases the U-Boot environment. |
| 110 | |
Patrick Delaunay | aa5f43a | 2022-04-14 19:07:05 +0200 | [diff] [blame] | 111 | Exists |
| 112 | ~~~~~~ |
| 113 | |
| 114 | The *env exists* command tests for existence of variable. |
| 115 | |
| 116 | name |
| 117 | name of the variable. |
| 118 | |
| 119 | Export |
| 120 | ~~~~~~ |
| 121 | |
| 122 | The *env export* command exports the U-Boot environment in memory; on success, |
| 123 | the 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 | |
| 143 | Flags |
| 144 | ~~~~~ |
| 145 | |
| 146 | The *env flags* command prints variables that have non-default flags. |
| 147 | |
| 148 | Grep |
| 149 | ~~~~ |
| 150 | |
| 151 | The *env grep* command searches environment, list environment name=value pairs |
| 152 | matching 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 | |
| 165 | Import |
| 166 | ~~~~~~ |
| 167 | |
| 168 | The *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 | |
| 198 | Info |
| 199 | ~~~~ |
| 200 | |
| 201 | The *env info* command displays (without argument) or evaluates the U-Boot |
| 202 | environment 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 Schuchardt | ec84a3c | 2024-04-17 10:06:12 +0200 | [diff] [blame^] | 212 | Load |
| 213 | ~~~~ |
| 214 | |
| 215 | The *env load* command loads the U-Boot environment from persistent storage. |
| 216 | |
Patrick Delaunay | aa5f43a | 2022-04-14 19:07:05 +0200 | [diff] [blame] | 217 | Print |
| 218 | ~~~~~ |
| 219 | |
| 220 | The *env print* command prints the selected variables in U-Boot environment or |
| 221 | in 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 | |
| 235 | Run |
| 236 | ~~~ |
| 237 | |
| 238 | The *env run* command runs commands in an environment variable. |
| 239 | |
| 240 | var |
| 241 | name of the variable. |
| 242 | |
| 243 | Save |
| 244 | ~~~~ |
| 245 | |
| 246 | The *env save* command saves the U-Boot environment in persistent storage. |
| 247 | |
Patrick Delaunay | aa5f43a | 2022-04-14 19:07:05 +0200 | [diff] [blame] | 248 | Select |
| 249 | ~~~~~~ |
| 250 | |
| 251 | The *env select* command selects an U-Boot environment target, it is useful to |
| 252 | overid the default location when several U-Boot environment backend are |
| 253 | availables. |
| 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 | |
| 260 | Set |
| 261 | ~~~ |
| 262 | |
| 263 | The *env set* command sets or delete (when 'value' or '-i' are absent) |
| 264 | U-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 | |
| 290 | Example |
| 291 | ------- |
| 292 | |
| 293 | Print the U-Boot environment variables:: |
| 294 | |
| 295 | => env print -a |
| 296 | => env print bootcmd stdout |
| 297 | |
| 298 | Update environment variable in memory:: |
| 299 | |
| 300 | => env set bootcmd "run distro_bootcmd" |
| 301 | => env set stdout "serial,vidconsole" |
| 302 | |
| 303 | Delete environment variable in memory:: |
| 304 | |
| 305 | => env delete bootcmd |
| 306 | => env set bootcmd |
| 307 | |
| 308 | Reset environment variable to default value, in memory:: |
| 309 | |
| 310 | => env default bootcmd |
| 311 | => env default -a |
| 312 | |
| 313 | Save current environment in persistent storage:: |
| 314 | |
| 315 | => env save |
| 316 | |
| 317 | Restore the default environment in persistent storage:: |
| 318 | |
| 319 | => env erase |
| 320 | |
| 321 | Create 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 | |
| 326 | Re-import this snapshot, deleting all other settings:: |
| 327 | |
| 328 | => env import -d -t ${backup_addr} |
| 329 | |
| 330 | Save environment if default enviromnent is used and persistent storage is |
| 331 | selected:: |
| 332 | |
| 333 | => if env info -p -d -q; then env save; fi |
| 334 | |
| 335 | Configuration |
| 336 | ------------- |
| 337 | |
| 338 | The env command is always available but some sub-commands depend on |
| 339 | configuration options: |
| 340 | |
| 341 | ask |
| 342 | CONFIG_CMD_ASKENV |
| 343 | |
| 344 | callback |
| 345 | CONFIG_CMD_ENV_CALLBACK |
| 346 | |
| 347 | edit |
| 348 | CONFIG_CMD_EDITENV |
| 349 | |
| 350 | exists |
| 351 | CONFIG_CMD_ENV_EXISTS |
| 352 | |
Patrick Delaunay | aa5f43a | 2022-04-14 19:07:05 +0200 | [diff] [blame] | 353 | erase |
| 354 | CONFIG_CMD_ERASEENV |
| 355 | |
| 356 | export |
| 357 | CONFIG_CMD_EXPORTENV |
| 358 | |
Heinrich Schuchardt | ec84a3c | 2024-04-17 10:06:12 +0200 | [diff] [blame^] | 359 | flags |
| 360 | CONFIG_CMD_ENV_FLAGS |
| 361 | |
Patrick Delaunay | aa5f43a | 2022-04-14 19:07:05 +0200 | [diff] [blame] | 362 | grep |
| 363 | CONFIG_CMD_GREPENV, CONFIG_REGEX for '-e' option |
| 364 | |
| 365 | import |
| 366 | CONFIG_CMD_IMPORTENV |
| 367 | |
| 368 | info |
| 369 | CONFIG_CMD_NVEDIT_INFO |
| 370 | |
| 371 | load |
| 372 | CONFIG_CMD_NVEDIT_LOAD |
| 373 | |
| 374 | run |
| 375 | CONFIG_CMD_RUN |
| 376 | |
| 377 | save |
| 378 | CONFIG_CMD_SAVEENV |
| 379 | |
| 380 | select |
| 381 | CONFIG_CMD_NVEDIT_SELECT |
| 382 | |
| 383 | set, print |
| 384 | CONFIG_CMD_NVEDIT_EFI for '-e' option |