Difference between revisions of "U-Boot"

From Dejvino's Knowledge Base
Jump to navigation Jump to search
Line 23: Line 23:
  
 
=== Distro Boot ===
 
=== Distro Boot ===
Source: [https://gitlab.denx.de/u-boot/u-boot/-/blob/master/doc/README.distro README.distro]
+
Source: [https://gitlab.denx.de/u-boot/u-boot/-/blob/master/doc/README.distro README.distro] [https://developer.toradex.com/knowledge-base/distro-boot-linux]
  
 
Standardized way of booting a [[Linux distribution]] from U-Boot, without needing to build the distribution specifically for the target device. A distribution needs to provide its own generic bootloader, e.g. [[syslinux]] (extlinux).
 
Standardized way of booting a [[Linux distribution]] from U-Boot, without needing to build the distribution specifically for the target device. A distribution needs to provide its own generic bootloader, e.g. [[syslinux]] (extlinux).
  
 
Enabled by: <code>CONFIG_DISTRO_DEFAULTS=y</code>
 
Enabled by: <code>CONFIG_DISTRO_DEFAULTS=y</code>
 +
 +
==== Devices order ====
 +
# Internal flash storage (e.g. eMMC)
 +
# External flash storage (e.g. SD card)
 +
# USB storage
 +
# Network storage obtained from DHCP
 +
 +
Note that the first two might be swapped, depending on the configuration. Often it makes more sense to give priority to a removable media before booting from the internal storage.
 +
 +
For each of these devices, U-Boot will search in the first partition marked with a bootable flag (via the MBR bootable flag, or GPT legacy_bios_bootable attribute). In its absence, it will fall back to looking at the first valid partition. Disto Boot recognizes FAT and ext2/3/4 filesystems.
  
 
U-Boot searches for {{code|/extlinux/extlinux.conf}} then {{code|/boot/extlinux/extlinux.conf}} on disk, or {{code|pxelinux.cfg/default}} over the network. The content is as recognized by [[syslinux]] (extlinux). It also supports its own {{code|bootcmd}} format in {{code|boot.scr}} file.
 
U-Boot searches for {{code|/extlinux/extlinux.conf}} then {{code|/boot/extlinux/extlinux.conf}} on disk, or {{code|pxelinux.cfg/default}} over the network. The content is as recognized by [[syslinux]] (extlinux). It also supports its own {{code|bootcmd}} format in {{code|boot.scr}} file.
 
  
 
== Related ==
 
== Related ==

Revision as of 19:58, 28 March 2020

Linux friendly bootloader. Used in various ARM devices like PinePhone and Orange Pi.

Boot process

Definitions

General

  • SPL (Secondary Program Loader) is a small binary, generated from U-Boot source, that fits in the SRAM and loads the main U-Boot into system RAM. [1]
  • TPL (Tertiary Program Loader) is a tiny SPL which loads moderate-sized middle layer called TPL and that loads the full U-Boot into RAM.

Board-specific

Device Tree

  • DTB (Device Tree Blob) TODO: Enhance
  • ITB TODO: ???
  • FIT (Flat Image Tree) TODO: Enhance

Boot sequence

  1. Device's built-in boot code is executed (BootROM)
    1. It searches connected storage devices for a bootloader signature at a predefined address
    2. If found it loads the bootloader into SRAM and executes it
  2. TPL does minimal initialization, loads and executes SPL
  3. SPL does more extended initialization, loads and executes U-Boot
  4. U-Boot finishes initialization, provides a command prompt / searches for OS images / boots them

Distro Boot

Source: README.distro [2]

Standardized way of booting a Linux distribution from U-Boot, without needing to build the distribution specifically for the target device. A distribution needs to provide its own generic bootloader, e.g. syslinux (extlinux).

Enabled by: CONFIG_DISTRO_DEFAULTS=y

Devices order

  1. Internal flash storage (e.g. eMMC)
  2. External flash storage (e.g. SD card)
  3. USB storage
  4. Network storage obtained from DHCP

Note that the first two might be swapped, depending on the configuration. Often it makes more sense to give priority to a removable media before booting from the internal storage.

For each of these devices, U-Boot will search in the first partition marked with a bootable flag (via the MBR bootable flag, or GPT legacy_bios_bootable attribute). In its absence, it will fall back to looking at the first valid partition. Disto Boot recognizes FAT and ext2/3/4 filesystems.

U-Boot searches for /extlinux/extlinux.conf then /boot/extlinux/extlinux.conf on disk, or pxelinux.cfg/default over the network. The content is as recognized by syslinux (extlinux). It also supports its own bootcmd format in boot.scr file.

Related

External

  • Repository: [3]
    • Distro boot doc [4]
  • Presentation of U-Boot and porting to devices [5]
  • Get More out of U-Boot (introduction, partitioning, etc.) [6]
  • Presentation on TPL: SPL loading SPL (and what is SPL?) [7]
  • Distro boot Linux: [8]