Adding a 3.5 LCD screen to a Raspberry
I bought a LCD pannel based on the Waveshare 3.5 screen. And ran a pre-loaded image, can find it here.
Burned the image into an SD card and it Worked.
So, if you are ok with that… you can stop reading.
So what’s the issue?
After booting I ran a dist-upgrade to see if it was ok, but the LCD screen stoped working.
I’d like to be able to use a fresh image from the official site. Desktop or Lite.
I’d like to know if I can take any Raspbian (or Linux based) image and make the screen run.
Installation (the hard way)
Note: This tutorial was build for Raspbian, based on Debian Stretch, CPU architecture armv7l and Linux kernel V4.14.34
Download an official image from the Raspberry site (Link above), burn it into an SD card and insert into the raspberry.
Power On.
Update packages $ sudo apt-get update; sudo apt-get upgrade
For security, let’s create a backup of the original files we are going to modify. I’m going to try to keep the original OS folder structure for future reference (to remember where they where located).
Wherever you want, create a root folder (bu_folder). And copy inside:
$ mkdir <bu_folder>/boot/
$ mkdir -p <bu_folder>/usr/share/X11/xorg.conf.d/
$ cp /boot/cmdline.txt <bu_folder>/boot/
$ cp /boot/config.txt <bu_folder>/boot/
$ cp /usr/share/X11/xorg.conf.d/99-fbturbo.conf <bu_folder>/usr/share/X11/xorg.conf.d/
Clone or download the files from https://github.com/swkim01/waveshare-dtoverlays
You only need the file waveshare35a-overlay.dtb (They recommend the waveshare35b-overlay.dtb, it’s up to you and your LCD)
Copy this file into /boot/overlays/ as waveshare35a-overlay.dtbo; notice that o at the end (I think it’s the reason why it didn’t run after the apt-get dist-upgrade)
Let’s edit /boot/config.txt:
Uncomment "dtparam=i2c_arm=on" (L46) # Allows i2c bus.
Uncomment "dtparam=spi=on" (L48) # Allows spi bus.
Add or uncomment "dtoverlay=waveshare35a"
Edit /usr/share/X11/xorg.conf.d/99-fbturbo.conf.
Notice a line where it says Option "fbdev" "/dev/fb0". Change the /dev/fb0 to /dev/fb, so it now looks like: Option "fbdev" "/dev/fb1". This will tell the X display manager to use the new LCD display and not the HDMI interface (I wonder if it can be configured to use both).
Boot.
Success! Now the LCD screen should be working and displaying your OS.
Aditional configuration.
Don’t forget to reboot after each step.
Screen orientation
The screen might be facing up. To adjust it, on /boot/config.txt adjust your dtoverlay to
dtoverlay=wavesahre35a:rotate=270.
FPS
The screen might seem to be runnig slow. And that’s not desired if you want to run any game (like retropie kind) or watch a video.
On /boot/config.txt adjust your dtoverlay to dtoverlay=wavesahre35,fps=30,speed=17000000.
With the orientation your dtoverlay might look like this:
dtoverlay=wavesahre35,fps=30,speed=17000000.
I want to highlight that I don’t have a correct value for the fps and speed, they need to be tunned to your requirements, where a high speed might cause the display to show incorrect colors or even start to behave incorrectly, on the other side a slow speed causes the frame rate to be really slow reaching points where it’s almost impossible to operate (levels bellow 5000000).
So if you need, tune it to your needs. Or a better alternative can be to use a display which uses the HDMI interface.
Calibrate the touch pannel.
TBD
Sources:
https://darwindelacruz.wordpress.com/2017/06/06/how-to-install-a-3-5-lcd-display-on-raspberry-pi/
https://www.raspberrypi.org/forums/viewtopic.php?t=137149&start=25