Raspberry PI Banggood’s 3.2” TFT display configuration

TFT_Main
Image from “The Elephants Dream” by Blender Foundation

A few months ago i bought a 3.2” TFT display from banggood for my Raspberry PI. After a few days trying to put it to work, here’s how. My approach doesn’t uses any custom kernel

First, a few specs for the TFT

Display module: flexfb, fbtft

Touchscreen module: ads7846

The TFT needs SPI support, lets enable it

 

1

2

3

4

5

6

Note: If you get the following error:

Don’t worry – just reboot your Raspberry PI now

After rebooting the PI, let’s start configuring the necessary modules

Add the following lines to /etc/modules (the support for the display and touchscreen)

For X, we need to configure it to start in the framebuffer /dev/fb1

Edit the configuration file for X display:

This is the contents of the file:

Change the line

to

Save the file and quit

In /boot/overlays there’s the device tree overlay to add support for the touchscreen this LCD brings – ads7846. We just need to tell to the RPi to add support for it.

Device Tree Overlays make possible the support of many hardware configurations with a single kernel and without the necessity to blacklist or load kernel modules.

More info about Device Tree Overlays in here.

There’s a small configuration file – config.txt – that controlls the usage of the Device Tree Overlays.

add the following line (at the end of the file):

Make sure the SPI line is also there:

Reboot the PI

Now, check the device in /proc/bus/input/devices

and you should see something like:

If you start X, you can now touch the screen, but it will not be calibrated.

Calibration

To calibrate the screen, we must do this as root

Install packages

Set the environment for the calibration, exporting two variables

Note: Every time you want to calibrate again, those two variables must be exported

Execute the calibration:

Just press were the crosshair is:

Calibration1

(and you should see the resolution in the console – given by ts_calibrate)

Your terminal should give some results:

The data (Calibration constantes) will be written to /etc/pointercal file. Just cat /etc/pointercal to see the file contents.

To test the calibration, execute ts_test (as root) and in the console you should see some information:

Calibration4 Calibration3

Press Ctrl+c to terminate

Now, reboot the PI

After the reboot, you should have the touchscreen calibrated

If you find out that the axis are reversed (It will probably happen), just create the file 99-configuration.conf (you can give it other name) in /usr/share/X11/xorg.conf.d/ with the following contents:

Start the display manager again and it should be ok

Note: You still have another option, that is adding the following line to /etc/X11/xinit/xinitrc, above the . /etc/X11/Xsession line, staying like the following

Between the . (dot) and / there’s a space

Now, you’re able to use your TFT without any fuss or custom kernels

References

http://www.circuitbasics.com/setup-lcd-touchscreen-raspberry-pi/

https://github.com/raspberrypi/firmware/blob/master/boot/overlays/README

https://github.com/notro/fbtft/issues/260

https://github.com/notro/fbtft/wiki/Touchpanel

Banggood avaliable Raspberry PI image with support for the TFT LCD display

10 Replies to “Raspberry PI Banggood’s 3.2” TFT display configuration

  1. Got up to where i change fb0 to fb1 and i am no longer able to type in the terminal or to save and quit??
    Please help.

  2. Ok… I managed to change fb0 to fb1 and followed through with the tutorial. I have the exact same screen but it still doesn’t work.

  3. This is a nice guide but unfortunately I can’t get the screen to work using it. Screen hardware is working because if I use image that came with it then it does work (on a B+). However, this is quite an old wheezy and I want to run with an updated jessie.
    my cat /proc/bus/input/devices looks Ok but dmesg shows
    [ 5.646689] systemd[1]: systemd-modules-load.service: main process exited, code=exited, status=1/FAILURE
    [ 5.669577] systemd[1]: Failed to start Load Kernel Modules.
    [ 5.677865] systemd[1]: Unit systemd-modules-load.service entered failed state.

    So I think something is going wrong on the display driver side.

    I did have some success previously using the earlier custom kernel nitro method on wheezy but understood that wasn’t needed now.

    I wonder whether the new method is Ok with B+ or whether it now needs a Pi2.

  4. I think the issue for my situation is with the mapping of dc and reset. If I look at the successful dmesg on the supplied wheezy image I see
    [ 22.780097] fbtft_device: GPIOS used by ‘flexfb’:
    [ 22.801560] fbtft_device: ‘dc’ = GPIO22
    [ 22.808282] fbtft_device: ‘reset’ = GPIO27

    However if I do sudo modprobe fbtft_device name=flexfb with the Jessie image I get
    [ 1246.632689] fbtft_device: GPIOS used by ‘flexfb’:
    [ 1246.632715] fbtft_device: ‘reset’ = GPIO25
    [ 1246.632729] fbtft_device: ‘dc’ = GPIO24

    I do have the line in modules
    fbtft_device name=flexfb gpios=dc:22,reset:27 speed=48000000

    but it seems that the gpios definition is not picked up and some default is being used. Don’t know how to fix this yet.

  5. I have got this basically working now. I checked the devices in the notro code and found that waveshare32b had the dc 22 and reset 27 defined. So I used waveshare32b instead of flexfb.

    I also edited /etc/modules-load.d/fbtft.conf and /etc/modprobe.d/fbtft.conf as per notro instead of modules

    Now I have to work out how to rotate the screen

    1. Hi Btidey !

      I’m happy you could figure that out ! I’ll add to the article a note about your findings – other users might have the same problem.

      Tell me, are you using Jessie for the Raspberry PI ?

      1. Yes. This is done with latest Jessie.
        I found that putting the various override parameters including rotate after the options in the /etc/modprobe.d/fbtft.conf file seems to work OK but didn’t work in /etc/modules. I’m not sure if that is to do with using jessie or not but the notro wiki seems to say that is where to put them now.

Leave a Reply to btidey Cancel reply

Your email address will not be published. Required fields are marked *