现在的位置: 首页 > 综合 > 正文

Fedora8上交叉编译qtopia4移植成功到s3c2410开发板

2013年09月01日 ⁄ 综合 ⁄ 共 6206字 ⁄ 字号 评论关闭

教程是这样的:

一.硬件平台


1.主机: PC机,512M内存以上。

2.目标机: UP-NetARM2410-S实验平台。

二.移植软件资源


1.Red Hat Linux 9.0(主机操作系统)

2.gcc-3.4.1.tar.gz(主机编译器)

3.arm-linux-gcc-3.4.1.tar.bz2(交叉编译器)

4.tslib-1.3.tar.bz2(管理目标平台的触摸屏)

5.qtopia-opensource-src-4.2.1.tar.gz(包含Qt,

Qtopia
core)

2
. GUI(QT)的移植过程


编译前的约定:

1)我的工作目录为:/mnt/nfs。

2)qtopia-opensource-src-4.2.1.tar.gz 软件包放在/mnt/nfs/qtopia4目录下。

一.编译主机编译器


gcc-3.4.1.tar.gz

步骤如下:

# tar –zxvf gcc-3.4.1.tar.gz

# ./configure (默认安装目录为:

/usr/local)

# make

# make install

安装完成后,可执行文件放在/usr/local/bin目录下,库文件放在/usr/local/lib目录下。

二.安装交叉编译器



arm-linux-gcc-3.4.1.tar.bz2

步骤如下:

# tar jxvf arm-linux-gcc-3.4.1.tar.bz2

解压后的文件为 usr目录,其已包括可执行文件,直接将usr拷贝到根目录下。然后

# vi /etc/profile

在里边添加:

export PATH=$PATH:/usr/local/arm/3.4.1/bin

保存退出,执行:

# source /etc/profile

三.编译


tslib-1.3.tar.bz2

详细步骤如下:

# tar jxvf tslib-1.3.tar.bz2

解压后的目录为tslib-1.3。

# cd tslib-1.3

# export CC=arm-linux-gcc

# export CXX= arm-linux-g++

# ./autogen.sh

# ./configure --prefix=/mnt/nfs/tslib1.3-install --host=arm-linux

( 配置目标平台为ARM-linux,在主机上的安装目录为/mnt/nfs/tslib1.3-install )

# make

# make install







编译



qtopia-opensource-src-4.2.1.tar.gz

编译前约定:

安装目录为:

/mnt/nfs/qtopia4/qtopiatslibinstall

目标目录为:

/mnt/nfs/qtopia4/qtopiatslibtarget

下面解压软件包:

# tar zxvf qtopia-opensource-src-4.2.1.tar.gz

然后重命名解压后的包:

# mv qtopia-opensource-4.2.1 qtopiatslibinstall

# cd qtopiatslibinstall

在此目录下,文件夹为qtopiacore的目录即是Qt,QtopiaCore所在目录,里边包含了开发所需的
Designer,qmake,uic,moc等工具,也包含了面向嵌入式平台的Qt库。

编译前,首先建立定位到安装目录和目标目录的环境变量


# export QTOPIAINST=/mnt/nfs/qtopia4/qtopiatslibinstall

# export QTOPIATARG=/mnt/nfs/qtopia4/qtopiatslibtarget

为了让编译适应于目标平台和去除编译中将出现的错误,我们需要对源码进行修改和裁减。因此,编译的详细过程如下:

1
. 修改源码包


1)

# cd src/libraries/qtopiabase/

# cp custom-linux-cassiopeia-g++.h custom-linux-arm-g++.h

# cp custom-linux-cassiopeia-g++.cpp custom-linux-arm-g++.cpp

2)修改3.4.1版的arm编译器的文件

# cd /usr/local/arm/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/3.4.1/arm-linux/sys_include/linux/videodev2.h

在其中添加如下内容:

#define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B','A','8','1')

/* 8 BGBG.. GRGR.. */

保存退出。

3) 修改时区信息

# vi src/libraries/qtopia/qtimezone.cpp

将114行的 /usr/share/zoneinfo/
改为/mnt/nfs/qtopia4/qtopiatslibtarget/zoneinfo/ ,保存退出。

# vi src/settings/systemtime/settime.cpp

将318行的 /usr/share/zoneinfo/
改为/mnt/nfs/qtopia4/qtopiatslibtarget/zoneinfo/ ,保存退出。

4) 裁减Qtopia core的库

# vi 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

5)注释掉其他文件里的QT_NO_QWS_CURSOR的定义

# vi qtopiacore/qt/src/corelib/global/qfeatures.h

注释掉如下内容:

/*

#if !defined(QT_NO_QWS_CURSOR) && (defined(QT_NO_CURSOR))

#define QT_NO_QWS_CURSOR

#endif

*/

保存退出。

# vi qtopiacore/qt/src/corelib/global/qglobal.h

注释掉以下内容:

//# define QT_NO_QWS_CURSOR
Qtopia4移植过程(三)2007-06-27 22:252.配置源码包

首先,确定目录为:


/mnt/nfs/qtopia4/qtopiatslibinstall

然后进行配置,执行如下命令 :


# ./configure -silent -release

-image /mnt/nfs/qtopia4/qtopiatslibtarget

-prefix /mnt/nfs/qtopia4/qtopiatslibtarget

-xplatform linux-arm-g++ -arch arm -no-qvfb

-displaysize 640x480 -no-modem

