当前位置:网站首页>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” |
边栏推荐
- 通过模拟Vite一起深入其工作原理
- In 2022, you still can't "low code"?Data science can also play with Low-Code!
- One hundred - day plan -- -- DAY2 brush
- 【七夕节】浪漫七夕,代码传情。将爱意变成绚烂的立体场景,给她(他)一个惊喜!(送代码)
- Data storage practice based on left-order traversal
- Dynamic management of massive service instances
- QT MV\MVC structure
- 引领数字医学高地,中山医院探索打造未来医院“新范式”
- 22-07-31周总结
- Everyone in China said data, you need to focus on core characteristic is what?
猜你喜欢
论治理与创新,2022 开放原子全球开源峰会 OpenAnolis 分论坛圆满落幕
A small tool to transfer files using QR code - QFileTrans 1.2.0.1
Beyond YOLO5-Face | YOLO-FaceV2 officially open source Trick+ academic point full
毕设-基于SSM房屋租赁管理系统
大像素全景制作完成后,推广方式有哪些?
Tencent Cloud [Hiflow] New Era Automation Tool
Dynamic management of massive service instances
ASP.NET application--Hello World
Is your data safe in this hyperconnected world?
【滤波跟踪】基于matlab无迹卡尔曼滤波惯性导航+DVL组合导航【含Matlab源码 2019期】
随机推荐
[Qixi Festival] Romantic Tanabata, code teaser.Turn love into a gorgeous three-dimensional scene and surprise her (him)!(send code)
Native js realizes the effect of selecting and canceling all the multi-select boxes
大像素全景制作完成后,推广方式有哪些?
CPDA|How Operators Learn Data Analysis (SQL) from Negative Foundations
Bubble Sort and Quick Sort
QT: The Magical QVarient
【软件测试】自动化测试之unittest框架
论治理与创新,2022 开放原子全球开源峰会 OpenAnolis 分论坛圆满落幕
ASP.NET application--Hello World
Lexicon - the maximum depth of a binary tree
627. 变更性别
Talking about data security governance and privacy computing
Everyone in China said data, you need to focus on core characteristic is what?
Tencent Cloud [Hiflow] New Era Automation Tool
Error: Not a signal or slot declaration
QStyle platform style
private封装
Syntax basics (variables, input and output, expressions and sequential statements)
Flink 1.15.1 Cluster Construction (StandaloneSession)
2022高处安装、维护、拆除考试题模拟考试题库及在线模拟考试