Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1140511
  • 博文数量: 322
  • 博客积分: 10010
  • 博客等级: 上将
  • 技术积分: 3276
  • 用 户 组: 普通用户
  • 注册时间: 2009-12-17 09:21
文章分类

全部博文(322)

文章存档

2010年(155)

2009年(167)

我的朋友

分类: 嵌入式

2010-01-19 17:24:43


最近在论坛上看到许多朋友在交叉编译Qtopia4时出现很多问题,而不能继续。
本人现在尝试使用版本qtopia-opensource-src-4.3.3的开发库进行移植,但是新的东东用的人少,网上资料也少,问题解决办法不容易查得到,希望一切顺利,lets go!
 
我的主机系统:Ubuntu 9.10
目标板:FS2410
目标板文件系统:nfs(/work/nfs/rootfsln)
代码编辑: Source Insight 3
 
可以在网上下载最新Qtopia版本:
总共大小:108.40M
交叉编译器:gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu
 
环境变量:
${WORKPATH}=/work                      我的工作路径
${FSROOT}=${WORKPATH}/nfs/rootfsln     开发板的nfs目录
将主机目录 /work/embedded 和 开发板目录 {FSROOT}/work/embedded 建立链接对应,我以后移植的驱动和应用程序都将放在此目录下。
mkdir -m777 ${FSROOT}/work
mkdir -m777 ${FSROOT}/work/embedded
ln -s ${FSROOT}/work/embedded ${WORKPATH}/embedded
 
我们可以更进一步的将这个目录设定到环境变量中去:
export EMBEDDED=${WORKPATH}/embedded
 
解压到目录:/work/apps/qt/qtopia-opensource-src-4.3.3/source  存放解压的源文件
创建目标:/work/apps/qt/qtopia-opensource-src-4.3.3/target   存放make所产生的文件

$ cd /work/apps/qt
$ tar zxvf qtopia-opensource-src-4.3.3.tar.gz
$ cd qtopia-opensource-src-4.3.3
$ mkdir source

$ mv ./* source

$ mkdir target

$ export QTOIA4=/work/apps/qt/qtopia-opensource-4.3.3

创建安装目录:${EMBEDDED}/qtopia4.3.3  存放make install 所产生的文件,也是arm板上所执行文件,我是采用nfs挂载根目录方式来和arm板连接的
 
首先,我使用的是gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu交叉编译器,所以videodev2.h 没有问题。不过要修改qmake.conf文件:
$ cp qtopiacore/qt/mkspecs/qws/linux-arm-g++/qmake.conf qtopiacore/qt/mkspecs/qws/linux-arm-g++/qmake.conf.bak
将其中带有arm-Linux-的部分前面换成arm-softfloat-linux-gnu-
 
假如使用的是arm-linux-gcc-3.4.1交叉编译器,那么你还要修改3.4.1版的arm编译器的文件
# cd /usr/local/arm/3.4.1/  这里是arm-linux-gcc-3.4.1交叉编译器的安装路径
# vi arm-linux/include/linux/videodev2.h
在其中添加如下内容:
#define V4L2_PIX_FMT_SBGGR8  v4l2_fourcc('B','A','8','1')  /* 8  BGBG.. GRGR.. */
保存退出。
# vi arm-linux/sys_include/linux/videodev2.h
在其中添加如下内容:
#define V4L2_PIX_FMT_SBGGR8  v4l2_fourcc('B','A','8','1')  /* 8  BGBG.. GRGR.. */
保存退出。
 
还有注意你的环境变量,假如你先是移植了tslib,并且在环境变量中设置了CC和CXX等变量值。编译完tslib后,请在重新登录你当前的终端来编译qtopia,就是取消环境变量CC和CXX,否则就会出现错误。
 
 
裁减Qtopia core的库
 
