Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.
Noralf Trønnes edited this page Nov 14, 2019 · 159 revisions

Linux Framebuffer drivers for small TFT LCD display modules.

Video: Raspberry Pi boots with Adafruit 2.2" LCD display

For a list of all wikipages see Pages

fbtft_device and flexfb are gone in 5.4

  • fbtft_device was removed because the gpio code had been reworked without fixing up fbtft_device so it didn't work. fbtft_device was never intended to be included in mainline and has survived for this long since "no-one" knew that it was a pure device adder module, which doesn't belong in mainline.

  • flexfb was removed because it will never be ported to the DRM graphics subsystem due to its nature. The init= DT property is not accepted.

  • fbtft will now only work with Device Tree due to the above mentioned disruptive gpio rework.

  • fbtft is currently listed as orphaned in MAINTANERS so it doesn't have someone looking after it, at least officially.

Raspberry Pi SPI DMA

To maximize throughput, make sure txbuflen is 16k or 32k (default is usually 4k). This is needed because of the DMA mapping/engine overhead per transfer that spi-bcm2835 has.

Device Tree: txbuflen = <32768>;
fbtft_device: txbuflen=32768

# Here it is 16k
$ dmesg | grep graphics
[    8.547173] graphics fb1: fb_ili9341 frame buffer, 320x240, 150 KiB video memory, 16 KiB DMA buffer memory, fps=50, spi0.0 at 48 MHz

See /boot/overlays/README and FBTFT RPI overlays for information about Device Tree overlays.

To use fbtft_device instead of a DT overlay, add to /boot/config.txt:

dtparam=spi=on

Step-by-step using FBTFT (without Device Tree)

Using the Adafruit 2.2" display as an example

Enable driver

Register device (the driver will load automatically)
sudo modprobe fbtft_device name=adafruit22

dmesg will show the default pin assignements, and that the driver is loaded.

   fbtft_device:  SPI devices registered:
   fbtft_device:      spidev spi0.0 500kHz 8 bits mode=0x00
   fbtft_device:      spidev spi0.1 500kHz 8 bits mode=0x00
   fbtft_device:  'fb' Platform devices registered:
   fbtft_device:      bcm2708_fb id=-1 pdata? no
   fbtft_device: Deleting spi0.0
   fbtft_device:  GPIOS used by 'adafruit22':
   fbtft_device:    'reset' = GPIO25
   fbtft_device:    'led' = GPIO23
   fbtft_device:  SPI devices registered:
   fbtft_device:      spidev spi0.1 500kHz 8 bits mode=0x00
   fbtft_device:      fb_hx8340bn spi0.0 32000kHz 8 bits mode=0x00
   graphics fb1: fb_hx8340bn frame buffer, 176x220, 75 KiB video memory, 16 KiB buffer memory, fps=20, spi0.0 at 32 MHz

Test

X Windows
FRAMEBUFFER=/dev/fb1 startx

Note: You might need to move an xorg config out of the way if X doesn't start:

sudo mv /usr/share/X11/xorg.conf.d/{,.}99-fbturbo.conf
Console
con2fbmap 1 1

Make it permanent (Debian Jessie, Arch Linux, systemd)

Add to file /etc/modules-load.d/fbtft.conf

spi-bcm2835
fbtft_device

(the auto loading of spi-bcm2835 is too late for fbtft_device to find the spi bus, so it has to be manually loaded)

Note: If the display is connected to SPI1, load the driver spi-bcm2835aux instead of spi-bcm2835

Add to file /etc/modprobe.d/fbtft.conf

options fbtft_device name=adafruit22

Thanks

Without the help from other people, this project would not exist

  • Matt Porter wrote st7735fb which FBTFT grew from
  • Texy has provided much input and testing that have helped move this project forward
  • Derek Campbell did the work to implement DMA
  • Several people have provided drivers and improvements

Also thanks to people that help answering questions about FBTFT.


Clone this wiki locally