Friday, December 11, 2009

Qt Application development on mini2440

Introduction

This blog emphasize on building QT based GUI application for embedded linux , Its describes on setting up the IDE for QT ,cross compiling QT 4.5 libraries for embedded application on mini2440 board in particular.


Setting QT Creator (IDE).

Qt Creator is a new cross-platform integrated development environment (IDE) tailored to the needs of Qt developers, Qt SDK includes the tools you need to build cross-platform applications with Qt in a single install.

Qt libraries

Qt Creator IDE

Qt development tools


Use the below link to download Qt SDK.

http://get.qt.nokia.com/qtsdk/qt-sdk-linux-x86-opensource-2009.05.bin

Login as root to the host machine and run the the binary file on the command promt.

LinuxHost>chmod +x qt-sdk-linux-x86-opensource-2009.05.bin

LinuxHost>./qt-sdk-linux-x86-opensource-2009.05.bin

Now once the installation is complete,run the QT Creator by clicking on desktop icon.


Navigate Tools->Options

Select the Qt installation path, in my case it is PATH “/opt/qtsdk-2009/qt”.

Now click on rebuild button to configure it,on success Qt creator will check the 'Debugging Helper'

The IDE is set to develop QT application for the Host machine.



Cross compilation of QT 4.5.3 for mini2440 board.

  1. Download the compressed package

http://qt.nokia.com/downloads/embedded-linux-cpp

now extract qt-embedded-linux-opensource-src-4.5.3.tar.gz to an appropriate folder and configure the source,it is assumed that the cross compiler is installed and the path is updated in the environment variable.



\path-to-mini2440\>tar -zxvf qt-embedded-linux-opensource-src-4.5.3.tar.gz

\path-to-mini2440>cd qt-embedded-linux-opensource-src-4.5.3

\path-to-mini2440\qt-embedded-linux-opensource-src-4.5.3>:



2. Compile the qt-embedded-linux-opensource-src-4.5.3. Remove some unnecessary features, keep most of the commonly used functions, and add support for the tslib touch screen recalibration.

./configure \
-prefix /new_disk/Hiteg/qt/build/ //specify the directory for installation,
-release -shared \
-fast \
-pch \
-no-qt3support \
-qt-sql-sqlite \
-no-libtiff -no-libmng \
-qt-libjpeg \
-qt-zlib \
-qt-libpng \
-qt-freetype \
-no-openssl \
-nomake examples -nomake demos -nomake tools \
-optimized-qmake \
-no-phonon \
-no-nis \
-no-opengl \
-no-cups \
-no-xcursor -no-xfixes -no-xrandr -no-xrender -no-xkb -no-sm \
-no-xinerama -no-xshape \
-no-separate-debug-info \
-xplatform qws/linux-arm-g++ \
-embedded arm \
-depths 16 \
-no-qvfb \
-qt-gfx-linuxfb \
-no-gfx-qvfb -no-kbd-qvfb -no-mouse-qvfb\
-qt-kbd-usb \
-confirm-license \
-qt-mouse-tslib

$ make (or gmake)
$ make install (or gmake install)
3.Build filesystem, copy necessary Qt libraries to the filesystem directory:
cd $rootfs #$rootfs is the filesystem directory

mkdir new_disk/hiteg/qt/build –p && cd new_disk/hiteg/qt/build
cp /new_disk/hiteg/qt/build/lib/libQtCore.so ./
cp /new_disk/hiteg/qt/build/lib/libQtGui.so.4 ./
cp /new_disk/hiteg/qt/build/lib/libQtNetwork.so.4 ./
mkdir fonts

copy the fonts that you want to implement in your Qt:

cp /mnt/qt/build/lib/fonts/xxxxx.qpf fonts


Installing tslib library on mini2440


  1. Where to download tslib source code.
    addr1 http://www.zelow.no/floppyfw/download/Development/src/(I suggest use this one)
    addr 2 http://mail.pdaxrom.org/download/1.1.0beta3/src/

