Building Qt for i.MX5x

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Building Qt for i.MX5x

32,338 Views
mdc
Contributor V
Hi,

I recently had the need to build Qt for the i.MX53 platform so thought I'd document the steps I had to go through here as had to jump through a few hoops to get it to build. If anyone has had similar experiences please share as I know some of the cross compilation difficulties can be somewhat host dependent.

This example has OpenGL ES support and runs under X11 via Xfbdev. Examples for building for OpenGL ES2.0 as well as OpenGL ES1.0 are given.

I borrowed heavily from the http://www.imxdev.org/wiki/index.php?title=All_Boards_Qt site, but I have fully documented the steps required here.

These instructions are based on the 11.03 Linux BSP, and the 4.7.2 release of Qt. 

HOST SETUP

My build system was an up to date ubuntu 10.10 (64-bit) machine. It is assumed the reader is familiar with how to use LTIB. Reference the "ltib_build_host_setup.pdf" file in the linuxdocs package in the latest BSP release for details on how to setup a host to build ltib, but the below shell script may be used to install required packages for an Ubuntu host.

# ---------------
#!/bin/bash
# Install packages needed by LTIB
sudo apt-get -y install gettext libgtk2.0-dev rpm bison m4 libfreetype6-dev
sudo apt-get -y install libdbus-glib-1-dev liborbit2-dev intltool
sudo apt-get -y install ccache ncurses-dev zlib1g zlib1g-dev gcc g++ libtool
sudo apt-get -y install uuid-dev liblzo2-dev
sudo apt-get -y install tcl dpkg
# Packages required for 64-bit Ubuntu
# Do "uname -a" and see if the word "x86_64" shows up.
if uname -a|grep -sq 'x86_64'; then
sudo apt-get -y install ia32-libs libc6-dev-i386 lib32z1
fi
# ---------------

For the host setup to build Qt, start by making sure all of the following packages are installed.

libx11-dev
libpng-dev
libjpeg-dev
libxext-dev
x11proto-xext-dev
qt3-dev-tools-embedded
libxtst-dev

I also installed the following packages mentioned at the bottom of http://trac.webkit.org/wiki/BuildingQtOnLinux when trying to fix various problems. Not sure if any of them are actually required, but shouldn't hurt.

$ sudo apt-get install bison flex libqt4-dev libqt4-opengl-dev libphonon-dev libicu-dev libsqlite3-dev libxext-dev libxrender-dev gperf libfontconfig1-dev libphonon-dev g++

Below is a dump of everything qt related I have installed on my host:

$ dpkg --get-selections | grep qt
libqt3-compat-headers            install
libqt3-headers                install
libqt3-mt                    install
libqt3-mt-dev                install
libqt4-dbus                    install
libqt4-declarative            install
libqt4-designer                install
libqt4-dev                    install
libqt4-help                    install
libqt4-network                install
libqt4-opengl                install
libqt4-opengl-dev                install
libqt4-qt3support                install
libqt4-script                install
libqt4-scripttools            install
libqt4-sql                    install
libqt4-sql-mysql                install
libqt4-svg                    install
libqt4-test                    install
libqt4-webkit                install
libqt4-xml                    install
libqt4-xmlpatterns            install
libqtcore4                    install
libqtgui4                    install
libqtwebkit-dev                install
libqtwebkit4                install
qt3-dev-tools                install
qt3-dev-tools-embedded            install
qt4-qmake                    install

BUILD LTIB

At the time of this writing, the latest BSP for the i.MX53 is 11.03.

This can be downloaded from Freescale's website here:

http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=i.MX535&fpsp=1&tab=Design_Tools_Tab

You'll want both the BSP source and the Multimedia codecs.

Build LTIB with the following packages included (just pick Min profile when initially running ltib config). Make sure to download and copy the multimedia codecs to /opt/freescale/pkgs, and check the patch that is also required for gst-fsl-plugin-1.9.8 in the 11.03 BSP release.

    * amd-gpu-x11-bin-mx51
    * libz160-bin
    * Freescale Multimedia Plugins/Codecs - fsl-mm-codec-libs & gstreamer-fsl-plugins
    * fontconfig
    * freetype
    * glib2
    * gstreamer
    * gstreamer-plugins-base
    * gstreamer-plugins-good
    * gstreamer-plugins-bad
    * gstreamer-plugins-ugly
    * Liberation fonts
    * libjpeg
    * libpng
    * liboil
    * libxml2
    * mysql
    * tslib
    * X11 (X.Org 7.5)
    * X11/libICE
    * X11/libSM
    * zlib

