Qt5 on MarS Board - FrankBau/meta-marsboard-bsp GitHub Wiki

Prerequisites

Graphical Backend

For testing, we used a simple fb (framebuffer) graphical backend, i.e. no X11 and no Wayland. Please read Choosing a graphical backend and change your settings accordingly. This may require a completely clean build!

HDMI Monitor

A HDMI Monitor was used for testing with a resolution of 1920x1080. Other resolutions will probably work too. Note that the monitor should already be connected when the board boots because it might not be detected later on.

The Linux Command Line in U-Boot should, among others, contain settings

video=mxcfb0:dev=hdmi,1920x1080M@60,if=RGB24,bpp=32

See Boot Linux on how to change and save the Linux Command Line. Other video interfaces may work as well, but need a different Linux Command Line.

Framebuffer Console

In the kernel menuconfig (bitbake -c menuconfig virtual/kernel) disable (uncheck) the Framebuffer Console which otherwise a console prompt will overlay you Qt5 App:

-> Device Drivers                    
  -> Graphics support                
    -> Console display driver support
       < > Framebuffer Console support

Add more layers to the bitbake environment

Add Qt5 Layer

In the sources folder of your BSPDIR enter:

git clone -b jethro https://github.com/meta-qt5/meta-qt5.git

This new layer should be in parallel to the existing meta-* layers.

Edit bblayers.conf

The new layer an the meta-ruby layer (within meta-openembedded) must be added to the conf/bblayers.conf file which should look like:

LCONF_VERSION = "6" 
BBPATH = "${TOPDIR}" 
BSPDIR := "${@os.path.abspath(os.path.dirname(d.getVar('FILE', True)) + '/../..')}" 
BBFILES ?= "" 
BBLAYERS = " \
  ${BSPDIR}/sources/poky/meta \
  ${BSPDIR}/sources/poky/meta-yocto \
  \
  ${BSPDIR}/sources/meta-openembedded/meta-oe \
  ${BSPDIR}/sources/meta-openembedded/meta-multimedia \
  ${BSPDIR}/sources/meta-openembedded/meta-ruby \
  \
  ${BSPDIR}/sources/meta-fsl-arm \
  ${BSPDIR}/sources/meta-fsl-arm-extra \
  ${BSPDIR}/sources/meta-fsl-demos \
  ${BSPDIR}/sources/meta-marsboard-bsp \
  ${BSPDIR}/sources/meta-qt5 \
" 

Build an Image with Qt

In a bitbake shell on the Linux Build Host, enter the command

bitbake image-multimedia-full-with-qt

This includes Qt5 in the image together with some examples like cinemeticexperience, see recipe. after installing the image on the MarS Board, you may enter

root@marsboard:~# Qt5_CinematicExperience -platform eglfs

and watch the demo.

Cross Compilation of Qt5 Apps

It is possible to cross-compile Qt5 Apps on the Linux Build Host from the QtCreator, a comfortable IDE:

Build the SDK

The Software Development Kit (SDK) is targeted to users which simply want to develop apps without using yocto. In a bitbake shell, enter the command

bitbake meta-toolchain-qt5

The result is an about 800 MB large .sh file in build-open/tmp-glibc/deploy/sdk. This file can be shipped to interested 3rd parties or used on the build host itself.

Install the SDK

sudo sh tmp-glibc/deploy/sdk/angstrom-glibc-x86_64-cortexa9hf-vfp-neon-v2014.12-toolchain.sh
You are about to install the SDK to "/usr/local/oecore-x86_64". Proceed[Y/n]?Y
Extracting SDK...done
Setting it up...done
SDK has been successfully set up and is ready to be used.

Install and Setup QtCreator

For testing, we installed Qt Creator 3.0.1 Based on Qt 5.2.1 (GCC 4.8.2, 64 bit) Built on Apr 9 2014 at 09:12:59 which is available on the download page https://www.qt.io/download/.

A Ubuntu 14.4.10 64-bit host was used for installation. It needed two fixes (may be slightly different on your system). Open a shell and enter:

Python Path

export PYTHONPATH='/usr/lib/python3.4/:/usr/lib/python3.4/plat-x86_64-linux-gnu/'

gdb-multiarch Debugger

had to be installed because the host is 64-bit but the target 32-bit:

sudo apt-get install gdb-multiarch

In the same shell, set the SDK environment and start qtcreaor in the background job:

source '/usr/local/oecore-x86_64/environment-setup-cortexa9hf-vfp-neon-angstrom-linux-gnueabi'
qtcreator &

Now you can setup the SDK in the QtCreator GUI:

  • in Tools > Options > Build& Run ** in Compilers add: /usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/bin/arm-angstrom-linux-gnueabi/arm-angstrom-linux-gnueabi-cpp ** in Debuggers add: /usr/bin/gdb-multiarch ** in Qt Versions add: /usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/bin/qt5/qmake ** in Kits add sysroot: /usr/local/oecore-x86_64/sysroots/cortexa9hf-vfp-neon-angstrom-linux-gnueabi
  • in Tools > Options > Devices add MarsBoard as default for Generic Linux

Build a Hello World Project

In QtCreator: File > New File or Project > Choose a Template: Embedded Linux Choose Applications, Qt Quick Application and continue with the default settings. Now, build the Hello World Project

Remote Debugging

The Hello World Project can be automatically deployed to and executed or debugged on the target. A network connection is needed for this.

In QtCreator Deployment settings you should add some environment variables which ensure that the Hello World Project runs smoothly (agian: your settings, e.g. screen resolution) may vary:

export QT_QPA_PLATFORM=eglfs::fb=/dev/fb2
export QT_QPA_EGLFS_FB=/dev/fb2
export QT_QPA_EGLFS_WIDTH=1920 
export QT_QPA_EGLFS_HEIGHT=1080

Now, you can deploy and debug Hello World simply by pressing F5 in QtCreator.

Further Reading