How does U-Boot pass control to the Linux kernel, and what state must the CPU be in?
Short answer: The bootm/bootz/booti command loads and checks the images, fixes up the device tree (memory size, bootargs into /chosen, initrd location), shuts down U-Boot's drivers, disables caches and the MMU, and jumps to the kernel entry point. On ARM64 it passes the DTB physical address in x0 (with x1–x3 zero); on 32-bit ARM it passes r0 = 0, r1 = machine type, r2 = DTB (or ATAGS) address.
Which command
| Command | Image format |
|---|---|
bootm |
legacy uImage (64-byte header) or FIT image (kernel + DTBs + initramfs + signatures in one file) |
bootz |
32-bit ARM zImage (self-decompressing) |
booti |
ARM64 / RISC-V Image (uncompressed, or compressed with U-Boot's help) |
Arguments are kernel_addr initrd_addr fdt_addr; - means "none" for the initrd.
What the kernel's boot protocol requires (ARM64, Documentation/arch/arm64/booting.rst)
- MMU off, data cache off (or cleaned), instruction cache may be on.
- All interrupts masked (DAIF set).
- CPU in EL2 (preferred, so the kernel can run KVM) or EL1.
x0= physical address of the DTB,x1–x3= 0.- The DTB must be 8-byte aligned and not overlap the kernel image.
- Secondary CPUs are held in firmware (PSCI) until the kernel asks for them.
32-bit ARM: jump with r0 = 0, r1 = machine ID (only used by old non-DT boards), r2 = DTB address. Conceptually:
void (*kernel_entry)(int zero, int arch, unsigned long params);
kernel_entry = (void *)kernel_addr;
kernel_entry(0, machid, (unsigned long)fdt_addr); /* never returns */
Device tree fix-ups U-Boot does before jumping: writes the real DRAM size into /memory, bootargs into /chosen/bootargs, initrd start/end into /chosen, MAC addresses, and reserved-memory regions.
Why caches and MMU are off: the kernel builds its own page tables in head.S. Stale cache lines from U-Boot or a mapping the kernel does not know about could corrupt memory.
Debugging tip: if nothing appears after "Starting kernel ...", add earlycon (with the right UART type and address) to bootargs; it prints from the earliest point in head.S/setup_arch before the real console driver probes.