README.pxe 9.4 KB

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