This is causing me a lot of problems. This page will serve as a log where I will write down my tests and their outcome. Don’t trust things written here. Using a cheap SPI-driven display with a touch panel.
First I need to install the drivers for the screen. I got this link from the seller, so:
sudo rm -rf LCD-show git clone https://github.com/goodtft/LCD-show.git chmod -R 755 LCD-show cd LCD-show/ sudo ./LCD35-show
The first rm is only needed if it has already been installed, I guess. After that the Pi reboots and the screen springs to life.
An event shows up. Do a cat on /dev/input/event0 and press the display and you should see a lot of garbage. Unfortunately the event0 moves if you add a keyboard. This must be looked into later, but for now I make a symbolic link to /dev/input/event0 called /dev/input/ts.
Now TSLIB needs to be installed.
sudo apt-get install evtest libts-bin
This complains about stuff missing. Do as it says and it will install X, I think. Or at least part of it. Then try again and it succeeds. Need to look into this, I don’t need X… Maybe it is evtest causing it, and I don’t think it is needed.
Now, setup the environment variables needed for TSLIB. I found these:
export TSLIB_TSEVENTTYPE=H3600 export TSLIB_CONSOLEDEVICE=none export TSLIB_FBDEVICE=/dev/fb0 export TSLIB_TSDEVICE=/dev/input/event0 export TSLIB_CALIBFILE=/etc/pointercal export TSLIB_CONFFILE=/usr/local/linux-arm/etc/ts.conf export TSLIB_PLUGINDIR=/usr/local/linux-arm/lib/ts
I changed them to
export TSLIB_TSEVENTTYPE=INPUT (or was it input?) export TSLIB_CONSOLEDEVICE=none export TSLIB_FBDEVICE=/dev/fb1 export TSLIB_TSDEVICE=/dev/input/ts export TSLIB_CALIBFILE=/etc/pointercal export TSLIB_CONFFILE=/etc/ts.conf #export TSLIB_PLUGINDIR=/usr/local/linux-arm/lib/ts
I don’t know what the first one does. This was inserted in .bashrc in /home/pi and /root. I’m not sure the /root one is needed, but without it there will be no environment variables when doing sudo su. Which might never be needed.
When running a “normal” sudo you need to add -E to get the variables from the pi user! I don’t know how to set it for the sudo user. Something to look into.
After a reboot you can run
sudo -E ts_calibrate
…and you pointercal file should be written.
Now you can test with
…and it should work fine.
For Qt to be configured correctly we also need to
sudo apt-get install libts-dev
Some strange printouts there about locale but it seems to install.
Now, on to Qt…
I’m following this guy with some changes. Visit his page!
In the pi user home directory:
mkdir Qt cd Qt wget http://download.qt.io/official_releases/qt/5.12/5.12.7/single/qt-everywhere-src-5.12.7.tar.xz tar xf qt-everywhere-src-5.12.7.tar.xz git clone https://github.com/oniongarlic/qt-raspberrypi-configuration.git cd qt-raspberrypi-configuration && make install DESTDIR=../qt-everywhere-src-5.12.7 sudo apt-get install build-essential libfontconfig1-dev libdbus-1-dev libfreetype6-dev libicu-dev libinput-dev libxkbcommon-dev libsqlite3-dev libssl-dev libpng-dev libjpeg-dev libglib2.0-dev libraspberrypi-dev
Now we make a directory for our shadow build (in the /home/pi/Qt directory).
mkdir build cd build
..and NOW, it is time for the configure command. This set up the whole build environment for Qt.
For Pi3 I use (*shrug*):
PKG_CONFIG_LIBDIR=/usr/lib/arm-linux-gnueabihf/pkgconfig:/usr/share/pkgconfig ../qt-everywhere-src-5.12.7/configure -platform linux-rpi3-g++ -v -opengl es2 -eglfs -no-gtk -opensource -confirm-license -release -reduce-exports -force-pkg-config -nomake examples -no-compile-examples -skip qtwayland -skip qtwebengine -no-feature-geoservices_mapboxgl -qt-pcre -no-pch -ssl -evdev -system-freetype -fontconfig -glib -prefix /opt/Qt5.12 -qpa eglfs -tslib -skip qtscript
…and for Pi4:
QT_LOGGING_RULESenvironment variable to
qt.qpa.input=truesudo apt-get install libegl1-mesa-dev libgbm-dev libgles2-mesa-dev mesa-common-dev
PKG_CONFIG_LIBDIR=/usr/lib/arm-linux-gnueabihf/pkgconfig:/usr/share/pkgconfig ../qt-everywhere-src-5.12.7/configure -platform linux-rpi4-v3d-g++ -v -opengl es2 -eglfs -no-gtk -opensource -confirm-license -release -reduce-exports -force-pkg-config -nomake examples -no-compile-examples -skip qtwayland -skip qtwebengine -no-feature-geoservices_mapboxgl -qt-pcre -no-pch -ssl -evdev -system-freetype -fontconfig -glib -prefix /opt/Qt5.12 -qpa eglfs -tslib
(This does not bild for Pi4, I’ll get back about this)
This will take some time.
When it is done, check config.summary for EGLFS. Pi3 should have EGLFS Raspberry Pi and Pi4 should have EGLFS EGLDevice. And of course no other errors or problems. Check that tslib was included!
…which will take eons of time. If you add -j2 on a Pi3 you might get away with 8 hours. Pi4 has more memory, so a -j4 might work fine (not yet tested) and save you some time.
Sometimes (at least on Pi3) after the build is finished there seems to be more to be compiled. Running make again takes a while. I don’t know if this is lack of memory when compiling or something else. When all is done:
sudo -E make install
I also added these environment variables:
…and now, when I start an application (for eample, scribble test application) I use:
./scribble -plugin tslib
…and it WORKS! 🙂 🙂 🙂