当前位置:网站首页>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” |
边栏推荐
- 1484. 按日期分组销售产品
- 汉字转拼音
- 21天学习挑战赛(2)图解设备树的使用
- 引领数字医学高地,中山医院探索打造未来医院“新范式”
- Beyond YOLO5-Face | YOLO-FaceV2 officially open source Trick+ academic point full
- tree table lookup
- sql server 安装提示用户名不存在
- Syntax basics (variables, input and output, expressions and sequential statements)
- Native js realizes the effect of selecting and canceling all the multi-select boxes
- QT language file production
猜你喜欢

The Tanabata copywriting you want has been sorted out for you!

虚拟内存原理与技术

dmp(dump)转储文件

A small tool to transfer files using QR code - QFileTrans 1.2.0.1

数据增强Mixup原理与代码解读

使用二维码传输文件的小工具 - QFileTrans 1.2.0.1

VSCode Change Default Terminal how to modify the Default Terminal VSCode

The 20th day of the special assault version of the sword offer
![[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]

Matlab drawing 3
随机推荐
Summary of domestic environments supported by SuperMap
Cybersecurity and the Metaverse: Identifying Weak Links
[Qixi Festival] Romantic Tanabata, code teaser.Turn love into a gorgeous three-dimensional scene and surprise her (him)!(send code)
The linear table lookup
QT语言文件制作
2022高处安装、维护、拆除考试题模拟考试题库及在线模拟考试
【七夕节】浪漫七夕,代码传情。将爱意变成绚烂的立体场景,给她(他)一个惊喜!(送代码)
627. 变更性别
语法基础(变量、输入输出、表达式与顺序语句)
A small tool to transfer files using QR code - QFileTrans 1.2.0.1
Apache DolphinScheduler, a new generation of distributed workflow task scheduling platform in practice - Medium
Beyond YOLO5-Face | YOLO-FaceV2 officially open source Trick+ academic point full
Object.defineProperty monitors data changes in real time and updates the page
开源协议说明LGPL
QStyle platform style
QT MV\MVC结构
Tencent Cloud [Hiflow] New Era Automation Tool
优炫数据库的单节点如何转集群
论治理与创新,2022 开放原子全球开源峰会 OpenAnolis 分论坛圆满落幕
High Item 02 Information System Project Management Fundamentals