Raspberry Pi and TFT Display

The 1.8″ TFT from Adafruit is the perfect display to attached to a Raspberry Pi.

These instructions also help with the Sainsmart display and you can find more info for both here:



The TFT isn’t ‘plug & play’ with the Raspberry, a patch has to be applied to the kernel to be able to interface via SPI with the ST7735R controller chip on the TFT. Once working, the display will act as a framebuffer device.

I spent two weeks trying to get it working, so I thought I would document it to help others.

#######Update March 2014#######
If you are interested in a TFT for your Raspberry Pi, this may interest you;
We have started a kickstarter for a 3.5″ TFT with touch control, which comes in a kit or preassembled.

###UPDATE 14th Nov 2013###
After a large number of request, I have now posted the compiled version of the kernel that supports the 1.8” TFT. Based on 2013-09-25-wheezy-raspbian.img. There are two links below, one for the Kernel the other is the instructions.

Icon of 1.8TFT Kernel 1.8TFT Kernel (36.2 MiB)


Icon of README1.8TFT Kernel 3.6.11 Tar README1.8TFT Kernel 3.6.11 Tar (654.0 B)




Thanks go to Kamal ( and Neil for responding to my emails & forum post, and their work on the ST7735R driver.
Thanks also go to Adafruit for their cool products.


As it takes over three hours to compile the kernel on the PI, I will show how to cross compile from another Linux PC. In my case, it is Ubuntu 12.10 running within VMWare on a Windows 7 Quad core PC. Kernel compile time is 15 mins.


Wire it up

Sainsmart wiring details are here on Kamal’s page:

You could also use a shield to make the wiring a lot easier, look here

Prepare the Raspberry Pi

-Download and install Raspbian “wheezy”.
This guide is based on 2013-02-09-wheezy-raspbian which is running 3.6.11 kernel

-Configure your Pi. E.g. Memory split, overclocking, etc..

pi@raspberrypi ~ $ sudo raspi-config


-Update firmware and reboot. I use Hexxeh’s script to update my firmware, which also needs GIT.

pi@raspberrypi ~ $ sudo apt-get update
pi@raspberrypi ~ $ sudo apt-get install git-core
pi@raspberrypi ~ $ sudo wget -O /usr/bin/rpi-update
pi@raspberrypi ~ $ sudo chmod +x /usr/bin/rpi-update
pi@raspberrypi ~ $ sudo rpi-update


Compile the Kernel

We will be cross compiling the kernel as compiling a kernel on the Raspberry Pi takes forever.

-Install packages used for cross compiling on the Ubuntu box.

mark@ubuntu~$ sudo apt-get install gcc-arm-linux-gnueabi make git-core ncurses-dev

-Get Kamal’s source which has the patch for ST7735R controller and the branch for the kernel that is used in 2013-02-09-wheezy-raspbian, which is 3.6.y;

mark@ubuntu~$ git clone git://
mark@ubuntu~$ cd raspberrypi-linux
mark@ubuntu~$ git checkout rpi-3.6.y+kamal-st7735fb

-Grab the current config off the Raspberry Pi.

pi@raspberrypi ~ $ sudo zcat /proc/config.gz > config

-Copy config from the Raspberry Pi to the Ubuntu box using SCP. Replace ‘raspberrypi’ below with the IP address of your Raspberry Pi if hostname lookup fails.
We will then rename it once it is on the Ubuntu box

mark@ubuntu~/raspberrypi-linux$ sudo scp pi@raspberrypi:config .
mark@ubuntu~/raspberrypi-linux$ mv config .config

-Configure .config to include the new patch and options.

mark@ubuntu~/raspberrypi-linux$ make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- oldconfig

You will be asked some questions for the new driver. If you are unsure of what values to use, then use these;

BCM2708 SPI controller driver (SPI0) (SPI_BCM2708) [N/m/y/?] (NEW) Y

ST7735 framebuffer support (FB_ST7735) [N/m/y/?] (NEW) Y
ST7735 ‘red tab’ panel type? (FB_ST7735_PANEL_TYPE_RED_TAB) [Y/n/?] (NEW) Y
ST7735 panel has reversed RGB? (FB_ST7735_RGB_ORDER_REVERSED) [N/y/?] (NEW) N (or Y if red and blue are reversed)
ST7735 framebuffer mapping to GPIO/SPI (FB_ST7735_MAP) [Y/n/m/?] (NEW) Y
ST7735 RST gpio pin number (FB_ST7735_MAP_RST_GPIO) [-1] (NEW) 25
ST7735 D/C gpio pin number (FB_ST7735_MAP_DC_GPIO) [-1] (NEW) 24
ST7735 SPI bus number (FB_ST7735_MAP_SPI_BUS_NUM) [0] (NEW) 0
ST7735 SPI bus chipselect (FB_ST7735_MAP_SPI_BUS_CS) [0] (NEW) 0
ST7735 SPI bus clock speed (Hz) (FB_ST7735_MAP_SPI_BUS_SPEED) [4000000] (NEW) 4000000 (or 32000000 for SainSmart)
ST7735 SPI bus mode (0, 1, 2, or 3) (FB_ST7735_MAP_SPI_BUS_MODE) [0] (NEW) 0

You will need to confirm that “BCM2708 SPI controller driver” is set to Y;

mark@ubuntu:~/raspberrypi-linux$ grep SPI_BCM2708 .config

If the above result is N or M, you will need to edit .config and change it to Y.

mark@ubuntu:~/raspberrypi-linux$sudo nano .config

If you are planning on displaying the console on the TFT, then enabling these options in .config will allow you to change the font size and rotate the display later on.


-Now compile the kernel.
To enable parallel processing for a faster compile. If you have a dual core processor add -j 3 to the end of the command below. If you have quad core, add -j 6

mark@ubuntu:~/raspberrypi-linux$ make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- -k

-Create modules on the Ubuntu box which we will copy over later.

mark@ubuntu:~/raspberrypi-linux$ sudo mkdir ../modules
mark@ubuntu:~/raspberrypi-linux$ sudo make modules_install ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- INSTALL_MOD_PATH=../modules/

-Copy the new kernel over to the Raspberry Pi

mark@ubuntu:~/raspberrypi-linux$ scp arch/arm/boot/Image pi@raspberrypi:.
pi@raspberrypi ~ $ sudo cp Image /boot/kernel.img

-Now copy over the new modules. First remove the unneeded directories, otherwise you will be copying over 1.9GB
The last step below is to SCP the files from from Ubuntu to the Raspberry Pi. If you have trouble SCPing into your Ubuntu box you may need to install open SSH on Ubuntu with sudo apt-get install openssh-server. This step also copies the files from my home folder ‘mark’… yours would be different.

mark@ubuntu:~/raspberrypi-linux$ sudo rm -f -r ../modules/lib/modules/3.6.11+/build
mark@ubuntu:~/raspberrypi-linux$ sudo rm -f -r ../modules/lib/modules/3.6.11+/source
pi@raspberrypi ~ $ sudo rm -f -r /lib/modules
pi@raspberrypi ~ $ sudo rm -f -r /lib/firmware
pi@raspberrypi ~ $ sudo scp -r mark@ubuntu:/home/mark/modules/lib /



If everything went well, you should now have /dev/fb1.



Displaying the console on the TFT;
If you build the st7735 driver pair as built-in, add these options to the end of the line in /boot/cmdline.txt. This will display the console on the TFT.

fbcon=map:10 fbcon=rotate:1 fbcon=font:ProFont6x11



Some programs that work with framebuffer devices

mplayer2 = video playback

pi@raspberrypi ~ $sudo mplayer -vo fbdev2:/dev/fb1 -x 128 -y 160 -zoom file


FBI = image viewer

pi@raspberrypi ~ $sudo fbi -noverbose -T 1 -a -d /dev/fb1 file


Links2 = web browser
Links2 uses directfb to speak to the TFT. And we need to configure directfb with our TFT details.

pi@raspberrypi ~ $sudo vi /etc/fb.modes

-Add these lines to the end of the file

mode “128×160″
geometry 128 160 128 160 16
timings 0 0 0 0 0 0 0

-Update /etc/directfbrc. If the file doesn’t exist, create it.

pi@raspberrypi ~ $sudo vi /etc/directfbrc

-Add these lines to the end of the file


-To run

pi@raspberrypi ~ $sudo links2 -g -mode 128x160x32k

X Windows

Start Xwindows with;

pi@raspberrypi ~ $sudo FRAMEBUFFER=/dev/fb1 startx -- -dpi 60



161 thoughts on “Raspberry Pi and TFT Display”

  1. Hi
    Firstly many thanks on the hard work and for making the compiled kernel freely available. I am finding it impossible to download the entire kernel, it keeps stopping at around 24 – 28MB. I’ve tried different browsers and download managers with no success.
    Very frustrating and a shame no-one can see your work. Is there some other way I can get hold of the download?

  2. Thanks for the guide – A matter of interest, is it possible to connect more than one screen with one Pi? How many can you put? Is it possible to show as different display rather than cloned” screen?

      1. thank you for all of your great contributions!

        I wonder if this can be applied on the 3rd and 4th screen?

        My idea is to use 4 screens to display 4 different graphics.

      2. Yes, the same approach can be extended to as many displays as you have spare GPIO lines (to control the chip select lines for each display). And you can gang displays together arbitrarily. If you can follow the HOWTO and understand the approach it’s taking, you should be fine to hack up the driver for more displays.

  3. ok, slightly off topic, but would like to know if the LCD from the Nokia N810 (AM 800x480x16) could be used with the RPi? It is a great screen, but unfortunately the hardware has become a bit outdated.

    Any thoughts?

  4. Hi,
    before i start “Clone my raspberrypi-linux repo” i have to run “uname -a” so i can find out my based branch.
    I typed it in and i have the Linux raspberrypi 3.10.19+.
    The manual of Kamal Mosafa says that you have select the rpi-3.2.27+kamal or the rpi-3.6.y+kamal. But my rpi is completly different.
    Does anybody know which i have to select?


      1. I guess I got ahead of myself with the XBMC…. I got your patch to work up to a point, with the latest Wheezy, but get and error when entering: to start X;

        “FRAMEBUFFER=/dev/fb1 startx”
        The gif, of the robot, appeared with the command pior to this one, but other than that I only see the boot up sequence, via the 1.8 TFT, then the TFT goes blank, with the exception of a “-” without the quotes.

  5. Hi,

    thanks a lot for your tutorial! I followed your instructions and all worked out well!
    I wonder if you have managed to use the SD slot on the lcd-board?


  6. when i want start the “startx” with FRAMEBUFFER=/dev/fb1 startx, then comes a white – on the LCD Display and thats it… why? (sorry for my english)

Leave a Reply