Skip to content

Waveshare 3.5inch RPi Display(a)

Set up a Waveshare 3.5inch RPi Display with a XPT2046 touch controller mounted on a Raspberry 3B. Tested with Raspberry Pi OS Bullseye Lite. This page shows how display drivers are installed for using touchpi.
We accept no liability for any problems that may arise when following this procedure.

touchpi @ waveshare 3.5a with Raspi 3B

Note

The driver installation with the supplied LCD-show script overwrites the system files. This can lead to conflicts with Raspberry installation updates. The script-controlled driver installation does not harmonize with a Raspberry OS lite. That is why we did not use the installation script and only carried out the most necessary steps manually (described on this page). The display has no hardware support for backlight control. So the display consumes power in screensaver mode. But therefore it is a relatively cheap display. There seem to be several clones of this display with different installation procedures.

Install Image

It is a good idea to save some system files after installation and first boot of the Raspberry Pi OS Bullseye Lite image. Image installation is described here: Installation.

Origin /boot/cmdline.txt
console=serial0,115200 console=tty1 root=PARTUUID=bd64a070-02 rootfstype=ext4 fsck.repair=yes rootwait cfg80211.ieee80211_regdom=DE
Origin /boot/config.txt
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# For more options and information see
# http://rpf.io/configtxt
# Some settings may impact device functionality. See link above for details

# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1

# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16

# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720

# uncomment if hdmi display is not detected and composite is being output
#hdmi_force_hotplug=1

# uncomment to force a specific HDMI mode (this will force VGA)
#hdmi_group=1
#hdmi_mode=1

# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
#hdmi_drive=2

# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4

# uncomment for composite PAL
#sdtv_mode=2

#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800

# Uncomment some or all of these to enable the optional hardware interfaces
#dtparam=i2c_arm=on
#dtparam=i2s=on
#dtparam=spi=on

# Uncomment this to enable infrared communication.
#dtoverlay=gpio-ir,gpio_pin=17
#dtoverlay=gpio-ir-tx,gpio_pin=18

# Additional overlays and parameters are documented /boot/overlays/README

# Enable audio (loads snd_bcm2835)
dtparam=audio=on

# Automatically load overlays for detected cameras
camera_auto_detect=1

# Automatically load overlays for detected DSI displays
display_auto_detect=1

# Enable DRM VC4 V3D driver
dtoverlay=vc4-kms-v3d
max_framebuffers=2

# Disable compensation for displays with overscan
disable_overscan=1

[cm4]
# Enable host mode on the 2711 built-in XHCI USB controller.
# This line should be removed if the legacy DWC2 controller is required
# (e.g. for USB device mode) or if USB support is not required.
otg_mode=1

[all]

[pi4]
# Run as fast as firmware / board allows
arm_boost=1

[all]
Update OS with
sudo apt update && sudo apt upgrade --yes
sudo apt install --yes --no-install-recommends git xorg xserver-xorg-video-fbturbo x11-apps xinput-calibrator

Note

The waveshare display uses fbturbo. Therefore, you have to install the package xorg-video-fbturbo and, you have to configure an appropriate 99-fbturbo.conf file

Install Display Driver

Download with git clone and copy display driver to /boot/overlays/
Display documentation at: 3.5inch_RPi_LCD_(A) - Waveshare Wiki

git clone https://github.com/waveshare/LCD-show.git
cd LCD-show/
sudo cp ./waveshare35a-overlay.dtb /boot/overlays/waveshare35a.dtbo
sudo cp ./waveshare35a-overlay.dtb /boot/overlays/ 

Changes in /boot/config.txt with

sudo nano /boot/config.txt
Uncomment in the section # Enable DRM VC4 V3D driver
61
62
63
# Enable DRM VC4 V3D driver
# dtoverlay=vc4-kms-v3d
# max_framebuffers=2
Add this lines to the end of the file
81
82
83
84
85
86
dtoverlay=waveshare35a:rotate=0
hdmi_group=2
hdmi_mode=1
hdmi_mode=87
hdmi_cvt 480 320 60 6 0 0 0
hdmi_drive=2

