Running Raspbian Buster on Raspberry Pi 4:
[on RPi] Install a bunch of development files (for simplicity we use build-dep, not everything is really needed, but it is easier this way).
Edit sources list in /etc/apt/sources.list and uncomment the deb-src line:
sudo nano /etc/apt/sources.list
Update your system and install required libraries:
sudo apt-get update sudo apt-get build-dep qt5-default sudo apt-get install libegl1-mesa libegl1-mesa-dev libgles2-mesa libgles2-mesa-dev libgbm-dev mesa-common-dev
Optional depending on your project:
sudo apt-get install wiringpi libnfc-bin libnfc-dev fonts-texgyre libts-dev
Optional depending if you want to use QtMultimedia:
sudo apt-get install libbluetooth-dev bluez-tools gstreamer1.0-plugins* libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libopenal-data libsndio7.0 libopenal1 libopenal-dev pulseaudio
[on RPi] Add pi user to render group
sudo gpasswd -a pi render
[on RPi] Prepare our target directory
sudo mkdir /usr/local/qt5pi
sudo chown pi:pi /usr/local/qt5pi
[on host] Create our working directory and get a toolchain:
mkdir ~/raspi
cd ~/raspi
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 -xvf gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf.tar.xz
[on host] Create a sysroot. Using rsync we can properly keep things synchronized in the future as well.
mkdir sysroot sysroot/usr sysroot/opt
rsync -avz pi@yourpi:/lib sysroot
rsync -avz pi@yourpi:/usr/include sysroot/usr
rsync -avz pi@yourpi:/usr/lib sysroot/usr
rsync -avz pi@$yourpi:/opt/vc sysroot/opt
[on host] Adjust symlinks to be relative. Use provided script, because the old fixQualifiedLibraryPaths is not working properly:
wget https://raw.githubusercontent.com/riscv/riscv-poky/master/scripts/sysroot-relativelinks.py
chmod +x sysroot-relativelinks.py
./sysroot-relativelinks.py sysroot
[on host] Get QT (start with qtbase first)
git clone git://code.qt.io/qt/qtbase.git -b 5.15.2
cd qtbase
[on host] Compile, make, make install
./configure -release -opengl es2 -device linux-rasp-pi4-v3d-g++ -device-option CROSS_COMPILE=~/$build_dir/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf- -sysroot ~/$build_dir/sysroot -opensource -confirm-license -make libs -prefix /usr/local/qt5pi -extprefix ~/$build_dir/qt5pi -hostprefix ~/$build_dir/qt5 -v make -j4 make install
If you failed build –>
git clean -dfx
[on host] Deploy Qt to the device. We simply sync everything from ~/raspi/qt5pi to the prefix we configured above.
rsync -avz qt5pi pi@yourpi:/usr/local
[on RPi] Update the device to let the linker find the Qt libs:
echo /usr/local/qt5pi/lib | sudo tee /etc/ld.so.conf.d/qt5pi.conf
sudo ldconfig
[on host] Build other Qt modules as desired, the steps are always the same:
git clone git://code.qt.io/qt/<qt-module>.git -b <qt-version>
cd <qt-module>
~/raspi/qt5/bin/qmake
make
make install
My Modules:
- qtbase
- qtxmlpatterns
- qtsvg
- qtdeclarative
- qtimageformats
- qtgraphicaleffects
- qtquickcontrols
- qtquickcontrols2
- qtvirtualkeyboard
- qtwebsockets
- qtwebglplugin
- qtcharts
- qtconnectivity
- qtmultimedia
- qtlocation
- qtmqtt
- qtserialport
Then deploy new files by running:
rsync -avz qt5pi pi@yourpi:/usr/local
Set physical Display size in mm:
sudo nano ~/.profile # physical display properties export QT_QPA_EGLFS_PHYSICAL_WIDTH=211 export QT_QPA_EGLFS_PHYSICAL_HEIGHT=127 source .profile
Workarounds:
Fehlermeldung:
Could not queue DRM page flip on screen DSI1
export QT_QPA_EGLFS_ALWAYS_SET_MODE="1"
Bluetooth Service startet nicht:
sudo nano /etc/systemd/system/bluetooth.target.wants/bluetooth.service
Change:
ExecStart=/usr/lib/bluetooth/bluetoothd --noplugin=sap
Berechtigungen setzen für Bluetooth:
sudo setcap 'cap_net_raw,cap_net_admin+eip' /path/to/your/application