Corsasri
Posts: 78
Joined: Sat Mar 07, 2015 9:40 am

Help installing a 2.2 ili9341 display

Fri May 29, 2015 6:26 am

I have wired my ili9341 display to my pi. And trying to get it to display my pi. But finding it hard to get it working. Is there a tutorial anywhere. An easy to follow one at that.
Need it to always use the tft display.

Thanks.
Last edited by Corsasri on Fri May 29, 2015 6:33 am, edited 1 time in total.

User avatar
DougieLawson
Posts: 34923
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Help installing a 2.2 ili9341 display

Fri May 29, 2015 6:31 am

Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a hippy & doctor free zone.

Corsasri
Posts: 78
Joined: Sat Mar 07, 2015 9:40 am

Re: Help installing a 2.2 ili9341 display

Fri May 29, 2015 6:40 am

Thanks for the link. But what bit on that page do I need to start from. As using the latest version of raspian and I have already updated my rpi.

Thanks.

User avatar
DougieLawson
Posts: 34923
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Help installing a 2.2 ili9341 display

Fri May 29, 2015 8:14 am

Corsasri wrote:Thanks for the link. But what bit on that page do I need to start from. As using the latest version of raspian and I have already updated my rpi.

Thanks.
Read the whole WiKi you'll learn how to get your display running by doing that.
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a hippy & doctor free zone.

Corsasri
Posts: 78
Joined: Sat Mar 07, 2015 9:40 am

Re: Help installing a 2.2 ili9341 display

Fri May 29, 2015 1:03 pm

I did read the link but it still dose not make any scene to me.

I started following this link step by step.
http://marcosgildavid.blogspot.co.uk/20 ... ng-on.html
typing this command powers up the screen (goes white) sudo modprobe fbtft_device custom name=fb_ili9341 gpios=reset:25,dc:24,led:18 speed=16000000 rotate=90 bgr=1
typing this comand dose nothing. con2fbmap 1 1
typing this gives me an error message. FRAMEBUFFER=/dev/fb1 startx

Code: Select all

X.Org X Server 1.12.4
Release Date: 2012-08-27
X Protocol Version 11, Revision 0
Build Operating System: Linux 3.2.0-2-mx5 armv7l Debian
Current Operating System: Linux raspberrypi 3.18.14+ #792 PREEMPT Sat May 23 15:53:19 BST 2015 armv6l
Kernel command line: dma.dmachans=0x7f35 bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2708.boardrev=0x12 bcm2708.serial=0x498b9bc8 smsc95xx.macaddr=B8:27:EB:8B:9B:C8 bcm2708_fb.fbswap=1 bcm2708.disk_led_gpio=47 bcm2708.disk_led_active_low=0 sdhci-bcm2708.emmc_clock_freq=250000000 vc_mem.mem_base=0xec00000 vc_mem.mem_size=0x10000000  dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait quiet
Build Date: 11 February 2015  09:31:17PM
xorg-server 2:1.12.4-6+deb7u6 (Julien Cristau <[email protected]>)
Current version of pixman: 0.33.1
        Before reporting problems, check http://wiki.x.org
        to make sure that you have the latest version.
