Why Device Tree Structure (DTS) file is needed both in bootloader and kernel source code?

24.8k views Asked by At

Bootloaders like U-Boot that do not implement the Open Firmware API, are expected to pass to the kernel a binary form of the flattened device tree - LinuxFDTBlob

Why are the DTS files present in the kernel as well? Isn't that redundant?

As an example, U-boot source code has following file:
arch/arm/dts/tegra124-jetson-tk1.dts

This file can also be found under Linux source code:
arch/arm/boot/dts/tegra124-jetson-tk1.dts

Although the kernel version is 4 times the U-boot version, I would like to know the reason behind this redundancy. I believe it is harder to maintain and use both for the maintainers and the developers

3

There are 3 answers

4
Hamzahfrq On BEST ANSWER

Below is the answer from the comments of Artlessnoise:

The u-boot source uses the u-boot DTB while Linux uses Linux DTB when kernel boots. The u-boot version is a stripped down version as there are not as many peripherals needed to boot. You always use the kernel version for Linux i.e. u-boot passes this one to Linux (as well as load bzImage or vmlinux).

Many of the u-boot drivers are almost identical to Linux. Obviously, you can make the same argument for all the u-boot drivers; most are copies of the Linux drivers with interrupts replaced by polling routines. Using the same open-firmware interface enables them to match closer.

2
Arun Valiaparambil On
  1. UBoot and Linux Kernel are two different projects. So they would require different copies for managing their separate projects.
  2. Linux kernels can be booted with other bootloaders as well. There are other ways to pass DTB to the linux kernel, eg. the kernel image can be appended with DTB it needs to use.

Because of the above mentioned reasons it makes sense to replicate copies of the DTS.

0
Sanjay Tandel On

Uboot has separate DTS file, which can be set as CONFIG_DEFAULT_DEVICE_TREE in uboot defconfig. This DTS file is built with uboot image, meaning it is a part of uboot image. Syntax of uboot DTS file is same as Linux kernel DTS file. Linux DTS file is compiled into DTB file and used as separately for parsing hardware configuration by Linux kernel. Linux DTB image is flashed separately from Linux kernel image.