Zynq7000开发系列-7(在Zybo上运行Linaro桌面系统)

目标板:Zybo(7Z010)

主机操作系统:Ubuntu 14.04.5 LTS 64bit

交叉编译链: arm-xilinx-linux-gnueabi-       [gcc version 4.9.2 (Sourcery CodeBench Lite 2015.05-17)]

Linaro系统:linaro-precise-ubuntu-desktop-20120923-436.tar.gz


〇、准备工作 

1、交叉编译环境搭建,见之前的记录:Zynq7000开发系列-4(新:Xilinx交叉编译环境搭建)

2、环境变量设置

gedit /etc/bash.bashrc
在文件底部添加:
export ARCH=arm
export CROSS_COMPILE=arm-xilinx-linux-gnueabi-gcc

重启终端后生效。(后续编译命令中即可省略对ARCH、CROSS_COMPILE的指定)

 

一、硬件平台搭建

[目标文件:硬件平台综合生成的比特流文件system_warpper.bit、SDK创建的FSBL执行文件fsbl.elf、SDK/ubuntu创建的设备树文件system.dts/devicetree.dtb]

1、硬件平台综合生成的比特流文件system_warpper.bit

1)安装Vivado 2015.4,参考:Zynq7000开发系列-1(Vivado HLx 2016.4下载及安装)

2)安装zybo板级文件,参考:Installing Vivado Board Files for Digilent Boards

3)创建硬件工程,如下各图(见注释):

#1 创建名为my_linux_bd的硬件工程

Zynq7000开发系列-7(在Zybo上运行Linaro桌面系统)_第1张图片

Zynq7000开发系列-7(在Zybo上运行Linaro桌面系统)_第2张图片

 

#2 创建名为system的block design顶层文件,添加zynq系统IP,导入zybo板级配置文件,并做必要修改

Zynq7000开发系列-7(在Zybo上运行Linaro桌面系统)_第3张图片

Zynq7000开发系列-7(在Zybo上运行Linaro桌面系统)_第4张图片

Zynq7000开发系列-7(在Zybo上运行Linaro桌面系统)_第5张图片

Zynq7000开发系列-7(在Zybo上运行Linaro桌面系统)_第6张图片

Zynq7000开发系列-7(在Zybo上运行Linaro桌面系统)_第7张图片

Zynq7000开发系列-7(在Zybo上运行Linaro桌面系统)_第8张图片

Zynq7000开发系列-7(在Zybo上运行Linaro桌面系统)_第9张图片

Zynq7000开发系列-7(在Zybo上运行Linaro桌面系统)_第10张图片

Zynq7000开发系列-7(在Zybo上运行Linaro桌面系统)_第11张图片

Zynq7000开发系列-7(在Zybo上运行Linaro桌面系统)_第12张图片

 

#3 添加必要的vivado-library(开源IP核[ axi_dynclk_v1_0、rgb2dvi ]及接口[ tmds_v1_0 ])

(在工程文件夹内创建名为repo的文件夹,repo文件夹内创建if、ip文件夹,拷贝接口文件tmds_v1_0到if文件夹内,拷贝IP核axi_dynclk_v1_0、rgb2dvi到ip文件夹内,并按下图操作)

