README.pxe 9.3 KB

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