加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

zedboard 建立 qt 运行环境

(2015-07-21 10:36:48)
标签:

杂谈

1、依据xilinx的说明建立 qt 库

该文 对于 如何 在 zedboard 出厂配置的情况下运行 qt 应用作了更详细的介绍。
但其中对于格式化文件,有一点与板子(rev.d)不同,要特别注意:
必须将文件格式化为 ext3 格式。否则在板子上挂载文件时会报错。

这篇文章讲了类似的事情。

4、下文介绍了 qt 交叉编译环境的建立:
ubuntukylin-13.04下玩zedboard——QT库的交叉编译

5、ZedBoard学习手记(七)小插曲:如何让代码开机自动运行

首先,按照 xilinx 的文档,进行库的编译,镜像文件制作。
这里要注意的是,最开始的环境变量的设置并非不重要(xilinx配置文件中对其有引用。),所以最好完全照搬。
1 Prerequisites1.1 Setting up the Environment
This tutorial requires the ARM GNU tools, which are part of the Xilinx Software Development Kit (SDK), to be installed on your host system. Specify the ARM cross-compiler by setting the CROSS_COMPILE environment variable and adding the cross-compiler to your PATH. Refer to the Zynq Tools wiki page for more information on how to set up the tool chain and known issues.

note: these instructions currently require a Linux host for building.

bash> export CROSS_COMPILE=arm-xilinx-linux-gnueabi-bash> export PATH=/path/to/cross/compiler/bin:$PATH
For simplicity we define two environment variables in this tutorial:
ZYNQ_QT_BUILD refers to the Qt build areaZYNQ_QT_INSTALL refers to the Qt install area
bash> export ZYNQ_QT_BUILD=/path/to/qt/buildbash> export ZYNQ_QT_INSTALL=/path/to/qt/installbash> export PATH=$ZYNQ_QT_INSTALL/bin:$PATH1.2 Extracting the Zynq Qt/Qwt Sources Archive
Download the Qt/Qwt sources archive and extract it to your Qt build area.

bash> cp qt_build_src.tar $ZYNQ_QT_BUILDbash> cd $ZYNQ_QT_BUILDbash> tar xfv qt_build_src.tar
The archive contains the following files:
qt-everywhere-opensource-src-4.7.3.tar.gz – Qt source archiveqmake.conf – Qt qmake configuration fileqwt-6.0.1.tar.bz2 – Qwt source archiveqwtconfig.pri – Qwt qmake project include file2 Cross-Compiling Qt for Embedded Linux
Qt for Embedded Linux is a C framework for GUI and application development for embedded devices. It runs on a variety of processors, usually with Embedded Linux. Qt for Embedded Linux provides the standard Qt API for embedded devices with a lightweight window system. Qt for Embedded Linux applications write directly to the framebuffer, eliminating the need for the X Window System and saving memory.

2.1 Extracting the Qt Source Archive
Extract the Qt source archive to your Qt build area.

bash> cd $ZYNQ_QT_BUILDbash> tar xzfv qt-everywhere-opensource-src-4.7.3.tar.gzbash> cd qt-everywhere-opensource-src-4.7.32.2 Preparing a mkspec
Before we can do the configuration for the target system, we will need a set of mkspecs that tells qmake which tool chain it should reference when it creates the Makefiles. In this example we will provide an mkspec to go along with the ARM GNU tools.

The mkspec consists of two files:
qmake.conf – This is a list of qmake variable assignments that tells qmake what flags to pass through to the compiler, which compiler to use etcqplatformdefs.h – This is a header file with various platform-specific #includes and #defines. Often this just refers to an existing qplatformdefs.h file from another generic mkspec
Copy the provided qmake.conf to the mkspec/qws/linux-arm-gnueabi-g sub-directory in the Qt build area.

bash> cp $ZYNQ_QT_BUILD/qmake.conf mkspecs/qws/linux-arm-gnueabi-g
The corresponding qplatformdefs.h file just refers to an existing generic one, so nothing needs to be done here.
2.3 Configuring the Target Build
We are now ready to configure Qt to use our mkspec and hence use our cross-compiling toolchain.

bash> ./configure \ -embedded arm \ -xplatform qws/linux-arm-gnueabi-g \ -little-endian \ -opensource \ -host-little-endian \ -confirm-license \ -nomake demos \ -nomake examples \ -prefix $ZYNQ_QT_INSTALL

Here is some information on some of the options that appear:
-xplatform <mkspec files to use> – Cross compile for the target platform using the environment specified in the mkspec files-embedded <target CPU architecture> – The CPU architecture of the target platform-prefix <path> – The path to install the cross-compiled Qt to-confirm-license – Lazy option to save agreeing to license agreement during configure process2.4 Building and Installing
Run make to build the cross-compiled target version of Qt.

bash> make
Once the build has completed it is time to install Qt. You may need to su to root to do this part depending upon what prefix you configured the build with.

