Jump to content

Orange PI PC HDMI LCD MPI3508 Touchscreen SPI move CS from pin 24 to pin 22


Peter Gregory

Recommended Posts

15 часов назад, Peter Gregory сказал:

[    7.220557] ads7846 spi0.1: failed to request pendown GPIO
[    7.220570] ads7846: probe of spi0.1 failed with error -2

Will you be able to photograph a section of the printed circuit board. Where is the chip soldered and the tracks that are connected to the pins?

Link to comment
Share on other sites

The issue with pen down GPIO (PA10) is that the Orange PI PC dts is using it for the power pins:

        leds {

                compatible = "gpio-leds";

 

                pwr_led {

                        label = "orangepi:green:pwr";

                        gpios = <0x46 0x00 0x0a 0x00>;

                        default-state = "on";

                };

 

                status_led {

                        label = "orangepi:red:status";

                        gpios = <0x16 0x00 0x0f 0x00>;

                };

        };

 

I moved the GPIO to PC7 and got past the GPIO error.

 

I'm still getting SPI error -22.  I think there is something wrong with my 2nd SPI CS declaration.

Not much progress tonight.

Link to comment
Share on other sites

If I understood this code correctly,

drivers/input/touchscreen/ads7846.c#L985

which returns your error, it believes that the touch is not connected. This pin must be configured <1> gpio active low.
When the touch of the display is connected, there should be a voltage on the IRQ pin and when a touch occurs,

the touch lowers the voltage, thereby signaling an event.

 

Link to comment
Share on other sites

I made a rookie mistake - I connect MOSI -> MOSI and MISO -> MISO (input to input, output to output).  No wonder it would not work.

I corrected my wiring connections and updated my dts:

 

2.8 Inch TFT SPI 240x320, ads7846 Touch => Orange PI PC

 

1 - VCC                => (1)  3.3v
2 - GND              => (6)  GND
3 - CS                  => (24) PC3 SPI0 CS
4 - RESET           =>  (29) PA7 GPIO 21
5 - DC                 =>  (31) PA8 GPIO 22
6 - SDI (MOSI)   =>  (21) PC1 SPI0 MISO
7 - SCLK             => (23) PC2 SPI0 CLK
8 - LED               => (33) PA9 GPIO 23
9 - SDO (MISO) => (19) PC0 SPI0 MOSI
10 - T_CLK         => (23) PC2 SPI0 CLK *
11 - T_CS           => (26) PA21 GPIO 11
12 - T_DIN         => (21) PC1 SPI0 MISO *
13 - T_DO          => (19) PC0 SPI0 MOSI *
14 - T_IRQ         => (18) GPIO.5 PC7
 

 

/dts-v1/;
/plugin/;
/ {
	compatible = "allwinner,sun8i-h3";

	fragment@1 {
		target = <&pio>;
		__overlay__ {
			spi0_cs1_pin: spi0-cs1-pin {
				pins = "PA21";
				function = "gpio_out";
				output-high;
			};

			ili9341_rst: ili9341-rst {
				pins = "PA7";
				function = "gpio_out";
				output-high;
			};

			ili9341_dc: ili9341-dc {
				pins = "PA8";
				function = "gpio_out";
				output-high;
			};
		
			ili9341_led: ili9341-led {
				pins = "PA9";
				function = "gpio_out";
				output-high;
			};
		
			ads7846_pin: ads7846-pin {
				pins = "PC7";
				function = "gpio_in";
			};
		};
	};

	fragment@3 {
		target = <&pio>;
		__overlay__ {
			ili9341_pins: ili9341_pins {
				pins = "PA7", "PA8", "PA9"; /*RESET, DC_RS, LED*/
				function = "gpio_out", "gpio_out", "gpio_out" ;
			};
		};
	};
	fragment@4 {
		target = <&spi0>;
		__overlay__ {
			#address-cells = <1>;
			#size-cells = <0>;
			cs_gpios = <0>, <&spi0_cs1_pin>;
			pinctrl-0 = <&spi0_pins>;
			status = "okay";
			ili9341: ili9341@0 {
				compatible = "ilitek,ili9341";
				reg = <0>;
				pinctrl-names = "default";
				pinctrl-0 = <&ili9341_pins>;
				status = "okay";
				debug = <0>;
				rotate = <90>;
				bgr;
				fps = <10>;
				buswidth = <8>;
				regwidth = <16>;
				reset-gpios = <&pio 0 7 1>;
				dc-gpios = <&pio 0 8 0>;
				led-gpios = <&pio 0 9 0>;
				spi-max-frequency = <1000000>;
			};

			xpt2046: xpt2046@1 {
				compatible = "ti,ads7846";
				reg = <1>;
				pinctrl-names = "default";
				pinctrl-0 = <&spi0_cs1_pin>;
				interrupts = <&ads7846_pin>;
				interrupt-parent = <&pio>;
				pendown_gpio = <&ads7846_pin>;
				status = "okay";
				spi-max-frequency = <1000000>;
			        ti,keep-vref-on = <1>;
                                ti,x-min = /bits/ 16 <00>;
                                ti,x-max = /bits/ 16 <0xFFF>;
                                ti,y-min = /bits/ 16 <00>;
                                ti,y-max = /bits/ 16 <0xFFF>;
                                ti,x-plate-ohms = /bits/ 16 <60>;
                                ti,pressure-max = /bits/ 16 <255>;
                                ti,swap-xy = <0>;			
			};
		};
	};

};

 