(开源vivado-library下载:https://github.com/Digilent/vivado-library)

Zynq7000开发系列-7(在Zybo上运行Linaro桌面系统)_第13张图片

Zynq7000开发系列-7(在Zybo上运行Linaro桌面系统)_第14张图片

Zynq7000开发系列-7(在Zybo上运行Linaro桌面系统)_第15张图片

 

#4 添加IP核:axi_dynclk_v1_0、rgb2dvi、gpio、vdma、vtc、stream2video等IP核,并作布线如下图所示

(布线方法:先手动连接时钟信号线FCLK_CLK0、FCLK_CLK1,然后点击上方的绿色自动布线选项)

Zynq7000开发系列-7(在Zybo上运行Linaro桌面系统)_第16张图片

其中,关键IP核配置如下:

##1 vdma

Zynq7000开发系列-7(在Zybo上运行Linaro桌面系统)_第17张图片

Zynq7000开发系列-7(在Zybo上运行Linaro桌面系统)_第18张图片

##2 vtc

Zynq7000开发系列-7(在Zybo上运行Linaro桌面系统)_第19张图片

##3 axis_subset_converter

Zynq7000开发系列-7(在Zybo上运行Linaro桌面系统)_第20张图片

##4 stream2video

Zynq7000开发系列-7(在Zybo上运行Linaro桌面系统)_第21张图片

##5 rgb2dvi

Zynq7000开发系列-7(在Zybo上运行Linaro桌面系统)_第22张图片

##6 gpio

Zynq7000开发系列-7(在Zybo上运行Linaro桌面系统)_第23张图片

##7 图中两个常量IP均为一位,数值为1,其一使converter不重置,其二使HDMI_OEN输出为高电平,指示当前hdmi为输出模式

 

#5 点击“validate design”,验证没有错误后,添加引脚约束文件,修改自ZYBO_Master.xdc

## This file is a general .xdc for the ZYBO Rev B board
## To use it in a project:
## - uncomment the lines corresponding to used pins
## - rename the used signals according to the project

##Audio Codec/external EEPROM IIC bus
#IO_L13P_T2_MRCC_34
set_property PACKAGE_PIN N18 [get_ports iic_0_scl_io]
set_property IOSTANDARD LVCMOS33 [get_ports iic_0_scl_io]

#IO_L23P_T3_34
set_property PACKAGE_PIN N17 [get_ports iic_0_sda_io]
set_property IOSTANDARD LVCMOS33 [get_ports iic_0_sda_io]


##HDMI Signals
#IO_L13N_T2_MRCC_35
set_property IOSTANDARD TMDS_33 [get_ports TMDS_clk_n]

#IO_L13P_T2_MRCC_35
set_property PACKAGE_PIN H16 [get_ports TMDS_clk_p]
set_property IOSTANDARD TMDS_33 [get_ports TMDS_clk_p]

#IO_L4N_T0_35
set_property IOSTANDARD TMDS_33 [get_ports {TMDS_data_n[0]}]

#IO_L4P_T0_35
set_property PACKAGE_PIN D19 [get_ports {TMDS_data_p[0]}]
set_property IOSTANDARD TMDS_33 [get_ports {TMDS_data_p[0]}]

#IO_L1N_T0_AD0N_35
set_property IOSTANDARD TMDS_33 [get_ports {TMDS_data_n[1]}]

#IO_L1P_T0_AD0P_35
set_property PACKAGE_PIN C20 [get_ports {TMDS_data_p[1]}]
set_property IOSTANDARD TMDS_33 [get_ports {TMDS_data_p[1]}]

#IO_L2N_T0_AD8N_35
set_property IOSTANDARD TMDS_33 [get_ports {TMDS_data_n[2]}]

#IO_L2P_T0_AD8P_35
set_property PACKAGE_PIN B19 [get_ports {TMDS_data_p[2]}]
set_property IOSTANDARD TMDS_33 [get_ports {TMDS_data_p[2]}]


#IO_L5P_T0_AD9P_35
set_property PACKAGE_PIN E18 [get_ports {hdmi_hpd_tri_i[0]}]
set_property IOSTANDARD LVCMOS33 [get_ports {hdmi_hpd_tri_i[0]}]

##IO_L6N_T0_VREF_35
set_property PACKAGE_PIN F17 [get_ports {HDMI_OEN[0]}]
set_property IOSTANDARD LVCMOS33 [get_ports {HDMI_OEN[0]}]

#IO_L16P_T2_35
set_property PACKAGE_PIN G17 [get_ports hdmi_ddc_scl_io]
set_property IOSTANDARD LVCMOS33 [get_ports hdmi_ddc_scl_io]

#IO_L16N_T2_35
set_property PACKAGE_PIN G18 [get_ports hdmi_ddc_sda_io]
set_property IOSTANDARD LVCMOS33 [get_ports hdmi_ddc_sda_io]

 

#6 点击“generate bitstream”,等待生成比特流文件

 

2、SDK创建的FSBL执行文件fsbl.elf

略。

 

3、SDK/ubuntu创建的设备树文件system.dts/devicetree.dtb

1)下载device_tree配置文件,链接:https://github.com/Xilinx/device-tree-xlnx/releases(注意下载的版本与vivado版本匹配)

