标签:
杂谈 |
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
note:
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
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
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 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
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>
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
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
将可执行应用程序文件,在这里就叫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
这样一来,就可以运行QT程序了。-qws指令用来建立一个运行QT软件必须的QWS Server,这是由QT的运行机制决定的,软件会从/arm/qt/qt-lib/文件夹里调用QT运行库。
/sdcard/zed_compile –qws
第一步,备份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_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