Now, my display will light up on reboot but I still get no images and no activity.  I thought I could force an image on /dev/fb1 using the following command:
sudo fbi -vt 1 -noverbose -d /dev/fb1 /boot/boot.bmp

but the screen does not change.  When I got the fbtft_device working in the legacy kernel, the screen would blank after initialization, so something must still be wrong

 

 

Edited by Peter Gregory
Link to comment
Share on other sites

Finally some success!  My original wiring was correct.  MISO goes to MISO and MOSI goes to MOSI.  The problem was in my DTS.  This device has a 8 bit bus, not a 16 bit bus. I also ran into a problem that pin A21 would not follow the DTS and was active all the time - making the touch active and corrupting the SPI data.  I moved it to PC4.

Correct wiring:

 

2.8 Inch TFT SPI 240x320, ads7846 Touch

1 - VCC     (1)  3.3v
2 - GND     (6)  GND
3 - CS         (24) PC3 SPI0 CS
4 - RESET     (29) PA7 GPIO 21
5 - DC         (31) PA8 GPIO 22
6 - SDI (MOSI)    (19) PC0 SPI0 MOSI
7 - SCLK    (23) PC2 SPI0 CLK
8 - LED        (33) PA9 GPIO 23
9 - SDO (MISO)    (21) PC1 SPI0 MISO
10 - T_CLK      (23) PC2 SPI0 CLK *
11 - T_CS       (16) PC4 GPIO 4
12 - T_DIN     (19) PC0 SPI0 MOSI *
13 - T_DO   (21) PC1 SPI0 MISO *
14 - T_IRQ    (18) PC7 GPIO.5

 

Correct DTS for the display (still working on the touch controller...)

 

/dts-v1/;
/plugin/;
/ {
	compatible = "allwinner,sun8i-h3";

	fragment@1 {
		target = <&pio>;
		__overlay__ {
			spi0_cs1_pin: spi0-cs1-pin {
				pins = "PC4";
				function = "gpio_out";
				output-high;
			};

			ili9341_rst: ili9341-rst {
				pins = "PA7";
				function = "gpio_out";
				output-high;
			};

			ili9341_dc: ili9341-dc {
				pins = "PA8";
				function = "gpio_out";
				output-high;
			};
		
			ili9341_led: ili9341-led {
				pins = "PA9";
				function = "gpio_out";
				output-high;
			};
		
			ads7846_pin: ads7846-pin {
				pins = "PC7";
				function = "gpio_in";
			};
		};
	};

        fragment@2 {
                target = <&pio>;
                __overlay__ {
                        ads7846_pins: ads7846_pins {
                                pins = "PC4", "PC7"; /*SPI0.1 CS, PINDOWN*/
                                function = "gpio_out", "gpio_in" ;
                        };
                };
        };
	fragment@3 {
		target = <&pio>;
		__overlay__ {
			ili9341_pins: ili9341_pins {
				pins = "PA7", "PA8", "PA9"; /*RESET, DC_RS, LED*/
				function = "gpio_out", "gpio_out", "gpio_out" ;
			};
		};
	};
	fragment@4 {
		target = <&spi0>;
		__overlay__ {
			#address-cells = <1>;
			#size-cells = <0>;
			cs_gpios = <0>, <&pio 2 4 0>;
			pinctrl-0 = <&spi0_pins>;
			status = "okay";
			ili9341: ili9341@0 {
				compatible = "ilitek,ili9341";
				reg = <0>;
				pinctrl-names = "default";
				pinctrl-0 = <&ili9341_pins>;
				status = "okay";
				debug = <0>;
				rotate = <0>;
				bgr = <1>;
				fps = <10>;
				buswidth = <8>;
				regwidth = <8>;
				reset-gpios = <&pio 0 7 1>;
				dc-gpios = <&pio 0 8 0>;
				led-gpios = <&pio 0 9 0>;
				spi-max-frequency = <16000000>;
			};

			xpt2046: xpt2046@1 {
				compatible = "ti,ads7846";
				reg = <1>;
				pinctrl-names = "default";
				pinctrl-0 = <&ads7846_pin>;
				interrupts = <2 7 2>;
				interrupt-parent = <&pio>;
				pendown_gpio = <&pio 2 7 2>;
				status = "okay";
				spi-max-frequency = <10000000>;
			        ti,keep-vref-on = <1>;
                                ti,x-min = /bits/ 16 <00>;
                                ti,x-max = /bits/ 16 <0xFFF>;
                                ti,y-min = /bits/ 16 <00>;
                                ti,y-max = /bits/ 16 <0xFFF>;
                                ti,x-plate-ohms = /bits/ 16 <60>;
                                ti,pressure-max = /bits/ 16 <255>;
                                ti,swap-xy = <0>;			
			};
		};
	};

};

 

