Solution for XPT2046 screens

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

Solution for XPT2046 screens

Post by alacecho »


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 8:24 pm, edited 1 time in total.
User avatar
Site Admin
Posts: 3266
Joined: Sat Nov 18, 2017 6:21 pm

Re: Solution for XPT2046 screens

Post by MichaIng »

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.
Posts: 1
Joined: Tue Jan 14, 2020 12:02 am

Re: Solution for XPT2046 screens

Post by bcnmartin »

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?
User avatar
Posts: 5693
Joined: Sat Nov 16, 2019 12:49 am

Re: Solution for XPT2046 screens

Post by Joulinar »

Pls can you try the follow

Code: Select all

apt-get install build-essential
Once done, restart your script
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Post Reply