blob: 42f913c61feba1b61ccbf46e1c51fe0a34d64fe3 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001SPDX-License-Identifier: GPL-2.0+
Jason Hobbs06283a62011-08-31 10:37:30 -05002/*
3 * Copyright 2010-2011 Calxeda, Inc.
Jason Hobbs06283a62011-08-31 10:37:30 -05004 */
5
6The 'pxe' commands provide a near subset of the functionality provided by
Bin Menga1875592016-02-05 19:30:11 -08007the PXELINUX boot loader. This allows U-Boot based systems to be controlled
8remotely using the same PXE based techniques that many non U-Boot based servers
Jason Hobbs06283a62011-08-31 10:37:30 -05009use.
10
11Commands
12========
13
14pxe get
15-------
16 syntax: pxe get
17
18 follows PXELINUX's rules for retrieving configuration files from a tftp
19 server, and supports a subset of PXELINUX's config file syntax.
20
21 Environment
22 -----------
23 'pxe get' requires two environment variables to be set:
24
25 pxefile_addr_r - should be set to a location in RAM large enough to hold
26 pxe files while they're being processed. Up to 16 config files may be
27 held in memory at once. The exact number and size of the files varies with
28 how the system is being used. A typical config file is a few hundred bytes
29 long.
30
31 bootfile,serverip - these two are typically set in the DHCP response
32 handler, and correspond to fields in the DHCP response.
33
34 'pxe get' optionally supports these two environment variables being set:
35
36 ethaddr - this is the standard MAC address for the ethernet adapter in use.
37 'pxe get' uses it to look for a configuration file specific to a system's
38 MAC address.
39
40 pxeuuid - this is a UUID in standard form using lower case hexadecimal
41 digits, for example, 550e8400-e29b-41d4-a716-446655440000. 'pxe get' uses
42 it to look for a configuration file based on the system's UUID.
43
44 File Paths
45 ----------
46 'pxe get' repeatedly tries to download config files until it either
47 successfully downloads one or runs out of paths to try. The order and
48 contents of paths it tries mirrors exactly that of PXELINUX - you can
49 read in more detail about it at:
50
51 http://syslinux.zytor.com/wiki/index.php/Doc/pxelinux
52
53pxe boot
54--------
55 syntax: pxe boot [pxefile_addr_r]
56
57 Interprets a pxe file stored in memory.
58
59 pxefile_addr_r is an optional argument giving the location of the pxe file.
60 The file must be terminated with a NUL byte.
61
62 Environment
63 -----------
64 There are some environment variables that may need to be set, depending
65 on conditions.
66
67 pxefile_addr_r - if the optional argument pxefile_addr_r is not supplied,
68 an environment variable named pxefile_addr_r must be supplied. This is
69 typically the same value as is used for the 'pxe get' command.
70
71 bootfile - typically set in the DHCP response handler based on the
72 same field in the DHCP respone, this path is used to generate the base
73 directory that all other paths to files retrieved by 'pxe boot' will use.
74 If no bootfile is specified, paths used in pxe files will be used as is.
75
76 serverip - typically set in the DHCP response handler, this is the IP
77 address of the tftp server from which other files will be retrieved.
78
79 kernel_addr_r, initrd_addr_r - locations in RAM at which 'pxe boot' will
Wenbin Songfce78502016-09-01 16:28:22 +080080 store the kernel(or FIT image) and initrd it retrieves from tftp. These
81 locations will be passed to the bootm command to boot the kernel. These
82 environment variables are required to be set.
Jason Hobbs06283a62011-08-31 10:37:30 -050083
Chander Kashyapa6559382012-09-06 19:36:31 +000084 fdt_addr_r - location in RAM at which 'pxe boot' will store the fdt blob it
85 retrieves from tftp. The retrieval is possible if 'fdt' label is defined in
86 pxe file and 'fdt_addr_r' is set. If retrieval is possible, 'fdt_addr_r'
87 will be passed to bootm command to boot the kernel.
88
89 fdt_addr - the location of a fdt blob. 'fdt_addr' will be passed to bootm
90 command if it is set and 'fdt_addr_r' is not passed to bootm command.
Jason Hobbs06283a62011-08-31 10:37:30 -050091
92pxe file format
93===============
94The pxe file format is nearly a subset of the PXELINUX file format; see
95http://syslinux.zytor.com/wiki/index.php/PXELINUX. It's composed of one line
96commands - global commands, and commands specific to labels. Lines begining
97with # are treated as comments. White space between and at the beginning of
98lines is ignored.
99
100The size of pxe files and the number of labels is only limited by the amount
Bin Menga1875592016-02-05 19:30:11 -0800101of RAM available to U-Boot. Memory for labels is dynamically allocated as
Jason Hobbs06283a62011-08-31 10:37:30 -0500102they're parsed, and memory for pxe files is statically allocated, and its
103location is given by the pxefile_addr_r environment variable. The pxe code is
104not aware of the size of the pxefile memory and will outgrow it if pxe files
105are too large.
106
107Supported global commands
108-------------------------
109Unrecognized commands are ignored.
110
Wolfgang Denk6b62b9a2011-12-19 12:03:40 +0100111default <label> - the label named here is treated as the default and is
112 the first label 'pxe boot' attempts to boot.
Jason Hobbs06283a62011-08-31 10:37:30 -0500113
114menu title <string> - sets a title for the menu of labels being displayed.
115
116menu include <path> - use tftp to retrieve the pxe file at <path>, which
Wolfgang Denk6b62b9a2011-12-19 12:03:40 +0100117 is then immediately parsed as if the start of its
118 contents were the next line in the current file. nesting
119 of include up to 16 files deep is supported.
Jason Hobbs06283a62011-08-31 10:37:30 -0500120
Wolfgang Denk6b62b9a2011-12-19 12:03:40 +0100121prompt <flag> - if 1, always prompt the user to enter a label to boot
122 from. if 0, only prompt the user if timeout expires.
Jason Hobbs06283a62011-08-31 10:37:30 -0500123
124timeout <num> - wait for user input for <num>/10 seconds before
Wolfgang Denk6b62b9a2011-12-19 12:03:40 +0100125 auto-booting a node.
Jason Hobbs06283a62011-08-31 10:37:30 -0500126
Wolfgang Denk6b62b9a2011-12-19 12:03:40 +0100127label <name> - begin a label definition. labels continue until
128 a command not recognized as a label command is seen,
129 or EOF is reached.
Jason Hobbs06283a62011-08-31 10:37:30 -0500130
131Supported label commands
132------------------------
133labels end when a command not recognized as a label command is reached, or EOF.
134
Wolfgang Denk6b62b9a2011-12-19 12:03:40 +0100135menu default - set this label as the default label to boot; this is
136 the same behavior as the global default command but
137 specified in a different way
Jason Hobbs06283a62011-08-31 10:37:30 -0500138
Wolfgang Denk6b62b9a2011-12-19 12:03:40 +0100139kernel <path> - if this label is chosen, use tftp to retrieve the kernel
Wenbin Songfce78502016-09-01 16:28:22 +0800140 (or FIT image) at <path>. it will be stored at the address
141 indicated in the kernel_addr_r environment variable, and
142 that address will be passed to bootm to boot this kernel.
Patrick Delaunay20230002018-10-02 10:54:48 +0200143 For FIT image, The configuration specification can be
144 appended to the file name, with the format:
145 <path>#<conf>[#<extra-conf[#...]]
146 It will passed to bootm with that address.
147 (see: doc/uImage.FIT/command_syntax_extensions.txt)
148 It useful for overlay selection in pxe file
149 (see: doc/uImage.FIT/overlay-fdt-boot.txt)
Jason Hobbs06283a62011-08-31 10:37:30 -0500150
Wolfgang Denk6b62b9a2011-12-19 12:03:40 +0100151append <string> - use <string> as the kernel command line when booting this
152 label.
Jason Hobbs06283a62011-08-31 10:37:30 -0500153
Wolfgang Denk6b62b9a2011-12-19 12:03:40 +0100154initrd <path> - if this label is chosen, use tftp to retrieve the initrd
155 at <path>. it will be stored at the address indicated in
156 the initrd_addr_r environment variable, and that address
157 will be passed to bootm.
Jason Hobbs06283a62011-08-31 10:37:30 -0500158
Chander Kashyapa6559382012-09-06 19:36:31 +0000159fdt <path> - if this label is chosen, use tftp to retrieve the fdt blob
160 at <path>. it will be stored at the address indicated in
161 the fdt_addr_r environment variable, and that address will
162 be passed to bootm.
163
Stefan Brüns6015f8f2015-08-30 19:10:58 +0200164fdtdir <path> - if this label is chosen, use tftp to retrieve a fdt blob
165 relative to <path>. If the fdtfile environment variable
166 is set, <path>/<fdtfile> is retrieved. Otherwise, the
167 filename is generated from the soc and board environment
168 variables, i.e. <path>/<soc>-<board>.dtb is retrieved.
169 If the fdt command is specified, fdtdir is ignored.
170
Jason Hobbs06283a62011-08-31 10:37:30 -0500171localboot <flag> - Run the command defined by "localcmd" in the environment.
Wolfgang Denk6b62b9a2011-12-19 12:03:40 +0100172 <flag> is ignored and is only here to match the syntax of
173 PXELINUX config files.
Jason Hobbs06283a62011-08-31 10:37:30 -0500174
175Example
176-------
177Here's a couple of example files to show how this works.
178
Stefan Brüns695c1322015-08-30 19:10:59 +0200179------------/tftpboot/pxelinux.cfg/menus/base.menu-----------
Jason Hobbs06283a62011-08-31 10:37:30 -0500180menu title Linux selections
181
182# This is the default label
183label install
184 menu label Default Install Image
185 kernel kernels/install.bin
186 append console=ttyAMA0,38400 debug earlyprintk
187 initrd initrds/uzInitrdDebInstall
188
189# Just another label
190label linux-2.6.38
191 kernel kernels/linux-2.6.38.bin
192 append root=/dev/sdb1
193
194# The locally installed kernel
195label local
196 menu label Locally installed kernel
197 append root=/dev/sdb1
198 localboot 1
199-------------------------------------------------------------
200
201------------/tftpboot/pxelinux.cfg/default-------------------
202menu include pxelinux.cfg/menus/base.menu
203timeout 500
204
205default linux-2.6.38
206-------------------------------------------------------------
207
208When a pxe client retrieves and boots the default pxe file,
209'pxe boot' will wait for user input for 5 seconds before booting
210the linux-2.6.38 label, which will cause /tftpboot/kernels/linux-2.6.38.bin
211to be downloaded, and boot with the command line "root=/dev/sdb1"
212
213Differences with PXELINUX
214=========================
Bin Menga1875592016-02-05 19:30:11 -0800215The biggest difference between U-Boot's pxe and PXELINUX is that since
216U-Boot's pxe support is written entirely in C, it can run on any platform
217with network support in U-Boot. Here are some other differences between
218PXELINUX and U-Boot's pxe support.
Jason Hobbs06283a62011-08-31 10:37:30 -0500219
Bin Menga1875592016-02-05 19:30:11 -0800220- U-Boot's pxe does not support the PXELINUX DHCP option codes specified
Jason Hobbs06283a62011-08-31 10:37:30 -0500221 in RFC 5071, but could be extended to do so.
222
Bin Menga1875592016-02-05 19:30:11 -0800223- when U-Boot's pxe fails to boot, it will return control to U-Boot,
224 allowing another command to run, other U-Boot command, instead of resetting
Jason Hobbs06283a62011-08-31 10:37:30 -0500225 the machine like PXELINUX.
226
Bin Menga1875592016-02-05 19:30:11 -0800227- U-Boot's pxe doesn't rely on or provide an UNDI/PXE stack in memory, it
228 only uses U-Boot.
Jason Hobbs06283a62011-08-31 10:37:30 -0500229
Bin Menga1875592016-02-05 19:30:11 -0800230- U-Boot's pxe doesn't provide the full menu implementation that PXELINUX
Jason Hobbs06283a62011-08-31 10:37:30 -0500231 does, only a simple text based menu using the commands described in
Wolfgang Denk6b62b9a2011-12-19 12:03:40 +0100232 this README. With PXELINUX, it's possible to have a graphical boot
Bin Menga1875592016-02-05 19:30:11 -0800233 menu, submenus, passwords, etc. U-Boot's pxe could be extended to support
Jason Hobbs06283a62011-08-31 10:37:30 -0500234 a more robust menuing system like that of PXELINUX's.
235
Bin Menga1875592016-02-05 19:30:11 -0800236- U-Boot's pxe expects U-Boot uimg's as kernels. Anything that would work
237 with the 'bootm' command in U-Boot could work with the 'pxe boot' command.
Jason Hobbs06283a62011-08-31 10:37:30 -0500238
Bin Menga1875592016-02-05 19:30:11 -0800239- U-Boot's pxe only recognizes a single file on the initrd command line. It
Jason Hobbs06283a62011-08-31 10:37:30 -0500240 could be extended to support multiple.
241
Bin Menga1875592016-02-05 19:30:11 -0800242- in U-Boot's pxe, the localboot command doesn't necessarily cause a local
Jason Hobbs06283a62011-08-31 10:37:30 -0500243 disk boot - it will do whatever is defined in the 'localcmd' env
244 variable. And since it doesn't support a full UNDI/PXE stack, the
245 type field is ignored.
246
Bin Menga1875592016-02-05 19:30:11 -0800247- the interactive prompt in U-Boot's pxe only allows you to choose a label
Jason Hobbs06283a62011-08-31 10:37:30 -0500248 from the menu. If you want to boot something not listed, you can ctrl+c
Bin Menga1875592016-02-05 19:30:11 -0800249 out of 'pxe boot' and use existing U-Boot commands to accomplish it.