修改qtopiacore/qconfig-qpe.h
首先注释掉关于鼠标光标的宏定义,让程序运行时,触摸屏中央有光标出现:
// Qtopia Core
/*
#ifndef QT_NO_QWS_CURSOR
#  define QT_NO_QWS_CURSOR
#endif
*/
/*
#ifndef QT_NO_QWS_MOUSE
#  define QT_NO_QWS_MOUSE
#endif
#ifndef QT_NO_QWS_MOUSE_AUTO
#  define QT_NO_QWS_MOUSE_AUTO
#endif
*/
其它宏定义根据需要进行注释。
保存后将qconfig-qpe.h拷贝到global目录。
$ cp qtopiacore/qconfig-qpe.h qtopiacore/qt/src/corelib/global/qconfig-qpe.h
事实上,执行configure的时候,这个文件的内容将变为:
#include "/work/apps/qt/qtopia-opensource-4.3.3/source/qtopiacore/qconfig-qpe.h"
 
注释掉其他文件里的QT_NO_QWS_CURSOR的定义
修改 qtopiacore/qt/src/corelib/global/qfeatures.h
注释掉如下内容:
/*
#if !defined(QT_NO_QWS_CURSOR) && (defined(QT_NO_CURSOR))
#define QT_NO_QWS_CURSOR
#endif
*/
保存退出。

修改 qtopiacore/qt/src/corelib/global/qglobal.h
注释掉以下内容:
//#    define QT_NO_QWS_CURSOR
 
由于项目中使用带有触摸功能的 TFT液晶屏作为显示和输入设备,需要添加对触摸屏的支持。一种方法是利用 Qtopia Core为 Linux TP协议提供的鼠标驱动接口类,修改触摸屏驱动的源代码,并在执行 configure配置时传递-qt-mouse-linuxtp选项激活;另一种方法是嵌入 Tslib。Tslib是一个开源的程序,能够为触摸屏驱动获得的采样提供诸如滤波、去抖、校准等功能。这里使用第一种方法,过程如下:
首先在源码树 qtopiacore\qt\src\gui\embedded\qmouselinuxtp_qws.h中加入宏定义:
#define QT_QWS_IPAQ
#define QT_QWS_IPAQ_RAW
然后修改 qtopiacore\qt\src\gui\embedded\qmouselinuxtp_qws.cpp文件,把 QWSLinuxTPMouseHandlerPrivate函数中打
开的设备文件节点 "/dev/h3600_tsraw" 替换为自己的触摸屏设备文件,如我的目标板中为 "/dev/event0" 。
 
裁剪Qtopia 应用程序
 
    用户可以定制Qtopia 的应用程序,通过修改源码src 目录下custom.pri,即可实现添加或裁剪应用程序。
    输入以下文本,实现裁剪应用程序:
    PROJECTS -= applications/addressbook games/fifteen
“-= ”表示要裁剪程序,后面是程序源码在src目录下的具体子路径。裁剪多个程序时,路径之间用空格符隔开;需要换行编辑时,则用 “ \ ”连接。
    若添加应用程序,改用“ += ”即可,而用“ *= ”可以避免重复添加已存在的程序。
 
这里先解决后面configure时出现的编译问题
 
1)Project ERROR: This is a dummy profile to be used for translations ONLY.
   WARNING: Failure to find: qlock.cpp
这个在configure的时候添加
-R ${QTOIA4}/source/qtopiacore/qt/src/gui/embedded \
选项后解决(找不到的文件都在这个目录下)。
 
2)You should create a device profile with custom files:

$ cp src/libraries/qtopiabase/custom-linux-generic-g++.h src/libraries/qtopiabase/custom-linux-arm-g++.h
$ cp src/libraries/qtopiabase/custom-linux-generic-g++.cpp src/libraries/qtopiabase/custom-linux-arm-g++.cpp


Qtopia4移植过程: 配置源码包
进入qtopia-opensource-src-4.3.3/target目录

$ cd ../target