Changed /boot/config.txt
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# For more options and information see
# http://rpf.io/configtxt
# Some settings may impact device functionality. See link above for details

# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1

# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16

# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720

# uncomment if hdmi display is not detected and composite is being output
#hdmi_force_hotplug=1

# uncomment to force a specific HDMI mode (this will force VGA)
#hdmi_group=1
#hdmi_mode=1

# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
#hdmi_drive=2

# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4

# uncomment for composite PAL
#sdtv_mode=2

#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800

# Uncomment some or all of these to enable the optional hardware interfaces
#dtparam=i2c_arm=on
#dtparam=i2s=on
#dtparam=spi=on

# Uncomment this to enable infrared communication.
#dtoverlay=gpio-ir,gpio_pin=17
#dtoverlay=gpio-ir-tx,gpio_pin=18

# Additional overlays and parameters are documented /boot/overlays/README

# Enable audio (loads snd_bcm2835)
dtparam=audio=on

# Automatically load overlays for detected cameras
camera_auto_detect=1

# Automatically load overlays for detected DSI displays
display_auto_detect=1

# Enable DRM VC4 V3D driver
# dtoverlay=vc4-kms-v3d
# max_framebuffers=2

# Disable compensation for displays with overscan
disable_overscan=1

[cm4]
# Enable host mode on the 2711 built-in XHCI USB controller.
# This line should be removed if the legacy DWC2 controller is required
# (e.g. for USB device mode) or if USB support is not required.
otg_mode=1

[all]

[pi4]
# Run as fast as firmware / board allows
arm_boost=1

[all]
dtoverlay=waveshare35a:rotate=0
hdmi_group=2
hdmi_mode=1
hdmi_mode=87
hdmi_cvt 480 320 60 6 0 0 0
hdmi_drive=2

Changes in /boot/cmdline.txt with

sudo nano /boot/cmdline.txt
add fbcon=map:10 fbcon=font:ProFont6x11 to the end of the line

Changed /boot/cmdline.txt
console=serial0,115200 console=tty1 root=PARTUUID=bd64a070-02 rootfstype=ext4 fsck.repair=yes rootwait cfg80211.ieee80211_regdom=DE fbcon=map:10 fbcon=font:ProFont6x11

Reboot

sudo reboot
After reboot the display should show the boot process.

Create X11 files

Create the file 99-fbturbo.conf with sudo nano /usr/share/X11/xorg.conf.d/99-fbturbo.conf and add this lines:

/usr/share/X11/xorg.conf.d/99-fbturbo.conf

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# This is a minimal sample config file, which can be copied to
# /etc/X11/xorg.conf in order to make the Xorg server pick up
# and load xf86-video-fbturbo driver installed in the system.
#
# When troubleshooting, check /var/log/Xorg.0.log for the debugging
# output and error messages.
#
# Run "man fbturbo" to get additional information about the extra
# configuration options for tuning the driver.

Section "Device"
        Identifier      "Allwinner A10/A13 FBDEV"
        Driver          "fbturbo"
        Option          "fbdev" "/dev/fb1"
        Option          "ShadowFB" "off"
        Option          "SwapbuffersWait" "true"
EndSection

Section "Monitor"
        Identifier      "Default-Monitor"
EndSection

Section "Screen"
        Identifier      "primary"
        Device          "Allwinner A10/A13 FBDEV"
        Monitor         "Default-Monitor"
EndSection

Section "ServerLayout"
        Identifier      "default"
        Screen 0        "primary" 0 0
        Option          "StandbyTime" "0"
        Option          "SuspendTime" "0"
EndSection

Run X window server in background

sudo -b /usr/lib/xorg/Xorg :0
Run xinput_calibrator
DISPLAY=:0.0 xinput_calibrator -v --output-type xorg.conf.d
Do a calibration

Create the file 99-calibration.conf with

sudo nano /usr/share/X11/xorg.conf.d/99-calibration.conf

Copy the section from stdout to the file.

The file will look like this (probably with other values):

