Solution for XPT2046 screens

Guides and tutorials for various stuff. Posted by DietPi users.
Post Reply
Posts: 1
Joined: Sun May 26, 2019 4:56 pm

Solution for XPT2046 screens

Post by alacecho » Sun May 26, 2019 5:25 pm


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:

Code: Select all

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:

Code: Select all

- Finally, I restart and the screen worked :)

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

Code: Select all

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!
Last edited by alacecho on Sun May 26, 2019 7:24 pm, edited 1 time in total.

User avatar
Posts: 1626
Joined: Sat Nov 18, 2017 5:21 pm

Re: Solution for XPT2046 screens

Post by MichaIng » Sun May 26, 2019 6:11 pm

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.

Post Reply