blob: 0113a3d4ec4ade4e5725721f27279bf15c285f6f [file] [log] [blame]
Simon Glass37c51952021-10-14 12:48:10 -06001.. SPDX-License-Identifier: GPL-2.0+
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -07002
3Generic Distro Configuration Concept
4====================================
5
6Linux distributions are faced with supporting a variety of boot mechanisms,
7environments or bootloaders (PC BIOS, EFI, U-Boot, Barebox, ...). This makes
8life complicated. Worse, bootloaders such as U-Boot have a configurable set
9of features, and each board chooses to enable a different set of features.
10Hence, distros typically need to have board-specific knowledge in order to
11set up a bootable system.
12
13This document defines a common set of U-Boot features that are required for
14a distro to support the board in a generic fashion. Any board wishing to
15allow distros to install and boot in an out-of-the-box fashion should enable
16all these features. Linux distros can then create a single set of boot
17support/install logic that targets these features. This will allow distros
18to install on many boards without the need for board-specific logic.
19
20In fact, some of these features can be implemented by any bootloader, thus
21decoupling distro install/boot logic from any knowledge of the bootloader.
22
23This model assumes that boards will load boot configuration files from a
24regular storage mechanism (eMMC, SD card, USB Disk, SATA disk, etc.) with
Masahiro Yamada28fd00b2015-07-07 18:47:17 +090025a standard partitioning scheme (MBR, GPT). Boards that cannot support this
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -070026storage model are outside the scope of this document, and may still need
27board-specific installer/boot-configuration support in a distro.
28
29To some extent, this model assumes that a board has a separate boot flash
30that contains U-Boot, and that the user has somehow installed U-Boot to this
31flash before running the distro installer. Even on boards that do not conform
32to this aspect of the model, the extent of the board-specific support in the
33distro installer logic would be to install a board-specific U-Boot package to
Masahiro Yamada28fd00b2015-07-07 18:47:17 +090034the boot partition during installation. This distro-supplied U-Boot can still
35implement the same features as on any other board, and hence the distro's boot
36configuration file generation logic can still be board-agnostic.
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -070037
38Locating Bootable Disks
39-----------------------
40
41Typical desktop/server PCs search all (or a user-defined subset of) attached
42storage devices for a bootable partition, then load the bootloader or boot
43configuration files from there. A U-Boot board port that enables the features
44mentioned in this document will search for boot configuration files in the
45same way.
46
47Thus, distros do not need to manipulate any kind of bootloader-specific
48configuration data to indicate which storage device the system should boot
49from.
50
51Distros simply need to install the boot configuration files (see next
52section) in an ext2/3/4 or FAT partition, mark the partition bootable (via
53the MBR bootable flag, or GPT legacy_bios_bootable attribute), and U-Boot (or
54any other bootloader) will find those boot files and execute them. This is
55conceptually identical to creating a grub2 configuration file on a desktop
56PC.
57
Masahiro Yamada28fd00b2015-07-07 18:47:17 +090058Note that in the absence of any partition that is explicitly marked bootable,
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -070059U-Boot falls back to searching the first valid partition of a disk for boot
60configuration files. Other bootloaders are recommended to do the same, since
61I believe that partition table bootable flags aren't so commonly used outside
62the realm of x86 PCs.
63
64U-Boot can also search for boot configuration files from a TFTP server.
65
66Boot Configuration Files
67------------------------
68
69The standard format for boot configuration files is that of extlinux.conf, as
70handled by U-Boot's "syslinux" (disk) or "pxe boot" (network). This is roughly
Simon Glass37c51952021-10-14 12:48:10 -060071as specified at BootLoaderSpec_:
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -070072
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -070073
74... with the exceptions that the BootLoaderSpec document:
75
76* Prescribes a separate configuration per boot menu option, whereas U-Boot
77 lumps all options into a single extlinux.conf file. Hence, U-Boot searches
78 for /extlinux/extlinux.conf then /boot/extlinux/extlinux.conf on disk, or
79 pxelinux.cfg/default over the network.
80
81* Does not document the fdtdir option, which automatically selects the DTB to
82 pass to the kernel.
83
Simon Glass37c51952021-10-14 12:48:10 -060084One example extlinux.conf generated by the Fedora installer is::
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -070085
Simon Glass37c51952021-10-14 12:48:10 -060086 # extlinux.conf generated by anaconda
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -070087
Simon Glass37c51952021-10-14 12:48:10 -060088 ui menu.c32
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -070089
Simon Glass37c51952021-10-14 12:48:10 -060090 menu autoboot Welcome to Fedora. Automatic boot in # second{,s}. Press a key for options.
91 menu title Fedora Boot Options.
92 menu hidden
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -070093
Simon Glass37c51952021-10-14 12:48:10 -060094 timeout 50
95 #totaltimeout 9000
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -070096
Simon Glass37c51952021-10-14 12:48:10 -060097 default Fedora (3.17.0-0.rc4.git2.1.fc22.armv7hl+lpae) 22 (Rawhide)
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -070098
Simon Glass37c51952021-10-14 12:48:10 -060099 label Fedora (3.17.0-0.rc4.git2.1.fc22.armv7hl) 22 (Rawhide)
100 kernel /boot/vmlinuz-3.17.0-0.rc4.git2.1.fc22.armv7hl
101 append ro root=UUID=8eac677f-8ea8-4270-8479-d5ddbb797450 console=ttyS0,115200n8 LANG=en_US.UTF-8 drm.debug=0xf
102 fdtdir /boot/dtb-3.17.0-0.rc4.git2.1.fc22.armv7hl
103 initrd /boot/initramfs-3.17.0-0.rc4.git2.1.fc22.armv7hl.img
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -0700104
Simon Glass37c51952021-10-14 12:48:10 -0600105 label Fedora (3.17.0-0.rc4.git2.1.fc22.armv7hl+lpae) 22 (Rawhide)
106 kernel /boot/vmlinuz-3.17.0-0.rc4.git2.1.fc22.armv7hl+lpae
107 append ro root=UUID=8eac677f-8ea8-4270-8479-d5ddbb797450 console=ttyS0,115200n8 LANG=en_US.UTF-8 drm.debug=0xf
108 fdtdir /boot/dtb-3.17.0-0.rc4.git2.1.fc22.armv7hl+lpae
109 initrd /boot/initramfs-3.17.0-0.rc4.git2.1.fc22.armv7hl+lpae.img
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -0700110
Simon Glass37c51952021-10-14 12:48:10 -0600111 label Fedora-0-rescue-8f6ba7b039524e0eb957d2c9203f04bc (0-rescue-8f6ba7b039524e0eb957d2c9203f04bc)
112 kernel /boot/vmlinuz-0-rescue-8f6ba7b039524e0eb957d2c9203f04bc
113 initrd /boot/initramfs-0-rescue-8f6ba7b039524e0eb957d2c9203f04bc.img
114 append ro root=UUID=8eac677f-8ea8-4270-8479-d5ddbb797450 console=ttyS0,115200n8
115 fdtdir /boot/dtb-3.16.0-0.rc6.git1.1.fc22.armv7hl+lpae
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -0700116
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -0700117
Simon Glass37c51952021-10-14 12:48:10 -0600118Another hand-crafted network boot configuration file is::
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -0700119
Simon Glass37c51952021-10-14 12:48:10 -0600120 TIMEOUT 100
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -0700121
Simon Glass37c51952021-10-14 12:48:10 -0600122 MENU TITLE TFTP boot options
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -0700123
Simon Glass37c51952021-10-14 12:48:10 -0600124 LABEL jetson-tk1-emmc
125 MENU LABEL ../zImage root on Jetson TK1 eMMC
126 LINUX ../zImage
127 FDTDIR ../
128 APPEND console=ttyS0,115200n8 console=tty1 loglevel=8 rootwait rw earlyprintk root=PARTUUID=80a5a8e9-c744-491a-93c1-4f4194fd690b
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -0700129
Simon Glass37c51952021-10-14 12:48:10 -0600130 LABEL venice2-emmc
131 MENU LABEL ../zImage root on Venice2 eMMC
132 LINUX ../zImage
133 FDTDIR ../
134 APPEND console=ttyS0,115200n8 console=tty1 loglevel=8 rootwait rw earlyprintk root=PARTUUID=5f71e06f-be08-48ed-b1ef-ee4800cc860f
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -0700135
Simon Glass37c51952021-10-14 12:48:10 -0600136 LABEL sdcard
137 MENU LABEL ../zImage, root on 2GB sdcard
138 LINUX ../zImage
139 FDTDIR ../
140 APPEND console=ttyS0,115200n8 console=tty1 loglevel=8 rootwait rw earlyprintk root=PARTUUID=b2f82cda-2535-4779-b467-094a210fbae7
141
142 LABEL fedora-installer-fk
143 MENU LABEL Fedora installer w/ Fedora kernel
144 LINUX fedora-installer/vmlinuz
145 INITRD fedora-installer/initrd.img.orig
146 FDTDIR fedora-installer/dtb
147 APPEND loglevel=8 ip=dhcp inst.repo=http://10.0.0.2/mirrors/fedora/linux/development/rawhide/armhfp/os/ rd.shell cma=64M
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -0700148
149U-Boot Implementation
150=====================
151
152Enabling the distro options
153---------------------------
154
Hans de Goede9f823612016-06-20 23:16:28 +0200155In your board's defconfig, enable the DISTRO_DEFAULTS option by adding
156a line with "CONFIG_DISTRO_DEFAULTS=y". If you want to enable this
157from Kconfig itself, for e.g. all boards using a specific SoC then
Masahiro Yamada7325f6c2018-04-25 18:47:52 +0900158add a "imply DISTRO_DEFAULTS" to your SoC CONFIG option.
Hans de Goede9f823612016-06-20 23:16:28 +0200159
Simon Glass37c51952021-10-14 12:48:10 -0600160In your board configuration file, include the following::
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -0700161
Simon Glass37c51952021-10-14 12:48:10 -0600162 #ifndef CONFIG_SPL_BUILD
163 #include <config_distro_bootcmd.h>
164 #endif
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -0700165
166The first of those headers primarily enables a core set of U-Boot features,
167such as support for MBR and GPT partitions, ext* and FAT filesystems, booting
168raw zImage and initrd (rather than FIT- or uImage-wrapped files), etc. Network
169boot support is also enabled here, which is useful in order to boot distro
170installers given that distros do not commonly distribute bootable install
171media for non-PC targets at present.
172
173Finally, a few options that are mostly relevant only when using U-Boot-
174specific boot.scr scripts are enabled. This enables distros to generate a
175U-Boot-specific boot.scr script rather than extlinux.conf as the boot
176configuration file. While doing so is fully supported, and
Adam Fordba8bf942018-02-06 07:49:32 -0600177CONFIG_DISTRO_DEFAULTS exposes enough parameterization to boot.scr to
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -0700178allow for board-agnostic boot.scr content, this document recommends that
179distros generate extlinux.conf rather than boot.scr. extlinux.conf is intended
180to work across multiple bootloaders, whereas boot.scr will only work with
181U-Boot. TODO: document the contract between U-Boot and boot.scr re: which
182environment variables a generic boot.scr may rely upon.
183
184The second of those headers sets up the default environment so that $bootcmd
185is defined in a way that searches attached disks for boot configuration files,
186and executes them if found.
187
188Required Environment Variables
189------------------------------
190
191The U-Boot "syslinux" and "pxe boot" commands require a number of environment
192variables be set. Default values for these variables are often hard-coded into
193CONFIG_EXTRA_ENV_SETTINGS in the board's U-Boot configuration file, so that
194the user doesn't have to configure them.
195
196fdt_addr:
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -0700197 Mandatory for any system that provides the DTB in HW (e.g. ROM) and wishes
198 to pass that DTB to Linux, rather than loading a DTB from the boot
199 filesystem. Prohibited for any other system.
200
201 If specified a DTB to boot the system must be available at the given
202 address.
203
204fdt_addr_r:
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -0700205 Mandatory. The location in RAM where the DTB will be loaded or copied to when
206 processing the fdtdir/devicetreedir or fdt/devicetree options in
207 extlinux.conf.
208
209 This is mandatory even when fdt_addr is provided, since extlinux.conf must
210 always be able to provide a DTB which overrides any copy provided by the HW.
211
212 A size of 1MB for the FDT/DTB seems reasonable.
213
Dennis Gilmore74f89772020-09-11 11:56:59 -0500214fdtfile:
Dennis Gilmore74f89772020-09-11 11:56:59 -0500215 Mandatory. the name of the DTB file for the specific board for instance
216 the espressobin v5 board the value is "marvell/armada-3720-espressobin.dtb"
217 while on a clearfog pro it is "armada-388-clearfog-pro.dtb" in the case of
218 a board providing its firmware based DTB this value can be used to override
219 the DTB with a different DTB. fdtfile will automatically be set for you if
220 it matches the format ${soc}-${board}.dtb which covers most 32 bit use cases.
221 AArch64 generally does not match as the Linux kernel put the dtb files under
Wolfgang Denk0a50b3c2021-09-27 17:42:38 +0200222 SoC vendor directories.
Dennis Gilmore74f89772020-09-11 11:56:59 -0500223
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -0700224ramdisk_addr_r:
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -0700225 Mandatory. The location in RAM where the initial ramdisk will be loaded to
226 when processing the initrd option in extlinux.conf.
227
Simon Glass37c51952021-10-14 12:48:10 -0600228 It is recommended that this location be highest in RAM out of fdt_addr_r,
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -0700229 kernel_addr_r, and ramdisk_addr_r, so that the RAM disk can vary in size
230 and use any available RAM.
231
232kernel_addr_r:
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -0700233 Mandatory. The location in RAM where the kernel will be loaded to when
234 processing the kernel option in the extlinux.conf.
235
236 The kernel should be located within the first 128M of RAM in order for the
237 kernel CONFIG_AUTO_ZRELADDR option to work, which is likely enabled on any
238 distro kernel. Since the kernel will decompress itself to 0x8000 after the
Masahiro Yamada28fd00b2015-07-07 18:47:17 +0900239 start of RAM, kernel_addr_r should not overlap that area, or the kernel will
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -0700240 have to copy itself somewhere else first before decompression.
241
242 A size of 16MB for the kernel is likely adequate.
243
Atish Patra414c34e2020-03-05 16:24:23 -0800244kernel_comp_addr_r:
245 Optional. This is only required if user wants to boot Linux from a compressed
Heinrich Schuchardt3af8d1c2021-02-17 08:06:05 +0100246 Image(.gz, .bz2, .lzma, .lzo) using the booti command. It represents the
247 location in RAM where the compressed Image will be decompressed temporarily.
248 Once the decompression is complete, the decompressed data will be moved to
249 kernel_addr_r for booting.
Atish Patra414c34e2020-03-05 16:24:23 -0800250
251kernel_comp_size:
252 Optional. This is only required if user wants to boot Linux from a compressed
253 Image using booti command. It represents the size of the compressed file. The
254 size has to at least the size of loaded image for decompression to succeed.
255
Vagrant Cascadian7101c4c2016-02-08 19:55:31 -0800256pxefile_addr_r:
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -0700257 Mandatory. The location in RAM where extlinux.conf will be loaded to prior
258 to processing.
259
260 A size of 1MB for extlinux.conf is more than adequate.
261
262scriptaddr:
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -0700263 Mandatory, if the boot script is boot.scr rather than extlinux.conf. The
264 location in RAM where boot.scr will be loaded to prior to execution.
265
266 A size of 1MB for extlinux.conf is more than adequate.
267
268For suggestions on memory locations for ARM systems, you must follow the
269guidelines specified in Documentation/arm/Booting in the Linux kernel tree.
270
271For a commented example of setting these values, please see the definition of
272MEM_LAYOUT_ENV_SETTINGS in include/configs/tegra124-common.h.
273
274Boot Target Configuration
275-------------------------
276
Simon Glass37c51952021-10-14 12:48:10 -0600277The `config_distro_bootcmd.h` file defines $bootcmd and many helper command
278variables that automatically search attached disks for boot configuration files
279and execute them. Boards must provide configure <config_distro_bootcmd.h> so
280that it supports the correct set of possible boot device types. To provide this
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -0700281configuration, simply define macro BOOT_TARGET_DEVICES prior to including
Simon Glass37c51952021-10-14 12:48:10 -0600282<config_distro_bootcmd.h>. For example::
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -0700283
Simon Glass37c51952021-10-14 12:48:10 -0600284 #ifndef CONFIG_SPL_BUILD
285 #define BOOT_TARGET_DEVICES(func) \
286 func(MMC, mmc, 1) \
287 func(MMC, mmc, 0) \
288 func(USB, usb, 0) \
289 func(PXE, pxe, na) \
290 func(DHCP, dhcp, na)
291 #include <config_distro_bootcmd.h>
292 #endif
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -0700293
294Each entry in the macro defines a single boot device (e.g. a specific eMMC
295device or SD card) or type of boot device (e.g. USB disk). The parameters to
296the func macro (passed in by the internal implementation of the header) are:
297
Pali Rohár2f5c9ad2022-04-06 11:35:46 +0200298- Upper-case disk type (DHCP, HOST, IDE, MMC, NVME, PXE, SATA, SCSI, UBIFS, USB,
299 VIRTIO).
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -0700300- Lower-case disk type (same options as above).
301- ID of the specific disk (MMC only) or ignored for other types.
302
303User Configuration
304==================
305
306Once the user has installed U-Boot, it is expected that the environment will
307be reset to the default values in order to enable $bootcmd and friends, as set
308up by <config_distro_bootcmd.h>. After this, various environment variables may
309be altered to influence the boot process:
310
311boot_targets:
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -0700312 The list of boot locations searched.
313
314 Example: mmc0, mmc1, usb, pxe
315
316 Entries may be removed or re-ordered in this list to affect the boot order.
317
318boot_prefixes:
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -0700319 For disk-based booting, the list of directories within a partition that are
320 searched for boot configuration files (extlinux.conf, boot.scr).
321
322 Example: / /boot/
323
324 Entries may be removed or re-ordered in this list to affect the set of
325 directories which are searched.
326
327boot_scripts:
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -0700328 The name of U-Boot style boot.scr files that $bootcmd searches for.
329
330 Example: boot.scr.uimg boot.scr
331
332 (Typically we expect extlinux.conf to be used, but execution of boot.scr is
333 maintained for backwards-compatibility.)
334
335 Entries may be removed or re-ordered in this list to affect the set of
336 filenames which are supported.
337
338scan_dev_for_extlinux:
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -0700339 If you want to disable extlinux.conf on all disks, set the value to something
340 innocuous, e.g. setenv scan_dev_for_extlinux true.
341
342scan_dev_for_scripts:
Dennis Gilmoreffb4f6f2015-01-22 11:34:20 -0700343 If you want to disable boot.scr on all disks, set the value to something
344 innocuous, e.g. setenv scan_dev_for_scripts true.
Karsten Merker8c249292015-03-21 14:15:38 +0100345
Stephen Warren3483b752016-01-26 11:10:12 -0700346boot_net_usb_start:
Stephen Warren3483b752016-01-26 11:10:12 -0700347 If you want to prevent USB enumeration by distro boot commands which execute
348 network operations, set the value to something innocuous, e.g. setenv
349 boot_net_usb_start true. This would be useful if you know your Ethernet
350 device is not attached to USB, and you wish to increase boot speed by
351 avoiding unnecessary actions.
Karsten Merker8c249292015-03-21 14:15:38 +0100352
Stephen Warren986691f2016-01-26 11:10:13 -0700353boot_net_pci_enum:
Stephen Warren986691f2016-01-26 11:10:13 -0700354 If you want to prevent PCI enumeration by distro boot commands which execute
355 network operations, set the value to something innocuous, e.g. setenv
356 boot_net_pci_enum true. This would be useful if you know your Ethernet
357 device is not attached to PCI, and you wish to increase boot speed by
358 avoiding unnecessary actions.
359
Karsten Merker8c249292015-03-21 14:15:38 +0100360Interactively booting from a specific device at the u-boot prompt
361=================================================================
362
363For interactively booting from a user-selected device at the u-boot command
364prompt, the environment provides predefined bootcmd_<target> variables for
365every target defined in boot_targets, which can be run be the user.
366
367If the target is a storage device, the format of the target is always
368<device type><device number>, e.g. mmc0. Specifying the device number is
369mandatory for storage devices, even if only support for a single instance
370of the storage device is actually implemented.
371
372For network targets (dhcp, pxe), only the device type gets specified;
373they do not have a device number.
374
375Examples:
376
377 - run bootcmd_usb0
378 boots from the first USB mass storage device
379
380 - run bootcmd_mmc1
381 boots from the second MMC device
382
383 - run bootcmd_pxe
384 boots by tftp using a pxelinux.cfg
385
386The list of possible targets consists of:
387
388- network targets
Simon Glass37c51952021-10-14 12:48:10 -0600389
Karsten Merker8c249292015-03-21 14:15:38 +0100390 * dhcp
391 * pxe
392
393- storage targets (to which a device number must be appended)
Simon Glass37c51952021-10-14 12:48:10 -0600394
Karsten Merker8c249292015-03-21 14:15:38 +0100395 * mmc
396 * sata
397 * scsi
398 * ide
399 * usb
Lukas Auera8da9ff2018-11-22 11:26:33 +0100400 * virtio
Karsten Merker8c249292015-03-21 14:15:38 +0100401
402Other *boot* variables than the ones defined above are only for internal use
403of the boot environment and are not guaranteed to exist or work in the same
404way in future u-boot versions. In particular the <device type>_boot
405variables (e.g. mmc_boot, usb_boot) are a strictly internal implementation
406detail and must not be used as a public interface.
Simon Glass37c51952021-10-14 12:48:10 -0600407
408.. _BootLoaderSpec: http://www.freedesktop.org/wiki/Specifications/BootLoaderSpec/
409
410.. sectionauthor:: (C) Copyright 2014 Red Hat Inc.
411.. sectionauthor:: Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.
412.. sectionauthor:: Copyright (C) 2015 K. Merker <merker@debian.org>