Chinaunix首页 | 论坛 | 博客
  • 博客访问: 146954
  • 博文数量: 49
  • 博客积分: 2010
  • 博客等级: 大尉
  • 技术积分: 576
  • 用 户 组: 普通用户
  • 注册时间: 2009-09-17 11:27
文章分类

全部博文(49)

文章存档

2011年(1)

2010年(15)

2009年(33)

我的朋友

分类: 嵌入式

2009-11-01 21:53:19

转过来的,部分还没看明白。
本文详细论述了QTQtopia的移植过程,针对的平台为PXA255处理器,对其他平台也具有参考意义。
1.1. QT Porting
1.1.1. QT/Embedded Installation and Environment Configuration
(1) Qt/Embedded Download
download qt-embedded-2.3.7 and decompress as shown under.
$ tar xvfz qt-embedded-2.3.7.tar.gz
Now you get a directory of qt-2.3.7
(2) Qt/Embedded Environment Configuration(host)
The first step is configure environment on host.
-- QTDIR : QTDIR : Directory where Qt is installed.
-- LD_LIBRARY_PATH : Directory where shared library used at Qt is
located.
$ vi ~/.bash_profile
QTDIR=~/qt-2.3.7
LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
PATH=$QTDIR/bin:$PATH
export QTDIR LDLIBRARY_PATH
$ source ~/.bash_profile
(2) Qt/Embedded Configuration
It describes how to make Makefile only for ARM.(refer to PLATFORM file
for further details.)
$ ./configure -xplatform linux-arm-g++ -shared
configure option
- shared : When making and using shared library.
- static : When making and using static library.
- release : When releasing.
- debug : When adding debugging information.
When you execute configure, following questions appear.
- When the question “ do you agrre to license?” appears, type yes.
- “Feature configuration” selection message apprears. Select 5.Everything.
- “Color depth” selection appears. Select 16.
- “Qt Virtual Framebuffer” support message apprears. It doesn’t matter that you type no, because you will port Qt for ARM to target board.
From now, we name Qt Virtual Framebuffer as qvfb in abbreviation. qvfb program realizes Framebuffer on X.
Most of the environments where embedded applications work don’t support X. For video output, we use independent framebuffer different from the information of video card. Even at the stage of development, qvfb program is more convenient for developers.
Conversion between XWindows and console is unnecessary. Display capture as well as display magnification/reduction are available.
When you finish evrironment configuration as shown above, following message appears.
Build on : linux-x86-g++-shared
Build for : linux-ARM-g++-shared
(3) Qt/Embedded compile
$ make
Verify compile through Qt/Embedded library.
$ cd $QTDIR/lib
$ ls
libqte.so -> libqte.so.2.3.7
libqte.so.2 -> libqte.so.2.3.7
libqte.so.2.3 -> libqte.so.2.3.7
libqte.so.2.3.7
Verify it through file command weather exe file is made fit for
target.
$ file libqte.so.2.3.7
libqte.so.2.3.2: ELF 32-bit LSB shared object, ARM, version 1
(SYSV), stripped
By the process above, Qt/Embedded is installed successfully.
1.1.2. QT/Embedded application porting to target board
CPU is Intel PXA255.
Compile Qt/Embedded for ARM.
'1. Refer to ’1. installation and environment configuration.
Compile the developed program for ARM
There is no developed program yet. If you compiled Qt/Embedded for ARM, example source would be compiled for ARM.
Go to $QTDIR/examples/hello/ and verify followings.
$ file hello
'libqte.so.2.3.7: ELF 32-bit LSB shared object, ARM,version 1 (ARM), not stripped'
Minicom execution for connecting target system.
Refer to X-Hyper255B manual.
NFS client configuration.
Refer to X-Hyper255B manual.
Copy qt-2.3.2 compiled for ARM to nfs mount directory.
$ cp -rf /root/qt-2.3.7 /mnt/nfs
/mnt/nfs : NFS mount directory.
Environment configuration on target board.
$ export QTDIR=/mnt/qt-2.3.7
$ export LD_LIBRARY=/mnt/qt-2.3.7/lib:$LD_LIBRARY_PATH
$ export QTFONTDIR=/mnt/qt-2.3.7/lib/fonts/fontdir (some examples will use some other fonts in fontdir, so we must specifise it)
Executing example program(Hello) on target board.
$ cd /nfs_share/qt-2.3.7/examples/hello
$ ./hello -qws
When you execute the program, it is printed to LCD through
framebuffer device.
1.2 Qtopia Porting
You will need the software listed below to be able to compile and use Qtopia
Qtopia-free-1.7.0.tar.gz (this packet)
Qt-Embedded-2.3.7.tar.gz (upon which Qtopia is built)
Qt-X11-2.3.2.tar.gz (for emulated desktop development, maybe it’s not necessary for Qtopia on ARM platform,but it should be useful to develop Qtopia program on host)
tmake (you need this to compile Qtopia packege, download it from trolltech website)
e2fsprogs-1.22.tar.gz (you should have this packet cross-compiled for ARM, so we can use it’s libraries and header file(libuuid, uuid/uuid.h) to compile Qtopia.
Below is a description of how to get everything built quickly without having to read the detailed instructions provided with each of the packages above.
1. Unpack Qtopia
$ tar zvxf qtopia-free-1.7.0.tar.gz
$ cd qtopia-free-1.7.0
$ export QPEDIR=$PWD
$ cd ..
2. Cross-compile e2fsprogs packege for ARM
$ tar zxvf e2fsprogs-1.22.tar.gz
$ cd e2fsprogs-1.22
$ ./configure –with-cc=arm-linux-gcc
$ make
$ cd ..
now you have the libuuid for ARM, don’t run conmmand “make install” as file INSTALL says, because that will overwrite your own system files on X86 and will make you system crash down, just copy what you need to directory Qtopia.
$ cp –dpR e2fsprogs-1.22/lib/uuid qtopia/include (copy the header files uuid/uuid.h)
$ cp –dpR e2fsprogs-1.22/lib/uuid/libuuid.* qtopia/lib (copy the arm-compiled lib uuid to qtopia foe later qtopia compile)
3. Replace tmake file
Using the tmake file provided by trolltech to replace the host tmake
$ cp –f tmake /usr/bin
4. Install Qt/Embedded
$ tar zxvf qt-embedded-2.3.7.tar.gz
$ cd qt-2.3.7
$ export QTDIR=$PWD
$ export QTEDIR=$QTDIR
$ export PATH=$QTDIR/bin:$PATH
$ export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
$ cp $QPEDIR/src/qt/qconfig-qpe.h src/tools/
$ ./configure –qconfig qpe –xplatform linux-arm-g++ -shared
$ make sub-src
$ cd ..
You may also want to use the configure options –system-jpeg and –gif for jpeg and gif support.
5. Install Qt/X11 2.3.2
Note that you must use 2.3.x, not 3.x, as this step is done to provide Qt 2 tools.
$ tar zxvf qt-x11-2.3.2.tar .gz
$ cd qt-2.3.2
$ export QTDIR=$PWD
$ export PATH=$QTDIR/bin:$PATH
$ export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
$ ./configure –no-xft (note that here you should specify –no-xft to complete the compile, or you can install freetype packege to enable this option,because my host isn’t have it)
$ make
$ cp bin/uic $QTEDIR/bin
$ cd ..
You may also want to build Qt designer ( in tools/designer )
6. Build Qtopia
$ cd qtopia-free-1.7.0
$ export QTDIR=$QTEDIR
$ export QPEDIR=$PWD
$ export PATH=$QPEDIR/bin:$PATH
$ cd src ( you may also goes into every sub-dir of libs in src/libraries/ and make it )
$ ./configure –xplatform linux-arm-g++
$ make
$ cd ..
7. Copy qtopia and qt-embedded to nfs mount directory
$ cp –dpR qtopia-free-1.7.0 /mnt/nfs
$ cp –dpR qt-2.3.7 /mnt/nfs
8. Running Qtopia on Xscale
ensure your enviroment has the following variables set.
$ export QPEDIR=/mnt/qtopia-free-1.7.0
$ export QTDIR=/mnt/qt-2.3.7
$ export QTEDIR=$QTDIR
$ export QTFONTDIR=$QTDIR/lib/fonts/fontdir (some examples will use some other fonts in fontdir, so we must specifise it)
$ export PATH=$QTDIR/bin:$QPEDIR/bin:$PATH
$ export LD_LIBRARY_PATH=$QTDIR/lib:$QPEDIR/lib:
$LD_LIBRARY_PATH
running qtopia
$ qpe –qws
1.2 Change Screen Display Mode
Now, we want to change screen display mode from default 640x480 to 800x600, follow the steps below:
1.     Modify driver/video/pxafb.h and set xres=800, yres=600, now the display mode has been changed, we can see that the whole screen has been fulfilled.
2.     Still a problem, the start frame of the picture displayed about 20 lines down on the screen, so we have to modify file pxafb.h again, set
#define LCD_BEGIN_FRAME_WAIT_COUNT     0     to
#define LCD_BEGIN_FRAME_WAIT_COUNT     20
So it’s working, and we actually have changed contents of BFW register.
3.     Recompile kernel, but maybe you should first modify Makefile and remove the compile option “__D_ASSEMBLY__”, and when you meet a problem associated with the “assembly”, redefine it in Makefile and compile again.
1.2 Make Touchscreen useful under Qt
We want to use touchscreen in Qt/e and Qtopia enviroment, but it doesn’t work yet, so we have to change it myself
Using Vi to open Qt/e source code “qt-2.3.7/src/kernel/qwsmouse_qws.cpp”, refer to the read function à read(ads7843_ts_read) in touchscreen driver “driver/char/ads7843_ts.c”, modify the file:
1.     Uncomment definition “#define QWS_CUSTOMTOUCHPANEL”, it means that you will use your own custom touchscreen class à QCustomTPanelHandlerPrivate
2.class QCustomTPanelHandlerPrivate : public QWSMouseHandler {
    Q_OBJECT
public:
    QCustomTPanelHandlerPrivate(MouseProtocol, QString dev);
    ~QCustomTPanelHandlerPrivate();
private:
    int mouseFD;
    int prevstate;    // add this line
private slots:
   void readMouseData();
};
3.QCustomTPanelHandlerPrivate::QCustomTPanelHandlerPrivate( MouseProtocol, QString )
{
#ifdef QWS_CUSTOMTOUCHPANEL
    if ((mouseFD = open( "/dev/ts", O_RDONLY)) < 0) {
        qWarning( "Cannot open /dev/ts (%s)", strerror(errno));
      return;
    } else {
        sleep(1);
    }
    prevstate = 0;      //add this line
    QSocketNotifier *mouseNotifier;
    mouseNotifier = new QSocketNotifier( mouseFD, SocketNotifier::Read, this );
    connect(mouseNotifier,SIGNAL(activated(int)),this, SLOT(readMouseData()));
#endif
}
4. void QCustomTPanelHandlerPrivate::readMouseData()
{
    if(!qt_screen)
      return;
    CustomTPdata data;
    short data2[4] = {0,};
    int ret ;
   
    ret=read(mouseFD,&data2,sizeof(data2));
    if(ret) {
      data.status=data2[0];
      data.xpos=(data2[1]);
      data.ypos=(data2[2]);
      QPoint q;
      q.setX(data.xpos);
      q.setY(data.ypos);
      mousePos=q;
     
if(data.status && !prevstate) {
          emit mouseChanged(mousePos,Qt::LeftButton);
      } else if (!data.status && prevstate) {
      emit mouseChanged(mousePos,0);
      }
      prevstate = data.status;
    }
    if(ret<0) {
      qDebug("Error %s",strerror(errno));
    }
#if 0                   // below has been disabled
#ifdef QWS_CUSTOMTOUCHPANEL
    if(!qt_screen)
      return;
    CustomTPdata data;
    unsigned char data2[5];
    int ret;
    ret=read(mouseFD,data2,5);
    if(ret==5) {
      data.status=data2[0];
      data.xpos=(data2[1] << 8) | data2[2];
      data.ypos=(data2[3] << 8) | data2[4];
      QPoint q;
      q.setX(data.xpos);
      q.setY(data.ypos);
      mousePos=q;
      if(data.status & 0x40) {
          emit mouseChanged(mousePos,Qt::LeftButton);
      } else {
      emit mouseChanged(mousePos,0);
      }
    }
    if(ret<0) {
      qDebug("Error %s",strerror(errno));
    }
#endif
#endif
}
5.     in function QWSMouseHandler* QWSServer::newMouseHandler(const QString& spec)
QWSMouseHandler *handler = 0;
mouseProtocol = TPanel;   // add this line
    switch ( mouseProtocol ) {

6.Change path to qt-2.3.7/src, and run “make”, just only compile qwsmouse_qws.cpp, and the libraries in qt-2.3.7/lib has been relinked, now you can run examples “hello” to test it.

taking fromhttp://blog.csdn.net/gufeng77/archive/2007/03/06/1521990.aspx

阅读(969) | 评论(0) | 转发(0) |
0

上一篇:Minigui 资源文件下载

下一篇:Tmake使用指南

给主人留下些什么吧!~~