CoR

Qt 4.5 on mini2440

by on Mar.26, 2009, under Mini2440

Well, you didn’t bought this fresh mini2440 with a 3,5″ or 7″ touchscreen just for putting another dust receiver on your desk didn’t you ?

Framebuffer

If you compiled a kernel from the mini2440 kernel repository with the mini2440_defconfig, the framebuffer driver is loaded by default. You should see an “Armwork” logo when booting your board. If it’s not the case and you have a 7″ screen, you have to pass “mini2440=1tb” as a boot argument for the kernel ( 0 is for 320×240, 1 for 800×480 ). This has to be done in u-boot.

The framebuffer for the screen should be avaiable on device /dev/fb0, if that entry does not exist, you probably want to make it by using the following command “mknod /dev/fb0 c 29 0″. If you wonder why those numbers, well, the major “29″ is from the /proc/devices file, there you can see that the major 29 is reserved for fb character devices, and as there is only one fb on the system, the minor is 0, but if you want to make sure of that, all character devices are listed on /sys/dev/char.

If you don’t have anything in /proc or /sys or both, you should mount them by doing:

mount /proc /proc -t proc
mount /sys /sys -t sysfs

If you don’t want to be bothered with than anymore, put them in /etc/fstab .

That should be it for the fb.

Touchscreen configuration

A nice “s3c2440-ts” driver should also be loaded when booting your board, it is responsible for providing the touchscreen input.

Char device

When booting, you can see that message: “input: s3c2410 TouchScreen as /devices/virtual/input/input1″. And indeed, if you go to the directory “/sys/devices/virtual/input/input1″ (don’t forget to mount /sys), you’ll see some nice things.
In this folder, 2 directories have interesting names: event1 and mouse0, and both of them have a “dev” file in their content. They contain major:minor addresses of their character devices. Hu ?
event1 provide a “touchscreen” way to access to the touchscreen input while the mouse0 provide another abstraction that show the ts as a mice.
To access them, we have to make a node in /dev as following:

mkdir /dev/input
mknod /dev/input/ts c 13 65 # (from event1/dev)
mknod /dev/input/mice c 13 32 # (from mouse0/dev)

BTW, I kind of discovered the mouse input after doing what’s next, but I didn’t really had good results with that abstraction.

tslib

In order to exploit what’s coming from /dev/input/ts (if you do “cat /dev/input/ts”, you should see some weird characters when touching the screen Wink ), we can use the tslib library.
I followed that howto to cross-compile it.

After the installation, you should be careful with the configuration.
About the ts.conf, I just uncommented “module_raw input”.
About the env variables, I exported as follow at first:

export TSLIB_TSEVENTTYPE=INPUT
export TSLIB_CONSOLEDEVICE=none
export TSLIB_FBDEVICE=/dev/fb0
export TSLIB_TSDEVICE=/dev/input/ts
export TSLIB_CALIBFILE=
export TSLIB_CONFFILE=/usr/etc/ts.conf
export TSLIB_PLUGINDIR=/usr/lib/ts

As you can see “TSLIB_CALIBFILE” is empty, if you put something in it, all ts_* tools will quit with a nice Seg fault …
Then calibrate your screen with “ts_calibrate /usr/etc/ts.calib” and a stylus. After that, calibration information’s will be stored in /usr/etc/ts.calib, data that you should put in the “TSLIB_CALIBFILE” env var.

If you want a more reliable configuration, put all those vars in the /etc/profile file, this will be load along with bash.

Qt Embedded 4.5

While the qt lib is a nice and heavy piece of work, cross-compiling is actually quite easy.

First you need to download the sources from Qt: http://get.qt.nokia.com/qt/source/qt-embedded-linux-opensource-src-4.5.2.tar.gz (last version here).

Untar it and then go in the directory.

First we need to provide what tools you’re going to use for cross-compiling the thing. On my host I use the toolchain provided by my openembedded installation, thus all my tools are starting by “arm-angstrom-linux-gnueabi-”. You have to modify the file

mkspecs/qws/linux-arm-g++/qmake.conf

to express what tools you want to use to cross-compile. Of course you have to do that according to your toolchain.
BTW, if your toolchain is a path that’s only in your user PATH var, you might want to put the full path to your toolchain, otherwise there will be some problems when doing “sudo make install”.

Then, let’s configure:

./configure -embedded arm -xplatform qws/linux-arm-g++ -prefix /usr/local/Qt -qt-mouse-tslib -little-endian

