bellboy
Posts: 9
Joined: Mon Mar 29, 2021 7:44 pm

ili9341V touchscreen on rpi Zero W - help needed

Mon Mar 29, 2021 9:19 pm

Hello everybody,
this is my first post over here so please be patient with me :)

I think I need some help in order to get my 2.4 SPI display working with ili9341V drivers (the V at the end sounds creepy, I've only seen 9341 around....).
I am running 5.10 Kernel so, from what I read, all the needed drivers are already provided with pi os, therefore I am trying to do that by loading an overlay in order to set up the spi screen

What I did so far:

Hooking:

Rpi - display
3,3 V - VCC
GND - GND
GPIO 23 - RESET
GPIO 23 - DC
GPIO10 (MOSI) - SDI (MOSI)
GPIO 11 (CLK) - SCK
GPIO 18 - LED
GPIO 9 (MISO) - MISO


Writing the ili9341.dts file

Code: Select all

* Device Tree overlay for 2.2" ILI9341 Generic Display
 *
 */

/dts-v1/;
/plugin/;

/ {
	compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";

	fragment@0 {
		target = <&spi0>;
		__overlay__ {
			status = "okay";

			spidev@0{
				status = "disabled";
			};

			spidev@1{
				status = "disabled";
			};
		};
	};

	fragment@1 {
		target = <&gpio>;
		__overlay__ {
			rpi_display_pins: rpi_display_pins {
				brcm,pins = <18 23 24>;
				brcm,function = <1 1 1>; /* out out out in */
			};
		};
	};

	fragment@2 {
		target = <&spi0>;
		__overlay__ {
			/* needed to avoid dtc warning */
			#address-cells = <1>;
			#size-cells = <0>;

			rpidisplay: rpi-display@0{
				compatible = "ilitek,ili9341";
				reg = <0>;
				pinctrl-names = "default";
				pinctrl-0 = <&rpi_display_pins>;

				spi-max-frequency = <32000000>;
				rotate = <270>;
				bgr;
				fps = <30>;
				buswidth = <8>;
				reset-gpios = <&gpio 23 0>;
				dc-gpios = <&gpio 24 0>;
				led-gpios = <&gpio 18 1>;
				debug = <0>;
			};
		};
	};
	__overrides__ {
		speed =   <&rpidisplay>,"spi-max-frequency:0";
		rotate =  <&rpidisplay>,"rotate:0";
		fps =     <&rpidisplay>,"fps:0";
		debug =   <&rpidisplay>,"debug:0";
	};
};
- Creating the ili9341.dtb file with dtc packge
- Copy the dtb file into boot/overlays
- set dtparam=spi=on in boot/config.txt
- append dtoverlay=ili9341 line to config.txt
- add fbcon=map:10 to cmdline.txt

Still it doesn't work.

Any help would be much appreciated, I have been stuck on this for a bit not
Thanks

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 3776
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: ili9341V touchscreen on rpi Zero W - help needed

Wed Mar 31, 2021 3:52 pm

Use "sudo vcdbg log msg" to look for errors from the firmware associated with loading the overlay. Note that with "dtoverlay=ili9341" it will try to load "ili9341.dtbo".

Use "dmesg -l err", "dmesg | grep fb" or "dmesg | grep ili" to look for relevant messages from the kernel.

bellboy
Posts: 9
Joined: Mon Mar 29, 2021 7:44 pm

Re: ili9341V touchscreen on rpi Zero W - help needed

Wed Mar 31, 2021 6:58 pm

Hello PhilE,
first of all thanks for your reply. I stumbled upon vcdbl yesterday over the internet and in some way it helped me figure out that overlay was working actually. I also changed .dtb to .dtbo when compiling. At least it loads the terminal now, still haven't figured out of to load the gui but I guess I need to declare screen Height and Width somewhere in the overlay. Meanwhile I simplified (I am attaching that) the script which at firs I derived from another overlay I found online

Code: Select all

/* Device Tree overlay for 2.2" ILI9341 Generic Display
 *
 */

/dts-v1/;
/plugin/;

/ {
	compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";

	fragment@0 {
		target = <&spi0>;
		__overlay__ {
			status = "okay";
		};
	};
	
		
	fragment@1 {
		target = <&spidev0>;
		__overlay__ {
			status = "disabled";

		};
	};



    fragment@2 {
		target = <&gpio>;
		__overlay__ {
			rpi_display_pins: rpi_display_pins {
				brcm,pins = <18 23 24>;
				brcm,function = <1 1 1>; /* out out out in */
			};
		};
	};
	
	fragment@3 {
		target = <&spi0>;
		__overlay__ {
			/* needed to avoid dtc warning */
			#address-cells = <1>;
			#size-cells = <0>;
            status = "okay";

			rpidisplay: rpi-display@0{
				compatible = "ilitek,ili9341";
				reg = <0>;
				pinctrl-names = "default";
				pinctrl-0 = <&rpi_display_pins>;

				spi-max-frequency = <32000000>;
				rotate = <270>;
				bgr;
				fps = <30>;
				buswidth = <8>;
				reset-gpios = <&gpio 23 1>;
				dc-gpios = <&gpio 24 0>;
				led-gpios = <&gpio 18 1>;
				debug = <0>;
			};
		};
	};
	__overrides__ {
		speed =   <&rpidisplay>,"spi-max-frequency:0";
		rotate =  <&rpidisplay>,"rotate:0";
		fps =     <&rpidisplay>,"fps:0";
		debug =   <&rpidisplay>,"debug:0";
	};
};
What still does not really make sense to me is that I figured how to work it out by double checking the wiring. In fact, I did notice that the screen only works by hooking the led pin to the 3.3 V pin of the board instead of GPIO18. Shouldn't the overlay keep the pin state high without or should I activate the pull up resistor?

These are the outputs I am getting right now,

Code: Select all

pi@raspwzero:~ $ dmesg | grep ili
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 113680
[   28.534881] fb_ili9341: module is from the staging directory, the quality is unknown, you have been warned.
[   28.536105] fb_ili9341 spi0.0: fbtft_property_value: buswidth = 8
[   28.536152] fb_ili9341 spi0.0: fbtft_property_value: debug = 0
[   28.536181] fb_ili9341 spi0.0: fbtft_property_value: rotate = 270
[   28.536211] fb_ili9341 spi0.0: fbtft_property_value: fps = 30
[   30.121192] graphics fb1: fb_ili9341 frame buffer, 320x240, 150 KiB video memory, 16 KiB buffer memory, fps=33, spi0.0 at 32 MHz
and

Code: Select all

pi@raspwzero:~ $ sudo vcdbg log msg
001304.064: brfs: File read: /mfs/sd/config.txt
001304.934: brfs: File read: 1820 bytes
001357.052: HDMI0:EDID error reading EDID block 0 attempt 0
001358.317: HDMI0:EDID error reading EDID block 0 attempt 1
001359.584: HDMI0:EDID error reading EDID block 0 attempt 2
001360.847: HDMI0:EDID error reading EDID block 0 attempt 3
001362.114: HDMI0:EDID error reading EDID block 0 attempt 4
001363.378: HDMI0:EDID error reading EDID block 0 attempt 5
001364.644: HDMI0:EDID error reading EDID block 0 attempt 6
001365.908: HDMI0:EDID error reading EDID block 0 attempt 7
001367.174: HDMI0:EDID error reading EDID block 0 attempt 8
001368.438: HDMI0:EDID error reading EDID block 0 attempt 9
001369.462: HDMI0:EDID giving up on reading EDID block 0
001371.724: brfs: File read: /mfs/sd/config.txt
001372.488: gpioman: gpioman_get_pin_num: pin LEDS_PWR_OK not defined
001392.292: brfs: File read: 1820 bytes
001569.608: gpioman: gpioman_get_pin_num: pin LEDS_PWR_OK not defined
001569.661: *** Restart logging
001570.385: hdmi: HDMI0:EDID error reading EDID block 0 attempt 0
001571.655: hdmi: HDMI0:EDID error reading EDID block 0 attempt 1
001572.922: hdmi: HDMI0:EDID error reading EDID block 0 attempt 2
001574.192: hdmi: HDMI0:EDID error reading EDID block 0 attempt 3
001575.460: hdmi: HDMI0:EDID error reading EDID block 0 attempt 4
001576.730: hdmi: HDMI0:EDID error reading EDID block 0 attempt 5
001577.997: hdmi: HDMI0:EDID error reading EDID block 0 attempt 6
001579.267: hdmi: HDMI0:EDID error reading EDID block 0 attempt 7
001580.535: hdmi: HDMI0:EDID error reading EDID block 0 attempt 8
001581.805: hdmi: HDMI0:EDID error reading EDID block 0 attempt 9
001582.832: hdmi: HDMI0:EDID giving up on reading EDID block 0
001583.165: hdmi: HDMI0:EDID error reading EDID block 0 attempt 0
001584.434: hdmi: HDMI0:EDID error reading EDID block 0 attempt 1
001585.701: hdmi: HDMI0:EDID error reading EDID block 0 attempt 2
001586.970: hdmi: HDMI0:EDID error reading EDID block 0 attempt 3
001588.238: hdmi: HDMI0:EDID error reading EDID block 0 attempt 4
001589.507: hdmi: HDMI0:EDID error reading EDID block 0 attempt 5
001590.774: hdmi: HDMI0:EDID error reading EDID block 0 attempt 6
001592.043: hdmi: HDMI0:EDID error reading EDID block 0 attempt 7
001593.312: hdmi: HDMI0:EDID error reading EDID block 0 attempt 8
001594.581: hdmi: HDMI0:EDID error reading EDID block 0 attempt 9
001595.606: hdmi: HDMI0:EDID giving up on reading EDID block 0
001595.651: hdmi: HDMI:hdmi_get_state is deprecated, use hdmi_get_display_state instead
001595.674: HDMI0: hdmi_pixel_encoding: 162000000
001595.921: vec: vec_middleware_power_on: vec_base: 0x7e806000 rev-id 0x00002708 @ vec: 0x7e806100 @ 0x00000420 enc: 0x7e806060 @ 0x00000220 cgmsae: 0x7e80605c @ 0x00000000
001601.423: dtb_file 'bcm2708-rpi-zero-w.dtb'
001605.181: brfs: File read: /mfs/sd/bcm2708-rpi-zero-w.dtb
001605.204: Loading 'bcm2708-rpi-zero-w.dtb' to 0x100 size 0x67b1
001617.854: brfs: File read: 26545 bytes
001626.921: brfs: File read: /mfs/sd/overlays/overlay_map.dtb
001692.923: brfs: File read: 1559 bytes
001695.542: brfs: File read: /mfs/sd/config.txt
001695.875: dtparam: i2c_arm=off
001703.923: dtparam: spi=on
001711.073: dtparam: audio=on
001721.568: brfs: File read: 1820 bytes
001724.725: brfs: File read: /mfs/sd/overlays/ili9341.dtbo
001736.548: Loaded overlay 'ili9341'
001780.702: brfs: File read: 1819 bytes
001781.893: brfs: File read: /mfs/sd/cmdline.txt
001781.937: Read command line from file 'cmdline.txt':
001781.962: 'console=serial0,115200 console=tty1 root=PARTUUID=3b4ab80f-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles fbcon=map:10'
003525.513: gpioman: gpioman_get_pin_num: pin EMMC_ENABLE not defined
003547.111: brfs: File read: 179 bytes
003944.306: brfs: File read: /mfs/sd/kernel.img
003944.328: Loading 'kernel.img' to 0x8000 size 0x5b5570
003944.361: Device tree loaded to 0x1bfe9200 (size 0x6db2)
003960.882: gpioman: gpioman_get_pin_num: pin SDCARD_CONTROL_POWER not defined
008259.986: vchiq_core: vchiq_init_state: slot_zero = 0x97d80000, is_master = 1
Am I doing something wrong with GPIO 18?
I'll try to set up touch control meanwhile.
Thanks

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 3776
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: ili9341V touchscreen on rpi Zero W - help needed

Wed Mar 31, 2021 7:17 pm

Use "raspi-gpio get 18" to find out the state of the LED GPIO - it should be an output with level=1.

Oh, this looks wrong:

Code: Select all

				led-gpios = <&gpio 18 1>;
The "1" after the GPIO number is a "flags" field, where 1 means active-low - not what you want for the backlight where 1 means on. Change that to a 0 and try again.

bellboy
Posts: 9
Joined: Mon Mar 29, 2021 7:44 pm

Re: ili9341V touchscreen on rpi Zero W - help needed

Wed Mar 31, 2021 8:22 pm

I'll give that a shot thanks a lot! I assume I assumed the sintax for GPIO to be the other way round (just like as coding).

Do you have any hint for the reason why when I set the the boot process to CLI in config.txt the display would correctly show the CLI while when setting the boot to gui it does show the boot message, then stops on black screen with a single underscore character on the display but still I can connect to the Py via VNC with my desktop computer and notice that the GUI is correctly loaded instead.
Shall I integrate the cmdline.txt file other than fbcon=10?

Thanks a lot

bellboy
Posts: 9
Joined: Mon Mar 29, 2021 7:44 pm

Re: ili9341V touchscreen on rpi Zero W - help needed

Fri Apr 02, 2021 6:12 pm

Still did not manage on how to load the GUI in the TFT. It does work if i set to load the CLI using sudo raspi-config but then, when i change the setting and try to load the gui, i see i displays messages during the boot process but then i get an underscore on the top left and that's it.
I tried to teak things and setup a config file in the X11 folder but still it does not work.

Thanks for any help, I am clueless right now

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 3776
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: ili9341V touchscreen on rpi Zero W - help needed

Fri Apr 02, 2021 8:08 pm

I have used fbcp to put the GUI on a secondary display by copying from fb0 to fb1, but other methods may exist.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 10840
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: ili9341V touchscreen on rpi Zero W - help needed

Fri Apr 02, 2021 9:10 pm

If you use the tiny DRM driver for ILI9341 instead of the fbtft one, then it shows up as a separate DRM device, and Xserver will happily extend the desktop over it and any other DRM displays. I went through that on viewtopic.php?f=63&t=306624, but haven't created the PR as yet.

Don't ask me why there are two different tiny driver for ILI9341 - mi0283qt and ili9341. For my display it's the mi0283qt driver that is needed.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

bellboy
Posts: 9
Joined: Mon Mar 29, 2021 7:44 pm

Re: ili9341V touchscreen on rpi Zero W - help needed

Sat Apr 03, 2021 8:54 pm

Thanks to both of you, but still no luck.

Though xrandr --listproviders oututs "Can't open display",
I also tried the other driversggested in 6by9's thread (which i stumbled into during the past days), it does tun the screen on like ili9341 overlay but it only works if i set to run the CLI in raspi config

When I try to ssh the Frame Buffer Output to fb1 I first of all get this message if running without sudo

Code: Select all

pi@raspwzero:~ $ FRAMEBUFFER=/dev/fb1 startx
xauth:  timeout in locking authority file /home/pi/.Xauthority
^C^X^C

X.Org X Server 1.20.4
X Protocol Version 11, Revision 0
Build Operating System: Linux 5.4.0-54-generic armv8l Raspbian
Current Operating System: Linux raspwzero 5.10.17+ #1403 Mon Feb 22 11:26:13 GMT 2021 armv6l
Kernel command line: coherent_pool=1M 8250.nr_uarts=0 snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1 bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2708_fb.fbswap=1 smsc95xx.macaddr=B8:27:EB:5A:90:A1 vc_mem.mem_base=0x1ec00000 vc_mem.mem_size=0x20000000  console=ttyS0,115200 console=tty1 root=PARTUUID=e5f6aa10-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait fbcon=map:10 fbcon=font:VGA8x8 quiet splash plymouth.ignore-serial-consoles
Build Date: 15 January 2021  02:03:57PM
xorg-server 2:1.20.4-1+rpt2+deb10u3 (https://www.debian.org/support) 
Current version of pixman: 0.36.0
	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: "/home/pi/.local/share/xorg/Xorg.2.log", Time: Sat Apr  3 20:46:39 2021
(==) Using system config directory "/usr/share/X11/xorg.conf.d"
(EE) 
Fatal server error:
(EE) parse_vt_settings: Cannot open /dev/tty0 (Permission denied)
(EE) 
(EE) 
Please consult the The X.Org Foundation support 
	 at http://wiki.x.org
 for help. 
(EE) Please also check the log file at "/home/pi/.local/share/xorg/Xorg.2.log" for additional information.
(EE) 
(EE) Server terminated with error (1). Closing log file.
xinit: giving up
xinit: unable to connect to X server: Connection refused
xinit: server error
And then with sudo

Code: Select all


pi@raspwzero:~ $ FRAMEBUFFER=/dev/fb1 startx
xauth:  timeout in locking authority file /home/pi/.Xauthority
^C^X^C

X.Org X Server 1.20.4
X Protocol Version 11, Revision 0
Build Operating System: Linux 5.4.0-54-generic armv8l Raspbian
Current Operating System: Linux raspwzero 5.10.17+ #1403 Mon Feb 22 11:26:13 GMT 2021 armv6l
Kernel command line: coherent_pool=1M 8250.nr_uarts=0 snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1 bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2708_fb.fbswap=1 smsc95xx.macaddr=B8:27:EB:5A:90:A1 vc_mem.mem_base=0x1ec00000 vc_mem.mem_size=0x20000000  console=ttyS0,115200 console=tty1 root=PARTUUID=e5f6aa10-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait fbcon=map:10 fbcon=font:VGA8x8 quiet splash plymouth.ignore-serial-consoles
Build Date: 15 January 2021  02:03:57PM
xorg-server 2:1.20.4-1+rpt2+deb10u3 (https://www.debian.org/support) 
Current version of pixman: 0.36.0
	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: "/home/pi/.local/share/xorg/Xorg.2.log", Time: Sat Apr  3 20:46:39 2021
(==) Using system config directory "/usr/share/X11/xorg.conf.d"
(EE) 
Fatal server error:
(EE) parse_vt_settings: Cannot open /dev/tty0 (Permission denied)
(EE) 
(EE) 
Please consult the The X.Org Foundation support 
	 at http://wiki.x.org
 for help. 
(EE) Please also check the log file at "/home/pi/.local/share/xorg/Xorg.2.log" for additional information.
(EE) 
(EE) Server terminated with error (1). Closing log file.
xinit: giving up
xinit: unable to connect to X server: Connection refused
xinit: server error
one thing to mention is that i can see from the command line that the spi screen should be tty1 instead of tty0, and more important, when i ssh this command then it loads the GUi on my desktop's VNC viewer but not on the display :?: :?: which keeps displayin the command line with the login row

Anyway, both the framebuffer seem to be active
pi@raspwzero:~ $ ls /dev/fb*
/dev/fb0 /dev/fb1
I have used fbcp to put the GUI on a secondary display by copying from fb0 to fb1, but other methods may exist.
You mean this https://github.com/tasanakorn/rpi-fbcp program?

Finally I tried to write a config file to be placed in X11 folder but it doen's even seem to be parsed at boot :shock: and I don't know why

Basically it can run cli with both drivers but when it comes to load the GUI i'm still stuck

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 10840
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: ili9341V touchscreen on rpi Zero W - help needed

Mon Apr 05, 2021 8:55 am

Ah, apologies, I'd missed you were on a Pi0. vc4-kms-v3d is likely to be too slow and memory intensive on that to be usable, and that is the configuration that makes using the DRM driver for ili9341 useful as X handles multiple DRM devices quite happily for extending and cloning desktops across them.
One of the framebuffer copying solutions is likely to be the better solution on a 0.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

bellboy
Posts: 9
Joined: Mon Mar 29, 2021 7:44 pm

Re: ili9341V touchscreen on rpi Zero W - help needed

Tue Apr 06, 2021 10:52 am

Thanks for your reply. Actually the vc4 line in my config file Is commented, i would not bother to uncomment that given Tour suggestion. What Is my best option now for copying the framebuffer? Using that tasanakorn GitHub?
Thanks

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 3776
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: ili9341V touchscreen on rpi Zero W - help needed

Tue Apr 06, 2021 1:55 pm

Yes, although I used the AdaFruit fork (https://github.com/adafruit/rpi-fbcp) which has a few modifications.

bellboy
Posts: 9
Joined: Mon Mar 29, 2021 7:44 pm

Re: ili9341V touchscreen on rpi Zero W - help needed

Tue Apr 06, 2021 7:01 pm

Thank you very much!
I'll give that a try, what is not really clear to me is wheter it should be used in combination with the overlay as fbcp only manages the fb mirroring or if it has built in drivers for the display therefore I will need to disable the pi os drivers used in my overlay, hence the overlay itself
Thanks

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 3776
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: ili9341V touchscreen on rpi Zero W - help needed

Tue Apr 06, 2021 7:27 pm

Add the README says:
This program [is] used [to] copy [the] primary framebuffer to [a] secondary framebuffer (eg. FBTFT).
Without your driver there will be no secondary framebuffer to copy, so you need both.

bellboy
Posts: 9
Joined: Mon Mar 29, 2021 7:44 pm

Re: ili9341V touchscreen on rpi Zero W - help needed

Wed Apr 07, 2021 9:51 pm

Sorted! got it working. Thank you very much for your patience :)

Next step is going to be get the touchscreen working

bellboy
Posts: 9
Joined: Mon Mar 29, 2021 7:44 pm

Re: ili9341V touchscreen on rpi Zero W - help needed

Sat Apr 10, 2021 12:54 pm

Still some help needed.
I haven't found a way on how to have the touch control working yet.
I integrated my overlay this way, as a variation of the Original Watterot Display.

Removed the old GPIO 18 line as i am wiring the led pin of the screen directly to the 3.3 V pin of the PiZero.

5 wirings added fo ts control

T_IRQ --> GPIO 25
T_DO --> GPIO 9 MISO (also the other MISO pin of the screen is attached to this Pin)
T_DIN --> GPIO 10 MOSI (also the other MOSI pin of the screen is attached to this Pin)
T_CS --> GPIO 7 (for chip selection)
T_CLK --> GPIO 11(also the SCK pin of the screen is attached to this pin).

Code: Select all

/*
 * Device Tree overlay for rpi-display by Watterott
 *
 */

/dts-v1/;
/plugin/;

/ {
	compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";

	fragment@0 {
		target = <&spi0>;
		__overlay__ {
			status = "okay";
		};
	};
	
		
	fragment@1 {
		target = <&spidev0>;
		__overlay__ {
			status = "disabled";

		};
	};
	
	fragment@2 {
		target = <&spidev1>;
		__overlay__ {
			status = "disabled";

		};
	};

	fragment@3 {
		target = <&gpio>;
		__overlay__ {
			rpi_display_pins: rpi_display_pins {
				brcm,pins = <23 24 25>;
				brcm,function = < 1 1 0>; /* out out out in */
			};
		};
	};

	fragment@4 {
		target = <&spi0>;
		__overlay__ {
			/* needed to avoid dtc warning */
			#address-cells = <1>;
			#size-cells = <0>;

			rpidisplay: rpi-display@0{
				compatible = "ilitek,ili9341";
				reg = <0>;
				pinctrl-names = "default";
				pinctrl-0 = <&rpi_display_pins>;

				spi-max-frequency = <32000000>;
				rotate = <270>;
				bgr;
				fps = <30>;
				buswidth = <8>;
				reset-gpios = <&gpio 23 1>;
				dc-gpios = <&gpio 24 0>;
				
				debug = <0>;
			};

			rpi-display-ts@1 {
				compatible = "ti,ads7846";
				reg = <1>;

				spi-max-frequency = <2000000>;
				interrupts = <25 2>; /* high-to-low edge triggered */
				interrupt-parent = <&gpio>;
				pendown-gpio = <&gpio 25 0>;
				ti,x-plate-ohms = /bits/ 16 <60>;
				ti,pressure-max = /bits/ 16 <255>;
			};
		};
	};
	__overrides__ {
		speed =   <&rpidisplay>,"spi-max-frequency:0";
		rotate =  <&rpidisplay>,"rotate:0";
		fps =     <&rpidisplay>,"fps:0";
		debug =   <&rpidisplay>,"debug:0";
	};
};

I plan to both control tft and touch screen using SPI 0, that's why some pins are shared.

Any help would be really appreciated as I am clearly missing something here, in this case I only get a blank screen, whereas using the old overlay works, but without touch control of course.
Thanks

Return to “Device Tree”