$ echo "yes" | \
../source/configure -release \
-image ${EMBEDDED}/qtopia4.3.3 \
-prefix ${EMBEDDED}/qtopia4.3.3 \
-R ${QTOIA4}/source/qtopiacore/qt/src/gui/embedded \
-xplatform linux-arm-g++ -arch arm -no-qvfb -displaysize 320x240 -no-modem \
-extra-qtopiacore-config \
"-release -xplatform qws/linux-arm-g++ -embedded arm -qconfig qpe -depths 4,8,16,32 \
-qt-gfx-qvfb -qt-gfx-transformed -qt-kbd-usb -no-opengl -no-kbd-tty \
-qt-sql-sqlite -qt-mouse-linuxtp "
\
2>../confgureERR.txt

 
主要配置选项解说如下:
################################################################################
-xplatform linux-arm-g++ -arch arm
目标平台为arm-linux,体系结构为arm。

-no-qvfb
目标平台已支持framebuffer,因而不使用虚拟帧缓冲。
--------------------------------------------------------------------------------
-extra-qtopiacore-config
为Qtopia core 配置选项。

-xplatform qws/linux-arm-g++ -embedded arm
目标平台编译配置文件使用qtopiacore/qt/mkspecs/qws/linux-arm-g++目录下的配置文件,嵌入式平台为arm。

-qconfig qpe
使用配置文件qconfig-qpe.h,若使用qconfig-large.h配置文件,则使用-qconfig large选项。

-qt-mouse-linuxtp
触摸屏协议支持linuxtp
--------------------------------------------------------------------------------
2>../confgureERR.txt
最后将配置过程中的错误输出到confgureERR.txt文件中。
################################################################################
 
在configure的过程中还是出现了一些警告,不过貌似可以忽略:

...
*******************************************************************************

Setting up the include directory for Qt (host). Please wait...
Cleaning your Qt (host) build tree. Please wait...


Preparing build tree...
You are licensed to use this software under the terms of either
the Q Public License (QPL) or the GNU General Public License (GPL)
versions 2 or 3


Creating qmake. Please wait...
/work/apps/qt/qtopia-opensource-4.3.3/source/qtopiacore/qt/src/corelib/tools/qdatetime.cpp: In member function ‘QString QDateTimeParser::sectionText(const QString&, int, int) const’:
/work/apps/qt/qtopia-opensource-4.3.3/source/qtopiacore/qt/src/corelib/tools/qdatetime.cpp:3838: warning: case label value is less than minimum value for type
/work/apps/qt/qtopia-opensource-4.3.3/source/qtopiacore/qt/src/corelib/tools/qdatetime.cpp:3839: warning: case label value is less than minimum value for type
/work/apps/qt/qtopia-opensource-4.3.3/source/qtopiacore/qt/src/corelib/tools/qdatetime.cpp:3840: warning: case label value is less than minimum value for type
...

Creating makefiles. Please wait...
Project ERROR: This is a dummy profile to be used for translations ONLY.
Project ERROR: This is a dummy profile to be used for translations ONLY.
WARNING: Failure to find: qlock.cpp
WARNING: Failure to find: qwssignalhandler.cpp
WARNING: Failure to find: qvfbhdr.h
WARNING: Failure to find: qlock_p.h
WARNING: Failure to find: qwssignalhandler_p.h
Project ERROR: This is a dummy profile to be used for translations ONLY.
...

 
confgureERR.txt文件显示的信息是WARNING,不是ERROR。

WARNING: You should create a device profile with custom files:
         /work/apps/qt/qtopia-opensource-4.3.3/source/devices/<mydevice>/custom.h
         /work/apps/qt/qtopia-opensource-4.3.3/source/devices/<mydevice>/custom.cpp
Using generic files instead.

.............................................................................................................................................................

 

custom.h/custom.cpp
Since these files are tied to a device it is useful to have them in the device profile. If these files are not present configure will look in the traditional location, <source>/src/libraries/qtopia/custom-<xplatform>.(h|cpp). See <custom.h> for more information about these files.