2. How to compile
We've to manual set some enviroment virables. and correctly configure the source code. I show you a build file wrote myself:
#step 1 play a trick
echo "ac_cv_func_malloc_0_nonnull=yes" > arm-linux.autogen

#step 2 set the enviroment
export CC=/cross-compile/bin/arm-linux-gcc
export CXX=/cross-compile/bin/arm-linux-g++
export CONFIG_SITE=arm-linux.autogen
#step 2
./configure --build=i386-linux --host=arm-linux --target=arm --disable-inputapi --prefix=/new_disk/Hiteg/qt//build

do make and make install,you will get what you want under ./build. Actually you can set the prefix as your root_fs befor hand then after the "make install" these file are stay on position.


3. Copy the libraries to the standard library path in file system and make it available to the application.

3.1 initialize the environment setting first, you'd better place them in /etc/profile or other place you like.
QTDIR=/new_disk/Hiteg/qt-arm/build
LD_LIBRARY_PATH=$QTDIR/lib
TSLIB_CONSOLEDEVICE=none
TSLIB_FBDEVICE=/dev/fb0
TSLIB_TSDEVICE=/dev/input/event0
TSLIB_CALIBFILE=/etc/pointercal
TSLIB_CONFFILE=/usr/local/etc/ts.conf
QWS_SIZE=240x320
QWS_DISPLAY="LinuxFb:mmWidth135:mmHeight155"
QWS_MOUSE_PROTO="Tslib:/dev/input/event0"
TSLIB_PLUGINDIR=$QTDIR/lib/ts
export USER LOGNAME PS1 PATH
export QTDIR
export LD_LIBRARY_PATH
export TSLIB_CONSOLEDEVICE
export TSLIB_FBDEVICE
export TSLIB_TSDEVICE
export TSLIB_CALIBFILE
export TSLIB_CONFFILE
export QWS_SIZE
export QWS_DISPLAY
export QWS_MOUSE_PROTO
export TSLIB_PLUGINDIR