My ltib directory was at /home/matt/imx/mx53/11.03/ltib - make sure to modify the succeeding instructions accordingly based on where you install ltib on your system.

After you build ltib, cd to your ltib/rootfs/usr/lib directory and do the following:

sudo ln -s libgsl-fsl.so libgsl.so

After building ltib, make a symbolic link /tftpboot/ltib pointing to your rootfs folder. This is needed to make the i.MX libs and incs available to qmake.

$ ln -s <rootfs folder dir> /tftpboot/ltib

For my example:

$ ln -s /home/matt/imx/mx53/11.03/ltib/rootfs /tftpboot/ltib

The instructions at the imxdev site also recommend restarting the nfs server (below command). This is only needed if you're mounting your rootfs via NFS. This step has no impact on the Qt build. I typically copy my rootfs to an SD card, so I skip this step.

$ sudo /etc/init.d/nfs-kernel-server restart

RUN QMAKE AND BUILD QT

Download the latest qt-everywhere-opensource release from http://get.qt.nokia.com/qt/source

As of this writing the latest release is 4.7.2:

http://get.qt.nokia.com/qt/source/qt-everywhere-opensource-src-4.7.2.tar.gz

Download and copy the qt-everywhere-opensource-src-4.7.2.tar.gz tar file to the directory where you'll build qt, and untar:

$ tar zxvf qt-everywhere-opensource-src-4.7.2.tar.gz

For the cross compiler path, after installing the 11.03 BSP release and running ltib, you should have this installed at /opt/freescale/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin. I put the full cross compile path in my qmake.conf as I would sometimes have problems during the Qt build without this. Hence you shouldn't need to export the cross compiler path.

Copy the attached mkspecs.mx5x.tar.gz to qt-everywhere-opensource-src-4.7.2
$ tar zxvf mkspecs.mx5x.tar.gz

This will put the qmake.conf at mkspecs/linux-g++-mx5x. Assuming you have the cross compiler installed in the default location noted above you shouldn't need to change anything in qmake.conf.

To build Qt with OpenGL ES2.0 support

$ ./configure -arch arm -xplatform linux-g++-mx5x -release -prefix /tftpboot/ltib/usr/local/Trolltech/Qt-4.7.2-mx5x-x11 -multimedia -phonon -phonon-backend -qt-gfx-linuxfb -qt-kbd-tty -little-endian -host-little-endian -fontconfig -sm -opengl es2

$ make

On my system, I had 3 spots where the build crashed. Not sure if this was specific to something on my system, or if something everyone will see. Bonus points for anyone who's able to figure these out.

Below are the signatures of the failures and how to get around them.

First crash:

make[1]: *** No rule to make target `../JavaScriptCore/release/libjscore.a', needed by `../../../../lib/libQtWebKit.so.4.7.2'.  Stop.
make[1]: Leaving directory `/home/matt/qt/target_builds/mx53/11.03/qt-everywhere-opensource-src-4.7.2/src/3rdparty/webkit/WebCore'
make: *** [sub-webkit-make_default-ordered] Error 2

To fix:

$ cd src/3rdparty/webkit/JavaScriptCore/release/
$ cp jscore. libjscore.a
$ cd -
$ make

Second crash:

/opt/freescale/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/../lib/gcc/arm-fsl-linux-gnueabi/4.4.4/../../../../arm-fsl-linux-gnueabi/bin/ld: cannot find -lpnp_basictools
collect2: ld returned 1 exit status
make[3]: *** [plugandpaint] Error 1
make[3]: Leaving directory `/home/matt/qt/target_builds/mx53/11.03/qt-everywhere-opensource-src-4.7.2/examples/tools/plugandpaint'
make[2]: *** [sub-plugandpaint-make_default-ordered] Error 2
make[2]: Leaving directory `/home/matt/qt/target_builds/mx53/11.03/qt-everywhere-opensource-src-4.7.2/examples/tools'
make[1]: *** [sub-tools-make_default] Error 2
make[1]: Leaving directory `/home/matt/qt/target_builds/mx53/11.03/qt-everywhere-opensource-src-4.7.2/examples'
make: *** [sub-examples-make_default-ordered] Error 2

