HCL:Raspberry Pi3 LCD

Jump to: navigation, search

The Raspberry Pi 3 can directly be connected to a SPI TFT display via the GPIO pins. This is helpful to build really small devices with all needed components included. The picture below shows a DIN Rail Raspberry Pi Case with a 320x240 TFT display.

Rpi3-spi-tft.png

GPIO pin connection

The SPI display pins need to be connected to the corresponding GPIO pins.

Qvga-tft-spi.jpg

VCC -------------------------- 3V3 (pin  1)
GND ----------------------- Ground (pin  9)
CS --------------------------- CE0 (pin 26) 
RESET --------------------- GPIO25 (pin 22) 
DC/RS --------------------- GPIO24 (pin 18) 
SDI/MOSI -------------------- MOSI (pin 19) 
SCK ------------------------- SCLK (pin 23) 
LED ----------------------- GPIO18 (pin 12) 
SDO/MISO -------------------- MISO (pin 21) 

GPIO to SPI Display.jpg

Boot preparation

After the display is connected we need to prepare the system to be able to speak to the SPI display. The first step to do this is an extra file inside the /boot/efi directory called extraconfig.txt. Add the following line into that file to enable the Raspberry Pi display device tree overlay driver.

dtoverlay=rpi-display

After this the kernel should be able to identify the connected display itself. Just look for a dmesg line like this.

[   39.920521] graphics fb1: fb_ili9341 frame buffer, 320x240, 150 KiB video memory, 16 KiB buffer memory, fps=33, spi0.0 at 32 MHz

This would be enough to work with the new frame buffer device /dev/fb1, but we want to have a login prompt as well. For that we need to add some kernel command line parameters into /etc/default/grub. The GRUB_CMDLINE_LINUX_DEFAULT variable needs to be extended with the following string.

fbcon=map:10 fbcon=font:VGA8x8

To activate the grub configuration change, you need to recreate the config file.

grub2-mkconfig -o /boot/grub2/grub.cfg

It is also recommended to change the /etc/issue file to be limited to 40 characters. Otherwise the message does not look pretty. Here's one example that should work.

Welcome to \S (\l).


Tools to work with

To display graphics via the command line, you need to install the tool fbi.

zypper install fbi

After installation you can run the command an push pictures to directly to the frame buffer device.

fbi -d /dev/fb1 -T 1 -noverbose -a opensuse.png

Rpi3-din-rail-installed.png