Steps to get the display up and running:

 

sudo nano /boot/armbianEnv.txt

 

disp_mode=720p60
user_overlays=touchscreen
extraargs=fbcon=map:1
 

nano touchscreen.dts

 

<insert DTS source from above>

 

sudo armbian-add-overlay touchscreen.dts
 

sudo nano /etc/modules-load.d/fbtft.conf

 

fbtft
fb_ili9341
 

sudo nano /usr/share/X11/xorg.conf.d/99-fbdev.conf

 

Section "Device"
  Identifier "myfb"
  Driver "fbdev"
  Option "fbdev" "/dev/fb1"
EndSection
 

 

reboot and your console / desktop will show in the LCD display

 

I'm still getting the error from the touch driver:

 

[    9.423938] SPI driver ads7846 has no spi_device_id for ti,tsc2046

[    9.423975] SPI driver ads7846 has no spi_device_id for ti,ads7843

[    9.423984] SPI driver ads7846 has no spi_device_id for ti,ads7845

[    9.423991] SPI driver ads7846 has no spi_device_id for ti,ads7873

[    9.424199] ads7846: probe of spi0.1 failed with error -22

 

I'm trying to find a DTS with a shared SPI instance (SPI0.0 and SPI0.1).  I'm pretty sure my setup for the second CS is causing the issue.

At least now the display works when it is fully wired up.

 

Edited by Peter Gregory
Link to comment
Share on other sites

25.09.2023 в 01:58, Peter Gregory сказал:

[    9.424199] ads7846: probe of spi0.1 failed with error -22

Look very carefully at fragments 1,2,3. It can be only one fragment0, which does not use the same pins (PA7 PC7) to describe different functions.

In a couple of days, my screen will reach the nearest post office.

I will be able to test it on a real stand and describe step by step how to connect three devices to one SPI.

Link to comment
Share on other sites

I'm getting closer - I finally got the touch and display to initialize.  The trick is determining which GPIO pins can be used and which support interrupts.

Here is the pinout and connection diagram I am using:

1 - VCC     (1)  3.3v
2 - GND     (6)  GND
3 - CS         (24) PC3 SPI0 CS
4 - RESET     (29) PA7 GPIO 21
5 - DC         (31) PA8 GPIO 22
6 - SDI (MOSI)    (19) PC0 SPI0 MOSI
7 - SCLK    (23) PC2 SPI0 CLK
8 - LED        (33) PA9 GPIO 23
9 - SDO (MISO)    (21) PC1 SPI0 MISO
10 - T_CLK      (23) PC2 SPI0 CLK *
11 - T_CS       (26) PC7 GPIO 5
12 - T_DIN    (19) PC0 SPI0 MOSI *
13 - T_DO    (21) PC1 SPI0 MISO *
14 - T_IRQ    (18) PA21 GPIO 11 (Supports interrupt)

 

DTS that is working

/dts-v1/;
/plugin/;

/ {
	compatible = "allwinner,sun8i-h3";

	fragment@0 {
		target = <&pio>;
		__overlay__ {
			spi0_cs1: spi0_cs1 {
				pins = "PC7"; 
				function = "gpio_out";
				output-high;
			};

			opiz_display_pins: opiz_display_pins {
				pins = "PA7", "PA8", "PA9";
				function = "gpio_out";
			};

			ads7846_pins: ads7846_pins {
				pins = "PA21";
				function = "irq";
			};
		};
	};

	fragment@1 {
		target = <&spi0>;
		__overlay__ {
			#address-cells = <1>;
			#size-cells = <0>;
			status = "okay";
			pinctrl-1 = <&spi0_cs1>;
			pinctrl-names = "default", "default";
			cs-gpios= <0>, <&pio 2 7 0>;

			opizdisplay: opiz-display@0 {
				reg = <0>; /* Chip Select 0 */
				compatible = "ilitek,ili9341";
				spi-max-frequency = <16000000>;
				status = "okay";
				pinctrl-names = "default";
				pinctrl-0 = <&opiz_display_pins>;
				rotate = <90>;
				bgr = <0>;
				fps = <10>;
				buswidth = <8>;
				dc-gpios = <&pio 0 8 0>;      /* PA8 */
				reset-gpios = <&pio 0 7 1 >; /* PA7 */
				led-gpios=<&pio 0 9 0>;      /*  PA9 */
				debug=<4>;                        
			};

			ads7846: ads7846@1 {
				reg = <1>; /* Chip Select 1 */
				compatible = "ti,ads7846";
				spi-max-frequency = <2000000>;
				status = "okay";
				pinctrl-names = "default";
				pinctrl-0 = <&ads7846_pins>;
				interrupt-parent = <&pio>;
				interrupts = <0 21 2>; /* PC7 IRQ_TYPE_EDGE_FALLING */
				pendown-gpio = <&pio 0 21 0>; /* PC7 */
				/* driver defaults, optional */
				ti,x-min = /bits/ 16 <0>;
				ti,y-min = /bits/ 16 <0>;
				ti,x-max = /bits/ 16 <0x0FFF>;
				ti,y-max = /bits/ 16 <0x0FFF>;
				ti,pressure-min = /bits/ 16 <0>;
				ti,pressure-max = /bits/ 16 <0xFFFF>;
				ti,x-plate-ohms = /bits/ 16 <400>;
			};

		};

	};

};