For reference implementations of these files, the existing files found in <source>/devices/<device>/custom.* and <source>/src/libraries/qtopiabase/custom-<xplatform>.* may be of assistance.

 
由此我们可以知道这里所需的文件custom.h/custom.cpp就是<source>/devices/<device>/custom.* 或者<source>/src/libraries/qtopiabase/custom-<xplatform>.* ,我们没有使用 -device 指定设备,故不新建<source>/devices/<device>/这个目录(这个目录的新建,可以参照<source>/devices/example)。我们的目标平台式linux-arm,而在解决这个问题则是新增源码<source>/src/libraries/qtopiabase/custom-<xplatform>.*

$ cp src/libraries/qtopiabase/custom-linux-generic-g++.h src/libraries/qtopiabase/custom-linux-arm-g++.h
$ cp src/libraries/qtopiabase/custom-linux-generic-g++.cpp src/libraries/qtopiabase/custom-linux-arm-g++.cpp

重新configure,confgureERR.txt文件就没有waring了。
 
解决了confgureERR问题,还有终端提示的ERROR和WARING。
1)warning: case label value is less than minimum value for type
这个好像是gcc或者系统的一个bug,暂且无视之。
2)Project ERROR: This is a dummy profile to be used for translations ONLY.
   WARNING: Failure to find: qlock.cpp
这个在configure的时候添加
-R ${QTOIA4}/source/qtopiacore/qt/src/gui/embedded \
选项后解决(找不到的文件都在这个目录下)。
 
 
make 2>../makeERR.txt
 
make install

Qtopia has been installed.

The files required to run Qtopia are in the image:
/work/embedded/qtopia4.3.3

Please note that Qtopia cannot be moved. It must be run from the image.

在编译安装完成后,在 /work/embedded/qtopia4.3.3 中就是Qtopia在arm上运行所需要的文件。
注意,编译安装后安装qtopia的image的存放路径是/work/embedded/qtopia4.3.3,必须和板子上的存放路径一致,前面我建立了一个链接:
ln -s ${FSROOT}/work/embedded /work/embedded
这样主机和目标板的根目录下的/work/embedded是一致的路径。
 

建立时区信息
$ mkdir -p -m777 ${FSROOT}/usr/share/zoneinfo/
$ cp -a /usr/share/zoneinfo/* ${FSROOT}/usr/share/zoneinfo/
 
到这一步主机上的工作已经基本完成。
 
 
输入目标板环境设置(${FSROOT}/etc/profile文件)
export QTOPIATARG=/work/embedded/qtopia4.3.3
export PATH=$PATH:${QTOPIATARG}/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${QTOPIATARG}/lib
export QWS_MOUSE_PROTO=LinuxTP:/dev/event0 
    待选:touchscreen/0 或者 /dev/input/mice
export QWS_DISPLAY="LinuxFb:mmWidth35:mmHeight45:0"  此句显示字体和图标。
 
后执行qpe -qws&
 
就可以看到目标板屏幕上启动的Qtopia 说明您已经成功了。
 
注:
a 由于在pc机上安装的时候qtopia的image的存放路径是file:/work/embedded/qtopia4.3.3 .
所以在板子上的存放路径也必须跟其一致。否则会出错。如下:
**********************************************************
* ERROR: Expecting this binary to be located in
* /opt/arm-qt/qt-arm-bin/bin/qpe
* but it is being run from
* /Qtopia/bin/qpe
*
* This generally indicates that you have specified the wrong
* value for -prefix when configuring Qtopia. Based on the
* location of this binary, you should be using a prefix of
* /Qtopia
**********************************************************
b 另外会提示如下错误:
Could not read calibration: "/etc/pointercal"
查看的在/etc目录下没有pointercal文件,而自己的qpe怎么也起不来五点校正图片,可以用tslib来校正一下,这边就不说明了。
 









阅读(2000) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~