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?
How does kernel know which device tree to load
device-treekernel
Best Answer
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 DTBfdt_file
from a FAT partition on a SATA device. These are loaded to memory addresses specified byloadaddr
andfdt_addr
respectively, and then handed off to U-Boot'sbootz
command.U-Boot's
bootz
usage: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