device tree
来源:互联网 发布:淘宝预售订单怎么取消 编辑:程序博客网 时间:2024/05/01 23:38
1 参考板origen的设备数文件为参考 cp arch/arm/boot/dts/exynos4412-origen.dts arch/arm/boot/dts/exynos4412-fs4412.dts2 添加新文件需修改Makefile才能编译vim arch/arm/boot/dts/Makefile,在exynos4412-origen.dtb \ 下添加如下内容 exynos4412-fs4412.dtb \3 编译设备树文件 make dtbs4 拷贝内核和设备树文件到/tftpboot目录下 cp arch/arm/boot/dts/exynos4412-fs4412.dtb /tftpboot/5 设置启动参数 set bootcmd tftp 0x41000000 uImage \; tftp 0x42000000 exynos4412-fs4412.dtb \; bootm 0x41000000 - 0x42000000
/* test_nod@12345678{ compatible = "farsight,test"; reg = <0x12345678 0x24 0x87654321 0x24>; testprop,mytest; test_list_string = "red fish","fly fish", "blue fish"; interrupt-parent = <&gpx1>; interrupts = <1 4>; };*/
常用的OF API
OF提供的函数主要集中在driver/of/目录下,有
address.c
base.c强调内容
fdt.c
irq.c
platform等
test_nod@12345678{ compatible = "test,farsight"; reg = <0xa2345678 0x24 0xb3456780 0x24>; testprop,mytest; test_list_string = "red fish", "blue fish"; interrupt-parent = <&gpx1>; // 因为按键接到了gpx1_1 interrupts = <1 2>; // 因为按键接到了gpx1_1 ,如果接到gpx2_1 ,那么就是<2 2>};一 在代码中先获取节点(所有的节点都是先得到节点) 1 先把节点获取到 struct device_node *np = NULL; np = of_find_node_by_path("/test_nod@12345678"); //获取到节点 printk("node name = %s\n", np->name); //获取节点名字并打印 printk("node full name = %s\n", np->full_name); //获取到节点全名并打印 2 获取到节点中的属性 struct property *prop = NULL; prop = of_find_property(np, "compatible",NULL); printk("compatible value = %s\n", prop->value); printk("compatible name = %s\n", prop->name); 3 查找是否存在 of_device_is_compatible(np, "farsight,test"); 4 读取到属性中的整数的数组 u32 regdata[U32_DATA_LEN]; int ret; ret = of_property_read_u32_array(np, "reg", regdata, U32_DATA_LEN); //把值存到regdata中去 if(!ret) { int i; for(i=0; i<U32_DATA_LEN; i++) printk("----regdata[%d] = 0x%x\n", i,regdata[i]); } 5 读取到属性中的字符串的数组 const char *pstr[3]; int i; for(i=0; i<3; i++) { //用指针pstr数组指向属性的字符串 ret = of_property_read_string_index(np, "test_list_string", i, &pstr[i]); if(!ret) printk("----pstr[%d] = %s\n", i,pstr[i]); } 6 获取到中断的号码 irqno = irq_of_parse_and_map(np, 0); printk("-----irqno = %d\n", irqno); 7 验证中断号码是否有效(中断申请) ret = request_irq(irqno, key_irq_handler, IRQF_TRIGGER_FALLING|IRQF_TRIGGER_RISING, "key_irq", NULL);
硬编码
arch/arm/mach-xxx
arch/arm/plat-xxxdevice-tree存放的位置
arch/arm/boot/des/*运行是查看的位置
/proc/device-tree/*只改匹配的方式
compatible = “xxx,xxx”
注:申请设备号是给应用层调用的
0 0
- Device Tree
- Device tree
- Device Tree
- Device Tree
- Device Tree
- Device Tree
- Device Tree
- device tree
- device tree
- Device Tree
- Device Tree
- device tree
- Device Tree
- Flattened Device Tree Blob
- Device Tree Usage
- Device Tree Usage
- Flattened Device Tree (FDT)
- ARM Device Tree起源
- Tomcat之Windows环境下配置多个服务器
- 内连接&左连接&右连接&全连接&交叉连接&自连接
- MySQL物理文件组成
- epoll解读
- php利用百度地图API进行IP定位和GPS定位
- device tree
- 看看一年内都发生了什么变化:Gartner 2016年应用程序平台即服务(aPaaS)魔力象限报告
- iOS 自定义Navigation
- Raptor实践参考:三色球问题
- 配置工具
- 指针作为函数形参
- android studio安装中出现Failed to install Intel HAXM错误的解决方法
- 提高机器学习模型准确率的八大方法
- 将进程的输出重定向至文件中