This article talks about the parsing of the device tree during kernel boot.
For related subjects, please refer to the SOC Table of Contents.
The parsing process of the DTB file by the kernel follows the following process and hierarchy:
- Parse each node of the DTB file
We can see that the start_kernel function handles the parsing of the device tree nodes, and the actual function that parses it is the unflatten_dt_node() function. When the Linux kernel boots up, it would parse the information of each node, and create different folders under the root file directory /proc/device-tree, as can be seen below:
Note that each folder is a child node of the root node, such as “aliases”, “cpus”, “chosen”, and “amba”. We can see that the root node properties are expressed as individual files, such as “#address-cells”, “#size-cells”, “compatible”, and “name”. We can use the cat command to view its contents. As an example, we will look at “compatible”.
We can see that its content is “xlnx,zynq-7000”. This matches with the root node’s compatible property value in the file zynq-7000.dtsi. Recall that the /proc/device-tree directory is the device tree representation in the root file system and is organized according to the tree structure. We can see amba’s child nodes by going into /proc/device-tree/amba.