设备树

设备树的由来以及基本概念

image
设备树文件代替的是device.c文件,拿到了内核外面,platform匹配上基本不变,不用重新编译内核了;
采用文本格式;

image

image

语法结构像树一样;
image

设备树基本语法

image

节点

image

image
阅读源文件,看节点从左往右看;看节点内容从上往下看;

节点名称
image

节点别名
image
uart8和serial关系

节点的引用
image

image

属性

reg属性

image

address-cells和size-cell
image
image

compatible属性

image

status属性

image

设备树中添加自定义节点

查看节点
image

image
此方法与上面的一样

编写自定义节点
image

编译自定义节点
image

image
注意配置ARCH 、CROSS_COMPILE

只编译一个dts文件
image

编译后生成文件在哪
image

烧写文件

设备树中常用的of操作函数

学习地址

image
2个结构体

查找节点函数
of_find_node_by_path()

查找节点属性函数
of_find_property()

读取属性值

示例
查找我们要查找的节点 of_find_node_by_path()
image

获取属性值 of_find_property()
image

image

image

根据读类型,选择函数

设备树下的platform总线

根节点里compatible属性,是跟内核匹配的如下
image
也就是说内核的运行,依赖设备树

image

image
确保已经有此节点了

image
3个name,优先级of_match_table > id_table > driver.name

获取属性
image

使用设备框架驱动,生成设备节点

补充知识点:
image

image


posted @ 2023-02-12 17:47  我爱茜茜公主  阅读(55)  评论(0)    收藏  举报