Patrick Delaunay | aa5f43a | 2022-04-14 19:07:05 +0200 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0-or-later: |
| 2 | |
| 3 | env command |
| 4 | =========== |
| 5 | |
| 6 | Synopsis |
| 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 | |
| 32 | Description |
| 33 | ----------- |
| 34 | |
| 35 | The *env* commands is used to handle the U-Boot (:doc:`../environment`) or |
| 36 | the UEFI variables. |
| 37 | |
| 38 | The 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 | |
| 46 | Ask |
| 47 | ~~~ |
| 48 | |
| 49 | The *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 | |
| 66 | Callbacks |
| 67 | ~~~~~~~~~ |
| 68 | |
| 69 | The *env callbacks* command prints callbacks and their associated variables. |
| 70 | |
| 71 | Default |
| 72 | ~~~~~~~ |
| 73 | |
| 74 | The *env default* command resets the selected variables in the U-Boot |
| 75 | environment 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 | |
| 84 | Delete |
| 85 | ~~~~~~ |
| 86 | |
| 87 | The *env delete* command deletes the selected variables from the U-Boot |
| 88 | environment. |
| 89 | |
| 90 | var |
| 91 | name of the variable to delete. |
| 92 | \-f |
| 93 | forcibly, overwrite read-only/write-once variables. |
| 94 | |
| 95 | Edit |
| 96 | ~~~~ |
| 97 | |
| 98 | The *env edit* command edits an environment variable. |
| 99 | |
| 100 | name |
| 101 | name of the variable. |
| 102 | |
| 103 | Exists |
| 104 | ~~~~~~ |
| 105 | |
| 106 | The *env exists* command tests for existence of variable. |
| 107 | |
| 108 | name |
| 109 | name of the variable. |
| 110 | |
| 111 | Export |
| 112 | ~~~~~~ |
| 113 | |
| 114 | The *env export* command exports the U-Boot environment in memory; on success, |
| 115 | the 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 | |
| 135 | Flags |
| 136 | ~~~~~ |
| 137 | |
| 138 | The *env flags* command prints variables that have non-default flags. |
| 139 | |
| 140 | Grep |
| 141 | ~~~~ |
| 142 | |
| 143 | The *env grep* command searches environment, list environment name=value pairs |
| 144 | matching 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 | |
| 157 | Import |
| 158 | ~~~~~~ |
| 159 | |
| 160 | The *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 | |
| 190 | Info |
| 191 | ~~~~ |
| 192 | |
| 193 | The *env info* command displays (without argument) or evaluates the U-Boot |
| 194 | environment 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 | |
| 204 | Print |
| 205 | ~~~~~ |
| 206 | |
| 207 | The *env print* command prints the selected variables in U-Boot environment or |
| 208 | in 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 | |
| 222 | Run |
| 223 | ~~~ |
| 224 | |
| 225 | The *env run* command runs commands in an environment variable. |
| 226 | |
| 227 | var |
| 228 | name of the variable. |
| 229 | |
| 230 | Save |
| 231 | ~~~~ |
| 232 | |
| 233 | The *env save* command saves the U-Boot environment in persistent storage. |
| 234 | |
| 235 | Erase |
| 236 | ~~~~~ |
| 237 | |
| 238 | The *env erase* command erases the U-Boot environment. |
| 239 | |
| 240 | Load |
| 241 | ~~~~ |
| 242 | |
| 243 | The *env load* command loads the U-Boot environment from persistent storage. |
| 244 | |
| 245 | Select |
| 246 | ~~~~~~ |
| 247 | |
| 248 | The *env select* command selects an U-Boot environment target, it is useful to |
| 249 | overid the default location when several U-Boot environment backend are |
| 250 | availables. |
| 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 | |
| 257 | Set |
| 258 | ~~~ |
| 259 | |
| 260 | The *env set* command sets or delete (when 'value' or '-i' are absent) |
| 261 | U-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 | |
| 287 | Example |
| 288 | ------- |
| 289 | |
| 290 | Print the U-Boot environment variables:: |
| 291 | |
| 292 | => env print -a |
| 293 | => env print bootcmd stdout |
| 294 | |
| 295 | Update environment variable in memory:: |
| 296 | |
| 297 | => env set bootcmd "run distro_bootcmd" |
| 298 | => env set stdout "serial,vidconsole" |
| 299 | |
| 300 | Delete environment variable in memory:: |
| 301 | |
| 302 | => env delete bootcmd |
| 303 | => env set bootcmd |
| 304 | |
| 305 | Reset environment variable to default value, in memory:: |
| 306 | |
| 307 | => env default bootcmd |
| 308 | => env default -a |
| 309 | |
| 310 | Save current environment in persistent storage:: |
| 311 | |
| 312 | => env save |
| 313 | |
| 314 | Restore the default environment in persistent storage:: |
| 315 | |
| 316 | => env erase |
| 317 | |
| 318 | Create 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 | |
| 323 | Re-import this snapshot, deleting all other settings:: |
| 324 | |
| 325 | => env import -d -t ${backup_addr} |
| 326 | |
| 327 | Save environment if default enviromnent is used and persistent storage is |
| 328 | selected:: |
| 329 | |
| 330 | => if env info -p -d -q; then env save; fi |
| 331 | |
| 332 | Configuration |
| 333 | ------------- |
| 334 | |
| 335 | The env command is always available but some sub-commands depend on |
| 336 | configuration options: |
| 337 | |
| 338 | ask |
| 339 | CONFIG_CMD_ASKENV |
| 340 | |
| 341 | callback |
| 342 | CONFIG_CMD_ENV_CALLBACK |
| 343 | |
| 344 | edit |
| 345 | CONFIG_CMD_EDITENV |
| 346 | |
| 347 | exists |
| 348 | CONFIG_CMD_ENV_EXISTS |
| 349 | |
| 350 | flsgs |
| 351 | CONFIG_CMD_ENV_FLAGS |
| 352 | |
| 353 | erase |
| 354 | CONFIG_CMD_ERASEENV |
| 355 | |
| 356 | export |
| 357 | CONFIG_CMD_EXPORTENV |
| 358 | |
| 359 | grep |
| 360 | CONFIG_CMD_GREPENV, CONFIG_REGEX for '-e' option |
| 361 | |
| 362 | import |
| 363 | CONFIG_CMD_IMPORTENV |
| 364 | |
| 365 | info |
| 366 | CONFIG_CMD_NVEDIT_INFO |
| 367 | |
| 368 | load |
| 369 | CONFIG_CMD_NVEDIT_LOAD |
| 370 | |
| 371 | run |
| 372 | CONFIG_CMD_RUN |
| 373 | |
| 374 | save |
| 375 | CONFIG_CMD_SAVEENV |
| 376 | |
| 377 | select |
| 378 | CONFIG_CMD_NVEDIT_SELECT |
| 379 | |
| 380 | set, print |
| 381 | CONFIG_CMD_NVEDIT_EFI for '-e' option |