env.rst 8.7 KB

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