The -prefix is telling Qt that it’s going to be installed in /usr/local/Qt : hu ? When I first compiled Qt, I had my sd card mounted on /media/disk, so I put -prefix /media/disk/usr/local/Qt as an option. While I had no problem for the installation, I had troubles running some examples, as they we’re looking for files in the prefix path and not the real path (which is /usr/local/Qt on the board). I played a bit with the options but didn’t find a nice way to do that, that’s why I did the really ugly hack that’s following. I’m looking for a better solution, so if anyone as any, please mail me …
I simply did a symbolic link from /usr/local/Qt to /media/disk/usr/local/Qt by doing :

sudo ln -sf /media/disk/usr/local/Qt /usr/local/Qt

That’s really ugly cause cross-compilation and virtual installation should be done nicely in userspace, while here I use a system wide path to do the trick.

Then you simply have to do :

make
sudo make install

It’s going to take a while so go drink a coffee and remember those nice times when you had fun installing a gentoo from stage1 on a k6-2 …

Then unmount your sd card and boot your board.

You first have to register the Qt lib dir, this two lines should do:

echo "/usr/local/Qt/lib" > /etc/ld.so.conf.d/qt.conf
ldconfig

Then, in order to configure QWS to use the tslib driver, you have to

export QWS_MOUSE_PROTO=tslib:/dev/input/ts

as mentioned in the Qt doc.

And … that should be all.
Have fun with Qt examples, starting by /usr/local/Qt/exemples/qws/mousecalibration in order to make sure that everything is all right.

Other ressources


Please comment this post, if you find any error or improvement I would be glad to take them in consideration Wink

:, , , ,