2)SDK添加device_tree配置文件

Xilinx Tools -> Repositories -> New

Zynq7000开发系列-7(在Zybo上运行Linaro桌面系统)_第24张图片

 

3)SDK创建device_tree工程,生成dts文件

File -> New -> Board Support Package

Zynq7000开发系列-7(在Zybo上运行Linaro桌面系统)_第25张图片

 

4)bootagrs参数设定

(e.g.  console=ttyPS0,115200 root=/dev/mmcblk0p2 rw earlyprintk rootfstype=ext4 rootwait devtmpfs.mount=1)

Zynq7000开发系列-7(在Zybo上运行Linaro桌面系统)_第26张图片

 

5)[重要] 根据相关硬件做出修改,如下:

#1 添加usb驱动配置

在pl.dtsi文件中最后一个分号“ } ; ”前添加:

/*add for usb0*/
    usb_phy_0: usb_phy {
        compatible = "usb-nop-xceiv";
        #phy-cells = <0x0>;
    };

并在zynq-7000.dtsi文件中,usb0标签的最后一个分号“ } ; ”前添加:

usb-phy = <&usb_phy_0>;//add for usb0

 

#2 添加hdmi驱动配置

在pl.dtsi文件中,amba_pl标签内作如下修改:

amba_pl: amba_pl {
        #address-cells = <1>;
        #size-cells = <1>;
        compatible = "simple-bus";
        ranges ;
        axi_dynclk_0: axi_dynclk@43c00000 {
            #clock-cells = <0x0>;//add
            compatible = "digilent,axi-dynclk";//change
            reg = <0x43c00000 0x10000>;
            xlnx,s00-axi-addr-width = <0x5>;
            xlnx,s00-axi-data-width = <0x20>;
            clocks = <&clkc  0xf>;//add, 0xf不能删掉
        };
        axi_gpio_hdmi: gpio@41200000 {
            #gpio-cells = <2>;
            compatible = "xlnx,xps-gpio-1.00.a";
            gpio-controller ;
            interrupt-parent = <&intc>;
            interrupts = <0 29 4>;
            reg = <0x41200000 0x10000>;
            xlnx,all-inputs = <0x1>;
            xlnx,all-inputs-2 = <0x0>;
            xlnx,all-outputs = <0x0>;
            xlnx,all-outputs-2 = <0x0>;
            xlnx,dout-default = <0x00000000>;
            xlnx,dout-default-2 = <0x00000000>;
            xlnx,gpio-width = <0x1>;
            xlnx,gpio2-width = <0x20>;
            xlnx,interrupt-present = <0x1>;
            xlnx,is-dual = <0x0>;
            xlnx,tri-default = <0xFFFFFFFF>;
            xlnx,tri-default-2 = <0xFFFFFFFF>;
        };
        axi_vdma_0: dma@43000000 {
            #dma-cells = <1>;
            compatible = "xlnx,axi-vdma-1.00.a";
            interrupt-parent = <&intc>;
            interrupts = <0 30 4>;
            reg = <0x43000000 0x10000>;
            //xlnx,flush-fsync = <0x1>;//change
            xlnx,num-fstores = <0x1>;
            dma-channel@43000000 {
                compatible = "xlnx,axi-vdma-mm2s-channel";
                interrupts = <0 30 4>;
                clocks = <&clkc>;//add
                clock-names = "axis";//add
                xlnx,datawidth = <0x20>;
                xlnx,device-id = <0x0>;
            };
        };
        v_tc_0: v_tc@43c10000 {
            compatible = "xlnx,v-tc-5.01.a";//change
            interrupt-parent = <&intc>;
            interrupts = <0 31 4>;
            reg = <0x43c10000 0x10000>;
            xlnx,det-achroma-en = <0x0>;
            xlnx,det-avideo-en = <0x1>;
            xlnx,det-fieldid-en = <0x0>;
            xlnx,det-hblank-en = <0x1>;
            xlnx,det-hsync-en = <0x1>;
            xlnx,det-vblank-en = <0x1>;
            xlnx,det-vsync-en = <0x1>;
            xlnx,detect-en = <0x0>;
            xlnx,fsync-hstart0 = <0x0>;
            xlnx,fsync-hstart1 = <0x0>;
            xlnx,fsync-hstart10 = <0x0>;
            xlnx,fsync-hstart11 = <0x0>;
            xlnx,fsync-hstart12 = <0x0>;
            xlnx,fsync-hstart13 = <0x0>;
            xlnx,fsync-hstart14 = <0x0>;
            xlnx,fsync-hstart15 = <0x0>;
            xlnx,fsync-hstart2 = <0x0>;
            xlnx,fsync-hstart3 = <0x0>;
            xlnx,fsync-hstart4 = <0x0>;
            xlnx,fsync-hstart5 = <0x0>;
            xlnx,fsync-hstart6 = <0x0>;
            xlnx,fsync-hstart7 = <0x0>;
            xlnx,fsync-hstart8 = <0x0>;
            xlnx,fsync-hstart9 = <0x0>;
            xlnx,fsync-vstart0 = <0x0>;
            xlnx,fsync-vstart1 = <0x0>;
            xlnx,fsync-vstart10 = <0x0>;
            xlnx,fsync-vstart11 = <0x0>;
            xlnx,fsync-vstart12 = <0x0>;
            xlnx,fsync-vstart13 = <0x0>;
            xlnx,fsync-vstart14 = <0x0>;
            xlnx,fsync-vstart15 = <0x0>;
            xlnx,fsync-vstart2 = <0x0>;
            xlnx,fsync-vstart3 = <0x0>;
            xlnx,fsync-vstart4 = <0x0>;
            xlnx,fsync-vstart5 = <0x0>;
            xlnx,fsync-vstart6 = <0x0>;
            xlnx,fsync-vstart7 = <0x0>;
            xlnx,fsync-vstart8 = <0x0>;
            xlnx,fsync-vstart9 = <0x0>;
            xlnx,gen-achroma-en = <0x0>;
            xlnx,gen-achroma-polarity = <0x1>;
            xlnx,gen-auto-switch = <0x0>;
            xlnx,gen-avideo-en = <0x1>;
            xlnx,gen-avideo-polarity = <0x1>;
            xlnx,gen-cparity = <0x0>;
            xlnx,gen-f0-vblank-hend = <0x500>;
            xlnx,gen-f0-vblank-hstart = <0x500>;
            xlnx,gen-f0-vframe-size = <0x2ee>;
            xlnx,gen-f0-vsync-hend = <0x500>;
            xlnx,gen-f0-vsync-hstart = <0x500>;
            xlnx,gen-f0-vsync-vend = <0x2d9>;
            xlnx,gen-f0-vsync-vstart = <0x2d4>;
            xlnx,gen-f1-vblank-hend = <0x500>;
            xlnx,gen-f1-vblank-hstart = <0x500>;
            xlnx,gen-f1-vframe-size = <0x2ee>;
            xlnx,gen-f1-vsync-hend = <0x500>;
            xlnx,gen-f1-vsync-hstart = <0x500>;
            xlnx,gen-f1-vsync-vend = <0x2d9>;
            xlnx,gen-f1-vsync-vstart = <0x2d4>;
            xlnx,gen-fieldid-en = <0x0>;
            xlnx,gen-fieldid-polarity = <0x1>;
            xlnx,gen-hactive-size = <0x500>;
            xlnx,gen-hblank-en = <0x1>;
            xlnx,gen-hblank-polarity = <0x1>;
            xlnx,gen-hframe-size = <0x672>;
            xlnx,gen-hsync-en = <0x1>;
            xlnx,gen-hsync-end = <0x596>;
            xlnx,gen-hsync-polarity = <0x1>;
            xlnx,gen-hsync-start = <0x56e>;
            xlnx,gen-interlaced = <0x0>;
            xlnx,gen-vactive-size = <0x2d0>;
            xlnx,gen-vblank-en = <0x1>;
            xlnx,gen-vblank-polarity = <0x1>;
            xlnx,gen-video-format = <0x2>;
            xlnx,gen-vsync-en = <0x1>;
            xlnx,gen-vsync-polarity = <0x1>;
            xlnx,generate-en = <0x1>;
            xlnx,has-axi4-lite = <0x1>;
            xlnx,has-intc-if = <0x0>;
            xlnx,interlace-en = <0x0>;
            xlnx,max-lines = <0x1000>;
            xlnx,max-pixels = <0x1000>;
            xlnx,num-fsyncs = <0x1>;
            xlnx,sync-en = <0x0>;
        };
        /*add for vga_hdmi_encoder*/
        digilent_encoder_0: digilent_encoder {
            compatible = "dglnt,drm-encoder";
            dglnt,edid-i2c = <&i2c1>;
        };
        /*add for drm*/
        xilinx_drm_0: xilinx_drm {
            compatible = "xlnx,drm";
            xlnx,vtc = <&v_tc_0>;
            xlnx,connector-type = "HDMIA";
            xlnx,encoder-slave = <&digilent_encoder_0>;
            clocks = <&axi_dynclk_0>;
            dglnt,edid-i2c = <&i2c1>;
            planes {
                xlnx,pixel-format = "xrgb8888";
                plane0 {
                    dmas = <&axi_vdma_0 0>;//0不能删掉
                    dma-names = "dma";
                };
            };
        };
    };

 

