How to enable 3.5" Touch Screen Monitor in Raspbian

We recommend you do the below commands via a SSH connection to allow copy & paste
Backup any important files before proceeding

Enable SPI and Screen (Required)

Update package lists
sudo apt-get update
Install and force evdev (instead of libinput)
sudo apt-get install -y 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
Edit boot config
sudo cp /boot/config.txt /boot/config.txt.bu
sudo nano /boot/config.txt
Copy the below text to the bottom of the file
Save the file (CTRL-X then Y then ENTER).

Show Raspbian GUI on Screen

Edit X11 config file to send GUI to 3.5" screen
sudo cp /usr/share/X11/xorg.conf.d/99-fbturbo.conf /usr/share/X11/xorg.conf.d/99-fbturbo.conf.bu
sudo sed -i 's/fb0/fb1/g' /usr/share/X11/xorg.conf.d/99-fbturbo.conf
Now reboot
sudo reboot
The Raspbian GUI should now show on the 3.5" screen

Raspbian Touch-screen Calibration

Run the below commands to calibrate the touch-screen.

Install the required packages
sudo apt-get install -y xinput-calibrator
Run the calibration program
If you are doing the commands via SSH, then use
DISPLAY=:0.0 xinput_calibrator
Copy the output of the program.
It should look similiar to this:
Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "ADS7846 Touchscreen"
        Option  "Calibration"   "3989 230 324 3976"
        Option  "SwapAxes"      "0"
Now run the below command to create and edit the file for our persistent calibration.
sudo nano /usr/share/X11/xorg.conf.d/99-calibration.conf
Paste in the copied text and save the file (Ctrl-X, Y, ENTER).
Now reboot and the screen should be calibrated.
sudo reboot

Disable Screen Blanking (optional)

sudo sed -i 's/^BLANK_TIME=30/BLANK_TIME=0/' /etc/kbd/config
sudo sed -i 's/^POWERDOWN_TIME=30/POWERDOWN_TIME=0/' /etc/kbd/config
sudo reboot

Image Test (optional)

Install fbi image viewer and test
sudo apt-get -y install wget fbi
cd ~
sudo fbi -noverbose -T 1 -a -d /dev/fb1 480x320.jpg
You should see the image on the 3.5" screen

Show Raspbian Boot Text on Screen (optional)

Edit boot config file to send console to 3.5" screen
sudo cp /boot/cmdline.txt /boot/cmdline.bu
sudo sed -i.bck '$s/$/ fbcon=map:10 fbcon=rotate:2 fbcon=font:ProFont6x11/' /boot/cmdline.txt
sudo reboot
The Raspbian console should now show on the 3.5" screen

Mirror HDMI Output to 3.5" Screen (optional)

Install cmake and build rpi-fbcp
sudo apt-get -y install cmake git
git clone
cd rpi-fbcp/

mkdir build
cd build/
cmake ..

sudo install fbcp /usr/sbin/fbcp
Start mirroring
fbcp &
Stop mirroring
killall fbcp
Start mirroring on boot
sudo cp /etc/rc.local /etc/rc.local.bu
sudo sed -i 's/^exit 0/fbcp \&\nexit 0/g' /etc/rc.local
sudo reboot