0% found this document useful (0 votes)
111 views22 pages

Buildroot Image With Qt5 OPEGN GLS 2.0 Mesa VC4 Driver in 32 Bit

The document provides steps to get Qt5 examples running on a Raspberry Pi 3 with a HDMI display. It details problems encountered with font display, mouse and keyboard input, and PNG decoding. Solutions involved adding environment variables, kernel overlays, and Mesa drivers. With these configurations, Qt5 demos and examples could be compiled and run successfully on the Raspberry Pi 3.

Uploaded by

ap8389546
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
111 views22 pages

Buildroot Image With Qt5 OPEGN GLS 2.0 Mesa VC4 Driver in 32 Bit

The document provides steps to get Qt5 examples running on a Raspberry Pi 3 with a HDMI display. It details problems encountered with font display, mouse and keyboard input, and PNG decoding. Solutions involved adding environment variables, kernel overlays, and Mesa drivers. With these configurations, Qt5 demos and examples could be compiled and run successfully on the Raspberry Pi 3.

Uploaded by

ap8389546
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

Raspberry pi 3

Buildroot image with Qt5 . OPEGN GLS 2.0 ,


mesa VC4 driver in 32 bit
It took me sometime to figure everything but eventually I got all QT5 demos running my raspberry
pi with HDMI display.

The problem I faced with:


1. DRM Device not found ( added kms overlay)
2. Mouse and keyboard did not worked ( remove all mouse drivers from mesa )
3. Fonts was not showing ( Add QPA font dir)
4. PNG was not decoded properly ( Added QT5 PNG and other format – clean and rebuilt)

In this document I an documenting what the steps I did in order to get:


1. All Qt base examples to work on raspberry pi 3
2. compile and run my own examples
( I did a youtube tutorial and document how I compiled QT5 program)

Starting from the raspberry pi configuration for 32 bit:

make raspberrypi3_defconfig

nothing to be change in Target architecture


Change as usual the savedefconfig and download
location

to the same place where all the builds you do. It could save time if downloaded package already
there.

Before I will go over the QT5 VC4 settings, I will start with the compiler.
While adding QT5 in 32 bit I am getting compiler error when using external download compiler and
external pre built

I tried to compile several times with external toolchain


But I got the following error when compiling with QT5 in the 32bit.
This is a problem of the compiler.

D_FILE_OFFSET_BITS=64 -Os --sysroot=/home/first/buildroot/blrpi3_32/buildroot-


2017.05/output/host/usr/arm-buildroot-linux-gnueabihf/sysroot -O3 -O3 -std=c++1z -
fvisibility=hidden -fvisibility-inlines-hidden -Wall -W -Wvla -Wdate-time -Wshift-overflow=2 -
Wduplicated-cond -D_REENTRANT -fPIC -DQT_NO_USING_NAMESPACE -
DQT_NO_FOREACH -DQT_USE_ICU -DQT_HAVE_POLL -DQT_HAVE_PPOLL -
DQT_BUILD_CORE_LIB -DQT_BUILDING_QT -DQT_NO_CAST_TO_ASCII -
DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -
DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x050000 -
D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG -I. -Iglobal -
I../3rdparty/harfbuzz/src -I../3rdparty/md5 -I../3rdparty/md4 -I../3rdparty/sha3 -I../3rdparty/double-
conversion/include -I../3rdparty/double-conversion/include/double-conversion -I../3rdparty/forkfd -
I../../include -I../../include/QtCore -I../../include/QtCore/5.8.0 -I../../include/QtCore/5.8.0/QtCore -
I.moc -I../../mkspecs/devices/linux-buildroot-g++ -o .obj/qhash.o tools/qhash.cpp
tools/qhash.cpp:148:54: error: attribute(target("+crc")) is unknown
static uint crc32(const Char *ptr, size_t len, uint h)

to solve this I edit the qhash.cpp and add at the top


#undef __ARM_FEATURE_CRC32
This solve the compilation problem

The internal build root compiler , complains about other error that I don't konw why.
Never mind , I don't want the internal toolchain any case.
Better place is to edit file:
put the define in comment
//#define __ARM_FEATURE_CRC32 0
output/build/qt5base-5.8.0/src/corelib/.moc/moc_predefs.h

