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