/usr/share/X11/xorg.conf.d/99-calibration.conf

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "ADS7846 Touchscreen"
        Option  "MinX"  "2338"
        Option  "MaxX"  "62275"
        Option  "MinY"  "3789"
        Option  "MaxY"  "63043"
        Option  "SwapXY"        "0" # unless it was already set to 1
        Option  "InvertX"       "0"  # unless it was already set
        Option  "InvertY"       "0"  # unless it was already set
EndSection

Restart X window server and test with calling e.g. DISPLAY=:0.0 xcalc

Rotation (screen and touch)

You can rotate the touch display with changes in the boot/config.txt and /usr/share/X11/xorg.conf.d/40-libinput.conf file. Edit with sudo nano.

/boot/config.txt /usr/share/X11/xorg.conf.d/40-libinput.conf
dtoverlay=waveshare35a:rotate=0
(USB on top, book form layout)
Option "TransformationMatrix" "1 0 0 0 1 0 0 0 1"
Option is optional. Not needed in the file.
dtoverlay=waveshare35a:rotate=90
(USB right, power cable down)
Use TransformationMatrix 270 ->
Option "TransformationMatrix" "0 -1 1 1 0 0 0 0 1"
dtoverlay=waveshare35a:rotate=180
(USB down)
Use TransformationMatrix 180 ->
Option "TransformationMatrix" "-1 0 1 0 -1 1 0 0 1"
dtoverlay=waveshare35a:rotate=270
(USB left, power cable up
preferred layout)
Use TransformationMatrix 90 ->
Option "TransformationMatrix" "0 1 0 -1 0 1 0 0 1"
Origin /usr/share/X11/xorg.conf.d/40-libinput.conf
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Match on all types of devices but joysticks
#
# If you want to configure your devices, do not copy this file.
# Instead, use a config snippet that contains something like this:
#
# Section "InputClass"
#   Identifier "something or other"
#   MatchDriver "libinput"
#
#   MatchIsTouchpad "on"
#   ... other Match directives ...
#   Option "someoption" "value"
# EndSection
#
# This applies the option any libinput device also matched by the other
# directives. See the xorg.conf(5) man page for more info on
# matching devices.

Section "InputClass"
        Identifier "libinput pointer catchall"
        MatchIsPointer "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
EndSection

Section "InputClass"
        Identifier "libinput keyboard catchall"
        MatchIsKeyboard "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
EndSection

Section "InputClass"
        Identifier "libinput touchpad catchall"
        MatchIsTouchpad "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
EndSection

Section "InputClass"
        Identifier "libinput touchscreen catchall"
        MatchIsTouchscreen "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
EndSection

Section "InputClass"
        Identifier "libinput tablet catchall"
        MatchIsTablet "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
EndSection
Changed /usr/share/X11/xorg.conf.d/40-libinput.conf
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Match on all types of devices but joysticks
#
# If you want to configure your devices, do not copy this file.
# Instead, use a config snippet that contains something like this:
#
# Section "InputClass"
#   Identifier "something or other"
#   MatchDriver "libinput"
#
#   MatchIsTouchpad "on"
#   ... other Match directives ...
#   Option "someoption" "value"
# EndSection
#
# This applies the option any libinput device also matched by the other
# directives. See the xorg.conf(5) man page for more info on
# matching devices.

Section "InputClass"
        Identifier "libinput pointer catchall"
        MatchIsPointer "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
EndSection

Section "InputClass"
        Identifier "libinput keyboard catchall"
        MatchIsKeyboard "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
EndSection

Section "InputClass"
        Identifier "libinput touchpad catchall"
        MatchIsTouchpad "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
EndSection

Section "InputClass"
        Identifier "libinput touchscreen catchall"
        MatchIsTouchscreen "on"
        Option "TransformationMatrix" "0 1 0 -1 0 1 0 0 1"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
EndSection

Section "InputClass"
        Identifier "libinput tablet catchall"
        MatchIsTablet "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
EndSection

Read more about offsets, scaling and rotation here.

Implement HW backlight control.

There are some hacks how to implement a hardware backlight control for this display.
Adding brightness control for cheap LCD - Raspberry Pi Forums Add backlight!