FBTFT Installation

Automatische Installation

Das Installationsskript rpi-display.sh herunterladen und mit Root-Berechtigung ausführen. Der letzte Parameter gibt die Displayausrichtung an und kann 0, 90, 180 oder 270 sein. Befehle (X windows ist der Desktop):

$ wget -N https://github.com/watterott/RPi-Display/raw/master/rpi-display.sh
$ sudo /bin/bash rpi-display.sh 270

Enable TFT display driver and activate X windows on TFT display? y/n Y
Activate the console on the TFT display? y/n Y
Install fbcp (Framebuffer Copy)? y/n N
Install xinput-calibrator? y/n Y
Install tslib (touchscreen library)? y/n N
Reboot the system now? y/n Y
Rebooting now...

$ sudo startx

Bei Problemen mit wget, curl zum Download verwenden: $ curl -k -L -o rpi-display.sh https://github.com/watterott/RPi-Display/raw/master/rpi-display.sh

Der 5.10+ Kernel benötigt ein aktualisiertes Device Tree Overlay:

wget -N https://github.com/watterott/RPi-Display/raw/master/software/rpi-display.dtbo
sudo cp rpi-display.dtbo /boot/overlays/rpi-display.dtbo

Bei Problemen mit Raspberry Pi OS Bullseye den Grafiktreiber in der /boot/config.txt ändern in dtoverlay=vc4-fkms-v3d.

Zum Start des Desktops folgende Kommandos verwenden.

$ sudo startx -- -layout TFT
$ sudo startx -- -layout HDMI
$ sudo startx -- -layout HDMITFT

Wenn -layout nicht angegeben ist, dann wird das TFT-Display verwendet.

Manuelle Installation

1. Install FBTFT

Further information here.

  • Raspbian / Raspberry Pi OS

    The latest official Raspberry Pi Device Tree enabled Kernel includes FBTFT, so you need an up to date system. To update your system run:

    $ sudo apt-get update
    $ sudo rpi-update
    $ sudo reboot
    
  • Other Linux Systems

    Update the Kernel with:

    $ sudo curl -L --output /usr/bin/rpi-update https://raw.githubusercontent.com/Hexxeh/rpi-update/master/rpi-update && sudo chmod +x /usr/bin/rpi-update
    $ sudo REPO_URI=https://github.com/notro/rpi-firmware rpi-update
    $ sudo reboot
    

    On compatibility errors run rpi-update as follows: $ sudo -E RPI_UPDATE_UNSUPPORTED=0 REPO_URI=https://github.com/notro/rpi-firmware rpi-update

  • Touchscreen Tools

    To install the touchscreen tools run:

    $ sudo apt-get install tslib libts-bin
    $ sudo apt-get install xinput
    $ sudo apt-get install xinput-calibrator
    

2. Activate FBTFT

Note: For a higher speed than 16MHz the display has to be connected directly to the Raspberry Pi or with wires not longer than 5cm.

