Qt Embedded Linux

How to compile Qt SDK for Apalis iMX6Q

In this link, I have explained how to make a custom Linux and I’m going to show you how to make a Qt SDK.

Go to your Yocto project directory
$ source export
$ bitbake meta-toolchain-qt5

After the above command successfully finished, before going further I should download and install proper software development kit from this link and install it.

$ chmod +x angstrom-glibc-x86_64-armv7at2hf-neon-v2017.12-toolchain.sh
$ ./angstrom-glibc-x86_64-armv7at2hf-neon-v2017.12-toolchain.sh
$ source environment-setup-armv7at2hf-neon-angstrom-linux-gnueabi
$ QtCreator

After that I can configure Qt Creator with a new tool-chain to cross-compile my source code and run it on the target.

Go to Tools‬‬ ‫→‬ ‫‪Options ‫from the Qt Creators menu

In the left panel choose Devices.

  • Press Add and choose Generic Linux Device
  • Specify a name
  • Specify Device’s IP Address and Port(Host,Port)
  • Authentication type

In the left panel select Build & Run.

  • Choose the Qt Versions tab
  • Press Add
  • Choose:
/usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/bin/qmake2
  • Fill in a name

Select the Compilers tab.

  • Press Add
  • Fill in a name: GCC (Qt Embedded)
  • Compiler path:
/usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/bin/arm-angstrom-linux-gnueabi/arm-angstrom-linux-gnueabi-g++
  • ABI should be detected automatically

Choose the Debuggers tab.

  • Press Add
  • Name: GDB (Qt Embedded)
  • Fill in the path:
/usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/bin/arm-angstrom-linux-gnueabi/arm-angstrom-linux-gnueabi-gdb

Choose the Kits tab

  • Press Add
  • Fill in a name: Toradex
  • Device: IMX6
  • Sysroot:
/usr/local/oecore-x86_64/sysroots/armv7at2hf-vfp-neon-angstrom-linux-gnueabi
  • Compiler: GCC (Qt Embedded)
  • Debugger: GDB (Qt Embedded)
  • Qt mkspec: leave empty

Now you can create a new project using the new kit. You can copy your program to the target board via SSH and then connect to the target and run it.

$ scp my_program root@192.168.1.2:/home
$ ssh 192.168.1.2
$~ ./my_program

How to configure EGLFS

EGLFS is a platform plugin for running Qt5 applications on top of EGL and OpenGL ES 2.0, without an actual windowing system like X11 or Wayland[²].

It may be useful to enable debug logs from the KMS/DRM backend. To do this, enable logging rule in verbose mode. Note: You have to use the target terminal then type these commands.

# QT_LOGGING_RULES=qt.qpa.*=true

QT_QPA_EGLFS_INTEGRATION we should set this environment variable when there are more than one plugin present in the target system.

# export QT_QPA_EGLFS_INTEGRATION=eglfs_kms

QT_QPA_EGLFS_KMS_CONFIG The KMS/DRM backend also supports custom configurations via a JSON file. To enable this, set the QT_QPA_EGLFS_KMS_CONFIG environment variable to the name of the file. You can also embed this file into the application via the Qt resource system[²].

# export QT_QPA_EGLFS_KMS_CONFIG=example.json

I am going to use the following JSON file to hide the mouse cursor and set the screen size to 1280x720.

{
"device": "/dev/dri/card1",
"hwcursor": false,
"pbuffers": true,
"outputs": [{"name": "HDMI1","primary": true,"mode": "1280x720"}]
}

Finally, I run my program with the following command.

# ./my_program --platform eglfs

Reference

  1. Embedded Linux Projects Using Yocto Project Cookbook
  2. https://doc.qt.io/qt-5/embedded-linux.html
  3. https://developer.toradex.com/knowledge-base/how-to-set-up-qt-creator-to-cross-compile-for-embedded-linux