Raspberry Pi Qt cross-compile: Unterschied zwischen den Versionen
Nick (Diskussion | Beiträge) Markierung: Manuelle Zurücksetzung |
Nick (Diskussion | Beiträge) |
||
| (13 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
| Zeile 132: | Zeile 132: | ||
|- | |- | ||
|<code>-release</code> | |<code>-release</code> | ||
|Debugging | |Debugging aus schalten | ||
|- | |- | ||
|<code>-opengl es2</code> | |<code>-opengl es2</code> | ||
| Zeile 173: | Zeile 173: | ||
|- | |- | ||
|<code>-no-use-gold-linker</code> | |<code>-no-use-gold-linker</code> | ||
| | |GNU Gold Linker wird nicht verwendet | ||
|- | |- | ||
|<code>-v</code> | |<code>-v</code> | ||
| Zeile 241: | Zeile 241: | ||
Qt version: Welches zuvor erstellt wurde | Qt version: Welches zuvor erstellt wurde | ||
Qt mkspec: bleibt leer | Qt mkspec: bleibt leer | ||
==GammaRay== | |||
sudo apt install gammaray | |||
==bcm2835== | ==bcm2835== | ||
| Zeile 247: | Zeile 250: | ||
Auf RPI herunterladen [https://www.airspayce.com/mikem/bcm2835/ bcm2835] | Auf RPI herunterladen [https://www.airspayce.com/mikem/bcm2835/ bcm2835] | ||
wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.69.tar.gz | wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.69.tar.gz | ||
tar zxvf bcm2835-1.69.tar.gz | |||
cd bcm2835-1.69 | |||
oder die angepasste Version vom Gitlab-Server [https://gitlab.hzdr.de/FWF/Libraries/rpi/bcm2835-custom bcm2835-custom] | |||
git clone https://gitlab.hzdr.de/FWF/Libraries/rpi/bcm2835-custom.git | |||
cd bcm2835-custom | |||
===Installation=== | ===Installation=== | ||
./configure | ./configure | ||
make | make | ||
| Zeile 257: | Zeile 263: | ||
Veränderung der <code>.h</code> und <code>.c</code> Datein: | Veränderung der <code>.h</code> und <code>.c</code> Datein: | ||
make clean | make clean | ||
./configure | ./configure | ||
| Zeile 266: | Zeile 271: | ||
===Einbinden in Qt Creator=== | ===Einbinden in Qt Creator=== | ||
Weiter auf dem RPI: | Weiter auf dem RPI: | ||
cp /usr/local/lib/libbcm2835.a /usr/lib/ | sudo cp /usr/local/lib/libbcm2835.a /usr/lib/ | ||
cp /usr/local/include/bcm2835.h /usr/include | sudo cp /usr/local/include/bcm2835.h /usr/include | ||
Danach das sysroot auf dem Host wieder syncronisieren: | Danach das sysroot auf dem Host wieder syncronisieren: | ||
rsync -avz pi@cm4:/lib sysroot | rsync -avz pi@cm4:/lib sysroot | ||
| Zeile 288: | Zeile 293: | ||
!Lösung | !Lösung | ||
|- | |- | ||
|Qt Creator bricht mit folgender Fehlermeldung ab: | |[HOST] Qt Creator bricht mit folgender Fehlermeldung ab: | ||
<code>qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.</code> | <code>qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.</code> | ||
|<code>export QT_DEBUG_PLUGINS=1</code> | |<code>export QT_DEBUG_PLUGINS=1</code> | ||
|- | |- | ||
|Qt Creator bricht mit folgender Fehlermeldung ab: | |[HOST] Qt Creator bricht mit folgender Fehlermeldung ab: | ||
<code>Cannot load library /home/user/Qt/Tools/QtCreator/lib/Qt/plugins/platforms/libqxcb.so</code> | <code>Cannot load library /home/user/Qt/Tools/QtCreator/lib/Qt/plugins/platforms/libqxcb.so</code> | ||
|<code>sudo apt install --reinstall libxcb-xinerama0</code> | |<code>sudo apt install --reinstall libxcb-xinerama0</code> | ||
|- | |- | ||
|Qt App bricht auf RPI mit folgender Fehlermeldung ab: | |[RPI] Qt App bricht auf RPI (DSI-Display) mit folgender Fehlermeldung ab: | ||
<code>drmModeGetResources failed (Operation not supported) | <code>drmModeGetResources failed (Operation not supported) | ||
no screens available, assuming 24-bit color</code> | no screens available, assuming 24-bit color</code> | ||
| | |<code>sudo vim /boot/config.txt | ||
dtoverlay=vc4-fkms-v3d</code> | |||
|} | |} | ||
Aktuelle Version vom 1. Juli 2021, 08:32 Uhr
Raspberry Pi Qt cross-compile
Anleitung Cross-Compiling von Qt auf dem Raspberry PI 4 (RPI4) und ComputeModul 4 (CM4).
Eigenheiten beim RPI4 oder CM4 sind gekennzeichnet mit [RPI4] oder [CM4].
Vorbereitung RPI
Download letztes raspian-lite:
wget https://downloads.raspberrypi.org/raspios_lite_armhf_latest wget https://downloads.raspberrypi.org/raspios_lite_armhf_latest -O "raspios.zip" unzip raspios.zip
[CM4] Um mit dem CM4 arbeiten zu können muss USB und/oder SSH aktiviert werden. Für das kopieren von raspbian.img auf den eMMC wird das Tool rpiboot benötigt.
- 1. Image mounten: Linux - ISO-Image bearbeiten
- 2. SSH und USB aktivieren: Raspberry Pi CM4
- 3. Image auf CM4 kopieren: Raspberry Pi CM4
Kopieren des Image auf einem RPI mit SD-Karte:
dd if=raspbian.img of=/dev/sdb bs=1M #raspbian.img ⇒ SD-Card dd if=/dev/sdb of=raspbian.img bs=1M #SD-Card ⇒ raspbian.img sync #leeren Zwischenspeicher BS
RPI starten, Dateisystem erweitern und Grafikspeicher erhöhen:
sudo raspi-config # 1 System Options ⇒ S4 Hostname ⇒ cm4
# 4 Performance Options ⇒ GPU Memory ⇒ 128
# 6 Advanced Options ⇒ A1 Expand Filesystem
sudo reboot
sudo apt update && sudo apt upgrade -y
sudo apt autoremove # Wenn nötig
Installation Bibliotheken:
sudo vim /etc/apt/sources.list #uncomment the deb-src line sudo apt update sudo apt build-dep qt5-qmake -y sudo apt build-dep libqt5gui5 -y sudo apt build-dep libqt5webengine-data -y sudo apt build-dep libqt5webkit5 -y sudo apt install libudev-dev libinput-dev libts-dev libxcb-xinerama0-dev libxcb-xinerama0 gdbserver -y
Zielverzeichnis anlegen:
sudo mkdir /usr/local/qt5.15 sudo chown pi:pi /usr/local/qt5.15
Zugriff RPI Datein
Variante 1: Netzwerk
Der RPI muss per ssh erreichbar sein.
Variante 2: mount image
Image von SD-Karte ziehen:
sudo mkdir /mnt/rasp-pi-rootfs dd if=/dev/sdb of=raspbian.img bs=1M fdisk -l raspian.img sudo mount -o loop,offset=62914560 raspian.img /mnt/rasp-pi-rootfs #Partition 2: 512 * 122880 = 62914560
Variante 3: mount SD-Card
Das mounten der SD-Karte erfolgt in den meisten Linux-Distributionen automatisch. Ansonsten:
sudo mount /dev/sdb2 /mnt/rasp-pi-rootfs
Vorbereitung HOST
Installation eines Ubuntu 20.04 (64Bit) (Minimal Installation) in einer VirtualBox.
Nach der BS installation Updates installiern:
sudo apt update && sudo apt upgrade -y sudo apt install build-essential -y
Cross-Compile Toolchain
Arbeitsverzeichnis und Tools
Arbeitsverzeichnis anlegen und nötige Tools installieren:
sudo mkdir /opt/qt5.15.2 /opt/qt5.15.2/build /opt/qt5.15.2/tools sudo chown -R user:user /opt cd /opt/qt5.15.2
sysroot
Erstellen des sysroot Verzeichniss-Struktur und synchronisation mit raspian-image sysroot verzeichniss.
mkdir sysroot sysroot/usr sysroot/opt
Mit gemounterter SD-Karte:
rsync -avz /mnt/rasp-pi-rootfs/lib sysroot rsync -avz /mnt/rasp-pi-rootfs/usr/include sysroot/usr rsync -avz /mnt/rasp-pi-rootfs/usr/lib sysroot/usr rsync -avz /mnt/rasp-pi-rootfs/opt/vc sysroot/opt
Oder übers Netzwerk:
rsync -avz pi@cm4:/lib sysroot rsync -avz pi@cm4:/usr/include sysroot/usr rsync -avz pi@cm4:/usr/lib sysroot/usr rsync -avz pi@cm4:/opt/vc sysroot/opt
Symlinks
Symlinks relativ anpassen:
wget https://raw.githubusercontent.com/Kukkimonsuta/rpi-buildqt/master/scripts/utils/sysroot-relativelinks.py chmod +x sysroot-relativelinks.py ./sysroot-relativelinks.py sysroot #Bei Problemen: sudo ln -s /usr/bin/python3 /usr/bin/python
Qt Resourcen
Download Qt Resourcen [Pfad: /opt/qt5.15.2]
sudo wget http://download.qt.io/archive/qt/5.15/5.15.2/single/qt-everywhere-src-5.15.2.tar.xz sudo tar -vxf qt-everywhere-src-5.15.2.tar.xz
mkspec Datei für den Compiler modifizieren
cp -R qt-everywhere-src-5.15.2/qtbase/mkspecs/linux-arm-gnueabi-g++ qt-everywhere-src-5.15.2/qtbase/mkspecs/linux-arm-gnueabihf-g++ sed -i -e 's/arm-linux-gnueabi-/arm-linux-gnueabihf-/g' qt-everywhere-src-5.15.2/qtbase/mkspecs/linux-arm-gnueabihf-g++/qmake.conf
Cross-Compiler
Download Linaro v7.4.1:
cd /opt/qt5.15.2/tools wget https://releases.linaro.org/components/toolchain/binaries/latest-7/arm-linux-gnueabihf/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf.tar.xz tar -vxf gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf.tar.xz
Qt für RPI kompilieren:
cd /opt/qt5.15.2/build ../qt-everywhere-src-5.15.2/configure -release -opengl es2 -device linux-rasp-pi4-v3d-g++ -device-option CROSS_COMPILE=/opt/qt5.15.2/tools/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf- -sysroot /opt/qt5.15.2/sysroot -prefix /usr/local/qt5.15 -extprefix /opt/qt5.15.2/qt5.15 -opensource -confirm-license -skip qtscript -skip qtwayland -skip qtwebengine -nomake tests -make libs -pkg-config -no-use-gold-linker -v -recheck
EGLFS-Bedingungen:
QPA backends:
DirectFB ............................... no
EGLFS .................................. yes [Sollte YES sein]
EGLFS details:
EGLFS OpenWFD ........................ no
EGLFS i.Mx6 .......................... no
EGLFS i.Mx6 Wayland .................. no
EGLFS RCAR ........................... no
EGLFS EGLDevice ...................... yes [Sollte YES sein]
EGLFS GBM ............................ yes
EGLFS VSP2 ........................... no
EGLFS Mali ........................... no
EGLFS Raspberry Pi ................... no [Sollte NO sein]
EGLFS X11 ............................ yes
LinuxFB ................................ yes
VNC .................................... yes
Wenn alles korrekt:
make -j2 #Anzahl verwendeter Kerne, hier 2 Kerne make install
| Option | Erklärung |
|---|---|
-release
|
Debugging aus schalten |
-opengl es2
|
OpenGL ES 2.0 - Offene Grafik Bibliothek für eingebettete Systeme |
-device linux-rasp-pi4-v3d-g++
|
RPI1: |
-device-option CROSS_COMPILE=/opt/qt5.15.2/tools/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-
|
Compiler |
-sysroot /opt/qt5.15.2/sysroot
|
sysroot Verzeichnis des Gerätes (RPI) |
-prefix /usr/local/qt5.15'
|
Qt Version für Qt-Creator |
-opensource
|
Die Lizenz wird auf GPL/LGPL gesetzt |
-confirm-license
|
Lizenzbedingungen zustimmen |
-skip qtscript -skip qtwayland -skip qtwebengine
|
Überspringen von Modulen (qtscript, qtwayland, qtwebengine) |
-nomake tests
|
Bauen von Tests aussschließen |
-make libs
|
Bauen von libs hinzufügen |
-pkg-config
|
Um Abhängigkeiten beim Cross-Compiling aufzulösen, erfordert PKG_CONFIG_PATH, PKG_CONFIG_PREFIX |
-no-use-gold-linker
|
GNU Gold Linker wird nicht verwendet |
-v
|
Ausführliche Informationen über jeden Schritt des configure-Prozesses ausgeben |
-recheck
|
Bei einer neuen configuration wird das Build-Verzeichnis aktualisiert |
Kompilierte Dateien auf RPI kopieren:
cd /opt/qt5.15.2
Mit gemounterter SD-Karte:
rsync -avz qt5.15 /mnt/rasp-pi-rootfs/usr/local
Oder übers Netzwerk:
rsync -avz --rsync-path="sudo rsync" qt5.15 pi@cm4:/usr/local/
Update RPI
RPI Bibliotheken updaten:
echo /usr/local/qt5.15/lib | sudo tee /etc/ld.so.conf.d/qt5.15.conf sudo ldconfig
QT Creator
QT 5.15.2 installieren. Sollte Qt Creator nicht starten:
/install_pfad/Qt/Tools/QtCreator/bin/qtcreator
| Fehler | Lösung |
|---|---|
| qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found. | export QT_DEBUG_PLUGINS=1
|
| Cannot load library /home/user/Qt/Tools/QtCreator/lib/Qt/plugins/platforms/libqxcb.so | sudo apt install --reinstall libxcb-xinerama0
|
Qt Creater starten und unter Werkzeuge ⇒ Einstellung... ⇒ Kits nachfolgende Parameter einstellen.
Qt Versionen
Einstellungen ⇒ Kits ⇒ Qt Versionen ⇒ Hinzufügen
qmake location: /opt/qt5.15.2/qt5.15/bin/qmake
Compiler
Einstellungen ⇒ Kits ⇒ Compilers ⇒ Hinzufügen ⇒ GCC ⇒ C und C++
Compiler path C: /opt/qt5.15.2/tools/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc Compiler path C++: /opt/qt5.15.2/tools/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++
Debugger
Einstellungen ⇒ Debuggers ⇒ Hinzufügen
/opt/qt5.15.2/tools/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gdb
Geräte
Einstellungen ⇒ Geräte ⇒ Hinzufügen ⇒ Geberic Linux Device ⇒ IP, user, pass ⇒ Finish
RPI root per SSH erlauben:
sudo vim /etc/ssh/sshd_config PermitRootLogin yes #Auskommentieren und auf yes ändern sudo reboot
Kits
Einstellungen ⇒ Build & Run ⇒ Kits ⇒ Hinzufügen
Device type: Generic Linux Device Device: Welches zuvor erstellt wurde Sysroot: /opt/qt5.15.2/sysroot Compiler: Welches zuvor erstellt wurde Debugger: Welches zuvor erstellt wurde Qt version: Welches zuvor erstellt wurde Qt mkspec: bleibt leer
GammaRay
sudo apt install gammaray
bcm2835
Sollten die bcm2835 Dateien angepasst werden sind die Schritte "Veränderung der .h und .c Datein:" und "Einbinden in Qt Creator" erneut durchzuführen.
Download
Auf RPI herunterladen bcm2835
wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.69.tar.gz tar zxvf bcm2835-1.69.tar.gz cd bcm2835-1.69
oder die angepasste Version vom Gitlab-Server bcm2835-custom
git clone https://gitlab.hzdr.de/FWF/Libraries/rpi/bcm2835-custom.git cd bcm2835-custom
Installation
./configure make sudo make check sudo make install
Veränderung der .h und .c Datein:
make clean ./configure make sudo make check sudo make install
Einbinden in Qt Creator
Weiter auf dem RPI:
sudo cp /usr/local/lib/libbcm2835.a /usr/lib/ sudo cp /usr/local/include/bcm2835.h /usr/include
Danach das sysroot auf dem Host wieder syncronisieren:
rsync -avz pi@cm4:/lib sysroot rsync -avz pi@cm4:/usr/include sysroot/usr rsync -avz pi@cm4:/usr/lib sysroot/usr rsync -avz pi@cm4:/opt/vc sysroot/opt
Nach einem rsync vom RPI zum Host ist ein erneutes anpassen der symlinks notwendig:
cd /opt/qt5.15.2 ./sysroot-relativelinks.py sysroot
Im Qt Creator die .pro anpassen
LIBS += -L"/usr/lib" -lbcm2835
Und dann die Header-Datei wie gewünscht einbinden:
#include <bcm2835.h>
Probleme
| Fehler | Lösung |
|---|---|
| [HOST] Qt Creator bricht mit folgender Fehlermeldung ab:
|
export QT_DEBUG_PLUGINS=1
|
| [HOST] Qt Creator bricht mit folgender Fehlermeldung ab:
|
sudo apt install --reinstall libxcb-xinerama0
|
| [RPI] Qt App bricht auf RPI (DSI-Display) mit folgender Fehlermeldung ab:
|
sudo vim /boot/config.txt
|
Quellen
Raspberry Pi Beginners Guide
RaspberryPi2EGLFS
Cross-Compile QT 5.15.2 / Raspberry Pi 4
Qt 5.15 cross compile RPI4 auf Ubuntu 20 LTS
qt cross-compile configure-options