Choose your respective Kernel version. The default on the latest Raspbian / Raspberry Pi OS is a Device Tree enabled Kernel.

  • FBTFT Device Tree enabled Kernel

    RPi-Display (8-Bit SPI)

    Open the file /boot/config.txt:

    $ sudo nano /boot/config.txt
    

    Add the following line at the file end (rotate can be 0, 90, 180, 270):

    dtoverlay=rpi-display,speed=32000000,rotate=270
    

    The default parameters are speed=32000000, backlight=12, fps=30, rotate=270.

    Reboot the system:

    $ sudo reboot
    
    ADS7846 Touchcontroller

    Parameters for the ADS7846 overlay (in /boot/config.txt) when the RPi-Display overlay is not used.

    dtoverlay=ads7846,cs=1,penirq=25,speed=2000000, swapxy=0, pmax=255, xohms=60, xmin=200, xmax=3900, ymin=200, ymax=3900
    

    To make the touchcontroller accessible as char device /dev/input/touchscreen create a new file /etc/udev/rules.d/95-ads7846.rules and add the following line:

    SUBSYSTEM=="input", KERNEL=="event[0-9]*", ATTRS{name}=="ADS7846 Touchscreen", SYMLINK+="input/touchscreen"
    
  • FBTFT Kernel Modules

    To use the fbtft_device module instead of an overlay on a Device Tree enabled Kernel, add the following line to /boot/config.txt:

    dtparam=spi=on
    

    If the SPI module (spi-bcm2708) is not loaded, remove or comment out the blacklist line in /etc/modprobe.d/raspi-blacklist.conf. To load the module by hand run $ sudo modprobe spi-bcm2708.

    Infos about the automatic loading of modules here.

    RPi-Display (8-Bit SPI)
    $ sudo modprobe fbtft_device name=rpi-display speed=32000000 rotate=270
    
    RPi-Display (9-Bit SPI)

    Note: Only first generation RPi-Displays before April 2014 use 9-Bit SPI.

    $ sudo modprobe fbtft_device name=mi0283qt-9a gpios=reset:23,led:18 speed=32000000 rotate=270
    
    MI0283QT-Adapter v1.5 (8-Bit SPI)

    Note: The display has to be set to 8-Bit SPI.

    $ sudo modprobe fbtft_device name=rpi-display speed=16000000 rotate=270
    
    MI0283QT-Adapter v1 on RPi-ShieldBridge v1 (9-Bit SPI)
    $ sudo modprobe fbtft_device name=mi0283qt-9a gpios=reset:23,led:24 speed=32000000 rotate=270
    
    MI0283QT-Adapter v2 on RPi-ShieldBridge v1 (8-Bit SPI)
    $ sudo modprobe fbtft_device name=mi0283qt-v2 gpios=reset:23 speed=16000000 rotate=270
    
    ADS7846 Touchcontroller
    $ sudo modprobe ads7846_device model=7846 cs=1 gpio_pendown=25 speed=2000000 keep_vref_on=1 x_plate_ohms=60 pressure_max=255 x_min=200 x_max=3900 y_min=200 y_max=3900
    

    To make the touchcontroller accessible as char device /dev/input/touchscreen create a new file /etc/udev/rules.d/95-ads7846.rules and add the following line:

    SUBSYSTEM=="input", KERNEL=="event[0-9]*", ATTRS{name}=="ADS7846 Touchscreen", SYMLINK+="input/touchscreen"
    
  • FBTFT compiled into Kernel (BRANCH=builtin)

    RPi-Display (8-Bit SPI)

    Add the following Kernel arguments to /boot/cmdline.txt:

    fbtft_device.name=rpi-display fbtft_device.speed=32000000 fbtft_device.rotate=270
    
    RPi-Display (9-Bit SPI)

    Note: Only first generation RPi-Displays before April 2014 use 9-Bit SPI.

    Add the following Kernel arguments to /boot/cmdline.txt:

    fbtft_device.name=mi0283qt-9a fbtft_device.speed=32000000 fbtft_device.gpios=reset:23,led:18 fbtft_device.rotate=270
    
    MI0283QT-Adapter v1.5 (8-Bit SPI)

    Note: The display has to be set to 8-Bit SPI.

    Add the following Kernel arguments to /boot/cmdline.txt:

    fbtft_device.name=rpi-display fbtft_device.speed=16000000 fbtft_device.rotate=270
    
    MI0283QT-Adapter v1 on RPi-ShieldBridge v1 (9-Bit SPI)

    Add the following Kernel arguments to /boot/cmdline.txt:

    fbtft_device.name=mi0283qt-9a fbtft_device.speed=16000000 fbtft_device.gpios=reset:23,led:24 fbtft_device.rotate=270
    
    MI0283QT-Adapter v2 on RPi-ShieldBridge v1 (8-Bit SPI)

    Add the following Kernel arguments to /boot/cmdline.txt:

    fbtft_device.name=mi0283qt-v2 fbtft_device.speed=4000000 fbtft_device.gpios=reset:23 fbtft_device.rotate=270
    

