如何用SDK生成device tree


目的:幫助初次使用Zynq & MPSoC的朋友,在PL添加IP(比如AXI-CAN),應如何生成對應的devic tree

Step1: 下載device-tree-xlnx自動生成工具集

參考http://www.wiki.xilinx.com/Fetch+Sources,下載device-tree-xlnx

The following table gives an overview of the relevant repositories:

Repository Name

Content

https://github.com/Xilinx/linux-xlnx.git

The Linux kernel with Xilinx patches and drivers

https://github.com/Xilinx/u-boot-xlnx.git

The u-boot bootloader with Xilinx patches and drivers

https://github.com/Xilinx/device-tree-xlnx.git

Device Tree generator plugin for xsdk

https://git.kernel.org/pub/scm/utils/dtc/dtc.git

Device Tree compiler (required to build U-Boot)

https://github.com/Xilinx/arm-trusted-firmware.git

ARM Trusted Firmware (required for Zynq UltraScale+ MPSoC

The sources of either project can be obtained through git by executing:

 

Step2:SDK中添加device-tree-xlnx

SDK --> Xilinx tools --> Repositories --> 添加device-tree-xlnx

 

 

Step3: 生成device-tree

SDK --> File --> New --> Board support package

 

 

根據實際情況填寫bootargs,也可以稍后自己手動加入,你可以看到axi-can已經在里面了

  

生成的device tree,會包含pl.dtsi就是在pl側添加的ip生產的對應的node和參數

 

 Pl.dtsi文件如下:

/*
 * CAUTION: This file is automatically generated by Xilinx.
 * Version:  
 * Today is: Thu Oct 19 13:15:57 2017
*/


/ {
    amba_pl: amba_pl@0 {
        #address-cells = <2>;
        #size-cells = <2>;
        compatible = "simple-bus";
        ranges ;
        can_0: can@a0000000 {
            clock-names = "can_clk s_axi_aclk";
            clocks = <&misc_clk_0>, <&misc_clk_1>;
            compatible = "xlnx,axi-can-1.00.a";
            reg = <0x0 0xa0000000 0x0 0x10000>;
            rx-fifo-depth = <0x2>;
            tx-fifo-depth = <0x2>;
        };
        psu_ctrl_ipi: PERIPHERAL@ff380000 {
            compatible = "xlnx,PERIPHERAL-1.0";
            reg = <0x0 0xff380000 0x0 0x80000>;
        };
        psu_message_buffers: PERIPHERAL@ff990000 {
            compatible = "xlnx,PERIPHERAL-1.0";
            reg = <0x0 0xff990000 0x0 0x10000>;
        };
        misc_clk_0: misc_clk_0 {
            #clock-cells = <0>;
            clock-frequency = <15686000>;
            compatible = "fixed-clock";
        };
        misc_clk_1: misc_clk_1 {
            #clock-cells = <0>;
            clock-frequency = <99999000>;
            compatible = "fixed-clock";
        };
    };
};

 

Step4:下載DTC,或者利用linux 包中以及集成的工具編譯device-tree, 命令參考wiki鏈接:

http://www.wiki.xilinx.com/Build+Device+Tree+Blob

 

Compiling a Device Tree Blob (.dtb) file from the DTS

A utility called device tree compiler (DTC) is used to compile the DTS file into a DTB file. DTC is part of the Linux source directory. linux-xlnx/scripts/dtc/ contains the source code for DTC and needs to be compiled in order to be used. One way to compile the DTC is to build the Linux tree. The DTC might also be available through your OS's package manager.

Once the DTC is available, the tool may be invoked to generate the DTB:

./scripts/dtc/dtc -I dts -O dtb -o <devicetree name>.dtb <devicetree name>.dts

DTC may also be used to convert a DTB back into a DTS:

./scripts/dtc/dtc -I dtb -O dts -o <devicetree name>.dts <devicetree name>.dtb

 

-end


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM