Solution for XPT2046 screens


Just I installed DietPi in my old Raspberry 2011.12 (Model B Revision 2.0 512MB). Really is so fast now, working with DietPi!

I have a 3.5 Inch 480x320 TFT Display with Touch Screen, previously working in Raspbian, but so difficult to work under last version of DietPi. I only found this topic in Dietpi Forum about problems with Waveshare driver, but without a solution.

I was testing several compatible drivers for the touch screen, and some configurations into DietPi-config. Finally, it is working, doing just this:

  • Into DietPi-config, into Display Options, I uninstall all panel
  • Then, I installed the Elecrow driver, following this instructions (same to get working the same screen in Raspbian). DON’T REBOOT AFTER THE DRIVER finish the installation.
  • I completed the setup, with:
apt-get update
apt-get install -y libts-bin evtest xinput python-dev python-pip
pip install evdev
apt-get install -y xinput-calibrator
  • When the Elecrow driver is installed, it change the /boot/config.txt file. BUT, DietPi really use /DietPi/config for this configuration file. Into /boot/config.txt you can read:

- Modifications to /boot/config.txt will not be preserved on reboot.

- Please ensure you edit from the DietPi-RAMdisk location: /DietPi/config.txt

  • So, the changes that the Elecrow driver into /boot/config.txt will dissapear after boot
  • I have commented all the lines about display into /DietPi/config file (you can find lines about SPI or Overclock configuration)
  • I opened the /boot/config.txt file and copy the lines that the Elecrow driver created during its installation. In my case:
  • Finally, I restart and the screen worked :slight_smile:

If you have problems to start the Desktop Enviroment (for example, Mate), you can add this lines to /ect/X11/xorg.conf.d/99-calibration.conf

Section "Device"
# WaveShare SpotPear 3.5", framebuffer 1
Identifier "uga"
driver "fbdev"
Option "fbdev" "/dev/fb1"
Option "ShadowFB" "off"

Section "Monitor"
# Primary monitor. WaveShare SpotPear 480x320
Identifier "WSSP"

Section "Screen"
Identifier "primary"
Device "uga"
Monitor "WSSP"

Section "ServerLayout"
Identifier "default"
Screen 0 "primary" 0 0

Before to add the previous code, keep the calibration lines you got during the first installation of the driver, before to repeat the calibration process.

You can find other compatible drivers in other websites, like this one. You can test to know which is better for your screen.

Hope this will be useful!

Many thanks for your tutorial. I will implement these steps into dietpi-config. Indeed this driver (dtoverlay) is not included with the RPi kernel, so it needs to be compiled from source, which is what your linked instructions do.

After the following steps I get this error in my Raspberry Pi 4 (4GB):
Login: root

git clone
cd Elecrow-LCD35
sudo ./Elecrow-LCD35
apt-get update
apt-get install -y libts-bin evtest xinput python-dev python-pip
pip install evdev

–Error during execution: pip install evdev

unable to execute ‘arm-linux-gnueabihf-gcc’: No such file or directory
error: command ‘arm-linux-gnueabihf-gcc’ failed with exit status 1

Command “/usr/bin/python -u -c “import setuptools, tokenize;file=’/tmp/pip-install-g9JEjC/evdev/’;f=getattr(tokenize, ‘open’, open)(file);’\r\n’, ‘\n’);f.close();exec(compile(code, file, ‘exec’))” install --record /tmp/pip-record-FBqOrC/install-record.txt --single-version-externally-managed --compile” failed with error code 1 in /tmp/pip-install-g9JEjC/evdev/


Any idea?

Pls can you try the follow

apt-get install build-essential

Once done, restart your script