Qt Embedded 4.6.0 + Qwt + kxps5 accelerometer!

After testing the operation of the kxps5 accelerometer with i2c-tools i wrote a test application using the i2c-dev interface. If you want to test your code before you write a kernel driver this is definately a good place to start. Once i had the configuration registers set properly and i had a routine for reading the acceleration vectors I stripped down a ds1621 kernel driver to a bare minimum, and then built it back up again to work with the kxps5. I then bitbaked the kxps5 driver as a kernel module, along with hwmon and it works perfectly! đŸ™‚ Next i cross compiled qwt 5.2.0 and plotted the acceleration as function of time. The video below is taken with antialiased lines which slows down the refresh rate but makes them look nice. If you plot it without this enabled it runs very smoothly. Here you see the kxps5 running without an external low pass filter (the internal filter is 1kHz) and despite this the output is pretty stable. What impressed me the most is the sensitivity. When placed on a desk the free fall interrupt indicator lights up if you drop one of the little nuts from the friendlyarm LCD about 10cm away from the device!


The kernel driver for this is now available here.

30 Replies to “Qt Embedded 4.6.0 + Qwt + kxps5 accelerometer!”

  1. First of all: Thanks for all the articles.
    Now to my question: How did you build/cross compile Qt4.6 for the mini? Did you use some self-made recipe and openembedded or did you use the Qt sources and manually compile it using the toolchain that OE generates?
    If you could describe the steps you took it would really help a lot.
    Thanks again.

  2. André :

    First of all: Thanks for all the articles.
    Now to my question: How did you build/cross compile Qt4.6 for the mini? Did you use some self-made recipe and openembedded or did you use the Qt sources and manually compile it using the toolchain that OE generates?
    If you could describe the steps you took it would really help a lot.
    Thanks again.

    You can do either, although it is probably easier to use open embedded. The two articles which explain both methods can be found here:

    Open Embedded
    Directly from source (obviously just use the latest source)

    Cor’s blog is very useful for setting up tslib if you compile from source. I used the tool chain I got from bitbaking the Qt SDK:

    bitbake meta-toolchain-qte

    Although I have used this this one in the past (no baking needed!).

    Just change your qmake.conf to have paths like this:

    QMAKE_CC = usr/local/angstrom/arm/arm-angstrom-linux-gnueabi-gcc

  3. André :

    I almost forgot: I already build Qt4.4.3 using the instruction from your previous article on my Ubuntu machine.

    Just use the same method with a later version of the source code. I think I built 4.6.2 the other week. If you were wondering which method Doug used in this demo, I believe it was built using open embedded.

  4. I’ve used both methods Will’s mentioned. It’s easier to use openembedded. If you clone the official repo you’ll get a recipe for Qt 4.6.X If you have trouble with this you could import just that recipe into the mini2440 repo (which is quite out of date but stable).

  5. @Doug
    Thanks for the replies.
    I first used the oe generated toolchain to compile Qt4.6.2, which worked.
    After that I tried openembedded. I added qt4-embedded in the mini2440-image.bb and copied the qt4 recipes from the official oe repo. After doing bitbake mini2440-image I got:

    NOTE: multiple providers are available for qt4-embedded (qt4-embedded, qt4-embedded-gles);
    NOTE: consider defining PREFERRED_PROVIDER_qt4-embedded
    NOTE: Preparing runqueue
    ERROR: Multiple .bb files are due to be built which each provide qt4-embedded (/home/andre/Projekte/openembedded/recipes/qt4/qt4-embedded_4.5.2.bb /home/andre/Projekte/openembedded/recipes/qt4/qt4-embedded-gles_4.6.2.bb).
    This usually means one provides something the other doesn’t and should.

    After a while I ended up with an error because of some omap gles stuff. The thing is that I’d really like to just use oe. So can you tell me what I’m doing wrong or how you (Doug) would compile the image including Qt4.6.2?
    I also haven’t figured out yet how to specify the Qt version I want. For some reason bitbake thinks that I’d like Qt4.6.2-embedded-gles.
    Thanks again.

  6. You can specify a version with a hyphen. From memory i think you can do:

    bitbake qt-embedded-4.6.2

    Or you can specify the recipe using the -b switch:

    bitbake -b recipe.bb

    Personally I would just clone the official repo see Will’s post

    This is what i do now, it saves the hassle of updating the mini2440 version. You don’t want qt4-embedded-gles because there’s no hardware support for it.

  7. @Doug
    As you suggested I used Will’s instructions and cloned the official oe repo.
    After about two hours of building base-image bitbake stopped because of some error. I then tried to just directly build qt-embedded-4.6.2 which started out fine. I ended up getting:
    NOTE: Tasks Summary: Attempted 2188 tasks of which 0 didn’t need to be rerun and 1 failed.
    ERROR: ‘/home/andre/Projekte/openembedded/recipes/gtk+/gtk+_2.18.6.bb’ failed
    after about 9 hours though.
    Building Qt4.6.2 using the oe generated toolchain works fine and building the mini2440-image using buserrors oe repo also works. For some reason I can’t get the official oe repo to build an image or to build a recent Qt version.
    It’s just getting kinda frustrating when I get up in the morning to see that it didn’t work not knowing what I did wrong.
    Are you maybe using a different branch of the or repo? I’m using master and not for example stable/2009 because the instructions don’t say to switch. Maybe something is wrong with the recipes for Qt4.6.2.
    Thanks again for any help you can give me to figure this out.

  8. Yeah, that branch can be pretty unstable. The only thing you can try is to clean the package bitbake -c clean gtk+, and rebuild again. If that doesn’t work you’ll have to keep updating until they patch it.

  9. @Will
    I tried… but right now it just does not seem to work. I guess I’ll just try to figure out how to build Qt4.6.2 using buserror’s repo again, since the first time around that also didn’t work.

  10. Hi Andre, yes, normally i’ve just used the master branch. I can confim the problem you’ve got. I’ve just disabled gtk+_2.18.6.bb and it’s fallen back to a slightly earlier version with a couple of seemingly minor complaints. I’ll let you know if it builds. I haven’t used phonon but I know Will has experimented with it although i’m not sure he got it to work…

  11. That failed as well but i think i’ve found the problem. Try installing gtk2-devel (yum install gtk2-devel) and clean gtk+ again. It looks like somethings changed as Fedora/OE has been updated. I’m not even sure why it needs GTK for the base image but anyway….

  12. It finished building the base image but i had to install python-devel and disable u-boot because it’s having trouble cloning the repo. It could well be my internet connection which is a joke at the moment. I’m going to try the stable branch tonight and see how it compares (git checkout origin/stable/2009 -b stable/2009).

  13. Hi Doug,

    Really well done.
    It’s funny as I’m willing to do quite the same thing : Mini2440 + QT + Accerometer.

    The fact is that I already bought the accelerometer that is SPI oriented instead of I2C.
    Do you have some ideas to do this please (here or my mail ) ?

  14. Thanks Nawac!

    This was my first device driver so i’m probably not the best person to ask.

    The process i used was to write some code for the i2c dev interface to read and write registers on the kxps5. Once this was working i found a simple i2c driver from the kernel and modified it using the code it’d written for the i2c dev interface. The i2c dev interface really helped because i didn’t have to keep recompiling and loading a kernel module. I just compiled the code directly on the mini2440.

    I haven’t done anything with SPI yet but i understand there is a spidev interface, see the
    kernel documentation.

    I would start by using this and following the same procedure i used for I2C. Sorry i can’t help any more than that.

    Good luck!

  15. Yes the spi kernel should be the best place . I had the same conclusion as there are not so much about SPI (why ? as many sensors use it) .

  16. One more things Doug : is it possible to read your code somewhere ? I’ve found codes for accelerometers within the kernel itself ( iioaccel)but how did you implemented it ? did you have to rebuild the kernel , it’s not possible to just read registers in a simple program ?

    1. Hi Nawac, eventually i will release the code but really it’s not much different to a temperature sensor apart from the naming of attributes and the registers. There really isn’t that much you need to change to get it working. I started looking at the lis3lv02d accelerometer driver but it’s much more complicated partly because it supports spi and registers the output as a joystick device. Maybe you need this functionality but i’d start by looking at something simple like the lm75 or the ds1621 and build it up from there. Cheers, Doug

  17. Hello All,

    I turned on the switch “-v” and the error message “….bin/qmake: 1: Syntax
    error: word unexpected (expecting “)”) ” is reported for the following:

    floatmath auto-detection… ()

    floatmath disabled.
    mmx auto-detection… ()

    mmx disabled.
    3dnow auto-detection… ()

    3dnow disabled.
    sse auto-detection… ()

    sse disabled.
    sse2 auto-detection… ()

    sse2 disabled.
    neon auto-detection… ()

    neon disabled.
    libjpeg auto-detection… ()

    libjpeg disabled.
    libtiff auto-detection… ()

    libtiff disabled.
    libmng auto-detection… ()

    libmng disabled.
    libpng auto-detection… ()

    libpng disabled.
    DB2 auto-detection… ()

    DB2 disabled.
    InterBase auto-detection… ()

    InterBase disabled.
    MySQL (thread-safe) auto-detection… ()

    MySQL (thread-safe) disabled.
    MySQL (thread-unsafe) auto-detection… ()

    MySQL (thread-unsafe) disabled.
    OCI auto-detection… ()

    OCI disabled.
    ODBC auto-detection… ()

    ODBC disabled.
    iODBC auto-detection… ()

    iODBC disabled.
    PostgreSQL auto-detection… ()

    PostgreSQL disabled.
    SQLite2 auto-detection… ()

    SQLite2 disabled.
    unknown SQL driver: sqlite_symbian
    TDS auto-detection… ()

    TDS disabled.
    NIS auto-detection… ()

    NIS disabled.
    Cups auto-detection… ()

    Cups disabled.
    D-Bus auto-detection… ()

    D-Bus disabled.
    EGL (EGL/egl.h) auto-detection… ()

    EGL (EGL/egl.h) disabled.
    EGL (GLES/egl.h) auto-detection… ()

    EGL (GLES/egl.h) disabled.
    Glib auto-detection… ()

    Glib disabled.
    tslib auto-detection… ()

    tslib disabled.
    The tslib functionality test failed!
    You might need to modify the include and library search paths by editing

    Please help, any input is welcome.

    Note: This error message is reported on Ubuntu 9.10 and 10.04 with
    arm-none-linux-gnueabi-g++ or arm-angstrom-linux-gnueabi-g++



  18. HI Doug,

    I didn’t found any email to contact you, so I post this message here.
    This is a serious message and I don’t want to polluate with it here (it’s the subject nevertheless), so if you can email me please, I’ll answer you then.


  19. Hi Doug,

    Thats very nice work. I watched your pass posts and I tried to connect i2c on my board and its succesed. I read time data from ds1307 with this command:

    > watch –interval=500 i2cget DaVinci I2C adapter 0xD1 w

    Now i want read time with Qt. But i dont know how to control i2c with Qt. Could you send me any example for it? (it maybe i2c or spi)

    Thanks, Can

    1. Hi Can, thanks for the comments!

      You can use the i2c-dev interface, see here:


      Or use a kernel driver, you won’t need to write one because i think it already exists, see here:


      You can either build it into the kernel by editing the config, or build it as a module. This will expose the sensor output as a file, which can be read from Qt, just as you would read from any other file. You could also test your Qt program using the on board eeprom…

      Hope that helps,

  20. Hello guy,

    i am developing a Qt aplication for the mini2440 and i need know two things:

    the first is how you compiled the qwt for use together with Qt? you compiled the qwt using the qmake of the qt-embedded?

    and the second thing is, you create a device driver for read the information of acellerometer and used the qt for create an interface?


  21. Hi Doug,

    I would like to know about the output from the accelerometer. Is it already in digital data or analog data??

    If it still in analog data, are you using the ADC from mini 2440 or you’re using another ADC and then connect it to mini 2440?? It seems the data look very nice from the video.


Leave a Reply

Your email address will not be published. Required fields are marked *