Qt5 settings
VC4 is a DRM driver.

https://en.wikipedia.org/wiki/Direct_Rendering_Manager
From wikipedia

Enable mesa 3d in graphics libraries and applications


* from this list

Gallium Etnaviv driver:

Enable the masa drivers


and the VC4 open gl driver by Broadcom.

We can see from the make linux-menuconfig that the kernel Is configured as module = m

means , if the vc4 will find the Broadcom GPU it will be loaded.

Once we enable vc4 driver in mesa we have the open gl option in Qt enabled
QT5 configurations.
Enable qt quick, jpeg, png and gif
The png and all others are for game like maroon that require png support
Loading overlays

If we don't load the vc4 overlay , the VC4 DRM driver will not be loaded.
And we will get from the raspberry pi 3 an error that DRM device was not loaded

we can load several overlays in one config as state above

In output/images/rpi-firmware/overlays

The VC4 driver needs is device tree blob


to load the device tree, open config.txt in output/images/rpi-firmware/config.txt

So in config.txt:

I will load two overlays


dtoverlay=pi3-miniuart-bt
dtoverlay=vc4-kms-v3d

There is a note:
# You should override this file using a post-build script.
I will deal with it later

output/images/rpi-firmware/cmdline.txt

I will add:
cma=128M
at the end

change:
gpu_mem_1024=256
When we use an overlay the VC4 DRI driver will load:

in buildroot mesa we need libinput

At the beginning , I added the above drivers: evdev, libinput , mouse


But when the mouse and keyboard did not worked in my small test program.

See mouse problem


So I removed all mouse related driver,
removed evded, input-libinput and input-mouse
and now it is working.

QT uses probably libinput directly and does not need the mesa drivers.
It also use xkbcommon for key mapping
The option to solve the font problem to create a link between /usr/share/fonts and /usr/lib/fonts
does not work
ln -s /usr/share/fonts /usr/lib/fonts
source link

The solution is to add QT_QPA_FONTDIR environment variable to tell QT where it can find fonts
See font problem

Maroon complains on png


so I added now all qt libraries for JPEG PNG AND GIF support

But remove qtengine because it did not compiled when I did make.
Could be that I can do make clean and make it will compile.
But seems that this library is not important.
http://doc.qt.io/archives/qt-5.5/enginio-index.html

qtwebkit also removed ( no support in the ARM)

Qt complains that it does not found libxbccommon


So I have added it now

Qt is complain that it cannot find the Physical with and height of the screen
After reading I found that the QT uses /dev/fb0 to determine the screen dimensions

So I have added:
This solved the problem with the cannot detect the screen dimension

Debugging
Note:When in doubt, enable logging from both the graphics and input subsystems by
setting the environment variable QT_LOGGING_RULES=qt.qpa.*=true before
launching the application. This will help identifying the correct input device nodes
and may uncover output configuration issues that can be difficult to debug otherwise.

Adding CTRL + C support


QT_QPA_EGLFS_INTEGRATION=eglfs_brcm

QT_QPA_ENABLE_TERMINAL_KEYBOARD to 1
enable the control C

Adding WIDTH AND HIEGHT in case not detected


QT_QPA_EGLFS_PHYSICAL_WIDTH and
QT_QPA_EGLFS_PHYSICAL_HEIGHT- Physical screen width and height in
millimeters. On platforms where the value cannot be queried from the framebuffer
device /dev/fb0 or via other means, a default DPI of 100 is used. This variable can be
used to override any such defaults. Setting this is important because QWidget or Qt
Quick Controls based applications rely on these values. Running with the hard-coded
settings may result in user interface element sizes unsuitable for the display in use.

https://stackoverflow.com/questions/40490113/eglfs-on-raspberry2-failed-to-add-service-already-
in-use

What is the use of various Qt platform plugins?


https://stackoverflow.com/questions/21488072/what-is-the-use-of-various-qt-platform-plugins

More debugging
export QML_IMPORT_TRACE=1

Font problem
I tried run marron example.
The maroon example have almost everything in QT5

