Earlier when Linux kernel wanted to deal with any device it used board files of that particular device to deal with it. In this method, kernel must be modified/compiled for each board or change in hardware on board. Kernels are typically built around a single board file and cannot boot on any other type of system.
Solution for this situation is provided by “Device tree” also called as” open firmware” or “Flattened Device Tree”.
A Device Tree (DT) is a data structure which provides description of the hardware in a system. It should include the name of the base CPU, its memory configuration, and any peripherals (internal and external). While using device tree, kernel no longer contains the description of the hardware, it is located in a separate binary blob called the device tree blob(.dtb). The device tree is passed to the kernel at boot time. Kernel reads through .dtb to learn about what kind of system it is. So on the change of board only developer needs to change device tree blob.
The device tree data is typically created and maintained in a human readable format in .dts source files and .dtsi source include files.
The device tree source is compiled into a binary format contained in a .dtb blob file. The format of the data in the .dtb blob file is commonly referred to as a Flattened Device Tree (FDT). The Linux operating system uses the device tree data to find and register the devices in the system.
for example arch/arm/mach-omap2/board-am335xevm.c is a board file used in beaglebone.
It’s pretty big (ie 4K+ lines), and quite difficult to modify. In addition to the beaglebone white, The boardfile also supports the am335x-evm and all the capes. Every new cape (board) that is to be supported has to modify this file. So all new boards must support booting using Device Tree.
The board file used in the new kernels is just arch/arm/mach-omap2/board-generic.c in place of board files in older kernel versions and supports booting kernels using omap2, omap3, omap4, omap5 and the am33xx family of the beaglebone.
Currently the Linux kernel can read device tree information in the ARM, x86, Microblaze, PowerPC, and Sparc architectures.
Advantages of DT: Simple to change the configuration of the system without having to recompile any source code.
Can easily add support for new hardware (for example if you have a new board which only changes some minor components, you may be able to run the same software load as previous board, with only small changes to the .dts file on the new board)
Can reuse existing .dts files with include statements, and can override previously defined functionality.
Disadvantages of DT: Not so easy to write a new .dts file, because it requires very detailed knowledge of the hardware.
For more information you may logon to www.ismuniv.com , ISM UNIV is the best Embedded Systems and IoT Training Institute in Bangalore India, for any training requirements on Embedded Systems or Internet of Things do contact us.