To fix:

$ cd examples/tools/plugandpaint/plugins/
$ cp pnp_basictools. libpnp_basictools.a
$ cd -
$ make

Third crash:

/opt/freescale/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/../lib/gcc/arm-fsl-linux-gnueabi/4.4.4/../../../../arm-fsl-linux-gnueabi/bin/ld: cannot find -ldemo_shared
collect2: ld returned 1 exit status
make[2]: *** [deform] Error 1
make[2]: Leaving directory `/home/matt/qt/target_builds/mx53/11.03/qt-everywhere-opensource-src-4.7.2/demos/deform'
make[1]: *** [sub-deform-make_default] Error 2
make[1]: Leaving directory `/home/matt/qt/target_builds/mx53/11.03/qt-everywhere-opensource-src-4.7.2/demos'
make: *** [sub-demos-make_default-ordered] Error 2

To fix:

$ cd demos/shared/
$ cp demo_shared. libdemo_shared.a
$ cd -
$ make

After the make completes successfully, do the following to install Qt to your rootfs:

$ sudo make install

This will install to the directory you have defined in the -prefix switch when you ran configure. In my example this is /tftpboot/ltib/usr/local/Trolltech/Qt-4.7.2-mx5x-x11.

If you want the fluidlauncher demo (referenced later), you'll need to build and copy this manually to the rootfs. The following will do this as well as everything at demos/embedded:

$ cd qt-everywhere-opensource-src-4.7.2/demos/embedded
$ make
$ sudo make install
$ cd fluidlauncher
$ make
$ cd ..
$ sudo cp -r fluidlauncher /tftpboot/ltib/usr/local/Trolltech/Qt-4.7.2-mx5x-x11/demos/embedded

Not sure why make install doesn't work in the fluidlauncher demo, but copying the executable directly works fine.

Copy the libs from usr/local/Trolltech/Qt-target-version/lib/ to usr/lib/:

$ sudo cp -a /tftpboot/ltib/usr/local/Trolltech/Qt-target-version/lib/* /tftpboot/ltib/usr/lib/

In my example:

$ sudo cp -a /tftpboot/ltib/usr/local/Trolltech/Qt-4.7.2-mx5x-x11/lib/* /tftpboot/ltib/usr/lib/

Now the rootfs should be ready to either NFS mount, or copy to an SD card. See the instructions at the end of the setup for details on copying the bootloader, kernel, and rootfs to an SD card.

Starting QT Demos and Examples

Boot the i.MX53 board, then from the console, start X11 using the command:

export DISPLAY=:0.0
Xfbdev -mouse mouse,,device=/dev/input/mice -keybd keyboard,,/dev/input/event2 &

This will start X11 with USB mouse and keyboard support and return the command prompt.

There are several demos and examples on folder /usr/local/Trolltech/Qt-target-version. The demo below shows OpenGLES 2.0 functionality:

cd /usr/local/Trolltech/Qt-target-version/demos/pathstroke
./pathstroke

Another good one is the fluidlauncher demo at /usr/local/Trolltech/Qt-target-version/demos/embedded/fluidlauncher
./fluidlauncher

In some of the fluidlauncher demos (i.e., the Pathstroke and Qt magnifying glass), if you click on the window, you'll see an OpenGL button that enables/disables OpenGL. Note I was seeing some color issues with the below message in the console when I enabled OpenGL in the fluidlauncher demo. Need to try to figure this one out.

     Warning: EGL suggested using X Visual ID 33 (ARGB0565) for EGL config 15 (ARGB1555), but this is incompatable


To build Qt with OpenGL ES1.0 support

If you need OpenGL ES1.0 support (i.e. - if you have existing Qt OpenGL 1.0 apps that you want to test), everything is the same as what's described above, with a couple exceptions as described below.

The first thing you'll need to change is go to the qt-everywhere-opensource-src-4.7.2/mkspecs/linux-g++-mx5x directory, and you'll note there are separate qmake.conf files for OpenGL ES1 and ES2. The primary difference between these files is modifying QMAKE_LIBS to include either -lGLESv2, or -lGLESv1_CM (I had trouble getting OpenGL to work if both were included).

Also, when you run configure you'll set the -opengl switch to "es1" instead of "es2":

$ ./configure -arch arm -xplatform linux-g++-mx5x -release -prefix /tftpboot/ltib/usr/local/Trolltech/Qt-4.7.2-mx5x-x11 -multimedia -phonon -phonon-backend -qt-gfx-linuxfb -qt-kbd-tty -little-endian -host-little-endian -fontconfig -sm -opengl es1

$ make

You'll hit the same 3 build errors as when building for OpenGL ES2.0 that you'll work around the same way as described above.

Note there is one additional problem you'll hit when building with the "es1" switch you'll need to work around. The signature of this crash is as follows:

In file included from ../../include/QtOpenGL/private/qpaintengine_opengl_p.h:1,
                 from qpixmapdata_x11gl_egl.cpp:54:
../../include/QtOpenGL/private/../../../src/opengl/qpaintengine_opengl_p.h:150: error: 'GLenum' has not been declared
make[1]: *** [.obj/release-shared/qpixmapdata_x11gl_egl.o] Error 1
make[1]: Leaving directory `/home/matt/qt/target_builds/mx53/11.03/es1/qt-everywhere-opensource-src-4.7.2/src/opengl'
make: *** [sub-opengl-make_default-ordered] Error 2

To work around this, copy the attached qt_qpaintengine_gles1.patch to qt-everywhere-opensource-src-4.7.2 and apply:

$ patch -p1 <qt_qpaintengine_gles1.patch
patching file src/opengl/qpaintengine_opengl_p.h

This can be done before you run configure.

Prepping an SD card

This info is available in the linux BSP user's guide, but is included here for completeness. In the below example, /dev/sdx should be replaced by whatever the device note is for your SD card reader (do "dmesg" after you insert your SD card and that should tell you).

$ sudo umount /dev/sdx*
$ cd /tftpboot/ltib/boot/
$ sudo dd if=u-boot.bin of=/dev/sdx bs=512 && sync && sync
$ sudo dd if=uImage of=/dev/sdx bs=512 seek=2048 && sync && sync
$ sudo fdisk /dev/sdx
    Command (m for help): u
    Command (m for help): n
    Command action
       e   extended
       p   primary partition (1-4)
    p
    Partition number (1-4): 1
    First sector (62-7744511, default 62): 8192
    Last sector, +sectors or +size{K,M,G} (8192-7744511, default 7744511): (Just hit return, your ending sector may be different)
    Command (m for help): w
$ sudo mkfs.ext3 /dev/sdx1
$ sudo mkdir /media/sd_mount
$ sudo mount /dev/sdx1 /media/sd_mount
$ cd /tftpboot/ltib
$ sudo cp -rpa [A-z]* /media/sd_mount
$ sync
$ sync
$ sudo umount /dev/sdx*

The SD card should now be ready to boot.

Note you'll need to setup the u-boot environment variables the first time you boot so the kernel command line and various variables to set the display, etc... are set. This is going to be specific to the board you're using. Consult the BSP user's guide and release notes for your board for the specifics here. This procedure was tested on an MX53EVK (an early eval board), but no reason it shouldn't work with the MX53 Quick Start Board, MX53 Sabre Tablet, MX51EVK, or other MX5x platforms (assuming you build and setup u-boot properly for your board).

Original Attachment has been moved to: 802-mkspecs.mx5x.tar.gz

Original Attachment has been moved to: 803-qt_qpaintengine_gles1.patch

Tags (2)
88 Replies

6,295 Views
MT
NXP Employee
NXP Employee

I have just built QT 4.7.4 for the i.MX53. Went very smoothly, except I had to add the following packages to my LTIB package list: hal,dbus,libusb

0 Kudos

6,295 Views
Swamy
Contributor III

Can anyone please suggest

0 Kudos

6,295 Views
Swamy
Contributor III

Thanks for the reply. Please find the attached package list enabled.

Regards

Swamy

0 Kudos

6,295 Views
bonil
Contributor I

Hi Swamy

The log file you attached here indicates that the gls library are missing.

Could you post the list of all packages you have enabled?

$ ./ltib -m listpkgs

0 Kudos

6,295 Views
Swamy
Contributor III

Hi,

I am using IMX53 and using LTIB to build the QT, I have used your spec qt-x11.spec file.

I am getting lot of error. please suggest. I have attached the error log.

Regards,

Swamy

 


Luca Bonifacio said:

Hi Matt!

Many thanks for this tutorial. I finally built successfully Qt on my imx51 evk board. I used BSP 10.2011 for imx53 and Qt 4.7.4 and I also had the three errors you got too. All errors could be fixed with your suggestions.

Just for your info and to share my experience with the community. Instead to use your mkspec file, I used directly LTIB to build Qt by modifying the qt-x11.spec file in <ltib-path>/dist/lfs-5.1/qt to get the same output file qmake.conf (see attachement). In LTIB I just selected Qt-X11 package without selecting the Phonon package. That works too.. I didn't have to replace fsl-mm-codeclib and gst-fsl-plugin files. LTIB builds Qt fine with version 1.9.5. The only thing I did different was linking libfsl.so to libgsl-fsl.so, and not inverse as you propose. I don't know if that is a mistake in your tutorial or is only for BSP 10.2011 imx53.
Command used:
$ sudo ln -s libgsl.so libgsl-fsl.so

Also gplay works fine. I can finally play videos. There is just missing the audio, but I don't need it for my final application.

 

Regards,

Luca

 

0 Kudos

6,295 Views
Swamy
Contributor III

If I uncheck gstreamer-fsl-plugins, I dont get the error. Please suggest.

0 Kudos

6,295 Views
Swamy
Contributor III

Thanks for the reply.

Yes. I have enabled it.

0 Kudos

6,295 Views
bonil
Contributor I

Hi Swamy!

Do you have fsl_mm_coded enabled in your LTIB?

Freescale Multimedia Plugins/Codecs -> fsl-mm-codec-libs & gstreamer-fsl-plugins

0 Kudos

6,295 Views
Swamy
Contributor III

Hi,

I am selected the same configuration, but I am getting following error. Please suggest

 

checking pkg-config is at least version 0.9.0... yes
checking for GST... yes
checking for GST_BASE... yes
checking for GST_PLUGINS_BASE... yes
checking for FSL_MM_CORE... no
configure: error: no fsl-mm-core header/libs found !
error: Bad exit status from /home/lucid/ltib/tmp/rpm-tmp.81224 (%build)

0 Kudos

6,295 Views
bonil
Contributor I

... and here qt-x11.spec file for everyone that want to build qt-x11 without OpenGL & OpenVG support (without graphics acceleration support)

 

Regards,

Luca

0 Kudos

6,295 Views
bonil
Contributor I

Hi Matt!

Many thanks for this tutorial. I finally built successfully Qt on my imx51 evk board. I used BSP 10.2011 for imx53 and Qt 4.7.4 and I also had the three errors you got too. All errors could be fixed with your suggestions.

Just for your info and to share my experience with the community. Instead to use your mkspec file, I used directly LTIB to build Qt by modifying the qt-x11.spec file in <ltib-path>/dist/lfs-5.1/qt to get the same output file qmake.conf (see attachement). In LTIB I just selected Qt-X11 package without selecting the Phonon package. That works too.. I didn't have to replace fsl-mm-codeclib and gst-fsl-plugin files. LTIB builds Qt fine with version 1.9.5. The only thing I did different was linking libfsl.so to libgsl-fsl.so, and not inverse as you propose. I don't know if that is a mistake in your tutorial or is only for BSP 10.2011 imx53.
Command used:
$ sudo ln -s libgsl.so libgsl-fsl.so

Also gplay works fine. I can finally play videos. There is just missing the audio, but I don't need it for my final application.

 

Regards,

Luca

0 Kudos

6,295 Views
philippecavenel
Contributor I

Hello !

Perfect ! Many thanks for this accurate tutorial. I got my Qt demo and it runs fine on my iMX53 board.

Regards,

Philippe.

0 Kudos

6,295 Views
kamejoko80
Contributor II

Hi all,

I started fluidlauncher on my i.mx233 custome board successfully. However I couldn't start apps from the slider. When select, there is an error message shows on the console:

Process error: 0

everyone met the same problem ?

Thanks and Best Regards.

0 Kudos

6,295 Views
NelePerdu
Contributor I
Thank you, it's fixed now
0 Kudos

6,295 Views
mdc
Contributor V
Sounds like you're using the 11.01 BSP release. There were issues with the codecs in this release. Recommend you switch to 11.05 which you can find on the i.MX53 page on freescale.com.
0 Kudos

6,295 Views
NelePerdu
Contributor I

Hello

 

I have an i.MX53 QSB

After LTIB tried to build, I got next error:

Processing: fsl-mm-codeclib
=============================
Build path taken because: no prebuilt rpm,
Testing network connectivity
OK GPP:

Try fsl-mm-codeclib-1.9.6.tar.gz.md5 from the GPP
http://bitshrine.org/gpp/fsl-mm-codeclib-1.9.6.tar.gz.md5:
07:38:22 ERROR 404: Not Found.
Try fsl-mm-codeclib-1.9.6.tar.gz from the GPP
http://bitshrine.org/gpp/fsl-mm-codeclib-1.9.6.tar.gz:
07:38:22 ERROR 404: Not Found.
Can't get: fsl-mm-codeclib-1.9.6.tar.gz at ./ltib line 790.


f_buildrpms() returned an error, exiting
traceback:
 main:560


Started: Wed Aug 24 07:38:07 2011
Ended:   Wed Aug 24 07:38:22 2011
Elapsed: 15 seconds

These packages failed to build:
fsl-mm-codeclib

Build Failed

Exiting on error or interrupt

 

I added fsl-mm-codeclib-1.9.7 to /opt/freescale/pkgs because that's the one I've found in IMX-MMCodecs_11_01_Bundle. Then I searched for version 1.9.6, but I didn't found that one, I only found 1.9.5. Does anyone knows where I can find the right version, or what I could do to use version 1.9.7?

 

Regards

Nele

0 Kudos

6,295 Views
G_rio
Contributor III

Hello guys,

My problem was fixed. I didn't start the X Server.. i think i was typing anything wrong.

 

OBS. to my touch works i type it.

Xfbdev -mouse tslib,,device=/dev/input/ts0 &

 

Thank's for all that help me with this topic.

0 Kudos

6,295 Views
kimjiang
Contributor I

Hello

Can you tell me how to start x server? thank you

0 Kudos

6,295 Views
G_rio
Contributor III

Hello Matt,

freescale login: root
root@freescale ~$ export DISPLAY=:0.0
<ouse mouse,,device=/dev/input/mice -keybd keyboard,,/dev/input/event2 &      
[1] 2248
root@freescale ~$ _XSERVTransSocketOpenCOTSServer: Unable to open socket for inet6
_XSERVTransOpen: transport open failed for inet6/freescale:0
_XSERVTransMakeAllCOTSServerListeners: failed to open listener for inet6
(EE) XKB: Couldn't open rules file /usr/share/X11/xkb/rules/base
(EE) XKB: No components provided for device Virtual core keyboard
Kbd option key (/dev/input/event2) of value ((null)) not assigned!
(EE) XKB: Couldn't open rules file /usr/share/X11/xkb/rules/base
(EE) XKB: No components provided for device (unnamed keyboard)

 

I Changed the event2 to event4 (my keyboard input) and i got the same error..

0 Kudos

6,295 Views
mdc
Contributor V

Make sure you're starting the X server and exporting the DISPLAY variable before trying to run the demos. You can run the below commands from the serial console.

 

export DISPLAY=:0.0
Xfbdev -mouse mouse,,device=/dev/input/mice -keybd keyboard,,/dev/input/event2 &

0 Kudos

6,295 Views
G_rio
Contributor III

Hi Luca, i've tried to run directly, but i got the same error in LCD.

I'll make a Qt console application to test..
I think the fluidlauncher is trying to connect to my host.

0 Kudos