目的:帮助初次使用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 |
The Linux kernel with Xilinx patches and drivers |
|
The u-boot bootloader with Xilinx patches and drivers |
|
Device Tree generator plugin for xsdk |
|
Device Tree compiler (required to build U-Boot) |
|
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