bash> su - #if you need root access to be able to installbash> make install3 Cross-Compiling Qwt – Qt Widgets for Technical Applications
The Qwt library contains GUI Components and utility classes which are primarily useful for programs with a technical background. Beside a 2D plot widget it provides scales, sliders, dials, compasses, thermometers, wheels and knobs to control or display values, arrays, or ranges of type double.
3.1 Extracting the Qwt Source Archive
Extract the Qwt source archive to your Qt build area.

bash> cd $ZYNQ_QT_BUILDbash> tar xjfv qwt-6.0.1.tar.bz2bash> cd qwt-6.0.13.2 Configuring the Build using qmake
Projects are described by the contents of project files (.pro). Files that end with the suffix .pri are included by the project files and contain definitions that are common for several project files. The information within these is used by qmake to generate a Makefile containing all the commands that are needed to build each project.

bash> cp $ZYNQ_QT_BUILD/qwtconfig.pri .bash> qmake qwt.pro3.3 Building and Installing
Run make to build the cross-compiled target version of Qwt.

bash> make
Once the build has completed it is time to install Qwt. You may need to su to root to do this part depending upon what prefix you configured the build with.

bash> su - #if you need root access to be able to installbash> make install4 Adding the GNU Standard C Library
In order to build and run your Qt application, the GNU Standard C Library of the ARM GNU Tools needs to be copied to the Qt install area's lib directory.

bash> cp -P /path/to/cross/compiler/arm-xilinx-linux-gnueabi/libc/usr/lib/libstdc .so* \ $ZYNQ_QT_INSTALL/lib5 Creating a File System Image with Pre-Compiled Qt/Qwt Libraries
The final step shows how to create an image file of the Qt install area that can be copied onto an SD card and then mounted on the target system. These libraries are required to run the Qt application on the target system. First we create an empty image file of size 80MB, then we format the image with the ext2 file system.

bash> cd $ZYNQ_QT_BUILDbash> dd if=/dev/zero of=qt_lib.img bs=1M count=80bash> mkfs.ext2(此处在REV.D 2014.9,必须为mkfs.ext3) -F qt_lib.img

Now we just need to mount the image on our host machine, copy over the libraries from the Qt install area and we are done. You may need to su to root to do this part.

bash> su - #if you need root access to be able to install 
bash> chmod go w qt_lib.img 
bash> mount qt_lib.img -o loop /mnt 
bash> cp -rf $ZYNQ_QT_INSTALL/* /mntbash> chmod go-w qt_lib.img 
bash> umount /mnt

然后根据2、文中的介绍,

将可执行应用程序文件,在这里就叫zed_complie,拷贝到SD卡中,在ZedBoard里装载qt3_lib.img(3表示需要格式化为ext3格式)。要注意的是,这个镜像最好装载到与本地安装目录相同的路径下,即ZYNQ_QT_INSTALL指向的目录,兔子就把这个镜像装载到/arm/qt/qt-lib/文件夹下(mmcblk0p2是SD卡的分区)。

mount /dev/mmcblk0p2 /mnt/

mount /mnt/qt_lib.img  /arm/qt/qt-lib/ 

这样一来,就可以运行QT程序了。-qws指令用来建立一个运行QT软件必须的QWS Server,这是由QT的运行机制决定的,软件会从/arm/qt/qt-lib/文件夹里调用QT运行库。

/sdcard/zed_compile –qws


最后,可以依据5、文中的介绍,通过修改 rcS 文件,让 应用程序 自动启动。

第一步,备份ramdisk8M.image.gz!兔子就悲剧过,莫要重蹈覆辙。

第二步,加载rootfs镜像文件:

cd /

mkdir sdcard

ls

mount /dev/mmcblk0p1 /sdcard

cd sdcard/

cp /sdcard/ramdisk8M.image.gz /tmp/

gunzip /tmp/ramdisk8M.image.gz

mount -o loop /tmp/ramdisk8M.image /mnt/

 

完成以后rootfs镜像就被加载到/mnt目录下了,可以通过指令查看一下效果:

cd /mnt

ls

 

第三步,修改/etc/init.d/rcS文件,可以看到Demo板的各个外围设备开机配置(如FTP和HTTP服务器等)都是通过这个文件实现的,在文件末尾加入指令,让驱动模块自动加载,并运行我们的App测试程序。

mount /dev/sda2 /mnt

insmod /mnt/my_gpio.ko

/mnt/my_gpio_app

(注:修改rcS文件可以通过cat指令,先要复制rcS文件原有内容哦~~)

 

最后一步,重新打包根文件系统镜像,覆盖到SD卡中。

umount -l /mnt

gzip -9 /tmp/ramdisk8M.image

mv /tmp/ramdisk8M.image.gz /sdcard/

umount -l /sdcard/

 

目前实际增加的几行是:

export ZYNQ_QT_INSTALL=/zynq/qt4.7.3

mkdir -p $ZYNQ_QT_INSTALL

mount /dev/mmcblk0p1 /mnt

mount /mnt/qt3_lib.img $ZYNQ_QT_INSTALL

/mnt/test1 -qws

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有