美文网首页
7. 在根文件系统中查看设备树

7. 在根文件系统中查看设备树

作者: JalynFang | 来源:发表于2019-04-07 13:05 被阅读0次

    在根文件系统中查看设备树,是一种不错的调试手段。

    一、对设备树的描述之原始dtb格式

    a. /sys/firmware/fdt // 原始dtb文件
    hexdump -C /sys/firmware/fdt

    在u-boot启动内核时,会将dtb文件的内存地址传递给内核,并将其所占内存保留;因此,我们在内核启动后,访问该内存,获得原始的dtb。

    二、对设备树的描述之目录结构dtb格式

    b. /sys/firmware/devicetree
    以目录结构程现的dtb文件, 根节点对应base目录, 每一个节点对应一个目录, 每一个属性对应一个文件

    dts文件描述:
    / {
        model = "SMDK24440";
        compatible = "samsung,smdk2440";
    
        #address-cells = <1>;
        #size-cells = <1>;
            
        memory@30000000 {
            device_type = "memory";
            reg =  <0x30000000 0x4000000>;
        };
    /*
        cpus {
            cpu {
                compatible = "arm,arm926ej-s";
            };
        };
    */  
        chosen {
            bootargs = "noinitrd root=/dev/mtdblock4 rw init=/linuxrc console=ttySAC0,115200";
        };
    
        
        led {
            compatible = "jz2440_led";
            pin = <S3C2410_GPF(5)>;
        };
    };
    

    内核中目录结构dtb格式:

    三、内核中现存的所有platform_device

    c. /sys/devices/platform // 系统中所有的platform_device, 有来自设备树的, 也有来有.c文件中注册的;
    对于来自设备树的platform_device,可以进入 /sys/devices/platform/<设备名>/of_node 查看它的设备树属性;

    对于有of_node属性的platform_device,证明其来源于dtb。

    备注:/proc/device-tree 是链接文件, 指向 /sys/firmware/devicetree/base

    相关文章

      网友评论

          本文标题:7. 在根文件系统中查看设备树

          本文链接:https://www.haomeiwen.com/subject/gbxsiqtx.html