Using this configuration I get the following from dmesg:

 

[    6.231015] fbtft: module is from the staging directory, the quality is unknown, you have been warned.

[    6.234683] fb_ili9341: module is from the staging directory, the quality is unknown, you have been warned.

[    6.235590] systemd[1]: Mounting sys-fs-fuse-connections.mount - FUSE Control File System...

[    6.235823] fb_ili9341 spi0.0: fbtft_property_value: buswidth = 8

[    6.235857] fb_ili9341 spi0.0: fbtft_property_value: debug = 4

[    6.235870] fb_ili9341 spi0.0: fbtft_property_value: rotate = 90

[    6.235892] fb_ili9341 spi0.0: fbtft_property_value: fps = 10

[    6.573436] fb_ili9341 spi0.0: Display update: 1787 kB/s, fps=0

[    6.574355] Console: switching to colour frame buffer device 40x30

[    6.575115] graphics fb1: fb_ili9341 frame buffer, 320x240, 150 KiB video memory, 16 KiB buffer memory, fps=10, spi0.0 at 16 MHz

[    8.471370] SPI driver ads7846 has no spi_device_id for ti,tsc2046

[    8.471402] SPI driver ads7846 has no spi_device_id for ti,ads7843

[    8.471410] SPI driver ads7846 has no spi_device_id for ti,ads7845

[    8.471417] SPI driver ads7846 has no spi_device_id for ti,ads7873

[    8.471620] ads7846 spi0.1: setup mode 0, 8 bits/w, 2000000 Hz max --> 0

[    8.471794] ads7846 spi0.1: supply vcc not found, using dummy regulator

[    8.481255] systemd[1]: Finished systemd-binfmt.service - Set Up Additional Binary Formats.

[    8.486590] ads7846 spi0.1: touchscreen, irq 62

[    8.501181] input: ADS7846 Touchscreen as /devices/platform/soc/1c68000.spi/spi_master/spi0/spi0.1/input/input2

 

I try touching the screen, but I'm not set up to use the new touch device as the main input yet.

I think I'm very close to getting this display operational.

 

running everest I get the following:

everest

'No device specified, trying to scan all of /dev/input/event*

Not running as root, no devices may be available.

Available devices:

/dev/input/event0: gpio-keys

/dev/input/event1: sunxi-ir

/dev/input/event2: ADS7846 Touchscreen

/dev/input/event3: BRLTTY 6.5 Linux Screen Driver Keyboard

 

evtest --grab /dev/input/event2

Input driver version is 1.0.1

Input device ID: bus 0x1c vendor 0x0 product 0x1ea6 version 0x0

Input device name: "ADS7846 Touchscreen"

Supported events:

  Event type 0 (EV_SYN)

  Event type 1 (EV_KEY)

    Event code 330 (BTN_TOUCH)

  Event type 3 (EV_ABS)

    Event code 0 (ABS_X)

      Value      0

      Min        0

      Max     4095

    Event code 1 (ABS_Y)

      Value      0

      Min        0

      Max     4095

    Event code 24 (ABS_PRESSURE)

      Value      0

      Min        0

      Max    65535

Properties:

Testing ... (interrupt to exit)

Event: time 1695777743.332287, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 1

Event: time 1695777743.332287, type 3 (EV_ABS), code 0 (ABS_X), value 562

Event: time 1695777743.332287, type 3 (EV_ABS), code 1 (ABS_Y), value 2228

Event: time 1695777743.332287, type 3 (EV_ABS), code 24 (ABS_PRESSURE), value 64919

Event: time 1695777743.332287, -------------- SYN_REPORT ------------

Event: time 1695777743.340652, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 0

Event: time 1695777743.340652, type 3 (EV_ABS), code 24 (ABS_PRESSURE), value 0

Event: time 1695777743.340652, -------------- SYN_REPORT ------------

