BespokeTech
Posts: 71
Joined: Thu Apr 04, 2019 8:14 pm

Anyone cross compiled QT for the Pi 4 yet.

Sun Jul 07, 2019 8:06 pm

Hi All,

Has anyone managed to cross compile QT for the Pi 4 yet? I am trying using my usual recipes but at the moment it is hanging the Pi whenever I launch things like qmlscene (I am using EGLFS).

I suspect it's to do with the VC drivers, I can never seem to get my head around the VC side of things.

User avatar
topguy
Posts: 5671
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Anyone cross compiled QT for the Pi 4 yet.

Mon Jul 08, 2019 12:08 am

Do you really need newer Qt5 thant 5.11 that is in Buster ? shouldnt QML run quite well with opengl as backend and not necessarily need eglfs ?

(I havent got a Pi4 yet so havent had time to experiment myself )

BespokeTech
Posts: 71
Joined: Thu Apr 04, 2019 8:14 pm

Re: Anyone cross compiled QT for the Pi 4 yet.

Mon Jul 08, 2019 3:26 pm

topguy wrote:
Mon Jul 08, 2019 12:08 am
Do you really need newer Qt5 thant 5.11 that is in Buster ? shouldnt QML run quite well with opengl as backend and not necessarily need eglfs ?

(I havent got a Pi4 yet so havent had time to experiment myself )
I haven’t actually tried that yet. Historically using the version that comes with the OS has been a bad idea but maybe things have changed.

BespokeTech
Posts: 71
Joined: Thu Apr 04, 2019 8:14 pm

Re: Anyone cross compiled QT for the Pi 4 yet.

Mon Jul 08, 2019 9:05 pm

This evening I have tried my newly built image (buster) on my trusty Pi 3b+ and it works just fine. So I think I can rule out the buster side of things.

In order to get it working on the Pi 3b+ I have always needed to preload the libraries which I do with....

LD_PRELOAD="/opt/vc/lib/libbrcmEGL.so /opt/vc/lib/libbrcmGLESv2.so"

Should I be pointing towards something else on the Pi 4? I don't want to use X11 and from what I am reading the new KMS driver requires it?? I may be wrong on that, I have read countless articles regarding the VideoCore on the Pi and I think I am now more confused then when I started!!

ali1234
Posts: 21
Joined: Tue Jan 05, 2016 1:31 am

Re: Anyone cross compiled QT for the Pi 4 yet.

Tue Jul 09, 2019 4:21 am

The Broadcom EGL implementation does not work on Pi 4 due to it being a different GPU. This is why Qt's brcm-eglfs platform integration does not work. Try using the mkspec for eglfs-bgm, it might work with fake KMS mode that Pi 4 uses. There is already a mkspec for it:

https://code.qt.io/cgit/qt/qtbase.git/t ... qmake.conf

This might not work without the real KMS driver which unfortunately also does not work yet on Pi 4, again due to it using a different GPU.

BespokeTech
Posts: 71
Joined: Thu Apr 04, 2019 8:14 pm

Re: Anyone cross compiled QT for the Pi 4 yet.

Tue Jul 09, 2019 7:20 am

ali1234 wrote:
Tue Jul 09, 2019 4:21 am
The Broadcom EGL implementation does not work on Pi 4 due to it being a different GPU. This is why Qt's brcm-eglfs platform integration does not work. Try using the mkspec for eglfs-bgm, it might work with fake KMS mode that Pi 4 uses. There is already a mkspec for it:

https://code.qt.io/cgit/qt/qtbase.git/t ... qmake.conf

This might not work without the real KMS driver which unfortunately also does not work yet on Pi 4, again due to it using a different GPU.
Thanks for the info, will give your idea a try this morning and will feedback on how I get on.

BespokeTech
Posts: 71
Joined: Thu Apr 04, 2019 8:14 pm

Re: Anyone cross compiled QT for the Pi 4 yet.

Tue Jul 09, 2019 7:51 am

Just attempting the build now EGLFS GBM passed the tests on the build config using the vc4 mkspec...


QPA backends:
DirectFB ............................... no
EGLFS .................................. yes
EGLFS details:
EGLFS OpenWFD ........................ no
EGLFS i.Mx6 .......................... no
EGLFS i.Mx6 Wayland .................. no
EGLFS RCAR ........................... no
EGLFS EGLDevice ...................... yes
EGLFS GBM ............................ yes
EGLFS VSP2 ........................... no
EGLFS Mali ........................... no
EGLFS Raspberry Pi ................... no
EGLFS X11 ............................ yes
LinuxFB ................................ yes
VNC .................................... yes
Mir client ............................. no
XCB:
Using system-provided XCB libraries .. no
XCB XKB .............................. no
XCB XInput ........................... yes
Native painting (experimental) ....... no
GL integrations:
GLX Plugin ......................... no
EGL-X11 Plugin ..................... yes

