全志平台uboot节点dts使用说明

free-jdx 2020-10-13 21:00:00 5722
1.前言

uboot中,在控制台修改device tree配置使用的方法

2. FDT工具

在UBOOT控制台停下后,输入fdt

sunxi#fdt
fdt - flattened device tree utility commands
Usage:
fdt addr [-c]  <addr> [<length>]   - Set the [control] fdt location to <addr>
fdt move   <fdt> <newaddr> <length> - Copy the fdt to <addr> and make it active
fdt resize                          - Resize fdt to size + padding to 4k addr
fdt print  <path> [<prop>]          - Recursive print starting at <path>
fdt list   <path> [<prop>]          - Print one level starting at <path>
fdt get value <var> <path> <prop>   - Get <property> and store in <var>
fdt get name <var> <path> <index>   - Get name of node <index> and store in <var>
fdt get addr <var> <path> <prop>    - Get start address of <property> and store in <var>
fdt get size <var> <path> [<prop>]  - Get size of [<property>] or num nodes and store in <var>
fdt set    <path> <prop> [<val>]    - Set <property> [to <val>]
fdt mknode <path> <node>            - Create a new node after <path>
fdt rm     <path> [<prop>]          - Delete the node or <property>
fdt header                          - Display header info
fdt bootcpu <id>                    - Set boot cpuid
fdt memory <addr> <size>            - Add/Update memory node
fdt rsvmem print                    - Show current mem reserves
fdt rsvmem add <addr> <size>        - Add a mem reserve
fdt rsvmem delete <index>           - Delete a mem reserves
fdt chosen [<start> <end>]          - Add/update the /chosen branch in the tree
                                        <start>/<end> - initrd start/end addr
fdt save                           - write fdt to flash
NOTE: Dereference aliases by omiting the leading '/', e.g. fdt print ethernet0.

Fdt list 用来查询节点配置
Fdt set 用来修改节点配置

3. 查询配置

先确定要查询的字段在device tree的路径,如果不知道路径,则需要用fdt命令查询