Markers: (--) probed, (**) from config file, (==) default setting,
        (++) from command line, (!!) notice, (II) informational,
        (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/var/log/Xorg.0.log", Time: Fri May 29 13:02:23 2015
(==) Using system config directory "/usr/share/X11/xorg.conf.d"
FATAL: Module g2d_23 not found.

User avatar
AndyD
Posts: 2329
Joined: Sat Jan 21, 2012 8:13 am
Location: Melbourne, Australia
Contact: Website

Re: Help installing a 2.2 ili9341 display

Fri May 29, 2015 1:14 pm

Corsasri wrote:

Code: Select all

FATAL: Module g2d_23 not found.
Everyone gets that error! It is just misleading. See this thread.

User avatar
AndyD
Posts: 2329
Joined: Sat Jan 21, 2012 8:13 am
Location: Melbourne, Australia
Contact: Website

Re: Help installing a 2.2 ili9341 display

Fri May 29, 2015 1:18 pm

Corsasri wrote:typing this comand dose nothing. con2fbmap 1 1
If you screen is working, then this is a good test. As it does nothing, it would suggest that there is a problem. Have you wired up your display the same way as the tutorial?

User avatar
DougieLawson
Posts: 34923
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Help installing a 2.2 ili9341 display

Fri May 29, 2015 2:43 pm

What overlay have you defined in /boot/config.txt?

File: rpi-display-overlay.dtb
Info: RPi-Display - 2.8" Touch Display by Watterott
Load: dtoverlay=rpi-display,<param>=<val>
Params: speed Display SPI bus speed

rotate Display rotation {0,90,180,270}

fps Delay between frame updates

debug Debug output level {0-7}

xohms Touchpanel sensitivity (X-plate resistance)


That's the one I use.

When Raspbian boots there's a whole lot of fbtft messages from the kernel dmesg command which document the pins used that aren't just the SPI pins.
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a hippy & doctor free zone.

Corsasri
Posts: 78
Joined: Sat Mar 07, 2015 9:40 am

Re: Help installing a 2.2 ili9341 display

Fri May 29, 2015 7:31 pm

AndyD wrote:
Corsasri wrote:typing this comand dose nothing. con2fbmap 1 1
If you screen is working, then this is a good test. As it does nothing, it would suggest that there is a problem. Have you wired up your display the same way as the tutorial?
I believe I have wired it up correct as my GPIO cable came with numbers fitted to end. Used the pin pi numbered as below.
Display Pins on pi
VCC Pin 1
GND Pin 9
CS Pin 24
Reset pin 22
Dc/rs. Pin 18
Sd1/mosi pin 19
Sck. Pin 23
Led. Pin 12
Sd0/mis0 pin 21

I even have two screens and both only light up wite.

Corsasri
Posts: 78
Joined: Sat Mar 07, 2015 9:40 am

Re: Help installing a 2.2 ili9341 display

Fri May 29, 2015 7:34 pm

DougieLawson wrote:What overlay have you defined in /boot/config.txt?

File: rpi-display-overlay.dtb
Info: RPi-Display - 2.8" Touch Display by Watterott
Load: dtoverlay=rpi-display,<param>=<val>
Params: speed Display SPI bus speed

rotate Display rotation {0,90,180,270}

fps Delay between frame updates

debug Debug output level {0-7}

xohms Touchpanel sensitivity (X-plate resistance)


That's the one I use.

When Raspbian boots there's a whole lot of fbtft messages from the kernel dmesg command which document the pins used that aren't just the SPI pins.
I have not done any overlay. As I said I did get a bit lost with the link you supplied.

Corsasri
Posts: 78
Joined: Sat Mar 07, 2015 9:40 am

Re: Help installing a 2.2 ili9341 display

Fri May 29, 2015 7:41 pm

Corsasri wrote:I did read the link but it still dose not make any scene to me.

I started following this link step by step.
http://marcosgildavid.blogspot.co.uk/20 ... ng-on.html
typing this command powers up the screen (goes white) sudo modprobe fbtft_device custom name=fb_ili9341 gpios=reset:25,dc:24,led:18 speed=16000000 rotate=90 bgr=1
typing this comand dose nothing. con2fbmap 1 1
typing this gives me an error message. FRAMEBUFFER=/dev/fb1 startx

Code: Select all

X.Org X Server 1.12.4
Release Date: 2012-08-27
X Protocol Version 11, Revision 0
Build Operating System: Linux 3.2.0-2-mx5 armv7l Debian
Current Operating System: Linux raspberrypi 3.18.14+ #792 PREEMPT Sat May 23 15:53:19 BST 2015 armv6l
Kernel command line: dma.dmachans=0x7f35 bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2708.boardrev=0x12 bcm2708.serial=0x498b9bc8 smsc95xx.macaddr=B8:27:EB:8B:9B:C8 bcm2708_fb.fbswap=1 bcm2708.disk_led_gpio=47 bcm2708.disk_led_active_low=0 sdhci-bcm2708.emmc_clock_freq=250000000 vc_mem.mem_base=0xec00000 vc_mem.mem_size=0x10000000  dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait quiet
Build Date: 11 February 2015  09:31:17PM
xorg-server 2:1.12.4-6+deb7u6 (Julien Cristau <[email protected]>)
Current version of pixman: 0.33.1
        Before reporting problems, check http://wiki.x.org
        to make sure that you have the latest version.
Markers: (--) probed, (**) from config file, (==) default setting,
        (++) from command line, (!!) notice, (II) informational,
        (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/var/log/Xorg.0.log", Time: Fri May 29 13:02:23 2015
(==) Using system config directory "/usr/share/X11/xorg.conf.d"
FATAL: Module g2d_23 not found.
In this it dose say. FATAL: Module g2d_23 not found.

User avatar
DougieLawson
Posts: 34923
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Help installing a 2.2 ili9341 display

Fri May 29, 2015 9:05 pm

That
Module g2d_23 not found.
isn't a problem on any RPi. You can get rid of it by tweaking your X11 conf.d files.
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a hippy & doctor free zone.

phoenix127
Posts: 5
Joined: Wed Apr 24, 2013 9:08 pm

Re: Help installing a 2.2 ili9341 display

Thu Sep 22, 2016 2:20 pm

Background
I found that a lot of the information on small TFT screens has changed substantially in the last couple of years, so I'm posting this to help others that may end up struggling to install. This posting lists all the useful info I found in once place - both for getting the screens working and helping to work out where the problems are when it doesn't.

My display is an e-bay sourced TJCTM24028-SPI board, which has an ili9341 TFT driver, a 2.8 inch screen and an XP2046 touch interface. This connected to a Raspberry PI 3 running Raspbian Jessie 4.4.13-v7+ . It took me several days work to find the updated information and get it all working correctly. I learned a lot more about Linux. but it was heavy going - even with diagnostic tools like a scope and a logic analyser. I knew that the display worked as I already had them up and running on an Arduino.

Most of the info on the Internet is based on the fbtft (framebuffer for TFT) project which is located at https://github.com/notro/fbtft, however this project has stated since 2014 that its no longer maintained as its being transitioned into the Linux kernel. Lots has changed since then. For example /etc/modules is no longer the place to add any modules, this has been superseded by the overlays as part of Linux's move to systemd, so many articles you look at do not work any more and its hard to tell if the changes did anything without a lot more work..

Since fbtft is the source of much about TFT screens, many articles link back to fbtft, however there are some inaccuracies, for example the pin mappings and driver options are different now..

Note that all the following work was done from an SSH connection to the Pi, not a local keyboard/screen configuration.

Connecting up
The most useful change since fbtft is that the drivers can now be directly configured and no longer requires a custom kernel build, which is really good news as its a lot less faffing around, requires less skill and a lot less time to make it work.

The new drivers are overlays, which can be found in /boot/overlays. There is a README file that details the summary of each overlay, The overlay definition for this display type is called rpi-display.

To find out what the actual pin mappings are, we need to look in the /boot/overlay/rpi-display.dtbo, but this is compiled, so it needs decompiling to see the text. We can do this with the following command

Code: Select all

dtc -Idtb -Odts /boot/overlays/rpi-display.dtbo  | less
Refer to the [email protected] section for the panel and [email protected] section for the touch screen. You will see lines like

Code: Select all

pendown-gpio = <0xdeadbeef [b]0x19[/b] 0x0>
All pin numbers (shown in bold) are in hex, so need converting to decimal, which you can do with the following command. Change the “19” to the hex number you want to convert

Code: Select all

echo "ibase=16; 19" | bc
Its good to see that the old '80's funny hex numbers trend still continues today - DEADBEEF.

As you can see, the rpi-display overlay includes a definition for the ads7846 touch controller (with only a subset of options being configurable). This means that the separate ads7846 overlay is not required

From the above file and standard RPI documentation, the pinout is as follows :

Panel Pin, Function name, GPIO pin
T_IRQ Panel Touch Interrupt = GPIO25
T_DO Touch Data Out = GPIO09
T_DIN Touch Data In = GPIO10
T_CS Touch Chip Select = SPI_CE1_N
T_CLK Touch Clock = GPIO11
SDO (MISO) TFT Data Out SPI_MISO = GPIO09
LED Backlight GPIO18 -- see note
SCK TFT Clock SPI_CLK = GPIO11
SDI (MOSI) TFT Data In SPI_MOSI = GPIO10
D/C TFT Data / Command = GPIO24
RESET Reset = GPIO23
CS TFT Chip Select = SPI_CE0_N = GPIO08
GND Ground = GND
VCC 3V3 supply +3V3

The LED backlight can be driven direct from the +3V3 supply, but this means that the software can't save power and turn the panel off
Some sites recommend a 50 ohm resistor to current limit and protect GPIO18, but this was a little dim for my liking, so I drove mine through a couple of small transistors. An NPN transistor acts as an inverter and the PNP acts as the power feed for the LED. Virtually any junk-box transistors can be used since the currents involved are very low. I used a 2n2222 for the NPN and a 2n3904 for the PNP. The connections are as follows :

GPIO 18 -> 2K2 resistor -> NPN transistor base
NPN transistor Emitter -> Ground
NPN transistor Collector via 100K to +3v3
PNP transistor Emitter to +3V3
PNP transistor base to 100K resistor / NPN transistor collector
PNP transistor Collector to the LED pin on the panel.

This allows for the Pi to control the back light and prevents too much current being pulled from the RPI GPIO pin, which would damage it.

If the panel's LED is directly to 3v3, then this is the reason people report a white background and nothing else happening. The display goes black when the driver has successfully loaded and initialised the screen. If its driven by the GPIO or the transistors, then it powers on the back light during initialisation, so you don't get the initial white screen.

Configuration
The most useful and up-to-date site I found is http://lallafa.de/blog/2015/03/fbtft-se ... raspbian/.

Rather than paste that content here, I've extracted the key points, which are :

In /boot/config.txt, add in the following at the bottom.

Code: Select all

# TFT display and touch panel
#dtoverlay=rpi-display,rotate=0,speed=10000000,xohms=100,debug=4
dtoverlay=rpi-display
dtparam=rotate=0
dtparam=speed=10000000
dtparam=xohms=100
dtparam=debug=4
When editing the config.txt, be aware of the following limitations, which are detailed in the README file (/boot/overlays/README)
1. Command lines are limited to 80 characters only, hence the recommendation to use the dtparam format instead of the single command line.
2. If a single command line is used, it must be separated by commas between each parameter, otherwise all subsequent parameters are silently ignored ! I found this out the hard way.

Once you reboot, the panel will blink and go black after its set up. If your Pi is set up to go into the graphical screen on boot, you should see the familiar GUI, just on a smaller scale..

If you check for correct operation by looking at the output of "dmesg", you should see references to the two chips being detected (ili9341 and ads7846) you will also see the definition of frame buffer 1(fb1). fb0 is the onboard HDMI based frame buffer (display). Lastly by looking at the installed modules, you should see both chip names listed as loaded modules

Code: Select all

dmesg | less
ls /dev/fb*
lsmod
If you do not see fb1, then the drivers are not installed correctly, you may have a different type of display chip or a wiring problem. However if you see both devices present, then you are making progress. If you are having problems, then look at the dmesg output or the video core debugger - vcdbg

Code: Select all

vcdbg log msg
Apparently the following command puts console output on display 1, but this didn’t work for me.

Code: Select all

con2fbmap 1 1
Once this is all working, you can enable the boot messages to the TFT screen.
Change /boot/cmdline.txt to add the following to the end of the existing line

Code: Select all

fbcon=map:10 fbcon=font:VGA8x8 logo.nologo
When you reboot, you will see the normal raspberry Pi boot text, without the Raspberry Pi logo, due to the size of it vs the TFT screen..

At this point during initial testing, the display shows an X configuration screen but touch didn’t work for me, however an external mouse did. This was a cabling issue due to a change in rpi-display as compared to the previous fbtft libraries and documentation - resulting in the decompilation of the overlay files detailed previously as I looked to understand what the driver was actually doing, since the touch panel's CE pin was not doing anything.

Basic touch checks
The xinput and evtest tools are useful for testing the touch device's basic functionality, so install those.

Code: Select all

apt-get install xinput evtest 
evtest
Note that the touch devices generate device links in /dev/input. Touch generates event0 on my system but the 0 may be different on yours depending on other hardware (i.e. a USB mouse). Similarly, evtest doesn’t handle the situation where devices are added or removed, it can show device 0, yet the /dev/input/eventX device ID’s do not line up, hence the utility fails. Just reboot to correct this, or don’t unplug input devices whilst testing !

With evtest, select the touch screen ID (or mouse), you should get a set of events decoded on-screen as things occur. Note that not all of the 3 mouse event handles generate events. The largest number was the active mouse on my system. If you have not installed evtest, its possible to see the raw data by just doing

Code: Select all

cat /dev/input/event0
This generates binary data when you move the input device (touch or mouse). The lack of data implies a driver / connectivity issue.

You can check for the OS handling touch events (when you touch or move on the display). This is found by

Code: Select all

cat  /proc/interrupts
Look at the line which says ads7846 (the touch screen chip driver).
If you see zero in all the CPU core columns, then you have a wiring issue as no interrupts are being received by the OS. If you see numbers then the OS is seeing the events and handling them..

Now we can test basic event and display operation
First, install some more testing tools

Code: Select all

apt-get install tsconf 
A simple moving/Drawing test can be performed with:

Code: Select all

sudo TSLIB_FBDEVICE=/dev/fb1 TSLIB_TSDEVICE=/dev/input/event0 ts_test
A 5 crosshairs calibration can be performed with:

Code: Select all

sudo TSLIB_FBDEVICE=/dev/fb1 TSLIB_TSDEVICE=/dev/input/event0 ts_calibrate
To help with debugging of the X system, you may need to look at the /var/log/Xorg0.log and Xorg1.log files

Panel calibration
xinput-calibrator is the tool for configuring X, again this was not originally part of the base OS and required the following to download and compile it. This is no longer necessary, you can get it as an ordinary package with

Code: Select all

apt-get install xinput-calibrator
If you want to roll your own, then you can obtain it and build it with the following steps

Code: Select all

apt-get install x11proto-input-dev x11proto-input-dev libx11-dev libxi-dev libxext-dev
git clone https://github.com/tias/xinput_calibrator.git
cd xinput_calibrator
./autogen.sh
./configure
make
sudo make install
To calibrate the screen, run the following:

Code: Select all

FRAMEBUFFER=/dev/fb1 startx &
DISPLAY=:0.0 xinput_calibrator
Now all you need to do is to copy the output of this into usr/share/X11/xorg.conf.d/99-calib.conf

Now do a final reboot to activate the updated calibration data and you will have a working TFT panel and touch screen with all the orientations lined up on both of them.

borpin
Posts: 20
Joined: Sun Jul 19, 2015 12:51 pm

Re: Help installing a 2.2 ili9341 display

Fri May 19, 2017 4:38 pm

phoenix127 wrote:Background
Since fbtft is the source of much about TFT screens, many articles link back to fbtft, however there are some inaccuracies, for example the pin mappings and driver options are different now..
So this is brilliant; it is a shame it is hidden away!

{edit} I had a problem with the cross hairs disappearing when I tried ts_test. I discovered I needed to run ts_calibrate first then it worked fine.

On Adafruit https://learn.adafruit.com/adafruit-pit ... -calibrate They suggest creating a udev rule so the touch event does not move around. I think this is using the older method of modules rather than layers. Is there a way to do this using layers?

This has been so helpful :D :D

Brian

tony1812
Posts: 354
Joined: Sat Jul 15, 2017 12:40 pm
Location: Boston MA.

Re: Help installing a 2.2 ili9341 display

Mon Aug 07, 2017 4:34 pm

Hello phoenix127. I too just got a Pi with Raspbian Jessie installed, and I too eager to set up my 2.4" TFT display for it.

I have a few display like this but was for the Arduino. However wuth th proper wirings, I don't see why it can' t be used on Pi 3. My display looks exactly like ths one in attached pic:
display.jpg
display.jpg (8.7 KiB) Viewed 8231 times
Software part I followed your in instructions, havn't encountered any problem. but the wireling confuses me.
But the pin configuration is different. it only have these marked pins. So with a lot of uncertainties, I guessed few of them.
//View FROM BOOTOM FARESTEST FOR SD CARD HOLDER
Display Pins | GPIO
J1
SD_SCK -> 23
SD_D0 -> ????
SD_D1 -> ????
SD_SS -> ????
LCD_D1 -> ????
LCD_D0 -> ????
J2
LCD_D7 -> ????
LCD_D6 -> ????
LCD_D5 ->????
LCD_D4 -> ????
LCD_D3 -> ????
LCD_D2 -> ????
J3
3,3V
5V -> 4
GND -> 6
J4
LCD_RD -> ????
LCD_WR -> ????
LCD_RS -> 16
LCD_CS -> 18
LCD_RST -> 20
I skipped any touvh relaed connects to simplfie things. Just to get the display working for now. Any advice? Thanks.

Return to “Beginners”