Event: time 1695777762.428725, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 1

Event: time 1695777762.428725, type 3 (EV_ABS), code 0 (ABS_X), value 21

Event: time 1695777762.428725, type 3 (EV_ABS), code 1 (ABS_Y), value 3185

Event: time 1695777762.428725, type 3 (EV_ABS), code 24 (ABS_PRESSURE), value 65502

Event: time 1695777762.428725, -------------- SYN_REPORT ------------

Event: time 1695777762.440670, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 0

Event: time 1695777762.440670, type 3 (EV_ABS), code 24 (ABS_PRESSURE), value 0

Event: time 1695777762.440670, -------------- SYN_REPORT ------------

 

I'm getting touch events.  I still need to find out how to set the touch device as the default pointer.

 

After testing and trying to get the touch working consistently I've come to the conclusion the interrupt is not working as expected.

I can hook my device up to a scope and every touch will cause a drop in the pen down pin, but I don't see a corresponding drop in CS1 pin to SPI activity to get the touch data.  Every now and then it will query the touch device in response to a touch event, but it does it only after repeated touch & move operations.  I don't see a way to turn on debugging for the touch module, so it is difficult to determine where the problem is.  Anyone else see this behavior?

Edited by Peter Gregory
Link to comment
Share on other sites

The LCD part is working well.  The touch part, not so well.  I try running evtest and selecting the touch device, but I don't see activity.

Connecting to the scope, I see the driver query the device and get data back, but I guess it is not decoding the results properly.

 

XP2046.png.a44f39d521480a18324eb4e29542ecb7.png

 

even with activity like listed above, it is not returning any results from evtest.

 

sudo evtest

No device specified, trying to scan all of /dev/input/event*

Available devices:

/dev/input/event0: gpio-keys

/dev/input/event1: ADS7846 Touchscreen

/dev/input/event2: sunxi-ir

/dev/input/event3: BRLTTY 6.5 Linux Screen Driver Keyboard

Select the device event number [0-3]: 1

Input driver version is 1.0.1

Input device ID: bus 0x1c vendor 0x0 product 0x1ea6 version 0x0

Input device name: "ADS7846 Touchscreen"

Supported events:

  Event type 0 (EV_SYN)

  Event type 1 (EV_KEY)

    Event code 330 (BTN_TOUCH)

  Event type 3 (EV_ABS)

    Event code 0 (ABS_X)

      Value      0

      Min        1

      Max    65535

    Event code 1 (ABS_Y)

      Value      0

      Min        1

      Max    65535

    Event code 24 (ABS_PRESSURE)

      Value      0

      Min        0

      Max      255

Properties:

Testing ... (interrupt to exit)

 

.... Crickets....

 

 

image.thumb.png.ac574e5f23495342fd2ec2892e747270.png

 

image.thumb.png.e12ce4d4be2f32c1f260dc35e97abafc.png

 

Does anyone have experience with the ads7843 driver interfacing with a XPT2046 chip?

Is there a magic configuration that makes it decode the data properly?  It looks like it should be valid to me.

 

Link to comment
Share on other sites

 

So, it is working!  It just wasn't working with my edge custom built image: Armbian_23.08.0-trunk_Orangepipc_bookworm_edge_6.5.5_minimal.img.

I reproduced my efforts on the latest armbian image Armbian_23.8.1_Orangepipc_bookworm_current_6.1.47.img and it is working as expected.

The display works and the touch events are working properly.  I changed my wiring to test swapping LCD and Touch.  Here is my working wiring chart:

1 - VCC     (1)  3.3v
2 - GND     (6)  GND
3 - CS         (24) PC3 SPI0 CS
4 - RESET     (26) PA21 GPIO 11
5 - DC         (31) PA8 GPIO 22
6 - SDI (MOSI)    (19) PC0 SPI0 MOSI
7 - SCLK    (23) PC2 SPI0 CLK
8 - LED        (33) PA9 GPIO 23
9 - SDO (MISO)    (21) PC1 SPI0 MISO
10 - T_CLK      (23) PC2 SPI0 CLK *
11 - T_CS       (18) PC7 GPIO 5
12 - T_DIN    (19) PC0 SPI0 MOSI *
13 - T_DO    (21) PC1 SPI0 MISO *
14 - T_IRQ    (29) PA7 GPIO 21
 

Here are steps to get the display working:

 

Install latest armbian image: Armbian_23.8.1_Orangepipc_bookworm_current_6.1.47.img

 

sudo armbian-config

 

enable desktop

 

sudo nano /boot/armbianEnv.txt

 

user_overlays=touchscreen
extraargs=fbcon=map:1
 

nano touchscreen.dts

 

/dts-v1/;
/plugin/;