(1)根目录查找
sunxi#fdt list  /    
/ {
        model = "sun50iw1p1";
        compatible = "arm,sun50iw1p1", "arm,sun50iw1p1";
        interrupt-parent = <0x00000001>;
        #address-cells = <0x00000002>;
        #size-cells = <0x00000002>;
        ......................
        cpuscfg {
        };
        ion {
        };
        dram {
...

如果找到需要的配置,比如wlan的配置,可查找关键字

sunxi#fdt list /wlan                //注意路径中的 /
wlan {
        compatible = "allwinner,sunxi-wlan";
        clocks = <0x00000096>;
        wlan_power = "vcc-wifi";
        wlan_io_regulator = "vcc-wifi-io";
        wlan_busnum = <0x00000001>;
        status = "okay";
        device_type = "wlan";
        wlan_regon = <0x00000077 0x0000000b 0x00000002 0x00000001 0xffffffff 0xffffffff 0x00000000>;
        wlan_hostwake = <0x00000077 0x0000000b 0x00000003 0x00000006 0xffffffff 0xffffffff 0x00000000>;
};
(2)SOC目录查找

比如nand0的配置,则该配置可能在soc目录下

sunxi#fdt list /soc
soc@01c00000 {
        compatible = "simple-bus";
        #address-cells = <0x00000002>;
        #size-cells = <0x00000002>;
        ranges;
        device_type = "soc";
       ......................
        hdmi@01ee0000 {
        };
.....

(3)使用路径别名查找
别名是device tree中完整路径的一个简写,有一个专门的节点( /aliases )来表示别名的相关信息,用如下命令可以查看系统中别名的配置情况:

sunxi#fdt list /aliases
aliases {
        serial0 = "/soc@01c00000/uart@01c28000";
       ..............
        mmc0 = "/soc@01c00000/sdmmc@01c0f000";
        mmc2 = "/soc@01c00000/sdmmc@01C11000";
        nand0 = "/soc@01c00000/nand0@01c03000";
        disp = "/soc@01c00000/disp@01000000";
        lcd0 = "/soc@01c00000/lcd0@01c0c000";
        hdmi = "/soc@01c00000/hdmi@01ee0000";
        pwm = "/soc@01c00000/pwm@01c21400";
        boot_disp = "/soc@01c00000/boot_disp";
};

注:在fdt的所有命令中,别名可用path 字段
fdt list [] - Print one level starting at
fdt set [] - Set [to ]

4. 修改配置
(1)修改整数配置

命令格式:fdt set path prop
示例: fdt set /wlan wlan_busnum <0x2>

sunxi#fdt list /wlan                
wlan {
        compatible = "allwinner,sunxi-wlan";
        clocks = <0x00000096>;
        wlan_power = "vcc-wifi";
        wlan_io_regulator = "vcc-wifi-io";
        wlan_busnum = <0x00000001>;
        status = "disable";
        device_type = "wlan";
};
sunxi#fdt set /wlan wlan_busnum <0x2>    
sunxi#fdt list /wlan                 
wlan {
        compatible = "allwinner,sunxi-wlan";
        clocks = <0x00000096>;
        wlan_power = "vcc-wifi";
        wlan_io_regulator = "vcc-wifi-io";
        wlan_busnum = <0x00000002>;    //修改后
        status = "disable";
        device_type = "wlan";
};
(2)修改字符串

命令格式:fdt set path prop "xxxxx"
示例: fdt set /wlan status "disable"

sunxi#fdt list /wlan
wlan {
        compatible = "allwinner,sunxi-wlan";
        clocks = <0x00000096>;
        wlan_power = "vcc-wifi";
        wlan_io_regulator = "vcc-wifi-io";
        wlan_busnum = <0x00000001>;
        status = "okay";
        device_type = "wlan";
};
sunxi#fdt set /wlan status "disable"                                               
sunxi#fdt list /wlan                
wlan {
        compatible = "allwinner,sunxi-wlan";
        clocks = <0x00000096>;
        wlan_power = "vcc-wifi";
        wlan_io_regulator = "vcc-wifi-io";
        wlan_busnum = <0x00000001>;
        status = "disable";              //修改后
        device_type = "wlan";
};
sunxi#
5. 保存配置

命令格式:fdt save
作用:保存配置到存储介质上,掉电不会丢失。
运行该命令后,可以接着运行 reset命令重启系统,然后用fdt查询命令看所修改的内容是否已永久生效。

声明:本文内容由易百纳平台入驻作者撰写,文章观点仅代表作者本人,不代表易百纳立场。如有内容侵权或者其他问题,请联系本站进行删除。
free-jdx
红包 14 2 评论 打赏
评论
0个
内容存在敏感词
手气红包
    易百纳技术社区暂无数据
相关专栏
置顶时间设置
结束时间
删除原因
  • 广告/SPAM
  • 恶意灌水
  • 违规内容
  • 文不对题
  • 重复发帖
打赏作者
易百纳技术社区
free-jdx
您的支持将鼓励我继续创作!
打赏金额:
¥1易百纳技术社区
¥5易百纳技术社区
¥10易百纳技术社区
¥50易百纳技术社区
¥100易百纳技术社区
支付方式:
微信支付
支付宝支付
易百纳技术社区微信支付
易百纳技术社区
打赏成功!

感谢您的打赏,如若您也想被打赏,可前往 发表专栏 哦~

举报反馈

举报类型

  • 内容涉黄/赌/毒
  • 内容侵权/抄袭
  • 政治相关
  • 涉嫌广告
  • 侮辱谩骂
  • 其他

详细说明

审核成功

发布时间设置
发布时间:
是否关联周任务-专栏模块

审核失败

失败原因
备注
拼手气红包 红包规则
祝福语
恭喜发财,大吉大利!
红包金额
红包最小金额不能低于5元
红包数量
红包数量范围10~50个
余额支付
当前余额:
可前往问答、专栏板块获取收益 去获取
取 消 确 定

小包子的红包

恭喜发财,大吉大利

已领取20/40,共1.6元 红包规则

    易百纳技术社区