73 Comments for this entry

  • ethem

    Hi
    i am using arm-linux-gcc v4.3.2. (came on the DVD) mini2440 7inch LCD.

    i dont use Qtopia or any other X on the board.

    i downloaded QT-4.5.3 embedded
    i followed the steps one by one
    i could make my ts_calibrate work. (it didnot work until i copied a pointercal file into /etc and specify it in the variables
    so now my tslib works
    then i came into Qt examples
    when compiling had no problems then copied into mmc (i boot from mmc) first tried the qws/framebuffer example and work perfect. second run ./mousecalibration but gave Segment Fault. i tried another example like Wiggly as ./wiggly it said QWSsocket couldnot connect to server try -qws option which resulted on Segment fault.

    iam realy confused. have been trying for compiling again and again. but nothing workout.

    what might be the problem? Please any idea. shall i change compiler or some library missing ?

    thanks
    Ethem

  • BullT

    Hi,

    I can not install except where indicated otherwise Embdded QT, nor make any program with MINI2440.

    The guide that you post is very useful, but for my case I’m not abituale linux user, I can not perform the installation.

    I hope you put a step by step guide, very detailed, of the steps needed to install the QT Embedded.

    Thanks

  • lim

    Having tried a different approach by putting the full paths for the toolchain. The compilation just works. Hence, the would like to suggest anyone who has compilation error messages published earlier, please making sure you have the mkspecs/qws/linux-arm-g++/qmake.conf contents set correctly with full path to your toolchain.

    Thanks

  • Shantanu

    Hi
    I have a mini2440 too and need tslib for it. Thanks to your details, I have been able to compile it (with codesourcery’s toolchain and it seems to be generated fine for armv4t as confirmed from readelf) but when i try to run any of the utilities like ts_calibrate, ts_test etc, I always get a “ts_calibrate/ts_test not found” error. BTW, I am using my own minimal busybox based rootfs. Would it be possible for you to send me a copy of your compiled tslib so that I can check if there is something wrong with my compilation.
    Thanks

  • Janusz

    Hi, I have created /dev/input directory but after restart there is no such directory. What is going on ?

    regards

  • anf

    Hi all
    I have a touchscreen calibration problem, I have created a ts.calib file by
    ts_calibrate > /usr/etc/ts.calib. I have exported this file “export TSLIB_CALIBFILE=/usr/etc/ts.calib”

    But my applications are not working right. When I drag to X axis mouse promt go to Y-axis, When I drag to Y axis mouse promt go to X-axis, also calibration is not true. ts_test works very good.

    Also When I added
    ” export QWS_MOUSE_PROTO=tslib:/dev/input/ts ” this , touch screen is not working.

  • Janusz

    ethem

    I have the same problem. Did you solve it ?

  • Allan

    ts_calibrate and ts_test working fine. When i run any QT demo/example app, as soon as I touch the screen i get a segmentation fault. Any ideas?

  • Muhammed ER

    Hi everybody,
    If you have any problem with /dev/input/ts, you should use /dev/input/event0 Wink

    For calib file, DON’T USE empty file!!!! use the existing one(before you have in qtopia)

  • Eric

    @Allan:
    I don’t know if this is related to your problem, but in case it could help, here is my experience.

    I got SegFaults when trying any demo I cross-compiled. After Googling a bit, I found that it seems to be a problem with the compiler optimisation. As suggested I recompiled the Qt libraries with optimisation off (-O0) by adding these lines :
    QMAKE_CFLAGS_RELEASE ~= s/-O[123s]/-O0/
    QMAKE_CXXFLAGS_RELEASE ~= s/-O[123s]/-O0/
    to mkspecs/qws/linux-arm-g++/qmake.conf

    After that no more SegFault, event if the application is itself compiled with optimisation.

    Since I’m quite newbie with Linux, Qt, Mini2440 et al. I leave true specialists comment on this.

    ${CROSS_COMPILE}gcc -v output :
    gcc version 4.3.2 (Sourcery G++ Lite 2008q3-72)

  • flux000

    Hello All,

    When a Qt application (e.g fluidlauncher) is started and i touch the screen, sometimes application in the background or desktop is activated. Is there a way to prevent the background apps from activating when running Qt application?

    My environment variables are shown below. I am using u-boot and GPE.

    export TSLIB_TSEVENTTYPE=INPUT
    export TSLIB_CONSOLEDEVICE=none
    export TSLIB_FBDEVICE=/dev/fb0
    export TSLIB_TSDEVICE=/dev/input/touchscreen0
    export TSLIB_CALIBFILE=/usr/local/tslib/etc/pointercal
    export TSLIB_CONFFILE=/usr/local/tslib/etc/ts.conf
    export TSLIB_PLUGINDIR=/usr/local/tslib/lib/ts
    export QWS_MOUSE_PROTO=tslib:/dev/input/touchscreen0

    Thanks,

    flux000

  • JFMartel

    Hi,
    Good work and thanks a lot. I succeeded to compile, install and develop a nice app for my mini2440.. thanks to your blog !

    I have a new question. Have you ever succeeded to launch your program at linux startup on the device ?
    I did succeed by adding the executable in the /etc/rcS file but the environment variables are not exported. And since the /etc/profile file is “loaded” only when a user logs in, I cannot figure out how to fire my app when device boots without having to log-in.

    Any advice would be greatly appreciated.

    Thanks again
    JF

  • flux000

    Hi Cor,

    When an Qt app is running on mini2440 and the touch screen is touch, the background or desktop is displayed on the screen.

    Anyway to resolve this.

    Thanks,

    flux000

  • cor

    Hi,
    I’m glad that you succedded.

    I think that you may want to make a short script that set your variables and then launch the app.
    For instance, something like that:

    #!/bin/sh

    export BLABLA = bla
    exec myApp

    A command like “source /etc/profile” might work too, I dunno.

    Good luck, please post a feedback telling how you managed to make it work, I’m interested Wink

  • JFMartel

    Hi,

    I finally managed to make it work.
    I tried A LOT of things but the linux kernel/distro that comes installed on the mini2440 is very wierd. Being a newbie, it’s been a lot of googling, trial and error but finally the solution is quite simple.

    Everything is done in /etc/rcS.
    To declare environment variables such as QWS_MOUSE_PROTO, you have to do it in two parts, first assing a value, and then export.
    For instance:

    QWS_MOUSE_PROTO=tslib:/dev/input/touchscreen0
    export QWS_MOUSE_PROTO

    When you have exported all the env. variables useful for Qt to work, then you can invoke your app.

    Now when my device boots, my app is launched and the touchscreen works fine.

    Again, thanks for your good walkthrough for installing Qt.

    JF

  • Matthias

    Hi,

    Thanks for the tutorial.
    I got a problem tough: I tried everything out what you said, but my calibration still doesn’t work…
    I only got that problem in Qt, out of Qt (while running a test) it works…
    But in Qt I got 2 possibilities:
    1. I don’t export: QWS_MOUSE_PROTO=tslib:/dev/input/ts
    => mouse isn’t moving the right way when touching the screen
    2. I do export it => mouse is blocking when touching the screen, it even doesn’t move anymore…

    can you plz help me out?

    Thanks

  • ketan

    hello.,
    i am working with mini2440 3.5″ LCD board
    i have successfully compiles Qtopia2.2.0 provided with the DVD or the download material.
    i want to install qtopia 4.5.2 or any version recent.
    i have referred to many forums but all says different. even i compiled once but i m not succeded.
    so any one please give me the full steps for that ?
    u can mail me even : ketanec2007@gmail.com

    thanks in advance
    ketan patel

  • jeremy

    Hi,

    Thanks for your work, it really helpfull for beginer as me Smile

    I am working with ubuntu 10.10 and I installed emdebian grip lenny on my mini2440.

    I installed tslib, it seems to work well then I configure/make/make install Qt. Both I installed in the usr/local folder;

    Then I cross-compiled a demo application “mousecalibration” and when I want to execute it : /lib/libc.so.6: version `GLIBC_2.9′ not found …

    I didn’t compile Qt with “-static” but anyway I think it will be the same problem.

    Do you have any issue ?

    Thank you very much guys !!

    Jeremy from France

  • annam

    Hi. Please come this blog to get the way cross-compile Qt4.6.2 for mini2440
    http://mini2440vietnam.blogspot.com/2011/04/upgrade-qt462-in-mini2440.html

  • Pavan

    Hi,

    Thanks a lot Cor. I have compiled my qt 4.6.3 and tslib successfully and loaded into mini2440 and run it from terminal by giving

    ./myapp -qws

    It run successfully. Now I want to launch from the desktop by creating an icon and by clicking on it.

    Please help me how to do it

  • Afonso

    Hi,
    Thanks for this tutorial. I need help with Touchscreen.
    I compiled Qt and tslib successfully.
    Typing “cat /dev/input/ts” works as mentioned (weird chars when touched).
    ts_calibrate and ts_test work fine too (touch screen is working fine).

    If I use “export QWS_MOUSE_PROTO=tslib:/dev/input/ts” it shows “Segmentation fault”. When I replace this line by just “export QWS_MOUSE_PROTO=” (without :” the my “Hello World” shows perfectly, but no touch screen.

    Compiling Qt with “-no-freetype” generates the same result: “Segmentation fault”.

    I can’t find a way to work touch with my app.

    Any suggestion?
    Thank you.
    Afonso.

  • Abhishek

    Guys m a newbie to arm board and linux. I have compiled the tslib lib.I m having n error in configuring qr-source-everywhere where it gives error
    relocation in generic elf em 3 for the file option.o.
    Wasted many days and couldnt get over dis problem.]
    For cross compiling i strictly followed this forum
    http://mini2440vietnam.blogspot.com/2011/04/upgrade-qt462-in-mini2440.html
    could understand were i am at fault..
    HELP !!! ASAP…

    Thanks in Advance

1 Trackback or Pingback for this entry

Leave a Reply

Click to Insert Smiley

SmileBig SmileGrinLaughFrownBig FrownCryNeutralWinkKissRazzChicCoolAngryReally AngryConfusedQuestionThinkingPainShockYesNoLOLSillyBeautyLashesCuteShyBlushKissedIn LoveDroolGiggleSnickerHeh!SmirkWiltWeepIDKStruggleSide FrownDazedHypnotizedSweatEek!Roll EyesSarcasmDisdainSmugMoney MouthFoot in MouthShut MouthQuietShameBeat UpMeanEvil GrinGrit TeethShoutPissed OffReally PissedMad RazzDrunken RazzSickYawnSleepyDanceClapJumpHandshakeHigh FiveHug LeftHug RightKiss BlowKissingByeGo AwayCall MeOn the PhoneSecretMeetingWavingStopTime OutTalk to the HandLoserLyingDOH!Fingers CrossedWaitingSuspenseTremblePrayWorshipStarvingEatVictoryCurseAlienAngelClownCowboyCyclopsDevilDoctorFemale FighterMale FighterMohawkMusicNerdPartyPirateSkywalkerSnowmanSoldierVampireZombie KillerGhostSkeletonBunnyCatCat 2ChickChickenChicken 2CowCow 2DogDog 2DuckGoatHippoKoalaLionMonkeyMonkey 2MousePandaPigPig 2SheepSheep 2ReindeerSnailTigerTurtleBeerDrinkLiquorCoffeeCakePizzaWatermelonBowlPlateCanFemaleMaleHeartBroken HeartRoseDead RosePeaceYin YangUS FlagMoonStarSunCloudyRainThunderUmbrellaRainbowMusic NoteAirplaneCarIslandAnnouncebrbMailCellPhoneCameraFilmTVClockLampSearchCoinsComputerConsolePresentSoccerCloverPumpkinBombHammerKnifeHandcuffsPillPoopCigarette

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...