-extra-qtopiacore-config "-release -xplatform qws/linux-arm-g++
-embedded arm -opengl -qconfig qpe -qt-sql-sqlite

-depths 4,8,16,32 -qt-kbd-usb -no-kbd-tty -no-mouse-linuxtp

-qt-mouse-tslib -I/mnt/nfs/tslib1.3-install/include
-L/mnt/nfs/tslib1.3-install/lib" 2>../qtopiaconfgureERR.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-sql-sqlite

数据库支持Sqlite。

-qt-kbd-usb

键盘支持usb协议。

-no-mouse-linuxtp -qt-mouse-tslib

-I/mnt/nfs/tslib1.3-install/include -L/mnt/nfs/tslib1.3-install/lib

触摸屏协议不支持linuxtp,支持tslib,并在后面添加上刚才编译的tslib的头文件和库。

2>../qtopiaconfgureERR.txt

最后将配置过程中的错误输出到qtopiaconfgureERR.txt文件中。

3
.编译源码包


执行如下命令:

# make 2>../qtopiamakeERR.txt

4
.安装编译后源码包


# make install

编译安装完成后,在/mnt/nfs/qtopia4/qtopiatslibtarget目录下产生各个目标文件。

5
.建立时区信息


# cd $QTOPIATARG

# mkdir zoneinfo

# cp -a /usr/share/zoneinfo/* $QTOPIATARG/zoneinfo/

五.编译后的处理


完成上面的步骤后,所有软件包已编译完成。下面建立环境变量,进行后期处理,建立开发环境。

1)将designer,qmake 等工具拷贝到$QTOPIATARG/bin/目录下。

# cp $QTOPIAINST/qtopiacore/host/bin/* $QTOPIATARG/bin/


2)建立环境变量:


# vi /etc/profile


添加如下内容:


QTOPIA="/mnt/nfs/qtopia4/qtopiatslibtarget"


LD_LIBRARY_PATH="/usr/lib:/usr/local/lib:/usr/X11R6/lib"


LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$QTOPIA/lib"


PATH="$PATH:$QTOPIA/bin"


QMAKESPEC=/mnt/nfs/qtopia4/qtopiatslibinstall/qtopiacore/qt/mkspecs/qws/linux-arm-g++


export QTOPIA PATH LD_LIBRARY_PATH QMAKESPEC


保存退出。


#source /etc/profile


3)修改ts.conf


# cd /mnt/nfs/tslib1.3-install/etc


# vi ts.conf


原文件内容如下:


#module mousebuts


module variance xlimit=50 ylimit=50 pthreshold=3


module dejitter xdelta=1 ydelta=1 pthreshold=3


module linear


将第一行的“#”去掉,让触摸屏起作用。


到此为止,开发环境建立完毕。


3 移植成果演示



在这里,我们以Qtopia自带的例子程序为例,来演示应用程序运行步骤。首先在/mnt/nfs
/qtopia4/目录下用VI编辑器建立qtopiatslib.sh文件:



export TSLIB_TSEVENTTYPE=event0


export TSLIB_TSDEVICE=/dev/input/event0


export
TSLIB_CONFFILE=/mnt/nfs/tslib1.3-install/etc/ts.conf



export TSLIB_CONSOLEDEVICE=none


export TSLIB_CALIBFILE=/mnt/yaffs/tmp/pointercal


export
TSLIB_PLUGINDIR=/mnt/nfs/tslib1.3-install/share/ts/plugins



export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/mnt/nfs


/tslib1.3-install/lib


export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/mnt/nfs


/qtopia4/qtopiatslibtarget/lib


export QWS_SIZE=640x480


export QWS_MOUSE_PROTO="Tslib:/dev/input/event0"


export POINTERCAL_FILE=/mnt/yaffs/tmp/pointercal

insmod /mnt/yaffs/touchscreen/ts-uptech.o


cd /mnt/nfs/tslib1.3-install/bin


./ts_calibrate

cd /mnt/nfs/qtopia4/qtopiatslibtarget/bin


if [ -f "$TSLIB_CALIBFILE" ]; then


./qpe -qws


else


/mnt/nfs/tslib1.3-install/bin/ts_calibrate


./qpe -qws


fi


保存退出,修改用户使用权限:


# chmod 777 qtopiatslib.sh


然后启动目标平台,打开minicom终端,进入目标平台的系统。在主机上启动NFS服务,将主机的/mnt
/nfs目录挂载到目标机的/mnt/nfs目录。



在终端里执行:

# ifconfig eth0 192.168.0.1


# mount -t nfs (主机IP地址):/mnt/nfs /mnt/nfs


# cd /mnt/yaffs


# mkdir tmp


# cd /mnt/nfs/qtopia4


# ./qtopiatslib.sh

执行qtopiatslib.sh文件,首先校准触摸屏,依次点击屏幕上出现的五个点,完成后,会在/mnt
/yaffs/tmp目录下生成pointercal校准文件。接下来就会启动qpe应用程序,进入Qtopia Phone的界面。



在实验的过程中可能会出现下面的错误:


“在make的时候,遇到了一个错误。/usr/bin/ld
.....debug-shared/moc.o提示could't read symbols :File in wrong format”



只要重新用新的源代码来做才能通过。


有时候嵌入式的问题真的很难说。总之,出现问题不要紧,能学到东西。努力吧,嵌入式的新人们。

抱歉!评论已关闭.