Week 5 ยท Lecture outline
UEFI, and Linux from first line to login
Modules 7: UEFI and 8: Linux boots. Lab: Lab 5, UEFI and Linux boot. Due: Lab 4. By the end of this week every line of the boot log is accounted for.
Learning goals
By the end of the week a student can:
- Explain what UEFI standardises, and why a generic distribution image boots unmodified on a board that implements it.
- Find the EFI system partition and the boot entries.
- Describe the kernel's boot: early console, device tree, driver probe and deferral, initramfs, root filesystem, init.
- Measure where a boot's time goes, and start a program at boot as a systemd service.
Lecture 1, block 1: what UEFI is
- A specification for the interface between firmware and an OS: storage, memory allocation, boot settings, and a few services that stay after the OS starts.
- Contrast with lab 4: there U-Boot was told exact files and addresses.
- U-Boot implements UEFI; both course boards keep a UEFI bootloader in SPI flash, so the boot media only carries the OS.
Lecture 1, block 2: the EFI system partition
- The OS's loader lives on a FAT filesystem, the EFI system partition.
- Firmware finds it through boot entries, or the fallback path
\EFI\BOOT\BOOTAA64.EFIon 64-bit Arm. efibootmgr -vlists the boot entries from Linux.
Lecture 1, block 3: one image, many boards
- On Arm boards the firmware passes the device tree to the OS through UEFI too.
- Distributions ship one arm64 image for many boards; the firmware carries what is specific to the board.
- On Das Frite, which has no card slot, this is how a stock distribution boots from a USB drive.
Lecture 2, block 1: the kernel takes over
- An early console reports problems before the real serial driver is loaded.
- The kernel reads the device tree for memory, CPUs and peripherals, and starts the other cores through the secure monitor.
- Each driver is matched to a device-tree node by its
compatiblestring and probed; one whose clock, regulator or GPIO is not ready is deferred and retried.
Lecture 2, block 2: root and init
- An initramfs can hold what is needed to find the real root filesystem.
- The kernel mounts root and starts init, process 1, which on most distributions is systemd.
- systemd starts every service, including the login prompt on the serial console.
- Kernel command-line arguments (read back in
/proc/cmdline) change its behaviour without rebuilding it: U-Boot'sbootargsin a hand boot, the distribution's boot-loader entry under UEFI.
Lecture 2, block 3: timing a boot
- The kernel's timestamps show where its time goes.
systemd-analyzesplits the boot, and itsblameview lists the slowest services.- A unit file with a restart policy is how a project starts on boot (week 9).
Board demo
- Boot a stock generic arm64 distribution from a second boot media through the bootloader in SPI flash.
- Show the EFI system partition, the fallback loader, and
efibootmgr -v. - Run
systemd-analyzeandsystemd-analyze blame, and read/proc/cmdline.
Check questions
In lab 4 you told U-Boot which files to load and where. Under UEFI, what makes those choices?
The firmware finds the OS's loader on the EFI system partition, through a boot entry or the fallback path \EFI\BOOT\BOOTAA64.EFI, and the loader picks the kernel. The firmware also passes the device tree, so the generic image needs nothing specific to the board.
What does it mean when a driver's probe is deferred?
Something it depends on, such as a clock, a regulator or a GPIO, is not ready yet. The kernel tries the probe again later instead of failing it.