README.pxe 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright 2010-2011 Calxeda, Inc.
  4. */
  5. The 'pxe' commands provide a near subset of the functionality provided by
  6. the PXELINUX boot loader. This allows U-Boot based systems to be controlled
  7. remotely using the same PXE based techniques that many non U-Boot based servers
  8. use.
  9. Commands
  10. ========
  11. pxe get
  12. -------
  13. syntax: pxe get
  14. follows PXELINUX's rules for retrieving configuration files from a tftp
  15. server, and supports a subset of PXELINUX's config file syntax.
  16. Environment
  17. -----------
  18. 'pxe get' requires two environment variables to be set:
  19. pxefile_addr_r - should be set to a location in RAM large enough to hold
  20. pxe files while they're being processed. Up to 16 config files may be
  21. held in memory at once. The exact number and size of the files varies with
  22. how the system is being used. A typical config file is a few hundred bytes
  23. long.
  24. bootfile,serverip - these two are typically set in the DHCP response
  25. handler, and correspond to fields in the DHCP response.
  26. 'pxe get' optionally supports these two environment variables being set:
  27. ethaddr - this is the standard MAC address for the ethernet adapter in use.
  28. 'pxe get' uses it to look for a configuration file specific to a system's
  29. MAC address.
  30. pxeuuid - this is a UUID in standard form using lower case hexadecimal
  31. digits, for example, 550e8400-e29b-41d4-a716-446655440000. 'pxe get' uses
  32. it to look for a configuration file based on the system's UUID.
  33. File Paths
  34. ----------
  35. 'pxe get' repeatedly tries to download config files until it either
  36. successfully downloads one or runs out of paths to try. The order and
  37. contents of paths it tries mirrors exactly that of PXELINUX - you can
  38. read in more detail about it at:
  39. http://syslinux.zytor.com/wiki/index.php/Doc/pxelinux
  40. pxe boot
  41. --------
  42. syntax: pxe boot [pxefile_addr_r]
  43. Interprets a pxe file stored in memory.
  44. pxefile_addr_r is an optional argument giving the location of the pxe file.
  45. The file must be terminated with a NUL byte.
  46. Environment
  47. -----------
  48. There are some environment variables that may need to be set, depending
  49. on conditions.
  50. pxefile_addr_r - if the optional argument pxefile_addr_r is not supplied,
  51. an environment variable named pxefile_addr_r must be supplied. This is
  52. typically the same value as is used for the 'pxe get' command.
  53. bootfile - typically set in the DHCP response handler based on the
  54. same field in the DHCP respone, this path is used to generate the base
  55. directory that all other paths to files retrieved by 'pxe boot' will use.
  56. If no bootfile is specified, paths used in pxe files will be used as is.
  57. serverip - typically set in the DHCP response handler, this is the IP
  58. address of the tftp server from which other files will be retrieved.
  59. kernel_addr_r, initrd_addr_r - locations in RAM at which 'pxe boot' will
  60. store the kernel(or FIT image) and initrd it retrieves from tftp. These
  61. locations will be passed to the bootm command to boot the kernel. These
  62. environment variables are required to be set.
  63. fdt_addr_r - location in RAM at which 'pxe boot' will store the fdt blob it
  64. retrieves from tftp. The retrieval is possible if 'fdt' label is defined in
  65. pxe file and 'fdt_addr_r' is set. If retrieval is possible, 'fdt_addr_r'
  66. will be passed to bootm command to boot the kernel.
  67. fdt_addr - the location of a fdt blob. 'fdt_addr' will be passed to bootm
  68. command if it is set and 'fdt_addr_r' is not passed to bootm command.
  69. fdtoverlay_addr_r - location in RAM at which 'pxe boot' will temporarily store
  70. fdt overlay(s) before applying them to the fdt blob stored at 'fdt_addr_r'.
  71. pxe_label_override - override label to be used, if exists, instead of the
  72. default label. This will allow consumers to choose a pxe label at
  73. runtime instead of having to prompt the user. If "pxe_label_override" is set
  74. but does not exist in the pxe menu, pxe would fallback to the default label if
  75. given, and no failure is returned but rather a warning message.
  76. pxe file format
  77. ===============
  78. The pxe file format is nearly a subset of the PXELINUX file format; see
  79. http://syslinux.zytor.com/wiki/index.php/PXELINUX. It's composed of one line
  80. commands - global commands, and commands specific to labels. Lines begining
  81. with # are treated as comments. White space between and at the beginning of
  82. lines is ignored.
  83. The size of pxe files and the number of labels is only limited by the amount
  84. of RAM available to U-Boot. Memory for labels is dynamically allocated as
  85. they're parsed, and memory for pxe files is statically allocated, and its
  86. location is given by the pxefile_addr_r environment variable. The pxe code is
  87. not aware of the size of the pxefile memory and will outgrow it if pxe files
  88. are too large.
  89. Supported global commands
  90. -------------------------
  91. Unrecognized commands are ignored.
  92. default <label> - the label named here is treated as the default and is
  93. the first label 'pxe boot' attempts to boot.
  94. menu title <string> - sets a title for the menu of labels being displayed.
  95. menu include <path> - use tftp to retrieve the pxe file at <path>, which
  96. is then immediately parsed as if the start of its
  97. contents were the next line in the current file. nesting
  98. of include up to 16 files deep is supported.
  99. prompt <flag> - if 1, always prompt the user to enter a label to boot
  100. from. if 0, only prompt the user if timeout expires.
  101. timeout <num> - wait for user input for <num>/10 seconds before
  102. auto-booting a node.
  103. label <name> - begin a label definition. labels continue until
  104. a command not recognized as a label command is seen,
  105. or EOF is reached.
  106. Supported label commands
  107. ------------------------
  108. labels end when a command not recognized as a label command is reached, or EOF.
  109. menu default - set this label as the default label to boot; this is
  110. the same behavior as the global default command but
  111. specified in a different way
  112. kernel <path> - if this label is chosen, use tftp to retrieve the kernel
  113. (or FIT image) at <path>. it will be stored at the address
  114. indicated in the kernel_addr_r environment variable, and
  115. that address will be passed to bootm to boot this kernel.
  116. For FIT image, The configuration specification can be
  117. appended to the file name, with the format:
  118. <path>#<conf>[#<extra-conf[#...]]
  119. It will passed to bootm with that address.
  120. (see: doc/uImage.FIT/command_syntax_extensions.txt)
  121. It useful for overlay selection in pxe file
  122. (see: doc/uImage.FIT/overlay-fdt-boot.txt)
  123. fdtoverlays <path> [...] - if this label is chosen, use tftp to retrieve the DT
  124. overlay(s) at <path>. it will be temporarily stored at the
  125. address indicated in the fdtoverlay_addr_r environment variable,
  126. and then applied in the load order to the fdt blob stored at the
  127. address indicated in the fdt_addr_r environment variable.
  128. kaslrseed - set this label to request random number from hwrng as kaslr seed.
  129. append <string> - use <string> as the kernel command line when booting this
  130. label.
  131. initrd <path> - if this label is chosen, use tftp to retrieve the initrd
  132. at <path>. it will be stored at the address indicated in
  133. the initrd_addr_r environment variable, and that address
  134. will be passed to bootm.
  135. fdt <path> - if this label is chosen, use tftp to retrieve the fdt blob
  136. at <path>. it will be stored at the address indicated in
  137. the fdt_addr_r environment variable, and that address will
  138. be passed to bootm.
  139. fdtdir <path> - if this label is chosen, use tftp to retrieve a fdt blob
  140. relative to <path>. If the fdtfile environment variable
  141. is set, <path>/<fdtfile> is retrieved. Otherwise, the
  142. filename is generated from the soc and board environment
  143. variables, i.e. <path>/<soc>-<board>.dtb is retrieved.
  144. If the fdt command is specified, fdtdir is ignored.
  145. localboot <flag> - Run the command defined by "localcmd" in the environment.
  146. <flag> is ignored and is only here to match the syntax of
  147. PXELINUX config files.
  148. Example
  149. -------
  150. Here's a couple of example files to show how this works.
  151. ------------/tftpboot/pxelinux.cfg/menus/base.menu-----------
  152. menu title Linux selections
  153. # This is the default label
  154. label install
  155. menu label Default Install Image
  156. kernel kernels/install.bin
  157. append console=ttyAMA0,38400 debug earlyprintk
  158. initrd initrds/uzInitrdDebInstall
  159. # Just another label
  160. label linux-2.6.38
  161. kernel kernels/linux-2.6.38.bin
  162. append root=/dev/sdb1
  163. # The locally installed kernel
  164. label local
  165. menu label Locally installed kernel
  166. append root=/dev/sdb1
  167. localboot 1
  168. -------------------------------------------------------------
  169. ------------/tftpboot/pxelinux.cfg/default-------------------
  170. menu include pxelinux.cfg/menus/base.menu
  171. timeout 500
  172. default linux-2.6.38
  173. -------------------------------------------------------------
  174. When a pxe client retrieves and boots the default pxe file,
  175. 'pxe boot' will wait for user input for 5 seconds before booting
  176. the linux-2.6.38 label, which will cause /tftpboot/kernels/linux-2.6.38.bin
  177. to be downloaded, and boot with the command line "root=/dev/sdb1"
  178. Differences with PXELINUX
  179. =========================
  180. The biggest difference between U-Boot's pxe and PXELINUX is that since
  181. U-Boot's pxe support is written entirely in C, it can run on any platform
  182. with network support in U-Boot. Here are some other differences between
  183. PXELINUX and U-Boot's pxe support.
  184. - U-Boot's pxe does not support the PXELINUX DHCP option codes specified
  185. in RFC 5071, but could be extended to do so.
  186. - when U-Boot's pxe fails to boot, it will return control to U-Boot,
  187. allowing another command to run, other U-Boot command, instead of resetting
  188. the machine like PXELINUX.
  189. - U-Boot's pxe doesn't rely on or provide an UNDI/PXE stack in memory, it
  190. only uses U-Boot.
  191. - U-Boot's pxe doesn't provide the full menu implementation that PXELINUX
  192. does, only a simple text based menu using the commands described in
  193. this README. With PXELINUX, it's possible to have a graphical boot
  194. menu, submenus, passwords, etc. U-Boot's pxe could be extended to support
  195. a more robust menuing system like that of PXELINUX's.
  196. - U-Boot's pxe expects U-Boot uimg's as kernels. Anything that would work
  197. with the 'bootm' command in U-Boot could work with the 'pxe boot' command.
  198. - U-Boot's pxe only recognizes a single file on the initrd command line. It
  199. could be extended to support multiple.
  200. - in U-Boot's pxe, the localboot command doesn't necessarily cause a local
  201. disk boot - it will do whatever is defined in the 'localcmd' env
  202. variable. And since it doesn't support a full UNDI/PXE stack, the
  203. type field is ignored.
  204. - the interactive prompt in U-Boot's pxe only allows you to choose a label
  205. from the menu. If you want to boot something not listed, you can ctrl+c
  206. out of 'pxe boot' and use existing U-Boot commands to accomplish it.