3. Enable for Console

Run in console (not desktop terminal):

$ con2fbmap 1 1

To make it permanent (on Debian) add to the file /boot/cmdline.txt at the end of the line the following Kernel arguments: fbcon=map:10 fbcon=font:VGA8x8

4. Enable for X-Window-System

If you have not used the automatic installation script then open 99-fbturbo.conf and change fb0 to fb1 (only needed once):

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

Start X-Window-System:

$ startx &

…wait till X-Window-System starts up and set the ADS7846 properties:

  • rotate=0 (no settings needed)

  • rotate=90

    $ DISPLAY=:0 xinput --set-prop 'ADS7846 Touchscreen' 'Evdev Axes Swap' 1
    $ DISPLAY=:0 xinput --set-prop 'ADS7846 Touchscreen' 'Evdev Axis Inversion' 1 0
    
  • rotate=180

    $ DISPLAY=:0 xinput --set-prop 'ADS7846 Touchscreen' 'Evdev Axis Inversion' 1 1
    
  • rotate=270

    $ DISPLAY=:0 xinput --set-prop 'ADS7846 Touchscreen' 'Evdev Axes Swap' 1
    $ DISPLAY=:0 xinput --set-prop 'ADS7846 Touchscreen' 'Evdev Axis Inversion' 0 1
    

…to stop X-Window-System:

$ sudo pkill x

To make it permanent (on Debian) add to the file /etc/X11/xinit/xinitrc the respective settings. Further infos: xinput settings and autostart x.

5. Calibrate Touchpanel (optional)

For better accuracy a touchpanel calibration can be done with:

  • xinput_calibrator
    $ sudo DISPLAY=:0 xinput_calibrator --device "ADS7846 Touchscreen" --output-type xinput
    
  • ts_calibrate
    $ sudo TSLIB_FBDEVICE=/dev/fb1 TSLIB_TSDEVICE=/dev/input/touchscreen ts_calibrate
    $ sudo TSLIB_FBDEVICE=/dev/fb1 TSLIB_TSDEVICE=/dev/input/touchscreen ts_test
    

6. Further Infos

Tests

Video Test

  • Download the test video (file is about 60MB big):

    $ wget http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4
    
  • Play with mplayer:

    $ sudo apt-get install mplayer
    $ mplayer -vo fbdev2:/dev/fb1 -vf scale=320:-3 BigBuckBunny_320x180.mp4
    
  • Play with omxplayer (fbcp for framebuffer mirroring required):

    $ fbcp &
    $ omxplayer BigBuckBunny_320x180.mp4
    $ killall fbcp
    

Pygame Test

Python

  • Install libsdl 1.2 (further infos here):

    wget -N https://files.watterott.com/fbtft/libsdl1.2debian_1.2.15+veloci1-1_armhf.deb
    sudo dpkg -i libsdl1.2debian_1.2.15+veloci1-1_armhf.deb
    sudo apt-get -f install
    

    File mirror: https://www.dropbox.com/s/0tkdym8ojhcmbu2/libsdl1.2debian_1.2.15+veloci1-1_armhf.deb

  • Install Pygame:

    sudo apt-get install python-pygame
    
  • Download and run test script:

    wget -N https://github.com/watterott/RPi-Display/raw/master/software/rpi-display.py
    sudo python rpi-display.py
    

Python3

  • Install libsdl 2:

    sudo apt-get install libsdl2-ttf-dev
    
  • Install Pygame:

    sudo apt-get install python3-pygame
    
  • Download and run test script:

    wget -N https://github.com/watterott/RPi-Display/raw/master/software/rpi-display.py
    sudo python3 rpi-display.py