Using the Qt-Cross-Toolchain and QtCreator

By using a cross-toolchain on your development computer, you can easily create Qt5- or bare C-applications to run on your Kontron hardware.

Setting up the toolchain

You can either create a installer for the toolchain by running

> bitbake meta-toolchain-qt5

inside the Yocto build environment, or you can download the installer from the Kontron server. If you created the toolchain-installer with Yocto, you can find it in the directory <build-dir>/tmp/deploy/sdk

The installer is a shell-script, that can be executed like this:

> sh exceet-glibc-x86_64-arm-toolchain-1.0.0.sh

The default installation path is /opt/exceet/ if not specified otherwise.

Setting up Qt/QtCreator

Installing Qt/QtCreator

Check the download page at http://download.qt.io/official_releases/qtcreator for the latest release of QtCreator and download either the
qt-creator-opensource-linux-x86-X.X.X.run or the
qt-creator-opensource-linux-x86_64-X.X.X.run file, depending on your OS (32 bit or 64 bit). Since version 3.6 only the 64 bit version is available.

Install QtCreator by double-clicking the *.run-file in the file-manager or by running

> chmod +x qt-creator-opensource-linux-x86_64-3.2.1.run
> ./qt-creator-opensource-linux-x86_64-3.2.1.run

Alternatively you might also want to consider installing the full Qt environment for your desktop, including sources, tools and QtCreator. The advantage is, that apart from the Yocto-based target toolchain, you also have a toolchain available for your desktop environment. This enables you to switch between deploying to the target and deploying to your desktop machine for testing.

The online installer for the latest OpenSource edition of Qt can be found here:
32bit: http://download.qt.io/official_releases/online_installers/qt-unified-linux-x86-online.run
64bit: http://download.qt.io/official_releases/online_installers/qt-unified-linux-x64-online.run

Running

