基于AX7020的petalinux生成并驱动液晶屏(071)

基于AX7020的petalinux生成并驱动触摸屏(071)

环境

Ubuntu14.04、触摸屏AN071
vivado 2015.4、petalinux 2015.4、黑金 zynq 开发板 AX7010/AX7020
测试:QT5.6.2

过程目录

1、PC下安装vivado2015.4
2、PC下安装qt5.6.2,并且交叉编译qt5.6.2
3、PC下安装petalinux
4、基于触摸屏的vivado工程文档来生成petalinux
5、下载SD卡准备

介绍

本文是对alinx的官方文档的一个整合,并基于其他工程而生成的petalinux,并修改了官方文档的两个错误。
一个是顶层设备数代码的Bug
一个是配置内核的选择

备注

用Xilinx的交叉编译器(2017前)所编译的QT库对于debian文件系统是不支持的,在运行程序时会报“未发现文件”的错,即linaro之类的文件系统配上arm-xilinx-linux-gnueabi-gcc/g++都是不行的。
qt库的编译,使用Xilinx提供的编译器,而LINUX的根文件系统不是.
在后来,Xilinx为了解决这个问题,放弃了自己的编译器,这个在后来就是2017.4版本,Xilinx放弃自己的编译器,即没有arm-xilinx-linux-gnueabi-系列的.

1、PC下安装vivado2015.4

基本库安装

sudo su
rm /bin/sh
ln -s /bin/bash /bin/sh
ls -al /bin/sh
apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0 lib32stdc++6
apt-get install iproute2:i386
apt-get install gawk:i386
apt-get install gcc
apt-get install gcc:i386
apt-get install git:i386
apt-get install make:i386
apt-get install net-tools:i386
apt-get install libncurses5-dev:i386
apt-get install zlib1g-dev:i386
apt-get install libssl-dev:i386
apt-get install flex:i386
apt-get install bison:i386
apt-get install libselinux1:i386
apt-get install libncurses5 libncurses5-dev
apt-get install libc6:i386
apt-get install libstdc++6:i386
apt-get install zlib1g:i386
apt-get install libssl-dev
apt-get install tftpd tftp openbsd-inetd

sudo tar -zxvf Xilinx_Vivado_SDK_2015.4_1118_2.tar.gz
cd Xilinx_Vivado_SDK_2015.4_1118_2
./xsetup

后三步解压安装,最好安装在/opt/Xilinx目录下,空间不够可以尝试扩盘
安装完成后,别忘了提升权限

sudo chmod 777 -R /opt/Xilinx/
chmod 777 -R ~/.Xilinx/

vivado的使用

sudo su
source /opt/Xilinx/Vivado/2015.4/settings64.sh
vivado&

2、PC下安装qt5.6.2,并且交叉编译qt5.6.2

基本库安装,对安装包提高权限,进入安装过程

sudo apt-get install mesa-common-dev libgl1-mesa-dev libglu1-mesa-dev freeglut3-dev g++
chmod +x qt-opensource-linux-x64-5.6.2.run
./qt-opensource-linux-x64-5.6.2.run

ZYNQ的QT编译
文件:alinx_heijin_QT.tar.gz
对它进行解压,注意解压到/home/work/目录下,进入里面然后运行

./build.sh

迚入 intall 目录可以看到头文件“include”目录,“lib”目录等等,其中“lib”是运行库和
“plugins”是一些插件。build.sh文件里面的make命令可以根据电脑性能来采用多线程
PC上安装nfs,并且将/home/work目录挂载上去,具体参见基本开发教程后几章。

3、PC下安装petalinux

sudo su
rm /bin/sh
ln -s /bin/bash /bin/sh
ls -al /bin/sh
apt-get install tofrodos:i386
apt-get install iproute2:i386
apt-get install gawk:i386
apt-get install gcc
apt-get install gcc:i386
apt-get install net-tools:i386
apt-get install zlib1g-dev:i386
apt-get install libssl-dev:i386
apt-get install flex:i386
apt-get install bison:i386
apt-get install libselinux1:i386
apt-get install libncurses5 libncurses5-dev
apt-get install libc6:i386
apt-get install libstdc++6:i386
apt-get install zlib1g:i386
apt-get install libssl-dev
apt-get install tftpd tftp openbsd-inetd

将 petalinux 安装包(petalinux-v2015.4-final-installer-dec.run)复制到 ubuntu 系统中,有些虚拟机可以直接复制,如果无法直接复制,可以先复制到 U 盘、移动硬盘,然后在虚拟机下从 U 盘复制。在 petalinux 安装包所在目录运行终端。
在 Petalinx 安装包的目录下打开 Ternimal 窗口,然后输入以下两条命令:

sudo su
chmod +x petalinux-v2015.4-final-installer-dec.run
./petalinux-v2015.4-final-installer-dec.run /opt/Xilinx

4、基于触摸屏的vivado工程文档来生成petalinux

(1)工程生成硬件文件

