当前位置:网站首页>21 Days Learning Challenge (2) Use of Graphical Device Trees
21 Days Learning Challenge (2) Use of Graphical Device Trees
2022-08-05 03:07:00 【Xiaohui_Super】
活动地址:CSDN21天学习挑战赛
Original column address:RK3399平台开发入门到精通系列专栏
原文地址:RK3399平台开发系列讲解(内核设备树篇)3.2、图解Kernel Device Tree(设备树)的使用
以前也接触过 Linux 的内核,The main thing is to write some small drivers,Debug some modules,But haven't really studied the bottom layer of the kernel,Because the bottom layer has been sorted out by the chip manufacturer,No need for me to debug.Take advantage of this now 21 天学习挑战赛,I plan to study hard Linux Some basic knowledge of the kernel,Might be able to use it later.
学习日记
What hardware information does the device tree contain?
设备树 Device Tree Hardware information that can be described includes:
- CPUs
- Memory
- Buses
- Peripheral Connections
- Interrupt Controllers
- GPIO Controllers
- Clock Controllers
设备树示例
下面是一个 Device Tree 的示例(From the original text of the course),重要的属性包括 compatible、reg、clocks、interrupts 和 status.The specific introduction of these properties is written in the following chapters.The image below is taken from the original text.

Device tree parsing
The structure of the device tree is simple,主要由 Node(节点)和 Property(属性)组成.比如上图就是一个 Node,Use one for each device in the system Node 来描述,这些 Node 被组织成树状结构.每个 Node 中包含了若干的 Property/Value 来描述 Node 的一些特性.
每个 Node 用 node name 进行标识,节点名字由 node-name 和 unit-address 组成.node-name Specifies the name of the device,Must start with a character,unit-address The primary address for this device,Required to be unique and associated with this node reg The starting address of the attribute is the same.
Example of device tree format:
[label:] node-name[@unit-address] {
[properties definitions]
[child nodes]
}
“[ ]” 表示可选项,label 是 Node 的标识,便于在 dts 文件中引用. child node 的格式和 node 完全相同.
Introduction to special nodes
根节点
A device tree can only have one root node(root node),至少需要由 cpu 和 memory 节点组成.
例如(Example of the original text)
/ {
compatible = "rockchip,rk3399";
interrupt-parent = <&gic>;
#address-cells = <2>;
#size-cells = <2>;
cpus {
......
}
别名节点
aliases Nodes can be used to define alias nodes.When referring to a node, you need to specify its full address,If you have to write the full address for each reference,未免有些麻烦,而 aliases 可以解决这个问题.The image below is taken from the original text.

CPU 节点
前面提到,The root node must have one cpu 节点,The example below is taken from the original text:
cpus {
#address-cells = <2>;
#size-cells = <0>;
cpu_l0: [email protected]0 {
device_type = "cpu";
compatible = "arm,cortex-a53", "arm,armv8";
reg = <0x0 0x0>;
enable-method = "psci";
#cooling-cells = <2>; /* min followed by max */
clocks = <&cru ARMCLKL>;
dynamic-power-coefficient = <100>;
};
Memory 节点
memory device node A required node for all device tree files,它描述了系统的物理内存布局.
可选节点
chosen Mainly used to describe the operating parameters specified by the system hardware,并不是一个真实的设备,该节点主要是为了 uboot 向 Linux 内核传递数据.重点是 bootargs 这个参数,例如:
chosen {
bootargs = "console=ttymxc0,115200"; };
属性
compatible 属性 和 model 属性
compatible Properties are usually used to implement device 和 driver 的适配,推荐格式为 “manufacturer,model”
There is usually one in the driver file OF 匹配表,里面有一些 compatible 值,如果设备节点的 compatible 与驱动 OF Same as any one in the match table,Then it means that the device can use this driver.
model The attribute is used to represent the model,Generally used to describe the information of the device module,如名字.
addressing properties
If there is an addressing requirement in the device node(定义了 reg),Then the following two properties must be defined:
- #address-cells
- #size-cells
‘#’ 符号表示 number 的意思,#address-cells 用来描述 sub node 中 reg The attribute's address field property,how many to use u32 to describe the address domain.如:
reg = <address1 length1 [address2 length2] [address3 length3] ... >
#size-cells Used to indicate the address length.
The image below is taken from the original text:

中断
Break properties include interrupt-controller,#interrupt-celles,interrupt-parent 和 interrupts.
Don't study for now.
节点状态
Generally used in the device tree okay 和 disabled to turn the device on or off,Below are some values related to device status:
| 值 | 描述 |
|---|---|
| “okay” | 设备可操作(已开启) |
| “diable” | 设备不可操作(已关闭) |
| “fail” | 设备不可操作,The device detected some errors |
| “fail-sss” | 同 “fail” |
边栏推荐
- QT MV\MVC结构
- Images using redis cache Linux master-slave synchronization server hard drive full of moved to the new directory which points to be modified
- Principle and Technology of Virtual Memory
- 21天学习挑战赛(2)图解设备树的使用
- QT MV\MVC structure
- undo问题
- Data storage practice based on left-order traversal
- How to transfer a single node of Youxuan database to a cluster
- Error: Not a signal or slot declaration
- .NET Application -- Helloworld (C#)
猜你喜欢

Simple description of linked list and simple implementation of code

Step by step how to perform data risk assessment

word分栏小记

CPDA|How Operators Learn Data Analysis (SQL) from Negative Foundations

Use SuperMap iDesktopX data migration tool to migrate map documents and symbols

人人都在说的数据中台,你需要关注的核心特点是什么?

Ant Sword Advanced Module Development
![[Filter tracking] based on matlab unscented Kalman filter inertial navigation + DVL combined navigation [including Matlab source code 2019]](/img/c9/fff226b6d33a773b59a0314a99a788.png)
[Filter tracking] based on matlab unscented Kalman filter inertial navigation + DVL combined navigation [including Matlab source code 2019]

通过模拟Vite一起深入其工作原理

word column notes
随机推荐
The Tanabata copywriting you want has been sorted out for you!
Flink 1.15.1 Cluster Construction (StandaloneSession)
使用二维码传输文件的小工具 - QFileTrans 1.2.0.1
torch.roll()
QT:神奇QVarient
(十一)元类
Dynamic management of massive service instances
Snapback - same tree
从“能用”到“好用” 国产软件自主可控持续推进
In 2022, you still can't "low code"?Data science can also play with Low-Code!
百日刷题计划 ———— DAY2
Syntax basics (variables, input and output, expressions and sequential statements)
Study Notes-----Left-biased Tree
龙蜥社区第二届理事大会圆满召开!理事换届选举、4 位特约顾问加入
北斗三号短报文终端露天矿山高边坡监测方案
语法基础(变量、输入输出、表达式与顺序语句完成情况)
Summary of domestic environments supported by SuperMap
Matlab drawing 3
leetcode - symmetric binary tree
QStyle platform style