Linux Device Tree
What is the device tree in linux kernel ?
Let's imagine there is no such a thing called "Device Tree". You bought a board and this board has some peripherals installed on it like (UART , SPI , I2C , EEPROM , Buttons , etc..).
How can OS know about these peripherals ? as they are not self-discoverable , cannot make their presence to the kernel by themselves.
The first solution comes to your mind is to create some sort of config source file containing data structure for each device for its own information and compile it with the kernel.
How then this device is initialized ?
when this device driver is loaded to the kernel (using insmod function which dynamically attach modules to the kernel on runtime). probe function is called to check if there is a device with this name defined in the kernel then initialize the device to be ready to be used.
What if I have many boards with different devices attached ? then I should compile the linux kernel each time with different board_config sourcefile.
MANY DEPENDENCIES ? could be a problem. For each board I have to hard-coding info and compile a new kernel.
So, the linux community suggested that each board vendor creates his own board config file and include them all in one general kernel for better reusability.
This board config files is called .dts/.dtsi (device tree source files). These files only need to be compiled with DTC (device tree compiler) producing .dtb files (device tree binary) that is then loaded to the RAM . Kernel needs only the address where this .dtb is loaded on RAM not the entire kernel to be changed with each board.
#Baby_Steps_Embedded_Linux
Senior Software Engineer at Tata Elxsi
2 个月Good point
ASIC Design Engineer at Nokia
4 年Neat and clean information for beginners. Keep posting more articles on Linux. Thanks.
Software Engineer Mercedes-Benz Innovation Lab
4 年if these devices is not self-discoverable? how kernel could know when the device is loaded to go and call probe function? using insmod function which dynamically attach modules to the kernel on runtime is it the answer ? can you explain more about insmod
Embedded Linux Tech Lead at Arrow Electronics
4 年Simple and informative
Embedded Systems Engineer | M.Sc. in ECE | Consulting Services Provider
4 年Clear, Short and yet informative. I would like to invite you be a guest writer at Aatdiat (https://atadiat.com/en/) if you are looking to host this series in a our blog.