LinuxCommandLibrary

dtc

Compile device tree source files

TLDR

Compile a device tree source .dts file into a binary device tree blob .dtb file

$ dtc -I dts -O dtb -o [path/to/output_file.dtb] [path/to/input_file.dts]
copy

Compile a device tree source .dts file into a binary device tree blob overlay .dtbo file
$ dtc -@ -I dts -O dtb -o [path/to/output_file.dtbo] [path/to/input_file.dts]
copy

Decompile a device tree blob .dtb file into a readable device tree source .dts file
$ dtc -I dtb -O dts -o [path/to/output_file.dts] [path/to/input_file.dtb]
copy

Decompile the current device tree from the system into a readable device tree source .dts file
$ dtc -I fs -O dts /proc/device-tree
copy

SYNOPSIS

dtc [options] [<input.dts>] [-o output.dtb]

PARAMETERS

-I format
    Input format: dts (default), dtb, asm, fs.

-O format
    Output format: dtb (default), dts, asm, fs, yaml.

-o file
    Output file; stdout if omitted.

-b size
    Set blob alignment to size bytes (default 4).

-@
    Generate symbols (@label) in output.

-s
    Suppress flex/bison warnings.

-p size
    Pad .dtb to specified size.

-f
    Suppress error messages.

-q
    Quiet mode: only errors.

-v
    Verbose mode.

-V version
    Set output DT version number.

-d level
    Debug output level (0-3).

-R count
    Reserve count cells for memory.

-U
    Use old phandle scheme.

-F file
    Apply fixups from file.

-H profile
    YAML profile (e.g., linux).

-i path
    Include directory.

-L path
    Plugin library directory.

-C
    Enable compression.

DESCRIPTION

The dtc (Device Tree Compiler) is an essential tool in Linux embedded development, converting human-readable Device Tree Source (.dts) files into compact binary Device Tree Blobs (.dtb). These blobs describe hardware configuration—like CPUs, memory, peripherals, and interrupts—to the Linux kernel at boot time, eliminating hardcoded configurations.

Primarily used in ARM, PowerPC, and RISC-V systems, dtc ensures hardware portability across kernels. It performs syntax checking, semantic validation, and supports features like overlays for runtime modifications, symbol references (@labels), phandles for node cross-references, and plugins for custom processing.

Input formats include dts (default textual), dtb (binary decompile), asm (assembly), and fs (flat source). Outputs match these plus YAML profiles. Common workflow: compile .dts to .dtb during kernel build (make dtbs), or manually for custom boards.

dtc integrates with build systems via scripts/dtc wrapper, aiding bootloader handoff (U-Boot, GRUB). Errors highlight line-specific issues for quick fixes. Version mismatches can cause boot failures, so kernel and dtc versions should align.

CAVEATS

Kernel DTB requires matching dtc version; mismatches cause boot issues. Large trees may exceed memory. No partial compilation—full tree processed.

COMMON USAGE

dtc -I dts -O dtb -o arch.dtb board.dts
Decompile: dtc -I dtb -O dts input.dtb

KERNEL INTEGRATION

Invoked by scripts/dtc/dtc wrapper in make dtbs. Supports overlays via fdtoverlay tool.

HISTORY

Originated in 2005 by Pantelis Antoniou for Freescale PowerPC. Evolved with Linux kernel (v2.6+), ARM adoption in 2012. Maintained by devicetree.org since 2014, with YAML/overlay support added in v1.4+.

SEE ALSO

fdtdump(1), dtc(1)

Copied to clipboard