/ {
	compatible = "allwinner,sun8i-h3";

	fragment@0 {
		target = <&pio>;
		__overlay__ {
			spi0_cs1: spi0_cs1 {
				pins = "PC7"; 
				function = "gpio_out";
				output-high;
			};

			opiz_display_pins: opiz_display_pins {
				pins = "PA21", "PA8", "PA9";
				function = "gpio_out";
			};

			ads7846_pins: ads7846_pins {
				pins = "PA7";
				function = "irq";
			};
		};
	};

	fragment@1 {
		target = <&spi0>;
		__overlay__ {
			#address-cells = <1>;
			#size-cells = <0>;
			status = "okay";
			pinctrl-1 = <&spi0_cs1>;
			pinctrl-names = "default", "default";
			cs-gpios= <0>, <&pio 2 7 0>; /* PC7 */

			ads7846: ads7846@1 {
				reg = <0>; /* Chip Select 0 */
				compatible = "ti,ads7846";
				spi-max-frequency = <500000>;
				status = "okay";
				pinctrl-names = "default";
				pinctrl-0 = <&ads7846_pins>;
				interrupt-parent = <&pio>;
				interrupts = <0 7 2>; /* PA7 IRQ_TYPE_EDGE_FALLING */
				pendown-gpio = <&pio 0 7 0>; /* PA7 */
				/* driver defaults, optional */
				ti,x-min = /bits/ 16 <0>;
				ti,y-min = /bits/ 16 <0>;
				ti,x-max = /bits/ 16 <0x0FFF>;
				ti,y-max = /bits/ 16 <0x0FFF>;
				ti,pressure-min = /bits/ 16 <0>;
				ti,pressure-max = /bits/ 16 <0xFFFF>;
				ti,x-plate-ohms = /bits/ 16 <400>;
			};

                        opizdisplay: opiz-display@0 {
                                reg = <1>; /* Chip Select 1 */
                                compatible = "ilitek,ili9341";
                                spi-max-frequency = <16000000>;
                                status = "okay";
                                pinctrl-names = "default";
                                pinctrl-0 = <&opiz_display_pins>;
                                rotate = <90>;
                                bgr = <0>;
                                fps = <10>;
                                buswidth = <8>;
                                dc-gpios = <&pio 0 8 0>;      /* PA8 */
                                reset-gpios = <&pio 0 21 1 >; /* PA21 */
                                led-gpios=<&pio 0 9 0>;      /*  PA9 */
                                debug=<0>;
                        };

		};

	};

};

 

sudo armbian-add-overlay touchscreen.dts

 

sudo nano /etc/modules-load.d/fbtft.conf

 

fbtft
fb_ili9341

 

sudo nano /usr/share/X11/xorg.conf.d/99-fbdev.conf

 

Section "Device"
  Identifier "myfb"
  Driver "fbdev"
  Option "fbdev" "/dev/fb1"
EndSection
 

reboot and your display and touch should work!

Edited by Peter Gregory
Answer to the question
Link to comment
Share on other sites

Thanks for sharing your journey. I've got to the exact same spot with the new kernel. SPI ADS7846 device connected and recognized with evtest, just no interrupt is trigger when pressing the screen. I am using a custom build of 6.6.12-current-sunxi. with all else being identical to my previous working build of 5.15.63. I compared the the output of gpioinfo and all the gpio connections seem to be configred correctly.


root@nanopiair:~# evtest
No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0:      ADS7846 Touchscreen
Select the device event number [0-0]: 0
Input driver version is 1.0.1
Input device ID: bus 0x1c vendor 0x0 product 0x1ea6 version 0x0
Input device name: "ADS7846 Touchscreen"
Supported events:
 Event type 0 (EV_SYN)
 Event type 1 (EV_KEY)
   Event code 330 (BTN_TOUCH)
 Event type 3 (EV_ABS)
   Event code 0 (ABS_X)
     Value      0
     Min      100
     Max     4095
   Event code 1 (ABS_Y)
     Value      0
     Min      100
     Max     4095
   Event code 24 (ABS_PRESSURE)
     Value      0
     Min        0
     Max     4095
Properties:
Testing ... (interrupt to exit)

 

 ..... more crickets
Perhaps an update in the kernel has broken something? Any tips would be great I've been stuck for a while on this one!

Link to comment
Share on other sites

On 9/30/2023 at 6:09 PM, Peter Gregory said:

So, it is working!  It just wasn't working with my edge custom built image: Armbian_23.08.0-trunk_Orangepipc_bookworm_edge_6.5.5_minimal.img.

Nice! I know this is an old post, but I have the same screen, MPI3508. I'm trying to get it to work on the Orange Pi Zero 3.

 

As far as I recall from looking at the pin diagrams, physically it should work. Software/drivers on the other hand I haven't had much luck with. Though until recently, as far as I'm able to understand anyway, SPI hasn't been working on the builds they've been working on for the OPiZ2/3 until recently.

 

