</>EmbeddedInterview

How does the kernel boot on an ARM64 system?

MediumLinux Kernel & Device Drivers

Short answer: The boot ROM loads a first-stage loader (SPL or TF-A BL2) that initialises DRAM; Trusted Firmware-A sets up the secure world and EL3 services (PSCI), then hands over to U-Boot or UEFI at EL2; the bootloader loads the kernel Image, the device tree and optionally an initramfs, and jumps to the kernel with the DTB address in x0, MMU off, at EL2 or EL1. The kernel sets up page tables and enables the MMU, then start_kernel() initialises memory, interrupts, timers and the scheduler, brings up secondary CPUs through PSCI, runs driver initcalls (probing devices from the DT), mounts the root filesystem and executes /sbin/init as PID 1.

Kernel-side steps in more detail

  1. head.S (primary_entry): checks the boot exception level, sets up identity and kernel page tables, enables the MMU, jumps to the virtual address space.
  2. start_kernel(): setup_arch() (parse DT memory, reserved regions, early console via earlycon), memory allocators (memblock → buddy/slab), trap_init, IRQ controller (GIC) init, timers (arch timer), sched_init, console, rest_init().
  3. kernel_init thread: SMP bring-up (PSCI CPU_ON), do_initcalls() in levels (core → postcore → arch → subsys → fs → device → late), which registers buses and drivers; devices from the DT are created by of_platform_populate.
  4. Unpack initramfs (if any) and run its /init, or mount the root device given by root= and run /sbin/init.
  5. PID 1 (systemd, BusyBox init) starts services and user space.

Debugging early boot: earlycon on the kernel command line, initcall_debug, ignore_loglevel, keep_bootcon, JTAG with the kernel stopped at start_kernel, and checking that the DTB address and memory node are correct.

See the Embedded Linux topic for bootloader details (SPL, U-Boot internals, FIT images).