6)修改后,工程会重新编译,复制device_tree_dsp_0整个文件夹到ubuntu系统下,执行以下命令生成设备树文件devicetree.dtb

cd device_tree_dsp_0
dtc -I dts -O dtb ./system.dts -o devicetree.dtb

(前提:安装dtc工具,或从Linux kernel源码中拷贝dtc执行文件出来)

(安装命令:sudo apt-get install device-tree-compile)

 

二、软件平台搭建

[目标文件:启动引导程序u-boot.elf、Linux内核文件uImage、文件系统linaro]

 

[待续...]

 

 

 

 


官方教程链接:

ZYBOt Guide [Reference.Digilentinc]
https://reference.digilentinc.com/learn/programmable-logic/tutorials/zybo-zybot-guide/start

Zybot - Getting Started Guide and Source Code: 8 Steps
http://www.instructables.com/id/Zybot-Getting-Started-Guide/


搭建好了硬件平台、Linaro软件桌面系统,下一步便是开发应用程序(用到Qt与OpenCV),然后交叉编译后移植到Linaro系统中运行。但此时又发生了一个重大问题:交叉编译后的应用程序不能运行,涉及到Linaro系统编译时所用的编译器版本问题、2012年后Linaro系统加载程序的路径及名称问题,以至于需要重装交叉编译链、重新交叉编译Qt与OpenCV等,下一篇文章再续。

 

转载于:https://www.cnblogs.com/wmxfd/p/zynq7000_development_7_running_linaro_desktop_system_on_zybo.html

你可能感兴趣的:(Zynq7000开发系列-7(在Zybo上运行Linaro桌面系统))