183d290c5STom RiniSPDX-License-Identifier: GPL-2.0+ 206283a64SJason Hobbs/* 306283a64SJason Hobbs * Copyright 2010-2011 Calxeda, Inc. 406283a64SJason Hobbs */ 506283a64SJason Hobbs 606283a64SJason HobbsThe 'pxe' commands provide a near subset of the functionality provided by 7a187559eSBin Mengthe PXELINUX boot loader. This allows U-Boot based systems to be controlled 8a187559eSBin Mengremotely using the same PXE based techniques that many non U-Boot based servers 906283a64SJason Hobbsuse. 1006283a64SJason Hobbs 1106283a64SJason HobbsCommands 1206283a64SJason Hobbs======== 1306283a64SJason Hobbs 1406283a64SJason Hobbspxe get 1506283a64SJason Hobbs------- 1606283a64SJason Hobbs syntax: pxe get 1706283a64SJason Hobbs 1806283a64SJason Hobbs follows PXELINUX's rules for retrieving configuration files from a tftp 1906283a64SJason Hobbs server, and supports a subset of PXELINUX's config file syntax. 2006283a64SJason Hobbs 2106283a64SJason Hobbs Environment 2206283a64SJason Hobbs ----------- 2306283a64SJason Hobbs 'pxe get' requires two environment variables to be set: 2406283a64SJason Hobbs 2506283a64SJason Hobbs pxefile_addr_r - should be set to a location in RAM large enough to hold 2606283a64SJason Hobbs pxe files while they're being processed. Up to 16 config files may be 2706283a64SJason Hobbs held in memory at once. The exact number and size of the files varies with 2806283a64SJason Hobbs how the system is being used. A typical config file is a few hundred bytes 2906283a64SJason Hobbs long. 3006283a64SJason Hobbs 3106283a64SJason Hobbs bootfile,serverip - these two are typically set in the DHCP response 3206283a64SJason Hobbs handler, and correspond to fields in the DHCP response. 3306283a64SJason Hobbs 3406283a64SJason Hobbs 'pxe get' optionally supports these two environment variables being set: 3506283a64SJason Hobbs 3606283a64SJason Hobbs ethaddr - this is the standard MAC address for the ethernet adapter in use. 3706283a64SJason Hobbs 'pxe get' uses it to look for a configuration file specific to a system's 3806283a64SJason Hobbs MAC address. 3906283a64SJason Hobbs 4006283a64SJason Hobbs pxeuuid - this is a UUID in standard form using lower case hexadecimal 4106283a64SJason Hobbs digits, for example, 550e8400-e29b-41d4-a716-446655440000. 'pxe get' uses 4206283a64SJason Hobbs it to look for a configuration file based on the system's UUID. 4306283a64SJason Hobbs 4406283a64SJason Hobbs File Paths 4506283a64SJason Hobbs ---------- 4606283a64SJason Hobbs 'pxe get' repeatedly tries to download config files until it either 4706283a64SJason Hobbs successfully downloads one or runs out of paths to try. The order and 4806283a64SJason Hobbs contents of paths it tries mirrors exactly that of PXELINUX - you can 4906283a64SJason Hobbs read in more detail about it at: 5006283a64SJason Hobbs 5106283a64SJason Hobbs http://syslinux.zytor.com/wiki/index.php/Doc/pxelinux 5206283a64SJason Hobbs 5306283a64SJason Hobbspxe boot 5406283a64SJason Hobbs-------- 5506283a64SJason Hobbs syntax: pxe boot [pxefile_addr_r] 5606283a64SJason Hobbs 5706283a64SJason Hobbs Interprets a pxe file stored in memory. 5806283a64SJason Hobbs 5906283a64SJason Hobbs pxefile_addr_r is an optional argument giving the location of the pxe file. 6006283a64SJason Hobbs The file must be terminated with a NUL byte. 6106283a64SJason Hobbs 6206283a64SJason Hobbs Environment 6306283a64SJason Hobbs ----------- 6406283a64SJason Hobbs There are some environment variables that may need to be set, depending 6506283a64SJason Hobbs on conditions. 6606283a64SJason Hobbs 6706283a64SJason Hobbs pxefile_addr_r - if the optional argument pxefile_addr_r is not supplied, 6806283a64SJason Hobbs an environment variable named pxefile_addr_r must be supplied. This is 6906283a64SJason Hobbs typically the same value as is used for the 'pxe get' command. 7006283a64SJason Hobbs 7106283a64SJason Hobbs bootfile - typically set in the DHCP response handler based on the 7206283a64SJason Hobbs same field in the DHCP respone, this path is used to generate the base 7306283a64SJason Hobbs directory that all other paths to files retrieved by 'pxe boot' will use. 7406283a64SJason Hobbs If no bootfile is specified, paths used in pxe files will be used as is. 7506283a64SJason Hobbs 7606283a64SJason Hobbs serverip - typically set in the DHCP response handler, this is the IP 7706283a64SJason Hobbs address of the tftp server from which other files will be retrieved. 7806283a64SJason Hobbs 7906283a64SJason Hobbs kernel_addr_r, initrd_addr_r - locations in RAM at which 'pxe boot' will 80fce78503SWenbin Song store the kernel(or FIT image) and initrd it retrieves from tftp. These 81fce78503SWenbin Song locations will be passed to the bootm command to boot the kernel. These 82fce78503SWenbin Song environment variables are required to be set. 8306283a64SJason Hobbs 84a655938aSChander Kashyap fdt_addr_r - location in RAM at which 'pxe boot' will store the fdt blob it 85a655938aSChander Kashyap retrieves from tftp. The retrieval is possible if 'fdt' label is defined in 86a655938aSChander Kashyap pxe file and 'fdt_addr_r' is set. If retrieval is possible, 'fdt_addr_r' 87a655938aSChander Kashyap will be passed to bootm command to boot the kernel. 88a655938aSChander Kashyap 89a655938aSChander Kashyap fdt_addr - the location of a fdt blob. 'fdt_addr' will be passed to bootm 90a655938aSChander Kashyap command if it is set and 'fdt_addr_r' is not passed to bootm command. 9106283a64SJason Hobbs 9206283a64SJason Hobbspxe file format 9306283a64SJason Hobbs=============== 9406283a64SJason HobbsThe pxe file format is nearly a subset of the PXELINUX file format; see 9506283a64SJason Hobbshttp://syslinux.zytor.com/wiki/index.php/PXELINUX. It's composed of one line 9606283a64SJason Hobbscommands - global commands, and commands specific to labels. Lines begining 9706283a64SJason Hobbswith # are treated as comments. White space between and at the beginning of 9806283a64SJason Hobbslines is ignored. 9906283a64SJason Hobbs 10006283a64SJason HobbsThe size of pxe files and the number of labels is only limited by the amount 101a187559eSBin Mengof RAM available to U-Boot. Memory for labels is dynamically allocated as 10206283a64SJason Hobbsthey're parsed, and memory for pxe files is statically allocated, and its 10306283a64SJason Hobbslocation is given by the pxefile_addr_r environment variable. The pxe code is 10406283a64SJason Hobbsnot aware of the size of the pxefile memory and will outgrow it if pxe files 10506283a64SJason Hobbsare too large. 10606283a64SJason Hobbs 10706283a64SJason HobbsSupported global commands 10806283a64SJason Hobbs------------------------- 10906283a64SJason HobbsUnrecognized commands are ignored. 11006283a64SJason Hobbs 11106283a64SJason Hobbsdefault <label> - the label named here is treated as the default and is 11206283a64SJason Hobbs the first label 'pxe boot' attempts to boot. 11306283a64SJason Hobbs 11406283a64SJason Hobbsmenu title <string> - sets a title for the menu of labels being displayed. 11506283a64SJason Hobbs 11606283a64SJason Hobbsmenu include <path> - use tftp to retrieve the pxe file at <path>, which 11706283a64SJason Hobbs is then immediately parsed as if the start of its 11806283a64SJason Hobbs contents were the next line in the current file. nesting 11906283a64SJason Hobbs of include up to 16 files deep is supported. 12006283a64SJason Hobbs 12106283a64SJason Hobbsprompt <flag> - if 1, always prompt the user to enter a label to boot 12206283a64SJason Hobbs from. if 0, only prompt the user if timeout expires. 12306283a64SJason Hobbs 12406283a64SJason Hobbstimeout <num> - wait for user input for <num>/10 seconds before 12506283a64SJason Hobbs auto-booting a node. 12606283a64SJason Hobbs 12706283a64SJason Hobbslabel <name> - begin a label definition. labels continue until 12806283a64SJason Hobbs a command not recognized as a label command is seen, 12906283a64SJason Hobbs or EOF is reached. 13006283a64SJason Hobbs 13106283a64SJason HobbsSupported label commands 13206283a64SJason Hobbs------------------------ 13306283a64SJason Hobbslabels end when a command not recognized as a label command is reached, or EOF. 13406283a64SJason Hobbs 13506283a64SJason Hobbsmenu default - set this label as the default label to boot; this is 13606283a64SJason Hobbs the same behavior as the global default command but 13706283a64SJason Hobbs specified in a different way 13806283a64SJason Hobbs 13906283a64SJason Hobbskernel <path> - if this label is chosen, use tftp to retrieve the kernel 140fce78503SWenbin Song (or FIT image) at <path>. it will be stored at the address 141fce78503SWenbin Song indicated in the kernel_addr_r environment variable, and 142fce78503SWenbin Song that address will be passed to bootm to boot this kernel. 143*2023000aSPatrick Delaunay For FIT image, The configuration specification can be 144*2023000aSPatrick Delaunay appended to the file name, with the format: 145*2023000aSPatrick Delaunay <path>#<conf>[#<extra-conf[#...]] 146*2023000aSPatrick Delaunay It will passed to bootm with that address. 147*2023000aSPatrick Delaunay (see: doc/uImage.FIT/command_syntax_extensions.txt) 148*2023000aSPatrick Delaunay It useful for overlay selection in pxe file 149*2023000aSPatrick Delaunay (see: doc/uImage.FIT/overlay-fdt-boot.txt) 15006283a64SJason Hobbs 15106283a64SJason Hobbsappend <string> - use <string> as the kernel command line when booting this 15206283a64SJason Hobbs label. 15306283a64SJason Hobbs 15406283a64SJason Hobbsinitrd <path> - if this label is chosen, use tftp to retrieve the initrd 15506283a64SJason Hobbs at <path>. it will be stored at the address indicated in 15606283a64SJason Hobbs the initrd_addr_r environment variable, and that address 15706283a64SJason Hobbs will be passed to bootm. 15806283a64SJason Hobbs 159a655938aSChander Kashyapfdt <path> - if this label is chosen, use tftp to retrieve the fdt blob 160a655938aSChander Kashyap at <path>. it will be stored at the address indicated in 161a655938aSChander Kashyap the fdt_addr_r environment variable, and that address will 162a655938aSChander Kashyap be passed to bootm. 163a655938aSChander Kashyap 1646015f8f1SStefan Brünsfdtdir <path> - if this label is chosen, use tftp to retrieve a fdt blob 1656015f8f1SStefan Brüns relative to <path>. If the fdtfile environment variable 1666015f8f1SStefan Brüns is set, <path>/<fdtfile> is retrieved. Otherwise, the 1676015f8f1SStefan Brüns filename is generated from the soc and board environment 1686015f8f1SStefan Brüns variables, i.e. <path>/<soc>-<board>.dtb is retrieved. 1696015f8f1SStefan Brüns If the fdt command is specified, fdtdir is ignored. 1706015f8f1SStefan Brüns 17106283a64SJason Hobbslocalboot <flag> - Run the command defined by "localcmd" in the environment. 17206283a64SJason Hobbs <flag> is ignored and is only here to match the syntax of 17306283a64SJason Hobbs PXELINUX config files. 17406283a64SJason Hobbs 17506283a64SJason HobbsExample 17606283a64SJason Hobbs------- 17706283a64SJason HobbsHere's a couple of example files to show how this works. 17806283a64SJason Hobbs 179695c1329SStefan Brüns------------/tftpboot/pxelinux.cfg/menus/base.menu----------- 18006283a64SJason Hobbsmenu title Linux selections 18106283a64SJason Hobbs 18206283a64SJason Hobbs# This is the default label 18306283a64SJason Hobbslabel install 18406283a64SJason Hobbs menu label Default Install Image 18506283a64SJason Hobbs kernel kernels/install.bin 18606283a64SJason Hobbs append console=ttyAMA0,38400 debug earlyprintk 18706283a64SJason Hobbs initrd initrds/uzInitrdDebInstall 18806283a64SJason Hobbs 18906283a64SJason Hobbs# Just another label 19006283a64SJason Hobbslabel linux-2.6.38 19106283a64SJason Hobbs kernel kernels/linux-2.6.38.bin 19206283a64SJason Hobbs append root=/dev/sdb1 19306283a64SJason Hobbs 19406283a64SJason Hobbs# The locally installed kernel 19506283a64SJason Hobbslabel local 19606283a64SJason Hobbs menu label Locally installed kernel 19706283a64SJason Hobbs append root=/dev/sdb1 19806283a64SJason Hobbs localboot 1 19906283a64SJason Hobbs------------------------------------------------------------- 20006283a64SJason Hobbs 20106283a64SJason Hobbs------------/tftpboot/pxelinux.cfg/default------------------- 20206283a64SJason Hobbsmenu include pxelinux.cfg/menus/base.menu 20306283a64SJason Hobbstimeout 500 20406283a64SJason Hobbs 20506283a64SJason Hobbsdefault linux-2.6.38 20606283a64SJason Hobbs------------------------------------------------------------- 20706283a64SJason Hobbs 20806283a64SJason HobbsWhen a pxe client retrieves and boots the default pxe file, 20906283a64SJason Hobbs'pxe boot' will wait for user input for 5 seconds before booting 21006283a64SJason Hobbsthe linux-2.6.38 label, which will cause /tftpboot/kernels/linux-2.6.38.bin 21106283a64SJason Hobbsto be downloaded, and boot with the command line "root=/dev/sdb1" 21206283a64SJason Hobbs 21306283a64SJason HobbsDifferences with PXELINUX 21406283a64SJason Hobbs========================= 215a187559eSBin MengThe biggest difference between U-Boot's pxe and PXELINUX is that since 216a187559eSBin MengU-Boot's pxe support is written entirely in C, it can run on any platform 217a187559eSBin Mengwith network support in U-Boot. Here are some other differences between 218a187559eSBin MengPXELINUX and U-Boot's pxe support. 21906283a64SJason Hobbs 220a187559eSBin Meng- U-Boot's pxe does not support the PXELINUX DHCP option codes specified 22106283a64SJason Hobbs in RFC 5071, but could be extended to do so. 22206283a64SJason Hobbs 223a187559eSBin Meng- when U-Boot's pxe fails to boot, it will return control to U-Boot, 224a187559eSBin Meng allowing another command to run, other U-Boot command, instead of resetting 22506283a64SJason Hobbs the machine like PXELINUX. 22606283a64SJason Hobbs 227a187559eSBin Meng- U-Boot's pxe doesn't rely on or provide an UNDI/PXE stack in memory, it 228a187559eSBin Meng only uses U-Boot. 22906283a64SJason Hobbs 230a187559eSBin Meng- U-Boot's pxe doesn't provide the full menu implementation that PXELINUX 23106283a64SJason Hobbs does, only a simple text based menu using the commands described in 23206283a64SJason Hobbs this README. With PXELINUX, it's possible to have a graphical boot 233a187559eSBin Meng menu, submenus, passwords, etc. U-Boot's pxe could be extended to support 23406283a64SJason Hobbs a more robust menuing system like that of PXELINUX's. 23506283a64SJason Hobbs 236a187559eSBin Meng- U-Boot's pxe expects U-Boot uimg's as kernels. Anything that would work 237a187559eSBin Meng with the 'bootm' command in U-Boot could work with the 'pxe boot' command. 23806283a64SJason Hobbs 239a187559eSBin Meng- U-Boot's pxe only recognizes a single file on the initrd command line. It 24006283a64SJason Hobbs could be extended to support multiple. 24106283a64SJason Hobbs 242a187559eSBin Meng- in U-Boot's pxe, the localboot command doesn't necessarily cause a local 24306283a64SJason Hobbs disk boot - it will do whatever is defined in the 'localcmd' env 24406283a64SJason Hobbs variable. And since it doesn't support a full UNDI/PXE stack, the 24506283a64SJason Hobbs type field is ignored. 24606283a64SJason Hobbs 247a187559eSBin Meng- the interactive prompt in U-Boot's pxe only allows you to choose a label 24806283a64SJason Hobbs from the menu. If you want to boot something not listed, you can ctrl+c 249a187559eSBin Meng out of 'pxe boot' and use existing U-Boot commands to accomplish it. 250