Setting up TonTec 3.5 Inch TFT using the fbtft driver

This is a follow up post to my other page describing how I managed to get the Tontec 3.5 inch TFT to work using a modified fbtft driver. Now my changes have been accepted to the fbtft project it is simpler to use the kernel provided Notro. These instructions are for the Raspbian distribution for the Raspberry Pi.

Step 1 – Install Raspbain

I will not cover this step as there are plenty of other sites offering tutorials about this. Just google for “install Raspbian”.

Step 2 – Update the system

Before you install the fbtft drivers it is wise to update the system. This step needs to be performed on the Raspberry Pi from a terminal window (or ssh from a remote computer).

Step 3 – Install fbtft kernel and modules

This step will install the latest kernel including the fbtft drivers and modules. Again from a terminal window issue the following command.

Step 4 – Configure the driver

In this step we will need to edit some files. The easiest editor on the command line is “nano”. The files we will be editing are as follows:

  • /etc/modprobe.d/raspi-blacklist.conf – Used to prevent modules from loading
  • /etc/modules – Used to load modules at boot time
  • /boot/cmdline.txt – Used to customise kernel driver options during boot.

First we will edit raspi-blacklist.conf. We need to prevent this from blacklisting “spi-bcm2708” as this is a dependency for fbtft. So type the following command in the terminal window.

File before editing:

Then change the file to look like this:

Save and exit nano using “ctrl+x” then press ‘y’. Next we need to edit /etc/modules. Before editing this file you need to know which TonTec display you have. There are currently 2 different models available. You can find this printed on the back of the LCD PCB.

  • WZ9486-Pi-EXT -> use name=tontec35_9486 for fbtft_device option
  • WZ9481-Pi-EXT -> use name=tontec35_9481 for the fctft_device option

File contents before editing:

Edit the file to look like this (remember to set the correct name=* option for your display. The rotate option can be 0, 90, 180 or 270. If not specified it will default to 0):

Once you have changed the file save and exit nano. Finally we will add a new parameter to /boot/cmdline.txt. This new option will tell the kernel to map the console output to frame buffer 1 (/dev/fb1).

File contents before editing:

Edit the file to look like this (remember that it one line and may be wrapper in your editor):

Ok you should now be able to test the changes. Save the file and exit nano. Then reboot the Raspberry Pi.

When the Raspberry Pi reboots you should now see the console messages being printed on the display.

Step 5 – Configure X to use /dev/fb1

In this step we will configure X to use /dev/fb1. First we need to install the frame buffer drivers for X.

Next we need to create a new config file for X.

Once nano has started enter the following details:

Save and exit nano (“ctrl+x” followed by ‘y’). Now try and start X using the following command:

Step 6 – Configure the touch screen drivers

Now you should have X running on your LCD. Next we will configure the ads7846 device. First we need to configure the ads7846 driver module. This is done using the ads7846_device helper module through the /etc/modules file. Open this file for editing using nano.

File contents before editing:

Change the file to look like this:

Once you have edited the file save and exit nano. Next you need to install some additional tools for accessing the touch screen from X. Issue the following command in the terminal window.

Finally you need to create a new touch screen calibration config file for X. Create the file with the following command:

Enter the following details into the file:

Save and exit nano. We now need to reboot the Raspberry Pi for the driver settings at the beginning of this step to take effect.

Once the Raspberry Pi has rebooted you can startx from the command line. The touch screen should now work as a mouse pointer.

Credits

  • Notro – for the excellent fbtft driver and providing pre-built kernels.
  • Greg – for the information related to X fbdev settings posted in the comments on my other page.
  • Minde – for the information related to X ADS7846 Touchscreen settings also posted in the comments on my other page.

Back up and running

About a year ago the server running my block suffered from a hard disk failure. I did not notice that my site was not up for at least another 6 months. By the time I did notice I contacted the hosts and they restored my site. Only the back up was very old and had none of my Raspberry Pi blog data. So a few more months have gone by I have finally got round to installing wordpress again.. Unfortunately all my old data is gone, sorry for any looking for my work on the EVE board. I will try and rewrite some of the info but this will not be as complete as before.

Up and coming will be some interesting info for anyone who owns a Tontec 3.5″ LCD Touch screen. Stay tuned.