anszom
Posts: 3
Joined: Wed Jun 26, 2019 3:50 pm

Re: Anyone cross compiled QT for the Pi 4 yet.

Tue Jul 09, 2019 8:56 am

I've managed to get it to work yesterday. I've used qt 5.9 for various historical reasons, but this should apply to later versions as well.

Building:

1. Install these dependencies into your raspberry pi sysroot: libegl1-mesa-dev libgbm-dev libgles2-mesa-dev mesa-common-dev. Not all of these may be strictly required, but this is what worked for me. The simplest way is to do it on a Raspberry Pi and then download the card image back to your PC. I use a qemu-chroot to run the apt command directly on the sysroot image on my PC (like described here: https://wiki.debian.org/RaspberryPi/qemu-user-static).

2. Configure qt with -device linux-rasp-pi3-vc4-g++. Ensure that you have a clean qt build tree, leftovers from previous attempts may mess things up.
My command line was: ./configure -opengl es2 -device linux-rasp-pi3-vc4-g++ -device-option CROSS_COMPILE=arm-linux-gnueabihf- -sysroot `pwd`/../image -opensource -confirm-license -optimized-qmake -reduce-exports -release -make libs -prefix /usr/local/qt5pi -hostprefix `pwd`/../qt5_pi

Running:
1. Add the 'pi' user to the 'render' group
2. Create a file "eglfs.json" with the following content:

Code: Select all

{ "device": "/dev/dri/card1" }
3. export QT_QPA_EGLFS_KMS_CONFIG=/wherever/is/the/file/eglfs.json
4. run your qt app :)

BespokeTech
Posts: 71
Joined: Thu Apr 04, 2019 8:14 pm

Re: Anyone cross compiled QT for the Pi 4 yet.

Tue Jul 09, 2019 11:38 am

anszom wrote:
Tue Jul 09, 2019 8:56 am
I've managed to get it to work yesterday. I've used qt 5.9 for various historical reasons, but this should apply to later versions as well.

Building:

1. Install these dependencies into your raspberry pi sysroot: libegl1-mesa-dev libgbm-dev libgles2-mesa-dev mesa-common-dev. Not all of these may be strictly required, but this is what worked for me. The simplest way is to do it on a Raspberry Pi and then download the card image back to your PC. I use a qemu-chroot to run the apt command directly on the sysroot image on my PC (like described here: https://wiki.debian.org/RaspberryPi/qemu-user-static).

2. Configure qt with -device linux-rasp-pi3-vc4-g++. Ensure that you have a clean qt build tree, leftovers from previous attempts may mess things up.
My command line was: ./configure -opengl es2 -device linux-rasp-pi3-vc4-g++ -device-option CROSS_COMPILE=arm-linux-gnueabihf- -sysroot `pwd`/../image -opensource -confirm-license -optimized-qmake -reduce-exports -release -make libs -prefix /usr/local/qt5pi -hostprefix `pwd`/../qt5_pi

Running:
1. Add the 'pi' user to the 'render' group
2. Create a file "eglfs.json" with the following content:

Code: Select all

{ "device": "/dev/dri/card1" }
3. export QT_QPA_EGLFS_KMS_CONFIG=/wherever/is/the/file/eglfs.json
4. run your qt app :)
Most interesting, many thanks for your input. Steps 1 and 2 I am already doing but the bit about the eglfs.json is new info for me.

BespokeTech
Posts: 71
Joined: Thu Apr 04, 2019 8:14 pm

Re: Anyone cross compiled QT for the Pi 4 yet.

Tue Jul 09, 2019 11:47 am

