Fundamentals 7 min read

How U‑Boot Passes the Device Tree to the Linux Kernel on ARM

This article explains how U‑Boot loads a device tree blob into memory, transfers its address to the ARM kernel via register r2 using either the bootm_header_t structure or board parameters, and details the kernel's two‑stage parsing and unflattening process.

Liangxu Linux
Liangxu Linux
Liangxu Linux
How U‑Boot Passes the Device Tree to the Linux Kernel on ARM

Device Tree Transfer from U‑Boot to the Kernel

When U‑Boot loads the device tree blob (DTB) into a specified memory location, it passes the address to the ARM kernel via the general‑purpose register r2. The kernel then processes the DTB further.

How U‑Boot Calls the Kernel

When the bootm command (or its wrapper bootz) is used, U‑Boot jumps to the kernel entry point through the function boot_jump_linux located in arch/arm/lib. This function is architecture‑specific and is a key API for handing control from U‑Boot to the kernel.

static void boot_jump_linux(bootm_headers_t *images, int flag)
{
    debug("## Transferring control to Linux (at address %08lx)...
", (ulong)kernel_entry);
    bootstage_mark(BOOTSTAGE_ID_RUN_OS);
    announce_and_cleanup(fake);
    if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len)
        r2 = (unsigned long)images->ft_addr;
    else
        r2 = gd->bd->bi_boot_params;
    ...
}

The register r2 can receive the DTB address in two ways: either from the ft_addr field of the bootm_headers_t structure or from the board‑level boot parameters gd->bd->bi_boot_params.

bootm_header_t Method

The bootm_headers_t structure is defined as:

typedef struct bootm_headers {
    ...
    char *ft_addr;   /* flat device tree address */
    ulong ft_len;    /* length of flat device tree */
    ...
} bootm_headers_t;

When this method is used, U‑Boot must ensure that both the device tree and the kernel image are non‑null.

gd->bd->bi_boot_params Method

This older method uses the board data field bi_boot_params, which holds the address of kernel boot parameters set during board initialization. It is rarely used in modern setups.

Kernel Parsing of the Device Tree

The kernel processes the DTB in two stages.

Stage 1 – Validation and Early Initialization

During early boot, the kernel verifies the DTB (CRC32 check) and scans nodes to extract information such as the chosen node, memory layout, and machine model. Example log output:

Booting Linux on physical CPU 0x0
Linux version 5.4.124 (qemu@qemu) ...
OF: fdt: Machine model: V2P-CA9

The machine model is defined in the DTB header, e.g.:

/dts-v1/;
#include "vexpress-v2m.dtsi"
{
    model = "V2P-CA9";
    ...
}

The relevant call chain includes setup_arch(), setup_machine_fdt(), early_init_dt_verify(), early_init_dt_scan_nodes(), and updates to __machine_arch_type and the chosen node.

Stage 2 – Unflattening the DTB

In the second stage the flattened device tree (FDT) is converted to an expanded device tree (EDT) and device_node structures are created.

unflatten_device_tree();
    __unflatten_device_tree()
        size = unflatten_dt_nodes(blob, NULL, dad, NULL);
        unflatten_dt_nodes(blob, mem, dad, mynodes);

After device_node creation, the kernel registers platform devices based on this information, making them available to drivers.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

ARMU-Bootboot_jump_linuxbootm
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.