Heinrich Schuchardt | e7574fc | 2023-08-23 23:49:55 +0200 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0-or-later |
| 2 | |
| 3 | Booting from TPL/SPL |
| 4 | ==================== |
| 5 | |
| 6 | The main U-Boot binary may be too large to be loaded directly by the Boot ROM. |
| 7 | This was the original driver for splitting up U-Boot into multiple boot stages. |
| 8 | |
| 9 | U-Boot typically goes through the following boot phases where TPL, VPL, and SPL |
| 10 | are optional. While many boards use SPL only few use TPL. |
| 11 | |
| 12 | TPL |
| 13 | Tertiary Program Loader. Very early init, as tiny as possible. This loads SPL |
| 14 | (or VPL if enabled). |
| 15 | |
| 16 | VPL |
| 17 | Verifying Program Loader. Optional verification step, which can select one of |
| 18 | several SPL binaries, if A/B verified boot is enabled. Implementation of the |
| 19 | VPL logic is work-in-progress. For now it just boots into SPL. |
| 20 | |
| 21 | SPL |
| 22 | Secondary Program Loader. Sets up SDRAM and loads U-Boot proper. It may also |
| 23 | load other firmware components. |
| 24 | |
| 25 | U-Boot |
| 26 | U-Boot proper. This is the only stage containing command. It also implements |
| 27 | logic to load an operating system, e.g. via UEFI. |
| 28 | |
| 29 | .. note:: |
| 30 | |
| 31 | The naming convention on the PowerPC architecture deviates from the other |
| 32 | archtitectures. Here the boot sequence is SPL->TPL->U-Boot. |
| 33 | |
| 34 | Further usages for U-Boot SPL comprise: |
| 35 | |
| 36 | * launching BL31 of ARM Trusted Firmware which invokes U-Boot as BL33 |
| 37 | * launching EDK II |
| 38 | * launching Linux, e.g. :doc:`Falcon Mode <../develop/falcon>` |
| 39 | * launching RISC-V OpenSBI which invokes main U-Boot |
| 40 | |
| 41 | Target binaries |
| 42 | --------------- |
| 43 | |
| 44 | Binaries loaded by SPL/TPL can be: |
| 45 | |
| 46 | * raw binaries where the entry address equals the start address. This is the |
| 47 | only binary format supported by TPL. |
| 48 | * :doc:`FIT <fit/index>` images |
| 49 | * legacy U-Boot images |
| 50 | |
| 51 | Configuration |
| 52 | ~~~~~~~~~~~~~ |
| 53 | |
| 54 | Raw images are only supported in SPL if CONFIG_SPL_RAW_IMAGE_SUPPORT=y. |
| 55 | |
| 56 | CONFIG_SPL_FIT=y and CONFIG_SPL_LOAD_FIT=y are needed to load FIT images. |
| 57 | |
| 58 | CONFIG_SPL_LEGACY_IMAGE_FORMAT=y is needed to load legacy U-Boot images. |
| 59 | CONFIG_SPL_LEGACY_IMAGE_CRC_CHECK=y enables checking the CRC32 of legacy U-Boot |
| 60 | images. |
| 61 | |
| 62 | Image load methods |
| 63 | ------------------ |
| 64 | |
| 65 | The image boot methods available for a board must be defined in two places: |
| 66 | |
| 67 | The board code implements a function board_boot_order() enumerating up to |
| 68 | five boot methods and the sequence in which they are tried. (The maximum |
| 69 | number of boot methods is currently hard coded as variable spl_boot_list[]). |
| 70 | If there is only one boot method function, spl_boot_device() may be implemented |
| 71 | instead. |
| 72 | |
| 73 | The configuration controls which of these boot methods are actually available. |
| 74 | |
| 75 | Loading from block devices |
| 76 | ~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 77 | |
| 78 | MMC1, MMC2, MMC2_2 |
| 79 | These methods read an image from SD card or eMMC. The first digit after |
| 80 | 'MMC' indicates the device number. Required configuration settings include: |
| 81 | |
| 82 | * CONFIG_SPL_MMC=y or CONFIG_TPL_MMC=y |
| 83 | |
| 84 | To use a PCI connected MMC controller you need to additionally specify: |
| 85 | |
| 86 | * CONFIG_SPL_PCI=y |
| 87 | |
| 88 | * CONFIG_SPL_PCI_PNP=y |
| 89 | |
| 90 | * CONFIG_MMC=y |
| 91 | |
| 92 | * CONFIG_MMC_PCI=y |
| 93 | |
| 94 | * CONFIG_MMC_SDHCI=y |
| 95 | |
| 96 | To load from a file system use: |
| 97 | |
| 98 | * CONFIG_SPL_FS_FAT=y or CONFIG_SPL_FS_EXT=y |
| 99 | |
| 100 | * CONFIG_SPL_FS_LOAD_PAYLOAD_NAME="<filepath>" |
| 101 | |
| 102 | NVMe |
| 103 | This methods load the image from an NVMe drive. |
| 104 | Required configuration settings include: |
| 105 | |
| 106 | * CONFIG_SPL_PCI=y |
| 107 | |
| 108 | * CONFIG_SPL_PCI_PNP=y |
| 109 | |
| 110 | * CONFIG_SPL_NVME=y |
| 111 | |
| 112 | * CONFIG_SPL_NVME_PCI=y |
| 113 | |
| 114 | * CONFIG_SPL_NVME_BOOT_DEVICE (number of the NVMe device) |
| 115 | |
| 116 | * CONFIG_SYS_NVME_BOOT_PARTITION (partition to read from) |
| 117 | |
| 118 | To load from a file system use: |
| 119 | |
| 120 | * CONFIG_SPL_FS_FAT=y or CONFIG_SPL_FS_EXT=y |
| 121 | |
| 122 | * CONFIG_SPL_FS_LOAD_PAYLOAD_NAME="<filepath>" |
| 123 | |
| 124 | SATA |
| 125 | This method reads an image from a SATA drive. |
| 126 | Required configuration settings include: |
| 127 | |
| 128 | * CONFIG_SPL_SATA=y or CONFIG_TPL_SATA=y |
| 129 | |
| 130 | To use a PCIe connecte SATA controller you additionally need: |
| 131 | |
| 132 | * CONFIG_SPL_PCI=y |
| 133 | |
| 134 | * CONFIG_SPL_SATA=y |
| 135 | |
| 136 | * CONFIG_SPL_AHCI_PCI=y |
| 137 | |
| 138 | * CONFIG_SPL_PCI_PNP=y |
| 139 | |
| 140 | To load from a file system use: |
| 141 | |
| 142 | * CONFIG_SPL_FS_FAT=y |
| 143 | |
| 144 | * CONFIG_SYS_SATA_FAT_BOOT_PARTITION=<partition number> |
| 145 | |
| 146 | * CONFIG_SPL_FS_LOAD_PAYLOAD_NAME="<filepath>" |
| 147 | |
| 148 | USB |
| 149 | The USB method loads an image from a USB block device. |
| 150 | Required configuration settings include: |
| 151 | |
| 152 | * CONFIG_SPL_USB_HOST=y |
| 153 | |
| 154 | * CONFIG_SPL_USB_STORAGE=y |
| 155 | |
| 156 | To use a PCI connected USB 3.0 controller you additionally need: |
| 157 | |
| 158 | * CONFIG_SPL_FS_FAT=y |
| 159 | |
| 160 | * CONFIG_SPL_PCI=y |
| 161 | |
| 162 | * CONFIG_SPL_PCI_PNP=y |
| 163 | |
| 164 | * CONFIG_USB=y |
| 165 | |
| 166 | * CONFIG_USB_XHCI_HCD=y |
| 167 | |
| 168 | * CONFIG_USB_XHCI_PCI=y |
| 169 | |
| 170 | To load from a file system use: |
| 171 | |
| 172 | * CONFIG_SPL_FS_FAT=y or CONFIG_SPL_FS_EXT=y |
| 173 | |
| 174 | * CONFIG_SYS_USB_FAT_BOOT_PARTITION=<partition number> |
| 175 | |
| 176 | * CONFIG_SPL_FS_LOAD_PAYLOAD_NAME="<filepath>" |
| 177 | |
| 178 | Loading from raw flash devices |
| 179 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 180 | |
| 181 | NAND |
| 182 | This method loads the image from NAND flash. To read from raw NAND the |
| 183 | following configuration settings are required: |
| 184 | |
| 185 | * CONFIG_SPL_NAND_SUPPORT=y or CONFIG_TPL_NAND_SUPPORT=y |
| 186 | |
| 187 | If CONFIG_SPL_NAND_RAW_ONLY=y only raw images can be loaded. |
| 188 | |
| 189 | For using UBI (Unsorted Block Images) volumes to read from NAND the |
| 190 | following configuration settings are required: |
| 191 | |
| 192 | * CONFIG_SPL_UBI=y or CONFIG_TPL_UBI=y |
| 193 | |
| 194 | The UBI volume to read can either be specified |
| 195 | |
| 196 | * by name using CONFIG_SPL_UBI_LOAD_BY_VOLNAME or |
| 197 | |
| 198 | * by number using CONFIG_SPL_UBI_LOAD_MONITOR_ID. |
| 199 | |
| 200 | NOR |
| 201 | This method loads the image from NOR flash. |
| 202 | Required configuration settings include: |
| 203 | |
| 204 | * CONFIG_SPL_NOR_SUPPORT=y or CONFIG_TPL_NOR_SUPPORT=y |
| 205 | |
| 206 | OneNAND |
| 207 | This methods loads the image from a OneNAND device. To read from raw OneNAND |
| 208 | the following configuration settings are required: |
| 209 | |
| 210 | * CONFIG_SPL_ONENAND_SUPPORT=y or CONFIG_TPL_ONENAND_SUPPORT=y |
| 211 | |
| 212 | For using the Ubi file system to read from NAND the following configuration |
| 213 | settings are required: |
| 214 | |
| 215 | * CONFIG_SPL_UBI=y or CONFIG_TPL_UBI=y |
| 216 | |
| 217 | SPI |
| 218 | This method loads an image form SPI NOR flash. |
| 219 | Required configuration settings include: |
| 220 | |
| 221 | * CONFIG_SPL_DM_SPI=y |
| 222 | |
| 223 | * CONFIG_SPL_SPI_FLASH=y |
| 224 | |
| 225 | * CONFIG_SPI_LOAD=y or CONFIG_TPL_SPI_LOAD=y |
| 226 | |
| 227 | |
| 228 | Sunxi SPI |
| 229 | This method which is specific to Allwinner SoCs loads an image form SPI NOR |
| 230 | flash. Required configuration settings include: |
| 231 | |
| 232 | * CONFIG_SPL_SPI_SUNXI=y |
| 233 | |
| 234 | Loading from other devices |
| 235 | ~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 236 | |
| 237 | BOOTROM |
| 238 | The binary is loaded by the boot ROM. |
| 239 | Required configuration settings include: |
| 240 | |
| 241 | * CONFIG_SPL_BOOTROM_SUPPORT=y or CONFIG_TPL_BOOTROM_SUPPORT=y |
| 242 | |
| 243 | DFU |
| 244 | :doc:`Device Firmware Upgrade <dfu>` is used to load the binary into RAM. |
| 245 | Required configuration settings include: |
| 246 | |
| 247 | * CONFIG_DFU=y |
| 248 | |
| 249 | * CONFIG_SPL_RAM_SUPPORT=y or CONFIG TPL_RAM_SUPPORT=y |
| 250 | |
| 251 | Ethernet |
| 252 | This method loads an image over Ethernet. The BOOTP protocol is used to find |
| 253 | a TFTP server and binary name. The binary is downloaded via the TFTP |
| 254 | protocol. Required configuration settings include: |
| 255 | |
| 256 | * CONFIG_SPL_NET=y or CONFIG_TPL_NET=y |
| 257 | |
| 258 | * CONFIG_SPL_ETH_DEVICE=y or CONFIG_DM_USB_GADGET=y |
| 259 | |
| 260 | FEL |
| 261 | This method does not actually load an image for U-Boot. |
| 262 | FEL is a routine contained in the boot ROM of Allwinner SoCs which serves |
| 263 | for the initial programming or recovery via USB |
| 264 | |
| 265 | RAM |
| 266 | This method uses an image preloaded into RAM. |
| 267 | Required configuration settings include: |
| 268 | |
| 269 | * CONFIG_SPL_RAM_SUPPORT=y or CONFIG_TPL_RAM_SUPPORT=y |
| 270 | |
| 271 | * CONFIG_RAM_DEVICE=y |
| 272 | |
| 273 | Sandbox file |
| 274 | On the sandbox this method loads an image from the host file system. |
| 275 | |
| 276 | Sandbox image |
| 277 | On the sandbox this method loads an image from the host file system. |
| 278 | |
| 279 | Semihosting |
| 280 | When running in an ARM or RISC-V virtual machine the semihosting method can |
| 281 | be used to load an image from the host file system. |
| 282 | Required configuration settings include: |
| 283 | |
| 284 | * CONFIG_SPL_SEMIHOSTING=y |
| 285 | |
| 286 | * CONFIG_SPL_SEMIHOSTING_FALLBACK=y |
| 287 | |
| 288 | * CONFIG_SPL_FS_LOAD_PAYLOAD_NAME=<path to file> |
| 289 | |
| 290 | UART |
| 291 | This method loads an image via the Y-Modem protocol from the UART. |
| 292 | Required configuration settings include: |
| 293 | |
| 294 | * CONFIG_SPL_YMODEM_SUPPORT=y or CONFIG_TPL_YMODEM_SUPPORT=y |
| 295 | |
| 296 | USB SDP |
| 297 | This method loads the image using the Serial Download Protocol as |
| 298 | implemented by the boot ROM of the i.MX family of SoCs. |
| 299 | |
| 300 | Required configuration settings include: |
| 301 | |
| 302 | * CONFIG_SPL_SERIAL=y |
| 303 | |
| 304 | * CONFIG_SPL_USB_SDP_SUPPORT=y or CONFIG_TPL_USB_SDP_SUPPORT |
| 305 | |
| 306 | VBE Simple |
| 307 | This method is used by the VPL stage to extract the next stage image from |
| 308 | the loaded image. |
| 309 | |
| 310 | Required configuration settings include: |
| 311 | |
| 312 | * CONFIG_VPL=y |
| 313 | |
| 314 | * CONFIG_SPL_BOOTMETH_VBE_SIMPLE_FW=y or CONFIG_TPL_BOOTMETH_VBE_SIMPLE_FW=y |
| 315 | |
| 316 | XIP |
| 317 | This method executes an image in place. |
| 318 | |
| 319 | Required configuration settings include: |
| 320 | |
| 321 | * CONFIG_SPL_XIP_SUPPORT |