Just curious though, in some places it seems like this, or similar displays can work without using the HDMI connection or am I misunderstanding? I guess similar screens may be capable of displaying images just using the 24-pin connector on the OrangePi, while others only use it for the touch interface.  

 

I'll look back over the steps you went through later and see if I can apply them to what I do know. Otherwise I'll look into what it takes to compile an image, and combine what you have, with what they've been doing to make Armbian work on the OPiZ2/3. 

Edited by Sma
Link to comment
Share on other sites

Finally getting around to testing your steps @Peter Gregory I did it once with a newer image, but wasn't sure which one. When it rebooted nothing happened on the mpi3508, or the monitor on HDMI. I'm about to run through the steps you documented and see what happens.

 

However, I haven't checked on the wiring. I'm using the OPiZ3, with that supposedly just hooking it up so that the ground and 3.3v pins are in the right places it's supposed to work, but I haven't checked the pinouts compared with what you have for your wiring. If this second round of setting up the OS doesn't work I'll have to look into the wiring. This might not be a bad thing, currently, the screen hangs off the side, due to how it has to be rotated. If I have to wire it to make it work, that may allow me to rotate it so it doesn't take up a bigger footprint.

Link to comment
Share on other sites

OK, so still at the nothing happens stage for me. Nothing on the HDMI or LCD. evtest comes back with 

 

/dev/input/event0:      DELL DELL USB Keyboard
/dev/input/event3:      BRLTTY 6.5 Linux Screen Driver Keyboard

 