at start it complains about font format.


So I added font and all fonts support in QT5.

In this time when adding I needed to rebuild.


When I did not clean and rebuilt I did not saw the changes and it still did not worked.

First we need fonts:

When using buildroot , all fonts are installed in /usr/share/fonts

And QT is looking for them in /usr/lib/fonts

I tried to do a link from share/fonts to lib/fonts but it did not helped.

Only setting QT_QPA_FONTDIR to /usr/share/fonts/dejavu

https://forum.qt.io/topic/75145/cross-compile-qt-5-7-for-raspberry-pi-3-problem-font-text-words-
in-application-not-showing-up-during-running/13

works!
Mouse and keyboard problem
Mouse problem solved by removing all mesa drivers mouse related

Don t check for evdec, libinput , mouse or tslib.


Qt will use libinput directly.

Summery of all environment variables:


Summery of QT environment variables:
#!/bin/sh
export QT_QPA_FONTDIR=/usr/share/fonts/dejavu
export QT_QPA_ENABLE_TERMINAL_KEYBOARD=1
export QT_QPA_EGLFS_INTEGRATION=eglfs_kms
export QT_LOGGING_RULES=qt.qpa.*=true
export QT_QPA_PLATFORM=eglfs
export QT_QPA_EGLFS_PHYSICAL_WIDTH=100
export QT_QPA_EGLFS_PHYSICAL_HEIGHT=100
#export QT_IMPORT_TRACE=0

I have added those exports into a file call profile at


output/target/etc/profile
Saving this configuration

make savedefconfig

will save to:

This I will upload to my github


https://github.com/EliArad/buildroot
Running examples
here is how maroon example for qt quick look like in ubunto:

And here how it looks like in the raspberry pi 3 target on HDMI monitor
QT quick gallery
Some pazzel game

As we can see , all examples are working , with font, mouse, and keyboard.
Summery of compiling QT 5 in command line

After we created a buildroot image , with QT5


we have two thing we need:

1. Compiler
2. Sysroot

Create a project in Qt Creator.

Open command terminal


and create two scripts files

1. ACTIVATE.sh for adding the path of the buildroot compilers

export PATH=$PATH:/home/first/buildroot/blrpi3_32/buildroot-2017.05/output/host/usr/bin

2. compile script

/home/first/buildroot/blrpi3_32/buildroot-2017.05/output/host/usr/bin/qmake $1 -spec
/home/first/Qt/5.9/Src/qtbase/mkspecs/arm-linux-gnueabihf-g++ CONFIG+=debug
CONFIG+=qml_debug

The compile script run buildroot qmake

we need to specify:
1. full path of the qmake in buildroot

2. the full path of the mkspecs

If we are not working inside the QT SRC the qmake will not know where the mkspcs.

The mkspec need to be created, in most cases it is not exist.


So copy from one of the arm-linux-unkonwn... using cp-r

and change all the compiler name to the buildroot compiler name

arm-linux-gnueabihf

The result of the new mkspec qmake.conf files should be:

#
# qmake configuration for building with arm-linux-gnueabihf-g++
#

MAKEFILE_GENERATOR = UNIX
CONFIG += incremental
QMAKE_INCREMENTAL_STYLE = sublib

include(../common/linux.conf)
include(../common/gcc-base-unix.conf)
include(../common/g++-unix.conf)

# modifications to g++.conf
QMAKE_CC = arm-linux-gnueabihf-gcc
QMAKE_CXX = arm-linux-gnueabihf-g++
QMAKE_LINK = arm-linux-gnueabihf-g++
QMAKE_LINK_SHLIB = arm-linux-gnueabihf-g++

# modifications to linux.conf
QMAKE_AR = arm-linux-gnueabihf-ar cqs
QMAKE_OBJCOPY = arm-linux-gnueabihf-objcopy
QMAKE_NM = arm-linux-gnueabihf-nm -P
QMAKE_STRIP = arm-linux-gnueabihf-strip
load(qt_config)

running compile script (which rans qmake with the cross compiler)
will generate make files for us

run
make

And the HelloWorld will be ready to transfer to target using SCP

* Just replace the full path above to your full path.

You might also like