Device tree is used at runtime on ARM devices to identify and load correct drivers with its configuration. But when I look into loaded DT at /proc/device-tree on my phone for example, there are many configurations unrelated to actuall platform. For example about 15 different display configurations that this specific device never used and never will. So far I thought only relevant DT gets included into the kernel and loaded but it seems all DTS from related /arch source folder are loaded. How does the kernel select the right one for the platform? Isn´t this a bit redundant?


Determining which device tree blob (DTB) file, which is compiled from the device tree source (DTS), to load is typically handled by the bootloader.

Many device manufacturers will customize the bootloader to add manufacturer-specific code for automating the task of determining which DTB file to load for that hardware.

An example for U-Boot, a commonly used bootloader, that loads a zImage kernel image and the DTB fdt_file from a FAT partition on a SATA device. These are loaded to memory addresses specified by loadaddr and fdt_addr respectively, and then handed off to U-Boot's bootz command.

fatload sata 0:1 ${loadaddr} ${image};
fatload sata 0:1 ${fdt_addr} ${fdt_file};
bootz ${loadaddr} - ${fdt_addr};

U-Boot's bootz usage:

bootz [addr [initrd[:size]] [fdt]]
    - boot Linux zImage stored in memory
        The argument 'initrd' is optional and specifies the address
        of the initrd in memory. The optional argument ':size' allows
        specifying the size of RAW initrd.
        When booting a Linux kernel which requires a flat device-tree
        a third argument is required which is the address of the
        device-tree blob. To boot that kernel without an initrd image,
        use a '-' for the second argument. If you do not pass a third
        a bd_info struct will be passed instead

For specifics regarding how U-Boot handles the fdt_file, you can reference the source code for bootm_find_images, as well as boot_get_fdt.

You can also try to glean some information from the U-Boot manual: https://www.denx.de/wiki/view/DULG/UBootCmdFDT


I think it isn't because Kernel load all DTS. Actually, an ARM firmware image can contain more than one dts inside, but It loads only on dts when it is booting. You see redundant device int /proc/device-tree because your device tree defined them. Even your phone does not have these device, you still can define that device, of cause, these devices can not work and may break your kernel.


On the same dts directory


There are one Makefile, open it and you can see which .dts file will be used for.

dtb-$(CONFIG_ARCH_XXXXXX) += some-dts-evb.dtb

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.