본문 바로가기
Xilinx SoC/Zynqberry

6.리눅스 디바이스 트리 파일 만들기

by 코딩스미스 2022. 5. 7.

SD카드에 넣을 리눅스용 디바이스 트리 파일을 준비한다.

 

Vivado에서 생성한 BitStream 파일에서 디바이스 트리를 추출한다.

이를 위해 device-tree-xlnx를 Xilinx Github에서 다운받아 Vitis 레포지토리에 등록해야 한다.

 

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

 

Vitis Xilinx>>Repositories

Preferences >> Xilinx >> Software Repositories >> Local Repositories

New

Add device-tree-xlnx 폴더

 

Vitis에서 Xilinx>>Generate Device Tree

Generate 실행하면, 아래 파일이 생성된다.

zynq-7000.dtsi

system-top.dts

Makefile

pcw.dtsi

pl.dtsi

skeleton.dtsi

 

여기에 Zynqberry 보드용 디바이스 트리 파일을 추가한다.

 

*zynqberry.dtsi

/ {
	model = "### TE0726-03M ZynqBerry DTS ###";
    chosen {
        bootargs = "console=ttyPS0,115200 root=/dev/mmcblk0p2 rw earlyprintk rootfstype=ext4 rootwait devtmpfs.mount=1 earlycon";
    };

    memory {    // Reduce memory for framebuffers
        device_type = "memory";
        //reg = <0x0 0x1FC00000>; 
        reg = <0x0 0x1F700000>;
    };

    // -- 512M (-02M modules) --
    framebuffer0: framebuffer@0x1FC00000 {      // HDMI out 
        compatible = "simple-framebuffer";
        // -- 512M (-02M modules) --
        reg = <0x1FC00000 (1280 * 720 * 4)>;    // 720p
        width = <1280>;                         // 720p
        height = <720>;                         // 720p
        stride = <(1280 * 4)>;                  // 720p
        format = "a8b8g8r8";
    };

    framebuffer1: framebuffer@0x1F700000 {      // CAMERA in
        compatible = "simple-framebuffer";
        reg = <0x1F700000 (1280 * 720 * 4)>;    // 720p
        width = <1280>;                         // 720p
        height = <720>;                         // 720p
        stride = <(1280 * 4)>;                  // 720p
        format = "a8b8g8r8";
    };

    vcc_3V3: fixedregulator@0 {
        compatible = "regulator-fixed";
        regulator-name = "vccaux-supply";
        regulator-min-microvolt = <3300000>;
        regulator-max-microvolt = <3300000>;
        regulator-always-on;
    };
};


&qspi {
    #address-cells = <1>;
    #size-cells = <0>;
    status = "okay";
    flash0: flash@0 {
        compatible = "spansion,s25fl128s";
        reg = <0x0>;
        #address-cells = <1>;
        #size-cells = <1>;
        spi-max-frequency = <50000000>;
        partition@0x00000000 {
            label = "boot";
            reg = <0x00000000 0x00500000>;
        };
        partition@0x00500000 {
            label = "bootenv";
            reg = <0x00500000 0x00020000>;
        };
        partition@0x00520000 {
            label = "kernel";
            reg = <0x00520000 0x00a80000>;
        };
        partition@0x00fa0000 {
            label = "spare";
            reg = <0x00fa0000 0x00000000>;
        };
    };
};


&gpio0 {
    interrupt-controller;
    #interrupt-cells = <2>;
};

&i2c1 {
    #address-cells = <1>;
    #size-cells = <0>;

    i2cmux0: i2cmux@70  {
        compatible = "nxp,pca9544";
        #address-cells = <1>;
        #size-cells = <0>;
        reg = <0x70>;


        i2c1@0 {
            #address-cells = <1>;
            #size-cells = <0>;
            reg = <0>;

            id_eeprom@50 {
                compatible = "atmel,24c32";
                reg = <0x50>;
            };

        };
        i2c1@1 {    // Display Interface Connector
            #address-cells = <1>;
            #size-cells = <0>;
            reg = <1>;
        };
        i2c1@2 {    // HDMI Interface Connector
            #address-cells = <1>;
            #size-cells = <0>;
            reg = <2>;
        };
        i2c1@3 {    // Camera Interface Connector
            #address-cells = <1>;
            #size-cells = <0>;
            reg = <3>;
        };
    };

};

/{
    usb_phy0: usb_phy@0 {
        compatible = "ulpi-phy";
        #phy-cells = <0>;
        reg = <0xe0002000 0x1000>;
        view-port = <0x0170>;
        drv-vbus;
    };
};

&usb0 {
    usb-phy = <&usb_phy0>;
} ;

&adc {
    status = "disabled";
};

 

system-top.dts의 말미에 아래 줄을 추가한다.

/include/ "zynqberry.dtsi"

 

gcc -I . -E -nostdinc -undef -D__DTS__ -x assembler-with-cpp -o system.dts system-top.dts

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

 

https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842279/Build+Device+Tree+Blob 

 

Build Device Tree Blob - Xilinx Wiki - Confluence

This page covers the generation of devicetree source (DTS) files using Xilinx tools as well as the building/compiling of these source files using standard open-source tools.  In particular, use of the Xilinx Devicetree Generator (DTG) will be covered for

xilinx-wiki.atlassian.net