Whatever that BRLTTY is (something to do with TTY service?), doesn't seem to be anything to do with the touch screen, as it doesn't show any input when I try it (though if the pins aren't right that could be it). gpioinfo for chip1 has 32 lines, I'm assuming that's where the GPIO would show up for the screen, but it says they're all unused.

Chip0 has 287 lines, most seem to be unnamed/unused (see bottom for examples). After dinner, I'll see if I can get the HDMI to come back. I guess the next step is to check the pinouts on my OPiZ3 compared with the screen and with the pinout above where it's said to have worked.

 

For reference, I'm using the latest image that @pixdrift provided in another thread (bookworm edge 6.7.4). However, I may try the previous one, as now that I look at it, the one I'm using now appears to have something to do with audio. Also, I went into Armbian config and turned on all the options for SPI and the TFT options as well. Maybe I'll go back and turn TFT off and run the command that added the DTS again. When I tried that it said it was already configured so might be interfering and not loading that DTS


     

  line  64:      unnamed       kernel   input  active-high [used]
        line  65:      unnamed       unused   input  active-high
        line  66:      unnamed       kernel   input  active-high [used]
        line  67:      unnamed       kernel   input  active-high [used]
        line  68:      unnamed       kernel   input  active-high [used]
        line  69:      unnamed       unused   input  active-high
        line  70:      unnamed       unused   input  active-high
        line  71:      unnamed       unused   input  active-high
        line  72:      unnamed       unused   input  active-high
        line  73:      unnamed  "interrupt"   input  active-high [used]
        line  74:      unnamed       unused   input  active-high
        line  75:      unnamed       unused   input  active-high
        line  76:      unnamed "red:status"  output  active-high [used]
        line  77:      unnamed "green:power" output active-high [used]
        line  78:      unnamed       unused   input  active-high
        line  79:      unnamed       unused   input  active-high
        line  80:      unnamed "regulator-usb1-vbus" output active-high [used]

         ...

        line 192:      unnamed       kernel   input  active-high [used]
        line 193:      unnamed       kernel   input  active-high [used]
        line 194:      unnamed       kernel   input  active-high [used]
        line 195:      unnamed       kernel   input  active-high [used]
        line 196:      unnamed       kernel   input  active-high [used]
        line 197:      unnamed       kernel   input  active-high [used]
        line 198:      unnamed       unused   input  active-high
        line 199:      unnamed       unused   input  active-high
        line 200:      unnamed       unused   input  active-high
        line 201:      unnamed       unused   input  active-high
        line 202:      unnamed       unused   input  active-high
        line 203:      unnamed       unused   input  active-high
        line 204:      unnamed       unused   input  active-high
        line 205:      unnamed       unused   input  active-high
        line 206:      unnamed       unused   input  active-high
        line 207:      unnamed       unused   input  active-high
        line 208:      unnamed       unused   input  active-high
        line 209:      unnamed       unused   input  active-high
        line 210:      unnamed      "reset"  output   active-low [used]

 

Link to comment
Share on other sites

Hmmmmm interesting. You are using ads7846 right? I'ved Confirmed the Linux 5.15.93-sunxi works, and the latest doesn't. If we could work backwards to different version of the kernel we might be able to find the offending code change.

Link to comment
Share on other sites

1 hour ago, Dandaman46 said:

Hmmmmm interesting. You are using ads7846 right? I'ved Confirmed the Linux 5.15.93-sunxi works, and the latest doesn't. If we could work backwards to different version of the kernel we might be able to find the offending code change.

To be honest, I'm not sure what ads7846 is.

 

This is the thread I've been following. They're been working on various Orange Pi Zero's. Most recently the Zero 2 and Zero 3. They have been working to get Armbian to work on the Zeros, and have gotten it working, and a few weeks ago were working on getting the SPI bus support going, which as far as I understand it is working now, but I'm not familiar with how that all works. Still learning a lot of how this works with armbian, and orange pi etc.

UPDATE

I noticed in the 99-fbdev.conf file it has  Option "fbdev" "/dev/fb1". FB as i understand is frame buffer. I had a look in /dev earlier and didn't see any /dev/fb0 or fb1. I did something that did show /dev/fb0, so i went back into that config file and changed it to fb0. After a reboot the desktop popped up on the HDMI output, so at least now I know how to get the HDMI back. I may have to dig into dmesg and see if there are any clues in there. 

Edited by Sma
Link to comment
Share on other sites

04.09.2023 в 21:01, going сказал:

Please extract it from the file system

dtc --sort -I fs -O dts  /sys/firmware/devicetree/base > cur-dts-out.txt

or from the existing dtb used and publish only two nodes pio and spi

For any image and for any board.


First you have to see the real picture. There is no point in jumping from one image or core to another.

Next, you change your dtb or make one correct dtb overlay.

It is necessary to check the file '/boot/ArmbianEnv'.

Nothing but your overlay should be loaded and the scp script should not be enabled.
If you are not sure, just post this file here.

Link to comment
Share on other sites

21 hours ago, Dandaman46 said:

@Sma ads7846 is a touch screen driver module

Ahhh gotcha. Maybe that's probably a step I'm missing. I'll look back through the thread for it.

 

 

Focusing on getting the LCD display to work first, I went to a different image, and went through the steps I previously did, but this time went through the steps on the lcd wiki to load the lcd driver (not the touch sensor yet). After reboot no real change. I checked Dmesg, and it does show the below, which is more than I got before (just the first line with the warning).

 

(This was the result of using an older DTS)

[    5.598832] fbtft: module is from the staging directory, the quality is unknown, you have been warned.
[    5.608672] systemd[1]: Mounting sys-fs-fuse-connections.mount - FUSE Control File System...
[    5.614293] systemd[1]: Finished systemd-remount-fs.service - Remount Root and Kernel File Systems.
[    5.615861] systemd[1]: systemd-pstore.service - Platform Persistent Storage Archival was skipped because of an unmet condition check (ConditionDirectoryNotEmpty=/sys/fs/pstore).
[    5.620811] systemd[1]: Starting systemd-random-seed.service - Load/Save Random Seed...
[    5.621197] fb_ili9341: module is from the staging directory, the quality is unknown, you have been warned.
[    5.621724] sun50i-h616-pinctrl 300b000.pinctrl: supply vcc-pa not found, using dummy regulator
[    5.622378] fb_ili9341 spi0.0: fbtft_property_value: regwidth = 8
[    5.622388] fb_ili9341 spi0.0: fbtft_property_value: buswidth = 8
[    5.622400] fb_ili9341 spi0.0: fbtft_property_value: debug = 0
[    5.622409] fb_ili9341 spi0.0: fbtft_property_value: rotate = 0
[    5.622419] fb_ili9341 spi0.0: fbtft_property_value: fps = 10
[    5.622583] sun50i-h616-pinctrl 300b000.pinctrl: pin PA7 already requested by spi0.0; cannot claim for 300b000.pinctrl:7
[    5.622595] sun50i-h616-pinctrl 300b000.pinctrl: error -EINVAL: pin-7 (300b000.pinctrl:7)
[    5.622610] fb_ili9341 spi0.0: error -EINVAL: Failed to request reset GPIO
[    5.622649] fb_ili9341: probe of spi0.0 failed with error -22

 

(This was the below is the newer DTS this reply of Peters) 

  

On 9/30/2023 at 6:09 PM, Peter Gregory said:

So, it is working!

 

[    5.550586] fbtft: module is from the staging directory, the quality is unknown, you have been warned.
[    5.560145] fb_ili9341: module is from the staging directory, the quality is unknown, you have been warned.

 

I noticed the difference between the older and newer DTS is pin assignments.

 

I just compared the pinouts for the MPI3508 and the Orange Pi Zero 3 and everything seems to match up with their labels, with the one exception, on my OPiZ3, SPI1/CS/PH9(pin 24) is one pin above the TP_CS pin (26) on the MPI3508.

I think another issue I'm having is the DTS that's been posted here is for the bigger Orange Pi, with the 40pin header, and my OPi has the 26pin header, which is the same count as that on the LCD. Because of that I probably need to rename/number something in the DTS, but I'm not sure what yet.

 

Edited by Sma
Update
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines