Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | SPDX-License-Identifier: GPL-2.0+ |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2010-2011 Calxeda, Inc. |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | The 'pxe' commands provide a near subset of the functionality provided by |
Bin Meng | 7557405 | 2016-02-05 19:30:11 -0800 | [diff] [blame] | 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 |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 9 | use. |
| 10 | |
| 11 | Commands |
| 12 | ======== |
| 13 | |
| 14 | pxe 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 | |
| 53 | pxe 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 Song | 9d03275 | 2016-09-01 16:28:22 +0800 | [diff] [blame] | 80 | 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 Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 83 | |
Chander Kashyap | 1644a9d | 2012-09-06 19:36:31 +0000 | [diff] [blame] | 84 | 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 Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 91 | |
Neil Armstrong | c77a1a3 | 2021-01-20 09:54:53 +0100 | [diff] [blame] | 92 | fdtoverlay_addr_r - location in RAM at which 'pxe boot' will temporarily store |
| 93 | fdt overlay(s) before applying them to the fdt blob stored at 'fdt_addr_r'. |
| 94 | |
Amjad Ouled-Ameur | 1d564a9 | 2021-11-13 14:09:20 +0100 | [diff] [blame] | 95 | pxe_label_override - override label to be used, if exists, instead of the |
| 96 | default label. This will allow consumers to choose a pxe label at |
| 97 | runtime instead of having to prompt the user. If "pxe_label_override" is set |
| 98 | but does not exist in the pxe menu, pxe would fallback to the default label if |
| 99 | given, and no failure is returned but rather a warning message. |
| 100 | |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 101 | pxe file format |
| 102 | =============== |
| 103 | The pxe file format is nearly a subset of the PXELINUX file format; see |
| 104 | http://syslinux.zytor.com/wiki/index.php/PXELINUX. It's composed of one line |
| 105 | commands - global commands, and commands specific to labels. Lines begining |
| 106 | with # are treated as comments. White space between and at the beginning of |
| 107 | lines is ignored. |
| 108 | |
| 109 | The size of pxe files and the number of labels is only limited by the amount |
Bin Meng | 7557405 | 2016-02-05 19:30:11 -0800 | [diff] [blame] | 110 | of RAM available to U-Boot. Memory for labels is dynamically allocated as |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 111 | they're parsed, and memory for pxe files is statically allocated, and its |
| 112 | location is given by the pxefile_addr_r environment variable. The pxe code is |
| 113 | not aware of the size of the pxefile memory and will outgrow it if pxe files |
| 114 | are too large. |
| 115 | |
| 116 | Supported global commands |
| 117 | ------------------------- |
| 118 | Unrecognized commands are ignored. |
| 119 | |
Wolfgang Denk | b60c557 | 2011-12-19 12:03:40 +0100 | [diff] [blame] | 120 | default <label> - the label named here is treated as the default and is |
| 121 | the first label 'pxe boot' attempts to boot. |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 122 | |
| 123 | menu title <string> - sets a title for the menu of labels being displayed. |
| 124 | |
| 125 | menu include <path> - use tftp to retrieve the pxe file at <path>, which |
Wolfgang Denk | b60c557 | 2011-12-19 12:03:40 +0100 | [diff] [blame] | 126 | is then immediately parsed as if the start of its |
| 127 | contents were the next line in the current file. nesting |
| 128 | of include up to 16 files deep is supported. |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 129 | |
Wolfgang Denk | b60c557 | 2011-12-19 12:03:40 +0100 | [diff] [blame] | 130 | prompt <flag> - if 1, always prompt the user to enter a label to boot |
| 131 | from. if 0, only prompt the user if timeout expires. |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 132 | |
| 133 | timeout <num> - wait for user input for <num>/10 seconds before |
Wolfgang Denk | b60c557 | 2011-12-19 12:03:40 +0100 | [diff] [blame] | 134 | auto-booting a node. |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 135 | |
Wolfgang Denk | b60c557 | 2011-12-19 12:03:40 +0100 | [diff] [blame] | 136 | label <name> - begin a label definition. labels continue until |
| 137 | a command not recognized as a label command is seen, |
| 138 | or EOF is reached. |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 139 | |
| 140 | Supported label commands |
| 141 | ------------------------ |
| 142 | labels end when a command not recognized as a label command is reached, or EOF. |
| 143 | |
Wolfgang Denk | b60c557 | 2011-12-19 12:03:40 +0100 | [diff] [blame] | 144 | menu default - set this label as the default label to boot; this is |
| 145 | the same behavior as the global default command but |
| 146 | specified in a different way |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 147 | |
Wolfgang Denk | b60c557 | 2011-12-19 12:03:40 +0100 | [diff] [blame] | 148 | kernel <path> - if this label is chosen, use tftp to retrieve the kernel |
Wenbin Song | 9d03275 | 2016-09-01 16:28:22 +0800 | [diff] [blame] | 149 | (or FIT image) at <path>. it will be stored at the address |
| 150 | indicated in the kernel_addr_r environment variable, and |
| 151 | that address will be passed to bootm to boot this kernel. |
Patrick Delaunay | 1d3ffee | 2018-10-02 10:54:48 +0200 | [diff] [blame] | 152 | For FIT image, The configuration specification can be |
| 153 | appended to the file name, with the format: |
| 154 | <path>#<conf>[#<extra-conf[#...]] |
| 155 | It will passed to bootm with that address. |
| 156 | (see: doc/uImage.FIT/command_syntax_extensions.txt) |
| 157 | It useful for overlay selection in pxe file |
| 158 | (see: doc/uImage.FIT/overlay-fdt-boot.txt) |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 159 | |
Neil Armstrong | c77a1a3 | 2021-01-20 09:54:53 +0100 | [diff] [blame] | 160 | fdtoverlays <path> [...] - if this label is chosen, use tftp to retrieve the DT |
| 161 | overlay(s) at <path>. it will be temporarily stored at the |
| 162 | address indicated in the fdtoverlay_addr_r environment variable, |
| 163 | and then applied in the load order to the fdt blob stored at the |
| 164 | address indicated in the fdt_addr_r environment variable. |
| 165 | |
Edoardo Tomelleri | 6acf1b9 | 2022-09-21 15:26:33 +0200 | [diff] [blame] | 166 | devicetree-overlay <path> [...] - if this label is chosen, use tftp to retrieve the DT |
| 167 | overlay(s) at <path>. it will be temporarily stored at the |
| 168 | address indicated in the fdtoverlay_addr_r environment variable, |
| 169 | and then applied in the load order to the fdt blob stored at the |
| 170 | address indicated in the fdt_addr_r environment variable. |
| 171 | Alias for fdtoverlays. |
| 172 | |
Zhang Ning | 9c1d9c5 | 2022-02-01 08:33:37 +0800 | [diff] [blame] | 173 | kaslrseed - set this label to request random number from hwrng as kaslr seed. |
| 174 | |
Wolfgang Denk | b60c557 | 2011-12-19 12:03:40 +0100 | [diff] [blame] | 175 | append <string> - use <string> as the kernel command line when booting this |
| 176 | label. |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 177 | |
Wolfgang Denk | b60c557 | 2011-12-19 12:03:40 +0100 | [diff] [blame] | 178 | initrd <path> - if this label is chosen, use tftp to retrieve the initrd |
| 179 | at <path>. it will be stored at the address indicated in |
| 180 | the initrd_addr_r environment variable, and that address |
| 181 | will be passed to bootm. |
Patrick Delaunay | 41c7e4a | 2022-10-28 11:01:19 +0200 | [diff] [blame] | 182 | For FIT image, the initrd can be provided with the same value than |
| 183 | kernel, including configuration: |
| 184 | <path>#<conf>[#<extra-conf[#...]] |
| 185 | In this case, kernel_addr_r is passed to bootm. |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 186 | |
Chander Kashyap | 1644a9d | 2012-09-06 19:36:31 +0000 | [diff] [blame] | 187 | fdt <path> - if this label is chosen, use tftp to retrieve the fdt blob |
| 188 | at <path>. it will be stored at the address indicated in |
| 189 | the fdt_addr_r environment variable, and that address will |
| 190 | be passed to bootm. |
Patrick Delaunay | 41c7e4a | 2022-10-28 11:01:19 +0200 | [diff] [blame] | 191 | For FIT image, the device tree can be provided with the same value |
| 192 | than kernel, including configuration: |
| 193 | <path>#<conf>[#<extra-conf[#...]] |
| 194 | In this case, kernel_addr_r is passed to bootm. |
Chander Kashyap | 1644a9d | 2012-09-06 19:36:31 +0000 | [diff] [blame] | 195 | |
Edoardo Tomelleri | 6acf1b9 | 2022-09-21 15:26:33 +0200 | [diff] [blame] | 196 | devicetree <path> - if this label is chosen, use tftp to retrieve the fdt blob |
| 197 | at <path>. it will be stored at the address indicated in |
| 198 | the fdt_addr_r environment variable, and that address will |
| 199 | be passed to bootm. Alias for fdt. |
| 200 | |
Stefan Brüns | 3a050ee | 2015-08-30 19:10:58 +0200 | [diff] [blame] | 201 | fdtdir <path> - if this label is chosen, use tftp to retrieve a fdt blob |
| 202 | relative to <path>. If the fdtfile environment variable |
| 203 | is set, <path>/<fdtfile> is retrieved. Otherwise, the |
| 204 | filename is generated from the soc and board environment |
| 205 | variables, i.e. <path>/<soc>-<board>.dtb is retrieved. |
| 206 | If the fdt command is specified, fdtdir is ignored. |
| 207 | |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 208 | localboot <flag> - Run the command defined by "localcmd" in the environment. |
Wolfgang Denk | b60c557 | 2011-12-19 12:03:40 +0100 | [diff] [blame] | 209 | <flag> is ignored and is only here to match the syntax of |
| 210 | PXELINUX config files. |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 211 | |
| 212 | Example |
| 213 | ------- |
| 214 | Here's a couple of example files to show how this works. |
| 215 | |
Stefan Brüns | 22cf6f0 | 2015-08-30 19:10:59 +0200 | [diff] [blame] | 216 | ------------/tftpboot/pxelinux.cfg/menus/base.menu----------- |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 217 | menu title Linux selections |
| 218 | |
| 219 | # This is the default label |
| 220 | label install |
| 221 | menu label Default Install Image |
| 222 | kernel kernels/install.bin |
| 223 | append console=ttyAMA0,38400 debug earlyprintk |
| 224 | initrd initrds/uzInitrdDebInstall |
| 225 | |
| 226 | # Just another label |
| 227 | label linux-2.6.38 |
| 228 | kernel kernels/linux-2.6.38.bin |
| 229 | append root=/dev/sdb1 |
| 230 | |
| 231 | # The locally installed kernel |
| 232 | label local |
| 233 | menu label Locally installed kernel |
| 234 | append root=/dev/sdb1 |
| 235 | localboot 1 |
| 236 | ------------------------------------------------------------- |
| 237 | |
| 238 | ------------/tftpboot/pxelinux.cfg/default------------------- |
| 239 | menu include pxelinux.cfg/menus/base.menu |
| 240 | timeout 500 |
| 241 | |
| 242 | default linux-2.6.38 |
| 243 | ------------------------------------------------------------- |
| 244 | |
| 245 | When a pxe client retrieves and boots the default pxe file, |
| 246 | 'pxe boot' will wait for user input for 5 seconds before booting |
| 247 | the linux-2.6.38 label, which will cause /tftpboot/kernels/linux-2.6.38.bin |
| 248 | to be downloaded, and boot with the command line "root=/dev/sdb1" |
| 249 | |
| 250 | Differences with PXELINUX |
| 251 | ========================= |
Bin Meng | 7557405 | 2016-02-05 19:30:11 -0800 | [diff] [blame] | 252 | The biggest difference between U-Boot's pxe and PXELINUX is that since |
| 253 | U-Boot's pxe support is written entirely in C, it can run on any platform |
| 254 | with network support in U-Boot. Here are some other differences between |
| 255 | PXELINUX and U-Boot's pxe support. |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 256 | |
Bin Meng | 7557405 | 2016-02-05 19:30:11 -0800 | [diff] [blame] | 257 | - U-Boot's pxe does not support the PXELINUX DHCP option codes specified |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 258 | in RFC 5071, but could be extended to do so. |
| 259 | |
Bin Meng | 7557405 | 2016-02-05 19:30:11 -0800 | [diff] [blame] | 260 | - when U-Boot's pxe fails to boot, it will return control to U-Boot, |
| 261 | allowing another command to run, other U-Boot command, instead of resetting |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 262 | the machine like PXELINUX. |
| 263 | |
Bin Meng | 7557405 | 2016-02-05 19:30:11 -0800 | [diff] [blame] | 264 | - U-Boot's pxe doesn't rely on or provide an UNDI/PXE stack in memory, it |
| 265 | only uses U-Boot. |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 266 | |
Bin Meng | 7557405 | 2016-02-05 19:30:11 -0800 | [diff] [blame] | 267 | - U-Boot's pxe doesn't provide the full menu implementation that PXELINUX |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 268 | does, only a simple text based menu using the commands described in |
Wolfgang Denk | b60c557 | 2011-12-19 12:03:40 +0100 | [diff] [blame] | 269 | this README. With PXELINUX, it's possible to have a graphical boot |
Bin Meng | 7557405 | 2016-02-05 19:30:11 -0800 | [diff] [blame] | 270 | menu, submenus, passwords, etc. U-Boot's pxe could be extended to support |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 271 | a more robust menuing system like that of PXELINUX's. |
| 272 | |
Bin Meng | 7557405 | 2016-02-05 19:30:11 -0800 | [diff] [blame] | 273 | - U-Boot's pxe expects U-Boot uimg's as kernels. Anything that would work |
| 274 | with the 'bootm' command in U-Boot could work with the 'pxe boot' command. |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 275 | |
Bin Meng | 7557405 | 2016-02-05 19:30:11 -0800 | [diff] [blame] | 276 | - U-Boot's pxe only recognizes a single file on the initrd command line. It |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 277 | could be extended to support multiple. |
| 278 | |
Bin Meng | 7557405 | 2016-02-05 19:30:11 -0800 | [diff] [blame] | 279 | - in U-Boot's pxe, the localboot command doesn't necessarily cause a local |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 280 | disk boot - it will do whatever is defined in the 'localcmd' env |
| 281 | variable. And since it doesn't support a full UNDI/PXE stack, the |
| 282 | type field is ignored. |
| 283 | |
Bin Meng | 7557405 | 2016-02-05 19:30:11 -0800 | [diff] [blame] | 284 | - the interactive prompt in U-Boot's pxe only allows you to choose a label |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 285 | from the menu. If you want to boot something not listed, you can ctrl+c |
Bin Meng | 7557405 | 2016-02-05 19:30:11 -0800 | [diff] [blame] | 286 | out of 'pxe boot' and use existing U-Boot commands to accomplish it. |