用vivado运行工程ts_an071_linux_ax7020,重新仿真,运行sdk,生成hd文件,但是原先的zip文件其实也有生成,直接用就是了。
在 vivado 工程的目录下会有“ts_an071_linux_ax7020.sdk/system_wrapper_hw_platform_0”目录产生,其中“system_wrapper_hw_platform_0”是 petalinux 需要的文件夹
将“system_wrapper_hw_platform_0”文件夹复制到装有 petalinux 的 Linux 系统中,这里我们在\home\work 目录下新建一个名为 petalinux 的文件夹。把“system_wrapper_hw_platform_0”文件夹复制到这个文件夹下,并改名为“ax7020_hw_platform_0”,以备 petalinux 使用。

(2)驱动以及petalinux工程生成创建

petalinux 下默认是没有 HDMI 输出相关的驱动的,黑金将这部分驱动加入到 petalinux 的驱动中,将黑金提供的驱动替换原有的驱动,首先复制驱动压缩文件"drivers.tar.gz"到
“/home/work/petalinux”目录下。

在 root 账户下迚入“/opt/Xilinx/petalinux-v2015.4-final/components/linux-kernel/xlnx-4.0”目录,这是 petalinux 安装后的 Linux 内核所在目录,然后运行解压命令。

sudo su
cd /opt/Xilinx/petalinux-v2015.4-final/components/linux-kernel/xlnx-4.0
tar -zxvf /home/work/petalinux/drivers.tar.gz

在/home/work/petalinux目录下

sudo su
source /opt/Xilinx/petalinux-v2015.4-final/settings.sh
source /opt/Xilinx/Vivado/2015.4/settings64.sh
petalinux-create --type project --template zynq --name ax7020_an071
cd ax7020_an071
petalinux-config --get-hw-description ../ax7020_hw_platform_0/

save、exit

(3)修改设备树

工程目录下,即/home/work/petalinux/ax7020_an071

gedit subsystems/linux/configs/device-tree/system-top.dts

复制如下

/dts-v1/;
/include/ "system-conf.dtsi"
/ {
	usb_phy0:usb_phy@0 {
		compatible = "ulpi-phy";
		#phy-cells = <0x0>;
		reg = <0xe0002000 0x1000>;
		view-port=<0x170>;
		reset-gpios = <&gpio0 8 0>;
		drv-vbus;
	};
	xilinx_drm_0: xilinx_drm {
		compatible = "xlnx,drm";
		xlnx,vtc = <&v_tc_0>;
		xlnx,connector-type = "HDMIA";
		xlnx,encoder-slave = <&an071_encoder_0>;
		clocks = <&axi_dynclk_0>;
		planes {
			xlnx,pixel-format = "xrgb8888";
			plane0 {dmas = <&axi_vdma_0 0x0>;
			dma-names = "dma";
				};
			};
		};
		an071_encoder_0: an071_encoder {
			compatible = "ax_lcd,drm-encoder";
		};
};

&usb0 {
	status = "okay";
	dr_mode = "host";
	usb-phy = <&usb_phy0>;
};

&axi_dynclk_0 {
	compatible = "digilent,axi-dynclk";
	#clock-cells = <0x0>;
	xlnx,s00-axi-addr-width = <0x5>;
	xlnx,s00-axi-data-width = <0x20>;
	clocks = <&clkc 0xf>;
};

&i2c1 {
	compatible = "cdns,i2c-r1p10";
	status = "okay";
	alinx_an071@38 {
		compatible = "alinx,an071";
		reg = <0x38>;
		interrupt-parent = <&intc>;
		interrupts = <0 29 4>;
	};
};

&v_tc_0 {
	compatible = "xlnx,v-tc-5.01.a";
	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>;
};

(4)配置内核

工程目录下,即/home/work/petalinux/ax7020_an071

petalinux-config -c kernel

Device Drivers ---->
Input device support --->
Touchscreens --->(注意这里先按Y)
<> Alinx_ts I2C Touchscreen support (注意这里按Y)
exit
exit
Graphics support --->
Direct Rendering Manager --->
ALINX LCD DRM Encoder Driver(注意这里按Y)
exit
exit
Common Clock Framework
<*> Digilent axi_dynclk Driver(注意这里按Y)
save
exit
petalinux-config -c rootfs

Filesystem Packages
base
external-xilinx-toolchain
libstdc++6
save
exit
petalinux-build

合并BOOT文件

petalinux-package --boot --fsbl ./images/linux/zynq_fsbl.elf --fpga ./images/linux/system_wrapper.bit --
uboot --force

将/home/work/petalinux/ax7020_an071/images/linux下的BOOT.BIN和image.ub拷贝到sd卡中,注意SD卡先格式化成FAT格式,不用分区。

(5)下载烧录准备

联网
查看ip,例如192.168.1.136

mount -t nfs -o nolock 192.168.1.136:/home/work /mnt
cd /mnt/alinx_heijin_QT
source qt_env_set.sh
打开一个交叉编译好的工程
./test

你可能感兴趣的:(基于AX7020的petalinux生成并驱动液晶屏(071))