19 comments:

  1. Hi Ratheendran,

    Thanks for the nice post!!

    I have done the whole cross-compiling and have saved the executable file into my board, now when I try to execute the file, a rather weird message comes up on the board. I by the way still have Qtopia 2.2.0 installed, i am under the impression that this may be the reason why a qtopia 4 app is not working with qt 2.2.0 installed. In any case, can you help me in building a file system for qtopia ver 4.6.0( the recent one ).
    -Som

    ReplyDelete
  2. Hi Som,

    I have removed the folder related with Qtopia from /opt directory as it is no longer required in Qt4.5.You need to place the compiled libraries on the filesystem of the board( I used ftp file transfer ) and update the env variable.

    ReplyDelete
    Replies
    1. Hello Ratheendran ,
      i need your help ,i am using ubuntu 10.10 where QT IDE is preinstalled and im following ur methods to cross compile Qt4.5.3 and for that tslib is needed and am thankful to u for the tslib link but i am confused ,where in which file to do all these steps

      #step 1 play a trick
      echo "ac_cv_func_malloc_0_nonnull=yes" > arm-linux.autogen

      #step 2 set the enviroment
      export CC=/cross-compile/bin/arm-linux-gcc
      export CXX=/cross-compile/bin/arm-linux-g++
      export CONFIG_SITE=arm-linux.autogen

      wheather ubuntu10.10 is suitable for QT4.5.3..??????

      Delete
  3. Hi Ratheendran, congratulations for your post.

    I'm stopped in the first stetp :P
    i'm not familiarized with linux and i'm searching how to integrate the cross compiler with the qt. you said "it is assumed that the cross compiler is installed and the path is updated in the environment variable."
    Can you explain how to do that?
    thank you

    ReplyDelete
  4. Hi Ximo,

    I am using 'arm-linux-gcc-4.3.2.tgz' as cross compiler for my board.now navigate to the cross compiler tools folder
    and extract this by typing this command on command promt 'tar -zxvf arm-linux-gcc-4.3.2.tgz -C /'.

    The toolchain will be extracted into 'usr/local/arm/4.3.2/'.

    Update this path to the system's environment variable.

    export PATH=/usr/local/arm/4.3.2/bin:$PATH.

    Then follow the steps mentioned above.

    I hope this will help you.

    ReplyDelete
  5. Thanks for your help. I've been lost this month. :D
    I will try it and continue

    ReplyDelete
  6. There are new images on the adnahammer.com downloads page. The FS is Qtopia/Qt4 if anyone wants to try Qt-creator on the new factory setup. Maybe you can skip all the compiling and start writing apps out of the box. At least the kernels support all the I/O.

    ReplyDelete
  7. Forgot. Also, there are kernels for the newwer X35 Sony LCDs.

    ReplyDelete
  8. the qt4 image does not work on mini2440 and the following msg comes

    bad gzip magic numbers---system haltelload Image of Linux---Uncompressing Linux..

    Can u post the qt4 fs image which is working on mini2440

    ReplyDelete
  9. the new zimage for VGA 1024x768 available on http://www.andahammer.com/downloads/ is .asc file...what does it mean?

    ReplyDelete
  10. #

    Hello Ratheendran ,
    i need your help ,i am using ubuntu 10.10 where QT IDE is preinstalled and im following ur methods to cross compile Qt4.5.3 and for that tslib is needed and am thankful to u for the tslib link but i am confused ,where in which file to do all these steps

    #step 1 play a trick
    echo "ac_cv_func_malloc_0_nonnull=yes" > arm-linux.autogen

    #step 2 set the enviroment
    export CC=/cross-compile/bin/arm-linux-gcc
    export CXX=/cross-compile/bin/arm-linux-g++
    export CONFIG_SITE=arm-linux.autogen

    wheather ubuntu10.10 is suitable for QT4.5.3..??????

    ReplyDelete
    Replies
    1. Hi Satyaprkash,

      Sorry for the delayed response.

      I hope ubuntu 10.10 u have mentioned is 32bit system,then you can cross-compile Qt4.5.

      the steps mentioned are to be done in tslib folder after extracting the tar file.

      also not in export should include full path to compiler link.

      I hope this info help you.

      Delete
    2. im thankful to u ..but one more problem ..im unable to create .desktop icon for any application using qmake ,,im getting only bin file can u explain me how to get .desktop icon using qmake

      Delete
    3. I have the same question with SATYAprakash,can Ratheendran help us? Thank u very much

      Delete
    4. Hi Satya, Chi Trinh Minh,

      I did not understands the scenario.. can you tell me the steps and what u r trying to achive with it.

      so please give more clarity on what are ur expectations.

      Delete
    5. Ratheendran thanks for ur response.

      I think Mr Chí Trịnh Minh is wondering for something,even i am not sure ,what he was asking .
      When i will feel i need to share ,i will share .
      for time being ,u can answer to Mr Chí Trịnh Minh(XYZ),he might need ur help .

      Delete
  11. The tslib functionality test failed!
    You might need to modify the include and library search paths by editing
    QMAKE_INCDIR and QMAKE_LIBDIR in
    /home/anbu/qtcross/arm-qte-4.6.3/qt-everywhere-opensource-src-4.6.3/mkspecs/qws/linux-arm-g++.

    ReplyDelete
  12. export PKG_CONFIG_PATH=/path to tslib/pkgconfig

    then include the header path and library path while configuring Qt

    please check my blog on "QT Media Player on mini2440" for details

    ReplyDelete
  13. Hi
    I have a preloaded linux mini2440 and a ubuntu PC with Qt 4.8.1. I want to cross compile Qt program for mini2440. can anybody help with the steps.

    ReplyDelete