1. Install these dependencies into your raspberry pi sysroot: libegl1-mesa-dev libgbm-dev libgles2-mesa-dev mesa-common-dev. Not all of these may be strictly required, but this is what worked for me. The simplest way is to do it on a Raspberry Pi and then download the card image back to your PC. I use a qemu-chroot to run the apt command directly on the sysroot image on my PC (like described here: https://wiki.debian.org/RaspberryPi/qemu-user-static).
I actually build my entire sysroot and resulting image using debootstrap and chroot. No Pi is involved in any of the build process other than to actually run what I am producing as the end product. The resulting image works really well on my Pi 3b+ and also the Pi 4 with the exception of the QT element, which hopefully with your guidance will soon be resolved.

BespokeTech
Posts: 71
Joined: Thu Apr 04, 2019 8:14 pm

Re: Anyone cross compiled QT for the Pi 4 yet.

Tue Jul 09, 2019 8:52 pm

I have now done some testing as per anszom's guidance and can report as follows....

1. With fake KMS enabled, launching qmlscene comes up with the following error...

* failed to add service - already in use?

2. Disabling vc4-fkms-v3d results in

Could not open DRM device /dev/dri/card1 (No such file or directory)

ali1234
Posts: 21
Joined: Tue Jan 05, 2016 1:31 am

Re: Anyone cross compiled QT for the Pi 4 yet.

Wed Jul 10, 2019 7:00 am

BespokeTech wrote:
Tue Jul 09, 2019 11:47 am
I actually build my entire sysroot and resulting image using debootstrap and chroot. No Pi is involved in any of the build process other than to actually run what I am producing as the end product. The resulting image works really well on my Pi 3b+ and also the Pi 4 with the exception of the QT element, which hopefully with your guidance will soon be resolved.
You might find this interesting, if only for the collection of workarounds: https://github.com/ali1234/rpi-ramdisk

anszom
Posts: 3
Joined: Wed Jun 26, 2019 3:50 pm

Re: Anyone cross compiled QT for the Pi 4 yet.

Wed Jul 10, 2019 9:41 am

BespokeTech wrote:
Tue Jul 09, 2019 8:52 pm
I have now done some testing as per anszom's guidance and can report as follows....

1. With fake KMS enabled, launching qmlscene comes up with the following error...

* failed to add service - already in use?
This message comes out from broadcom OpenGL libraries. For some reason you seem to still be using these instead of mesa.
BespokeTech wrote:
Tue Jul 09, 2019 8:52 pm
2. Disabling vc4-fkms-v3d results in
... not having any 3D driver.

User avatar
topguy
Posts: 5671
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Anyone cross compiled QT for the Pi 4 yet.

Wed Jul 10, 2019 10:22 am

Just a quick reminder of the "ldd" command which will list the libraries (and their path) that will be loaded when running the executable file you use as parameter for "ldd".

BespokeTech
Posts: 71
Joined: Thu Apr 04, 2019 8:14 pm

Re: Anyone cross compiled QT for the Pi 4 yet.

Wed Jul 10, 2019 1:16 pm

anszom wrote:
Wed Jul 10, 2019 9:41 am
BespokeTech wrote:
Tue Jul 09, 2019 8:52 pm
I have now done some testing as per anszom's guidance and can report as follows....

1. With fake KMS enabled, launching qmlscene comes up with the following error...

* failed to add service - already in use?
This message comes out from broadcom OpenGL libraries. For some reason you seem to still be using these instead of mesa.
BespokeTech wrote:
Tue Jul 09, 2019 8:52 pm
2. Disabling vc4-fkms-v3d results in
... not having any 3D driver.
Doh... yep it was me being stupid I still had the previous LD_PRELOAD being set on boot up. Removed that and it is now working!! Well it launches qmlscene I havent gone beyond that yet.

Many thanks for your help.

Markus1981
Posts: 9
Joined: Tue Nov 26, 2013 8:14 am

Re: Anyone cross compiled QT for the Pi 4 yet.

Thu Jul 11, 2019 7:01 pm

So i got QT compiled and i managed to launch my programm with EGLFS from the command line with a sh script
called start.sh

Code: Select all

#!/bin/sh
export QT_QPA_EGLFS_KMS_CONFIG=/home/pi/eglfs.json
cd /opt/MyProgram
./MyProgram
I am trying to launch the script at startup via systemd like i used to on my Pi3 (which worked )

Code: Select all

sudo nano /etc/systemd/system/startmyprogram.service

Code: Select all


[Unit]

Description=QTTest

[Service]

Type=simple

ExecStart=/home/pi/start.sh

[Install]

WantedBy=multi-user.target

Code: Select all

sudo systemctl enable /etc/systemd/system/startmyprogram.service
Can someone help me why my application is not visible after boot ?

kilograham
Posts: 76
Joined: Fri Apr 12, 2019 11:00 am
Location: austin tx

Re: Anyone cross compiled QT for the Pi 4 yet.

Fri Jul 12, 2019 3:18 am

BespokeTech wrote:
Tue Jul 09, 2019 11:47 am

I actually build my entire sysroot and resulting image using debootstrap and chroot (under x86_64 ubuntu with qemu-static userland). No Pi is involved in any of the build process other than to actually run what I am producing as the end product. The resulting image works really well on my Pi 3b+ and also the Pi 4 with the exception of the QT element, which hopefully with your guidance will soon be resolved.
Note strictly on topic, but I am trying to build some stuff for pi 4 for the first time using deboostrap and chroot, so figured i'd ask in response to above comment..

Does anyone have recent instructions for setting up the chroot environment? I have followed a mixture of plausible looking online instructions, and have a reasonable build environment set up, however I have openssl problems which break a lot of builds relying on curl or github

Code: Select all

curl https://sh.rustup.rs
curl: (60) SSL certificate problem: unable to get local issuer certificate
More details here: https://curl.haxx.se/docs/sslcerts.html

curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.
Anyone seen this before an know how to fix... i'm sure if I copied some of the ssl config from my pi4 I'd be fine, but googling seems to be inconclusive

BespokeTech
Posts: 71
Joined: Thu Apr 04, 2019 8:14 pm

Re: Anyone cross compiled QT for the Pi 4 yet.

Fri Jul 12, 2019 7:37 am

Kilograham,

Due to a bug, debootstrap doesn’t build a buster sysroot without using a 32bit host. You will get strange issues such as SSL problems like you are having.

To fix the problem either use a 32bit host, or do what I do and that is to use docker in a 64bit environment but with an i386 image.

kilograham
Posts: 76
Joined: Fri Apr 12, 2019 11:00 am
Location: austin tx

Re: Anyone cross compiled QT for the Pi 4 yet.

Fri Jul 12, 2019 10:52 pm

BespokeTech wrote:
Fri Jul 12, 2019 7:37 am
Kilograham,

Due to a bug, debootstrap doesn’t build a buster sysroot without using a 32bit host. You will get strange issues such as SSL problems like you are having.

To fix the problem either use a 32bit host, or do what I do and that is to use docker in a 64bit environment but with an i386 image.
Thanks for that, saved me a HUGE amount of time! Do you have a link to an issue to track/understand?

I have set up Ubuntu x86_64-> buster i686 -> buster armhf and things seem to be working remarkably well thus far considering I've managed to avoid using either chroot or docker before (though of course I lost my changes once, by exiting a docker run-ed bash shell; growing pains!)

BespokeTech
Posts: 71
Joined: Thu Apr 04, 2019 8:14 pm

Re: Anyone cross compiled QT for the Pi 4 yet.

Sat Jul 13, 2019 8:45 am

kilograham wrote:
Fri Jul 12, 2019 10:52 pm
BespokeTech wrote:
Fri Jul 12, 2019 7:37 am
Kilograham,

Due to a bug, debootstrap doesn’t build a buster sysroot without using a 32bit host. You will get strange issues such as SSL problems like you are having.

To fix the problem either use a 32bit host, or do what I do and that is to use docker in a 64bit environment but with an i386 image.
Thanks for that, saved me a HUGE amount of time! Do you have a link to an issue to track/understand?

I have set up Ubuntu x86_64-> buster i686 -> buster armhf and things seem to be working remarkably well thus far considering I've managed to avoid using either chroot or docker before (though of course I lost my changes once, by exiting a docker run-ed bash shell; growing pains!)
Hi,

I believe the bug causing the issue is this one....

https://bugs.launchpad.net/qemu/+bug/1805913

With regards to getting around losing data from the docker container.... You can stop that by binding directories on your host to the docker container using the -v flag. More info here... https://stackoverflow.com/questions/362 ... o-the-host

My script is a bit of a mess at the moment, but if I get chance today I will tidy it up and share a copy.

kilograham
Posts: 76
Joined: Fri Apr 12, 2019 11:00 am
Location: austin tx

Re: Anyone cross compiled QT for the Pi 4 yet.

Sat Jul 13, 2019 1:39 pm

I believe the bug causing the issue is this one....

https://bugs.launchpad.net/qemu/+bug/1805913
ooh; that sucks!
With regards to getting around losing data from the docker container.... You can stop that by binding directories on your host to the docker container using the -v flag. More info here... https://stackoverflow.com/questions/362 ... o-the-host
Ah ha... that'll be super useful, so I can use my host side IDE to work on the codebase also, and debug the same code easily on the host side.
My script is a bit of a mess at the moment, but if I get chance today I will tidy it up and share a copy.
That would be awesome messy or not (dependent on your personal dirty laundry tolerance); i've been using https://www.raspberrypi.org/forums/view ... hp?t=76178, but slowly adapting to fix things like proc, tmpfs mounting etc.

BespokeTech
Posts: 71
Joined: Thu Apr 04, 2019 8:14 pm

Re: Anyone cross compiled QT for the Pi 4 yet.

Sat Jul 13, 2019 2:36 pm

I have tidied it up, just running it to make sure I haven't knackered it then I will post a link.


kilograham
Posts: 76
Joined: Fri Apr 12, 2019 11:00 am
Location: austin tx

Re: Anyone cross compiled QT for the Pi 4 yet.

Sat Jul 13, 2019 6:24 pm

awesome; thank you

Return to “Advanced users”