设备树DTS

device tree

一、 介绍

调试平台

   ubuntu18.04

二、 dts 和 dtb 相互转换

device tree 调试工具

sudo sudo apt-get install device-tree-compiler

dts 转 dtb

dtc -I dts -O dtb -o *.dtb *.dts

dtb 转 dts

dtc -I dtb -O dts *.dtb -o *.dts

dtb 转数组到数组 *.c

xxd -i *.dtb ./*.c

三、 device tree 语法格式

*.dts 文件开头必须采用如下所示开头

 /dts-v1/;     // version: 17     // last_comp_version: 16     // boot_cpuid_phys: 0x0

16进制数组表示方法如下(注:字节间必须有一个空格,且暂时不支持换行)

mac {
   
        sta_mac_addr = [C8 43 57 82 73 40];
        ap_mac_addr = [C8 43 57 82 73 02];
    };

字符串或者字符串数据表示方法如下

model = "bl bl602 AVB board";
compatible = "bl,bl602-sample", "bl,bl602-common";

32bit数据表示方法(可以使用16进制ox方式,也可使用10进制方式,字节间必须有一个空格,且暂时不支持换行)

pwr_table = <0x4 0x64>
pwr_table = <4 100>

四、 device tree 模块配置

串口配置

串口暂时仅支持配置以下功能
使能串口

status = "okay";

关闭串口
闭串口时,余下其他引脚、波特率等配置均无效,不会初始化相关硬件

status = "disable";

配置引脚

暂时不支持配置cts和rts相关功能,故暂时feature中rts和cts均为disable。如果使用了串的tx和rx,feature中到tx和rx需要配置为okay,pin中的tx和rx需要选择相关引脚。

pin {
   
    rx = <7>;
    tx = <16>;
};
feature {
   
    rts = "disable";
    cts = "disable";
    rx = "okay";
    tx = "okay";
};

配置波特率

配置波特率参考如下,最大支持 2000000 bps这里以9600为例

baudrate = <9600>;

配置id号

配置id参考如下,这里以<0>为例

id = <0>;

配置设备名

目前串口设备名为/dev/ttyS,接当前串口id号,目前调试口使用 /dev/ttyS0

pin {
   
        rx = <7>;
        tx = <16>;
    };
feature {
   
    rts = "disable";
    cts = "disable";
    rx = "okay";
    tx = "okay";
};
path = "/dev/ttyS0";

五、 device tree 模块配置示例

bl_factory_params_IoTKitA_40M.dts

/dts-v1/;
/include/ "bl602_base.dtsi";
// version: 17
// last_comp_version: 16
// boot_cpuid_phys: 0x0

/ {
   
    model = "bl bl602 AVB board";
    compatible = "bl,bl602-sample", "bl,bl602-common";
    #address-cells = <0x1>;
    #size-cells = <0x1>;
    gpio {
   
        #address-cells = <1>;
        #size-cells = <1>;
        max_num = <40>;
        gpio0 {
                                     
            status = "okay";     //启用/禁用串口           
            pin  = <5>;         //cpu引脚                       
            feature = "led";    //功能                 
            active = "Hi"; //Hi or Lo
            mode = "blink"; //blink or hearbeat
            time = <100>; //duration for this mode
        };
        gpio1 {
                                     
            status = "disable";                     
            pin  = <6>;                          
            feature = "led";                     
            active = "Hi"
  • 4
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

唯有云缱绻

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值