Buy from US Buy from UK Buy from DE Buy from IT Buy from FR Buy from ES Buy from JP

This tutorial is just for SPI screen working with raspios BOOKWORM version. If you install Raspberry Pi OS Legacy (bullseye) arm64 with desktop, please visit other tutorial: https://osoyoo.com/?p=50824

Install touch driver for OSOYOO 3.5 SPI Screen working with Raspberry Pi OS bookworm

Step 1. Burn burn the Raspberry Pi OS (BOOKWORM Version) with desktop (please download OS from Raspberry Pi official website,) in a TF card/micro SD card, and insert this card in your raspberry Pi. (please confirm that the SD card have enough space for touch driver)

Note: If you use Raspberry Pi OS (Legacy) with desktop, please follow the tutorial: https://osoyoo.com/?p=50824

Step 2. Connect Raspberry Pi to your HDMI monitor or TV. Put a keyboard and mouse into Raspberry Pi USB ports, as following. (please don’t install 3.5″ SPI screen now, as it will show white screen)

Step 3. Getting the Raspberry Pi connected to the Internet (If you want to learn how to get the Raspberry Pi connected to the Internet, please visit https://osoyoo.com/2017/06/20/raspberry-pi-3-basic-tutorial/ )

Step 4. Open terminal, and enter the following command to get the Raspberry Pi’s IP address

hostname -I

Step 5. Shut down and remove the HDMI/TV monitor. keyboard and mouse, then install the 3.5″ SPI screen with the Raspberry Pi which has install touch driver.(There are 40 pins on Raspberry Pi, but there are 26 pins on the LCD, so you should pay attention to connecting the pins to your Pi accordingly)

Step 6. Power on this Raspberry Pi screen.( The screen will show white, but when the Raspberry Pi board restart, his indicator light will show green)

Step 7. Use ssh tool to control Raspberry Pi remotely. Here we use putty. To learn more about how to use putty to control raspberry pi remotely, please click here.
Enter the IP address you got from the last step under Host Name (or IP address) and 22 under Port (by default it is 22) ,then click open, then login.

Step 8. Download and Compile fbcp

Open the Raspberry Pi terminal and execute:

sudo apt install libraspberrypi-dev -y
sudo apt-get install unzip -y
sudo apt-get install cmake -y
sudo wget https://osoyoo.com/driver/osoyoo35b.zip
sudo unzip ./osoyoo35b.zip
sudo cp osoyoo35b.dtbo /boot/overlays/
sudo wget https://osoyoo.com/driver/Rpi-fbcp.zip
sudo unzip ./Rpi-fbcp.zip
cd rpi-fbcp/
sudo rm -rf build
sudo mkdir build
cd build
sudo cmake ..
sudo make -j4
sudo install fbcp /usr/local/bin/fbcp

Step 9: Edit “config.txt” file:

sudo nano /boot/firmware/config.txt

Blocking the following sentence:

Add the following code at the end of config.txt:

dtparam=spi=on 
dtoverlay=osoyoo35b:speed=20000000 
hdmi_force_hotplug=1 
max_usb_current=1 
hdmi_group=2 
hdmi_mode=1 
hdmi_mode=87 
hdmi_cvt 480 320 60 6 0 0 0 
hdmi_drive=2 
display_rotate=2

Step 10: Set Auto-start startx and fbcp

sudo nano ~/.bash_profile

Add the following code at the bottom of the “.bash_profile” file:

if [ "$(cat /proc/device-tree/model | cut -d ' ' -f 3)" = "5" ]; then
    # rpi 5B configuration
    export FRAMEBUFFER=/dev/fb1
    startx  2> /tmp/xorg_errors
else
    # Non-pi5 configuration
    export FRAMEBUFFER=/dev/fb0
    fbcp &
    startx  2> /tmp/xorg_errors
fi

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

Add the following code in “99-fbturbo.~” file:

Section "Device"
        Identifier      "Allwinner A10/A13 FBDEV"
        Driver          "fbturbo"
        Option          "fbdev" "/dev/fb0"

        Option          "SwapbuffersWait" "true"
EndSection

Step 11: Set CLI Auto-login

sudo raspi-config nonint do_boot_behaviour B2
sudo raspi-config nonint do_wayland W1
sudo reboot

After rebooting, the main screen can normally display.(If the screen still show white, please power off and restart the Raspberry Pi)

Step 12: Configure Touch

sudo apt-get install xserver-xorg-input-evdev 
sudo cp -rf /usr/share/X11/xorg.conf.d/10-evdev.conf /usr/share/X11/xorg.conf.d/45-evdev.conf
sudo apt-get install xinput-calibrator

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

Add the following content to the “99-calibration.conf” configuration file:

Section "InputClass"
Identifier "calibration"
MatchProduct "ADS7846 Touchscreen"
Option "Calibration" "241 3854 3885 240"
Option "SwapAxes" "1"
EndSection

Reboot to take effect.

sudo reboot