Skip to content

Spotpear Raspberry Pi 1.54inch Game LCD

Set up a 1.54inch Game LCD Display (ST7789V) with a XPT2046 touch controller mounted on Raspberry Zero 2W. 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 @ spotpear pi 1.54inch_Game_LCD

Note

The display driver installs a second framebuffer for the SPI LCD screen in addition to the standard HDMI screen. Then the content is mirrored from the first to the second using a fbcp tool. However, the developers of these tools recommend no longer using them. Therefore, in this setup, the framebuffer of the LCD screen is addressed directly via the X11 fbturbo driver. The console terminal is using directly the framebuffer of the LCD screen with fbcon in cmdline.txt. This setup therefore deviates from the manufacturer's description.

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 Game LCD display driver can use fbturbo. Therefore, the package xorg-video-fbturbo is installed, and you have to configure later an appropriate 99-fbturbo.conf file.

Install Display Driver

Download with wget and copy display driver to /boot/overlays/
Display documentation at: Spotpear - Raspberry Pi 1.54inch Game LCD User Guide

mkdir display
cd display/
wget https://cdn.static.spotpear.com/uploads/download/diver/gm154/lcd154.dtbo
sudo cp lcd154.dtbo /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
87
88
89
90
dtparam=spi=on
dtoverlay=lcd154:rotate=0
hdmi_force_hotplug=1
max_usb_current=1
hdmi_group=2
hdmi_mode=1
hdmi_mode=87
hdmi_cvt 480 480 60 6 0 0 0
hdmi_drive=2
dtoverlay=ads7846,cs=1,penirq=17,penirq_pull=2,speed=50000,keep_vref_on=1,swapxy=0,pmax=255,xohms=60,xmin=200,xmax=3900,ymin=200,ymax=3900

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
87
88
89
90
# 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]
dtparam=spi=on
dtoverlay=lcd154:rotate=0
hdmi_force_hotplug=1
max_usb_current=1
hdmi_group=2
hdmi_mode=1
hdmi_mode=87
hdmi_cvt 480 480 60 6 0 0 0
hdmi_drive=2
dtoverlay=ads7846,cs=1,penirq=17,penirq_pull=2,speed=50000,keep_vref_on=1,swapxy=0,pmax=255,xohms=60,xmin=200,xmax=3900,ymin=200,ymax=3900

Changes in /boot/cmdline.txt with

sudo nano /boot/cmdline.txt
add fbcon=map:10 fbcon=font:ProFont6x11 to the end of the line. This will define the framebuffer /dev/fb1 of the SPI display as main display for the consoles.

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 file

Run fbset -i and get the name of the frame buffer device. You can use the name as identifier in your conf file.

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      "BCM2708 FB"
        Driver          "fbturbo"
        Option          "fbdev" "/dev/fb1"
        Option          "ShadowFB" "off"
        Option          "SwapbuffersWait" "true"
EndSection

Section "Monitor"
        Identifier      "Default-Monitor"
EndSection

Section "Screen"
        Identifier      "primary"
        Device          "BCM2708 FB"
        Monitor         "Default-Monitor"
EndSection

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

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=lcd154:rotate=0
(USB right)
Option "TransformationMatrix" "1 0 0 0 1 0 0 0 1"
Option is optional. Not needed in the file.
dtoverlay=lcd154:rotate=90
(USB down)
Use TransformationMatrix 90 ->
Option "TransformationMatrix" "0 -1 1 1 0 0 0 0 1"
dtoverlay=lcd154:rotate=180
(USB left)
Use TransformationMatrix 180 ->
Option "TransformationMatrix" "-1 0 1 0 -1 1 0 0 1"
dtoverlay=lcd154:rotate=270
(USB on top
preferred layout)
Use TransformationMatrix 270 ->
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

Adjust touch dimension

Scale the touch dimension if the cursor does not reach the edges Read more here.

Sample of a final /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.4 -0.2 -1.4 0 1.15 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

When the cursor reaches the edges you can finally calibrate the touch input.

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"  "0"
        Option  "MaxX"  "4095"
        Option  "MinY"  "0"
        Option  "MaxY"  "4095"
        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