To run QtCreator with the exceet-cross-environment you have to modify the start script <qtcreator-install-dir>/bin/qtcreator.sh. Add the following line at the very beginning of the file (before #!/bin/sh):

> source /opt/exceet/mx6sexceet/environment-setup-cortexa9hf-vfp-neon-exceet-linux-gnueabi

This will source the build environment upon starting QtCreator. Adjust the script path and toolchain if you chose to install the toolchain in a non-default location.

Please ensure, that you are always starting QtCreator through the qtcreator.sh script, and not directly by executing the binary.

You can modify the Ubuntu-Launcher icon to make this easier. Usually it is saved in the file /usr/share/applications/(QtProject-)qtcreator.desktop. With the following command the file can be opened as root and modified:

> sudo gedit /usr/share/applications/(QtProject-)qtcreator.desktop

The modification is to attach an additionally .sh to the content of the Exec variable, so that after clicking on the symbol the script is called:

Exec=/opt/qtcreator-3.2.1/bin/qtcreator.sh` or `Exec=qtcreator.sh

In case that after translating a project problems with unset environment variables occur (like c: Command not found), the file needs to be modified again and the following must be added:

Exec=bash -c $(Path to Qt Creator start script)

Deploying to the target

If you are using a development environment provided by Kontron, and you are running a build of image-exceet on your hardware (includes ssh-server, sftp-server, gdbserver), you should be able to deploy your app to the target via network. To change the settings of the remote device (IP-Adress, ...) in QtCreator, go to Tools -> Options -> Devices -> i.mx6 exceet.
QtCreator uses sftp and ssh to copy the files and run the application remotely.

The deployment of your files is configured in your qmake project file by setting the INSTALLS variable. The Kontron demo programs contain some simple deployment rules. For more information see the Qt/qmake documentation.

Copy files manually to the target

Using the protocols sftp and scp files can be copied to the target. If the target has the IP address 192.168.0.10 the content of the target can be shown by using the URL sftp://root@192.168.0.10/ in a browser window.
To copy files via command line the program scp can be used.
You can also start a remote shell on the target via ssh:

user@BSPIMX:~$ ssh root@192.168.0.10
root@192.168.0.10:~

Adding your own device

To be able to use the deploy and debugging features within QtCreator with your own device you can modify an existing configuration or create a new one.

If you want to create a new configuration in QtCreator or modify an existing one go to Tools -> Options -> Devices and add your device by clicking Add .... Choose Generic Linux Device from the drop down menu. Set the appropriate values for the device name, ip address and the username and password. The connection can be tested with the Test button in the devices tab.

Debbuging

If gdbserver is running on the target (default in image-exceet) you should be able to use the debugging features in QtCreator.

For debugging you need an appropriate so called kit for your device. This kit provides all information needed for debugging with your hardware like

  • cross toolchain
  • debugger binary
  • debug symbols and headers for the libraries the target uses (sysroot)

For further information see the kit section

If you want to debug QML based applicaitons ensure, that (QML-)debugging is enabled in the project settings. If you are trying to debug a QML-app and you get an error message "Invalid Signal", then try to skip the message by clicking 'OK' and the use the button with the green arrow to continue debugging.

Setting up your kit

Kontron suggests to use one of the provided kits for the demo boards. The two kits Exceet IMX6 UL Board and Exceet IMX6 S Board are available. If have to modify one of the kits or you want to create your own kit, these kits are a good starting point.

Kits can be modified in the Build&Run view (Tools -> Options -> Build & Run). Here you can configure your kit with:

  • its name (choose what you want)
  • the device type (only Generic Linux Device for Kontron devices)
  • the device to be used (see devices configuration for deployment)
  • the sysroot - headers and libraries for the Yocto firmware (toolchain base directory/sysroots/cortex*)
  • cross-compiler (toolchain base directory/sysroots/x86*/usr/bin/arm-exceet-linux-gnueabi/arm-*-gdb)
  • cross-debugger (since morty /usr/bin/gdb-multiarch)
  • Qt version (toolchain base directory/sysroots/x86*/usr/bin/qt5/qmake)

The configuration entries for compiler, debugger and Qt version have several tabs to enter the matching configuration settings. In the kits view you can only select already pre-defined settings.

Further hints for debugging

  • Disable optimization
    Debugging an optimized binary might be difficult because the compiler may reorder or optimize away some code. To disable optimization for debugging purposes you can set some QMAKE variables in your project file to disable optimization. But be aware that this might lead to differnt timings for your applicaiton!
  QMAKE_CXXFLAGS_DEBUG += -O0
  QMAKE_CFLAGS_DEBUG += -O0
  • Rejected loading of shared libraries
    Loading of shared libraries is sometimes rejected by gdb due to 'insecure path settings'. Put these gdb commands into your QtCreator configuration for gdb to disable secure path setting. set auto-load safe-path / You can configure additional start commands for gdb thru Tools -> Options -> Debugger -> GDB.

  • Using gdb-multarch
    Qt Creator uses so called pretty printers to provide a easy interface to basic Qt classes like e.g. Qt strings. These pretty printers are implemented with the help of python functions in gdb. The cross toolchain for the devices may lack some python libraries Qt creator needs for its pretty printers. To circumvent this use the gdb-mulitarch debugger of your development machine for remote debugging (already default for morty). You can install gdb-multiarch on your development host by running sudo apt install gdb-multiarch.

Analyzing with GammaRay

GammaRay is a free software introspection tool for Qt applications developed by KDAB. You can use it to analyze and manipulate Qt applications at runtime.

The latest Kontron SDK comes with a precompiled GammaRay executable for 64bit hosts . You can run the launcher by executing:

>  /opt/exceet/<machine>/gammaray/bin/gammaray

On the target run your Qt application with GammaRay (needs to be included in the image or installed manually):

> gammaray --inject-only <path_to_qt_app>

For example:

> gammaray --inject-only /usr/bin/kontron-demo_qml

Finally ensure, that you have a working network connection between host and target and then move to the "Connect" tab in the GammaRay launcher window, enter the IP of your target device and click "Connect".

After successfully connecting to the target device, you should see the GammaRay window with a list of all Qt Objects. For further information on the usage of GammaRay visit the website or watch the talks by Volker Krause on Qt Developer Day ([1], [2]).

Qt Environment

Qt offers several options concerning framebuffer, eglfs, input devices, etc. that can be set via environment variables.
Please use this page as a reference for the available options: Qt for Embedded Linux

QML Software Rendering

To be able to use QML/QtQuick applications on SoCs without GPU, it is possible to select the included software renderer. This enables you to use QML/QtQuick for example on our SoMs with i.MX6UL/ULL. Some features such as shaders, etc. won't be available and you might experience performance issues, depending on how your application is designed.

To use the software backend, set QT_QUICK_BACKEND=software in your environment.

Creating a Yocto-recipe for a Qt-app

To build your Qt-app with bitbake and include it in a Yocto-image, you have to create a recipe similar to the following example. Create it as your-app_version.bb in your custom layer meta-customer/recipes-customer/your-app/. The example fetches the sources from a GIT-repository. Instead of that, the sources can also be fetched from local files in the recipe directory, from a tarball or a SVN-server. See the Yocto-Dev-Manual for more information on how to write your own recipe.

SUMMARY = "The Qt5 Demo QML Application for the Kontron i.MX6 Board"
HOMEPAGE = ""
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.GPLv2;md5=751419260aa954499f7abaabaa882bbe"

# Use qmake
inherit qmake5

OE_QMAKE_PATH_HEADERS = "${OE_QMAKE_PATH_QT_HEADERS}"

# Build Dependencies
DEPENDS += "qtbase qtdeclarative qtmultimedia"

# Runtime Dependencies for the kontron-demo package
RDEPENDS_${PN} += "qtmultimedia-qmlplugins qtmultimedia-plugins \
           gst-plugins-base-meta gst-fsl-plugin \
           gst-plugins-good-meta gst-plugins-bad-meta \
           qtdeclarative-qmlplugins qtbase-plugins qtbase-fonts"

# Specify the path to the source files
S = "${WORKDIR}/git"

FILESEXTRAPATHS_prepend := "${THISDIR}/files:"

# Fetch the latest version from the master branch of the GIT repo
SRCBRANCH = "master"
SRCREV = "${AUTOREV}"

# Where to fetch the sources from
SRC_URI = "git://${EXCEET_GIT_APPS}/exceet-demo.git;protocol=ssh;branch=${SRCBRANCH}"
SRC_URI_http = "git://${EXCEET_GIT_APPS}/exceet-demo.git;protocol=http;user=exceet-user:user;branch=${SRCBRANCH}"

# Which files to include in the kontron-demo package
FILES_${PN} = "/opt/exceet_demo_qml/* \
           /usr/src/debug/exceet-demo/* \
           /usr/bin/exceet_demo_qml \
        "

# Which files to include in the exceet-demo-dbg package
FILES_${PN}-dbg = "/opt/exceet_demo_qml/.debug* \
          "