robertoj Posted September 16 Posted September 16 I tried all weekend to add the touch function of the LCD's XPT2046 With this DTS: Spoiler /dts-v1/; /plugin/; / { compatible = "allwinner,sun8i-h3"; fragment@0 { target = <&pio>; __overlay__ { display_pins: display_pins { pins = "PC4", "PA2"; /*reset,dc*/ function = "gpio_out", "gpio_out"; }; ads7846_pins: ads7846_pins { pins = "PA19"; /*irq*/ function = "irq"; }; spi0_cs0: spi0_cs0 { pins = "PC3"; function = "gpio_out"; output-high; }; spi0_cs1: spi0_cs1 { pins = "PC7"; function = "gpio_out"; output-high; }; }; }; /*closing of fragment@0*/ fragment@1 { target = <&spi0>; __overlay__ { pinctrl-names = "default", "default"; pinctrl-1 = <&spi0_cs1>; cs-gpios = <0>, <&pio 2 7 0>; /* PC7 */ }; }; /*closing of fragment@1*/ fragment@2 { target = <&spi0>; __overlay__ { /* needed to avoid dtc warning */ #address-cells = <1>; #size-cells = <0>; status="okay"; pinctrl-names = "default", "default"; /*added by ryjelsum*/ cs-gpios = <&pio 2 3 0>, <&pio 2 7 0>; /* cs0=C3,cs1=C7 */ #num-chipselects = <2>; /*deleted by ryjelsum*/ display: display@0 { /*compatible = "ilitek,ili9341";*/ compatible = "adafruit,yx240qv29", "ilitek,ili9341"; reg = <0>; pinctrl-names = "default"; pinctrl-0 = <&display_pins>; pinctrl-1 = <&spi1_cs0>; /*added by ryjelsum*/ spi-max-frequency = <24000000>; status="okay"; /*added by ryjelsum*/ rotation= <90>; bgr = <0>; fps = <15>; buswidth = <8>; height = <320>; width = <240>; reset-gpios = <&pio 2 4 0>; /* C4,GPIO 24 polarity 0 for adafruit */ dc-gpios = <&pio 0 2 0>; /* A2,GPIO 25 */ debug = <3>; }; ads7846: ads7846@1 { /*this whole block added by ryjelsum*/ reg = <1>; /* Chip Select 1 */ compatible = "ti,ads7846"; spi-max-frequency = <1000000>; status = "okay"; pinctrl-2=<&spi0_cs1 &spi0_cs1>; pinctrl-names = "default"; pinctrl-3 = <&ads7846_pins>; interrupt-parent = <&pio>; interrupts = <0 19 2>; /* PA19 IRQ_TYPE_EDGE_FALLING */ pendown-gpio = <&pio 0 19 0>; /* PA19 */ /* 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>; }; }; }; /*closing of fragment@2*/ __overrides__ { rotation = <&display>, "rotation:0"; fps = <&display>, "fps:0"; debug = <&display>, "debug:0"; }; /* closing of overrides */ }; It gets compiled, but the bootloader rejects it: Applying user provided DT overlay ili9341-touch-sp0.dtbo failed on fdt_overlay_apply(): FDT_ERR_NOT_FOUND Error applying DT overlays, restoring original DT (i included the spi-add-cs1.dtbo as suggested in https://ryjelsum.me/homelab/xpt2046-ili9341-opi-zero/ ) 0 Quote
Ryzer Posted September 16 Posted September 16 Hi robertoj, I can see some lines that look problematic. Firstly you are defining cs-gpio twice. Once here: 5 hours ago, robertoj said: fragment@1 { target = <&spi0>; __overlay__ { pinctrl-names = "default", "default"; pinctrl-1 = <&spi0_cs1>; cs-gpios = <0>, <&pio 2 7 0>; /* PC7 */ }; Note - Remember that 0 refers to the native cs line (PC3) 5 hours ago, robertoj said: fragment@2 { target = <&spi0>; __overlay__ { /* needed to avoid dtc warning */ #address-cells = <1>; #size-cells = <0>; status="okay"; pinctrl-names = "default", "default"; /*added by ryjelsum*/ cs-gpios = <&pio 2 3 0>, <&pio 2 7 0>; /* cs0=C3,cs1=C7 */ Here the pinctrl references are wrong. I am not sure how strictly the ordering matters but for clarity 'pinctrl-names' should be before the actual pin control nodes. 5 hours ago, robertoj said: pinctrl-2=<&spi0_cs1 &spi0_cs1>; pinctrl-names = "default"; pinctrl-3 = <&ads7846_pins>; Adding spi-add-cs1.dtbo is not needed as all it does it defined the pins to use as cs lines which you have already done above anyway. My other suggestion would be to look into what the latest bindings should for the ads7846 touch controller. Let me know how you get on with following overlay: Spoiler /dts-v1/; /plugin/; / { compatible = "allwinner,sun8i-h3"; fragment@0 { target = <&pio>; __overlay__ { display_pins: display_pins { pins = "PC4", "PA2"; /*reset,dc*/ function = "gpio_out", "gpio_out"; }; ads7846_pins: ads7846_pins { pins = "PA19"; /*irq*/ function = "irq"; }; spi0_cs0: spi0_cs0 { pins = "PC3"; function = "gpio_out"; output-high; }; spi0_cs1: spi0_cs1 { pins = "PC7"; function = "gpio_out"; output-high; }; }; }; /*closing of fragment@0*/ fragment@1 { target = <&spi0>; __overlay__ { /* needed to avoid dtc warning */ #address-cells = <1>; #size-cells = <0>; status="okay"; pinctrl-names = "default", "default"; /*added by ryjelsum*/ pinctrl-1 = <&spi0_cs1>; /* pinctrl-0 is already declared in the primary dts */ cs-gpios = <0>, <&pio 2 7 0>; /* cs0=C3,cs1=C7 */ num-chipselects = <2>; display: display@0 { /*compatible = "ilitek,ili9341";*/ compatible = "adafruit,yx240qv29", "ilitek,ili9341"; reg = <0>; pinctrl-names ="default"; pinctrl-0 = <&display_pins>; spi-max-frequency = <24000000>; status="okay"; rotation= <90>; bgr = <0>; fps = <15>; buswidth = <8>; height = <320>; width = <240>; reset-gpios = <&pio 2 4 0>; /* C4,GPIO 24 polarity 0 for adafruit */ dc-gpios = <&pio 0 2 0>; /* A2,GPIO 25 */ debug = <3>; }; ads7846: ads7846@1 { reg = <1>; /* Chip Select 1 */ compatible = "ti,ads7846"; spi-max-frequency = <1000000>; status = "okay"; pinctrl-names ="default"; pinctrl-0 = <&ads7846_pins>; interrupt-parent = <&pio>; interrupts = <0 19 2>; /* PA19 IRQ_TYPE_EDGE_FALLING */ pendown-gpio = <&pio 0 19 0>; /* PA19 */ /* 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>; }; }; }; /*closing of fragment@2*/ __overrides__ { rotation = <&display>, "rotation:0"; fps = <&display>, "fps:0"; debug = <&display>, "debug:0"; }; /* closing of overrides */ }; best of luck Ryzer 0 Quote
robertoj Posted September 16 Posted September 16 I went with your corrected DTS ... so far it looks great Spoiler roberto@bananapim2zero:~$ lsmod |grep ads ads7846 20480 0 roberto@bananapim2zero:~$ lsmod |grep spi roberto@bananapim2zero:~$ sudo cat /proc/interrupts | grep ads [sudo] password for roberto: 59: 574 0 0 0 sunxi_pio_edge 19 Edge ads7846 roberto@bananapim2zero:~$ dmesg | grep spi [ 7.139676] ads7846 spi0.1: supply vcc not found, using dummy regulator [ 7.140801] ads7846 spi0.1: touchscreen, irq 59 [ 7.153779] input: ADS7846 Touchscreen as /devices/platform/soc/1c68000.spi/spi_master/spi0/spi0.1/input/input1 [ 7.195022] panel-ilitek-ili9341 spi0.0: get optional vcc failed [ 7.196412] [drm] Initialized ili9341 1.0.0 20210716 for spi0.0 on minor 1 [ 7.702554] panel-ilitek-ili9341 spi0.0: [drm] Initialized display serial interface [ 7.762184] panel-ilitek-ili9341 spi0.0: [drm] fb0: ili9341drmfb frame buffer device (Did NOT use the spi-add-cs1.dtbo, as advised) I went out running to work, and I will continue tests when I go back home Day 2 of testing: Spoiler roberto@bananapim2zero:~$ dmesg | grep ads [ 1.702669] ads7846@1 enforce active low on GPIO handle [ 7.139676] ads7846 spi0.1: supply vcc not found, using dummy regulator [ 7.140801] ads7846 spi0.1: touchscreen, irq 59 roberto@bananapim2zero:~$ sudo cat /sys/kernel/debug/gpio gpiochip0: GPIOs 0-223, parent: platform/1c20800.pinctrl, 1c20800.pinctrl: gpio-0 (CON2-P13 ) gpio-1 (CON2-P11 ) gpio-2 (CON2-P22 |dc ) out hi gpio-3 (CON2-P15 ) gpio-4 (CON3-P03 ) gpio-5 (CON3-P02 ) gpio-6 (CON2-P07 ) gpio-7 (CON2-P29 ) gpio-8 (CON2-P31 ) gpio-9 (CON2-P33 ) gpio-10 (CON2-P35 ) gpio-11 (CON2-P05 ) gpio-12 (CON2-P03 ) gpio-13 (CON2-P08 ) gpio-14 (CON2-P10 ) gpio-15 (CON2-P16 ) gpio-16 (CON2-P12 ) gpio-17 (CON2-P37 ) gpio-18 (CON2-P28 ) gpio-19 (CON2-P27 |pendown ) in hi IRQ gpio-20 (CON2-P40 ) gpio-21 (CON2-P38 ) gpio-64 (CON2-P19 ) gpio-65 (CON2-P21 ) gpio-66 (CON2-P23 ) gpio-67 (CON2-P24 ) gpio-68 (CON2-P18 |reset ) out hi gpio-71 (CON2-P26 |spi0 CS1 ) out hi ACTIVE LOW gpio-110 (CSI-PWR-EN ) gpio-128 (CN3-P17 ) gpio-129 (CN3-P13 ) gpio-130 (CN3-P09 ) gpio-131 (CN3-P07 ) gpio-132 (CN3-P19 ) gpio-133 (CN3-P21 ) gpio-134 (CN3-P22 ) gpio-135 (CN3-P20 ) gpio-136 (CN3-P18 ) gpio-137 (CN3-P16 ) gpio-138 (CN3-P14 ) gpio-139 (CN3-P12 ) gpio-140 (CN3-P05 ) gpio-141 (CN3-P03 ) gpio-142 (CN3-P06 ) gpio-143 (CN3-P08 ) gpio-160 (SDC0-D1 ) gpio-161 (SDC0-D0 ) gpio-162 (SDC0-CLK ) gpio-163 (SDC0-CMD ) gpio-164 (SDC0-D3 ) gpio-165 (SDC0-D2 ) gpio-166 (SDC0-DET |cd ) in hi gpio-192 (WL-SDIO-CLK ) gpio-193 (WL-SDIO-CMD ) gpio-194 (WL-SDIO-D0 ) gpio-195 (WL-SDIO-D1 ) gpio-196 (WL-SDIO-D2 ) gpio-197 (WL-SDIO-D3 ) gpio-198 (BT-UART-TX ) gpio-199 (BT-UART-RX ) gpio-200 (BT-UART-RTS ) gpio-201 (BT-UART-CTS ) gpio-202 (WL-WAKE-AP ) gpio-203 (BT-WAKE-AP |host-wakeup ) in lo gpio-204 (BT-RST-N |shutdown ) out hi gpio-205 (AP-WAKE-BT |device-wakeup ) out hi gpiochip1: GPIOs 352-383, parent: platform/1f02c00.pinctrl, 1f02c00.pinctrl: gpio-353 (CPUX-SET |vdd-cpux ) out hi gpio-354 (CON2-P32 ) gpio-355 (POWER-KEY |power ) in hi IRQ ACTIVE LOW gpio-356 (CON2-P36 ) gpio-357 (VCC-IO-EN ) gpio-358 (USB0-ID |usb0_id_det ) in hi IRQ gpio-359 (WL-PWR-EN |reset ) out hi ACTIVE LOW gpio-360 (PWR-STB |vcc1v2 ) out hi gpio-361 (PWR-DRAM |vcc-dram ) out hi gpio-362 (PWR-LED |bananapi-m2-zero:red) out lo ACTIVE LOW gpio-363 (IR-RX ) roberto@bananapim2zero:~$ sudo apt install evtest ...done roberto@bananapim2zero:~$ 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 Select the device event number [0-1]: 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 3303 Min 0 Max 4095 Event code 1 (ABS_Y) Value 2584 Min 0 Max 4095 Event code 24 (ABS_PRESSURE) Value 62397 Min 0 Max 65535 Properties: Testing ... (interrupt to exit) Event: time 1726556440.417809, type 3 (EV_ABS), code 0 (ABS_X), value 3294 Event: time 1726556440.417809, type 3 (EV_ABS), code 1 (ABS_Y), value 2585 Event: time 1726556440.417809, type 3 (EV_ABS), code 24 (ABS_PRESSURE), value 64811 Event: time 1726556440.417809, -------------- SYN_REPORT ------------ Event: time 1726556440.477739, type 3 (EV_ABS), code 0 (ABS_X), value 3303 Event: time 1726556440.477739, type 3 (EV_ABS), code 1 (ABS_Y), value 2584 Event: time 1726556440.477739, type 3 (EV_ABS), code 24 (ABS_PRESSURE), value 63498 ... evtest shows a random stream of events, then stops... then lcd touches dont get reactions. I will check my wiring and order a new LCD, because mine has a cracked glass Is there any way to tell that the SPI, IRQ, CS inputs/outputs to the XPT2046 (ADS 7846) is working correctly, and blame everything on a bad resistive panel? 0 Quote
robertoj Posted September 18 Posted September 18 When doing sudo evtest, I get random events. It may be related to https://forum.armbian.com/topic/15271-spi0-cs1-held-low-when-ads7846-is-loaded/ 0 Quote
robertoj Posted September 19 Posted September 19 I had some success by changing the touch chip pins from: CS1=PC7 PA18 (I avoided the "native Spi0 CS1 PC7" and used PA18) IRQ=PA19 PA7 (maybe this was unnecessary) New DTS: Spoiler roberto@bananapim2zero:~/ili9341$ cat ili9341-touch-sp0-ryzer-other-cs1-irq.dts /dts-v1/; /plugin/; / { compatible = "allwinner,sun8i-h3"; fragment@0 { target = <&pio>; __overlay__ { display_pins: display_pins { pins = "PC4", "PA2"; /*reset,dc*/ function = "gpio_out", "gpio_out"; }; ads7846_pins: ads7846_pins { pins = "PA7"; /*irq*/ function = "irq"; }; spi0_cs0: spi0_cs0 { pins = "PC3"; function = "gpio_out"; output-high; }; spi0_cs1: spi0_cs1 { pins = "PA18"; function = "gpio_out"; output-high; }; }; }; /*closing of fragment@0*/ fragment@1 { target = <&spi0>; __overlay__ { /* needed to avoid dtc warning */ #address-cells = <1>; #size-cells = <0>; status="okay"; pinctrl-names = "default", "default"; /*added by ryjelsum*/ pinctrl-1 = <&spi0_cs1>; /* pinctrl-0 is already declared in the primary dts */ cs-gpios = <0>, <&pio 0 18 0>; /* cs0=PC3,cs1=PA18 */ num-chipselects = <2>; display: display@0 { /*compatible = "ilitek,ili9341";*/ compatible = "adafruit,yx240qv29", "ilitek,ili9341"; reg = <0>; pinctrl-names ="default"; pinctrl-0 = <&display_pins>; spi-max-frequency = <24000000>; status="okay"; rotation= <90>; bgr = <0>; fps = <15>; buswidth = <8>; height = <320>; width = <240>; reset-gpios = <&pio 2 4 0>; /* C4,GPIO 24 polarity 0 for adafruit */ dc-gpios = <&pio 0 2 0>; /* A2,GPIO 25 */ debug = <3>; }; ads7846: ads7846@1 { reg = <1>; /* Chip Select 1 */ compatible = "ti,ads7846"; spi-max-frequency = <1000000>; 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 <200>; ti,y-min = /bits/ 16 <200>; ti,x-max = /bits/ 16 <3900>; ti,y-max = /bits/ 16 <3900>; /*ti,pressure-min = /bits/ 16 <0>;*/ ti,pressure-max = /bits/ 16 <255>; ti,x-plate-ohms = /bits/ 16 <60>; }; }; }; /*closing of fragment@2*/ __overrides__ { rotation = <&display>, "rotation:0"; fps = <&display>, "fps:0"; debug = <&display>, "debug:0"; }; /* closing of overrides */ }; With inspiration from https://github.com/jonathan-gatard/ili9486-xpt2046/tree/main for the IOs and the analog parameters Now sudo evtest prints an event each time I press on the LCD screen Spoiler roberto@bananapim2zero:~$ sudo evtest [sudo] password for roberto: No device specified, trying to scan all of /dev/input/event* Available devices: /dev/input/event0: gpio-keys /dev/input/event1: ADS7846 Touchscreen Select the device event number [0-1]: 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 3312 Min 200 Max 3900 Event code 1 (ABS_Y) Value 2579 Min 200 Max 3900 Event code 24 (ABS_PRESSURE) Value 238 Min 0 Max 255 Properties: Testing ... (interrupt to exit) Event: time 1726725202.045512, type 3 (EV_ABS), code 0 (ABS_X), value 3319 Event: time 1726725202.045512, type 3 (EV_ABS), code 1 (ABS_Y), value 2588 Event: time 1726725202.045512, type 3 (EV_ABS), code 24 (ABS_PRESSURE), value 4 Event: time 1726725202.045512, -------------- SYN_REPORT ------------ Event: time 1726725202.885527, type 3 (EV_ABS), code 0 (ABS_X), value 3311 Event: time 1726725202.885527, type 3 (EV_ABS), code 1 (ABS_Y), value 2596 Event: time 1726725202.885527, type 3 (EV_ABS), code 24 (ABS_PRESSURE), value 30 Event: time 1726725202.885527, -------------- SYN_REPORT ------------ Event: time 1726725205.495577, type 3 (EV_ABS), code 0 (ABS_X), value 3280 Event: time 1726725205.495577, type 3 (EV_ABS), code 1 (ABS_Y), value 2560 Event: time 1726725205.495577, type 3 (EV_ABS), code 24 (ABS_PRESSURE), value 43 Event: time 1726725205.495577, -------------- SYN_REPORT ------------ Event: time 1726725206.767507, type 3 (EV_ABS), code 0 (ABS_X), value 3304 Event: time 1726725206.767507, type 3 (EV_ABS), code 1 (ABS_Y), value 2579 Event: time 1726725206.767507, type 3 (EV_ABS), code 24 (ABS_PRESSURE), value 87 ... If an LCD suffers a disconnection and reconnection, is it possible to reset, re-initialize and continue working the LCD? Or would it always need a Linux reboot? 0 Quote
robertoj Posted September 22 Posted September 22 problem solved: IRQ i/o needed the reverse polarity in pendown-gpio. armbianEnv.txt and DTS here: (it is working with sudo evtest, so I dont know if it needs calibration... and I wonder if I need to reverse the polarity in the interrupts line too) Spoiler roberto@bananapim2zero:~/ili9341$ cat ili9341-touch-sp0.dts /dts-v1/; /plugin/; / { compatible = "allwinner,sun8i-h3"; fragment@0 { target = <&pio>; __overlay__ { display_pins: display_pins { pins = "PC4", "PA2"; /*reset,dc*/ function = "gpio_out", "gpio_out"; }; ads7846_pins: ads7846_pins { pins = "PA7"; /*irq*/ function = "irq"; }; spi0_cs0: spi0_cs0 { pins = "PC3"; function = "gpio_out"; output-high; }; spi0_cs1: spi0_cs1 { pins = "PA18"; function = "gpio_out"; output-high; }; }; }; /*closing of fragment@0*/ fragment@1 { target = <&spi0>; __overlay__ { /* needed to avoid dtc warning */ #address-cells = <1>; #size-cells = <0>; status="okay"; pinctrl-names = "default", "default"; /*added by ryjelsum*/ pinctrl-1 = <&spi0_cs1>; /* pinctrl-0 is already declared in the primary dts */ cs-gpios = <0>, <&pio 0 18 0>; /* cs0=PC3,cs1=PA18 */ num-chipselects = <2>; display: display@0 { /*compatible = "ilitek,ili9341";*/ compatible = "adafruit,yx240qv29", "ilitek,ili9341"; reg = <0>; pinctrl-names ="default"; pinctrl-0 = <&display_pins>; spi-max-frequency = <24000000>; status="okay"; rotation= <90>; bgr = <0>; fps = <15>; buswidth = <8>; height = <320>; width = <240>; reset-gpios = <&pio 2 4 0>; /* C4,GPIO 24 polarity 0 for adafruit */ dc-gpios = <&pio 0 2 0>; /* A2,GPIO 25 */ debug = <3>; }; ads7846: ads7846@1 { reg = <1>; /* Chip Select 1 */ compatible = "ti,ads7846"; spi-max-frequency = <1000000>; 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 1>; /* PA7 */ /* driver defaults, optional*/ ti,x-min = /bits/ 16 <0>; ti,y-min = /bits/ 16 <0>; ti,x-max = /bits/ 16 <0xFFF>; ti,y-max = /bits/ 16 <0xFFF>; ti,pressure-min = /bits/ 16 <0>; ti,pressure-max = /bits/ 16 <0xFFFF>; ti,x-plate-ohms = /bits/ 16 <400>; }; }; }; /*closing of fragment@2*/ __overrides__ { rotation = <&display>, "rotation:0"; fps = <&display>, "fps:0"; debug = <&display>, "debug:0"; }; /* closing of overrides */ }; roberto@bananapim2zero:~/ili9341$ cat /boot/armbianEnv.txt verbosity=1 bootlogo=false console=both disp_mode=1920x1080p60 overlay_prefix=sun8i-h3 rootdev=UUID=c809ccbe-42ae-40e8-b871-04e14b950d7a rootfstype=ext4 user_overlays=ili9341-touch-sp0 usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u roberto@bananapim2zero:~/ili9341$ 0 Quote
robertoj Posted September 22 Posted September 22 I could run lightdm with apt install xinit xterm xauth x11-apps xserver-xorg lightdm xserver-xorg-input-evdev xserver-xorg-video-fbdev /usr/share/X11/xorg.conf.d/99-fbdev.conf: Section "Device" Identifier "myfb" Driver "fbdev" Option "fbdev" "/dev/fb0" EndSection However, the cursor is moving at 90-degrees from my finger movement. Also, it is very unstable... it crashes, leaving a white screen. The white screen remains after reboot, and I can only make it work again by removing and connecting the 5V power. Can someone share how they installed a window manager with ili9341? is 24MHz too fast? Would native cs1 help anything? 0 Quote
robertoj Posted September 24 Posted September 24 https://github.com/raspberrypi/linux/issues/6067 https://github.com/raspberrypi/linux/pull/6029 https://forums.raspberrypi.com/viewtopic.php?p=2206990&hilit=ads7846#p2206990 https://github.com/raspberrypi/bookworm-feedback/issues/88 There seems to be some instability in the ads7846 driver in the latest linux. If anyone is having a good experience with ads7846, please indicate how you did it. 0 Quote
Ryzer Posted September 25 Posted September 25 (edited) Hi robertoj, There are addtional touchscreen parameters that you could try to address the cursor movement being wrong. based on what you have said I would suggest adding the line 'ti,swap-xy = <1>;' to: ads7846: ads7846@1 { reg = <1>; /* Chip Select 1 */ compatible = "ti,ads7846"; spi-max-frequency = <1000000>; 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 1>; /* PA7 */ /* driver defaults, optional*/ ti,x-min = /bits/ 16 <0>; ti,y-min = /bits/ 16 <0>; ti,x-max = /bits/ 16 <0xFFF>; ti,y-max = /bits/ 16 <0xFFF>; ti,pressure-min = /bits/ 16 <0>; ti,pressure-max = /bits/ 16 <0xFFFF>; ti,x-plate-ohms = /bits/ 16 <400>; }; In regards to the crashing that, will be a bit harder to pin down. Thinking about I would suggest double checking 'interrupts = <0 7 2>;' as I would have expected it to be something like 'interrupts = <0 7 IRQ_TYPE_EDGE_FALLING>. That said, it does appear to be registering correctly when looking here: On 9/16/2024 at 4:26 PM, robertoj said: gpio-19 (CON2-P27 |pendown ) in hi IRQ Does /proc/interrupts list the gpio as being set to trigger on falling edge as expected? 24MHz is the maximum speed that the ili9341 will work at in spi mode. It may be possible that there indeed problems with the driver but without investigating deeper its hard to say. Raspberry Pi have there own distinct linux kernel fork so the problems mentioned may not be common to the mainline kernel used by Armbian. I wonder if the crashes are possibly caused by the cs lines of both devices being pulled low at the same time under certain conditions. best of luck Ryzer Edited September 25 by Ryzer 0 Quote
robertoj Posted September 26 Posted September 26 Thank you. I will try that, and I learned about the xinput_calibrator, which I will apply next time. (and https://github.com/reinderien/xcalibrate/blob/main/xcalibrate is a new interesting project) Now I am focusing on moving the touchscreen pins to an independent gpio-based SPI set of pins... we will know whether the LCD crash is from interfering SPI commands. I did an experiment with the "backlight = <&backlight_gpio>" parameter as shown in https://github.com/beagleboard/bb.org-overlays/blob/master/src/arm/BB-LCD-ADAFRUIT-24-SPI0-00A0.dts and https://forums.raspberrypi.com/viewtopic.php?t=358240 but so far it ended up in a kernel not loading. I will leave this task for last. If the DTS configuration does not specify CPHA and CPOL, what is the default setting of the SPI protocol? 0 Quote
robertoj Posted September 29 Posted September 29 I decided to use the gpio-spi driver, to emulate software spi just for the touch chip ADS7846/XPT2048, and use a different DTS file Here is what I think would work: ads7846-spi-gpio.dts Spoiler /* Configure the GPIO to handle ADS7846 touch surface chip with the gpio-spi driver: https://www.kernel.org/doc/Documentation/devicetree/bindings/spi/spi-gpio.txt https://stackoverflow.com/questions/78905378/how-do-i-use-spi-gpio-driver-in-linux https://gist.github.com/BjoernSch/39d3bca950a3b025b806decc2b686bbc */ /dts-v1/; /plugin/; / { compatible = "allwinner,sun4i-a10", "allwinner,sun7i-a20", "allwinner,sun8i-h3", "allwinner,sun50i-a64", "allwinner,sun50i-h5"; fragment@0 { target = <&pio>; __overlay__ { ads7846_pins: ads7846_pins { pins = "PA1"; /*irq*/ function = "irq"; }; }; }; fragment@1 { /*target = <&spi-gpio>; /* what goes here ???? */ target-path = "/"; /* what goes here ???? */ __overlay__ { my_new_spi { compatible = "spi-gpio"; /* needed to avoid dtc warning */ #address-cells = <1>; ranges; status="okay"; mosi-gpios = <&pio 0 12 0>; /*t_din= PA12*/ sck-gpios = <&pio 0 11 0>; /*t_clk= PA11*/ miso-gpios = <&pio 0 6 0>; /*t_dout=PA6*/ cs-gpios = <&pio 0 0 0>; /*t_cs= PA0*/ num-chipselects = <1>; ads7846: ads7846@1 { reg = <0>; /* Chip Select 0 on this separate SPI bus */ compatible = "ti,ads7846"; spi-max-frequency = <1000000>; status = "okay"; pinctrl-names ="default"; pinctrl-0 = <&ads7846_pins>; interrupt-parent = <&pio>; interrupts = <0 1 2>; /* PA1 IRQ_TYPE_EDGE_FALLING */ pendown-gpio = <&pio 0 1 1>; /* PA1 */ /* driver defaults, optional*/ ti,x-min = /bits/ 16 <0>; ti,y-min = /bits/ 16 <0>; ti,x-max = /bits/ 16 <0xFFF>; ti,y-max = /bits/ 16 <0xFFF>; ti,pressure-min = /bits/ 16 <0>; ti,pressure-max = /bits/ 16 <0xFFFF>; ti,x-plate-ohms = /bits/ 16 <400>; ti,swap-xy = <1>; }; }; //end of my_new_spi }; }; }; I used these references: https://www.kernel.org/doc/Documentation/devicetree/bindings/spi/spi-gpio.txt https://stackoverflow.com/questions/78905378/how-do-i-use-spi-gpio-driver-in-linux https://gist.github.com/BjoernSch/39d3bca950a3b025b806decc2b686bbc and need to check this too: http://terminal28.blogspot.com/2015/12/bitbanging-spi-on-raspberry-pi-via-spi.html http://terminal28.blogspot.com/2016/05/enabling-spi1-on-raspberry-pi-bzero23.html My DTS compiles well but the linux in my armbian image did not include spi-gpio.ko, in /lib/modules/6.6.44-current-sunxi/kernel/drivers/spi/ Therefore, I am building a new OS image. Does anyone see a problem with my DTS? Update:) it works good stability now the only problem is that both x-axis and y-axis are reversed (not swapped). More updates on the way 0 Quote
Ryzer Posted September 30 Posted September 30 Hi robertoj, On 9/26/2024 at 5:03 PM, robertoj said: If the DTS configuration does not specify CPHA and CPOL, what is the default setting of the SPI protocol? This would most like be set somewhere within the SPI controller driver. I tried that in my other post with not much success but I will try to give it another shot. maybe you could try reversing the min and max values best of luck Ryzer 0 Quote
robertoj Posted October 1 Posted October 1 I simply rotated the image with the "rotation" parameter in the LCD DTS, and turned the screen 180 degrees physically. I will try the min, max swap later, but right now I am on a roll, making my tkinter apps work Another thing I will try is not using a chip select pin at all, since LCD and touch-chip are on different buses now. 0 Quote
Koliber93 Posted December 16 Posted December 16 (edited) Hi all, I tried to compile codes from this topic on my banana pi m2 berry but it still don't work, I tried with chat gpt implement my pins but in my analyzer I cannot see anything on ouptut, on dmesg of spi I have information about timeout of connecting to ili9341. Below I put my dts configuration: Spoiler /dts-v1/; /plugin/; / { compatible = "allwinner,sun4i-a10", "allwinner,sun7i-a20", "allwinner,sun8i-h3", "allwinner,sun50i-a64", "allwinner,sun50i-h5"; fragmen@0 { target = <&pio>; __overlay__ { display_pins: display_pins { pins = "PH27", "PH26"; function = "gpio_out", "gpio_out"; }; }; }; fragment@1 { target = <&spi0>; __overlay__ { /* needed to avoid dtc warning */ #address-cells = <1>; #size-cells = <0>; status="okay"; cs-gpios = <&pio 2 23 0>; num-chipselects = <1>; display: display@0 { compatible = "adafruit,yx240qv29", "ilitek,ili9341"; reg = <0>; pinctrl-names = "default"; pinctrl-0 = <&display_pins>; spi-max-frequency = <8000000>; rotation= <270>; bgr = <0>; fps = <10>; buswidth = <8>; height = <240>; width = <320>; reset-gpios = <&pio 7 27 1>; /* GPIO 24 */ dc-gpios = <&pio 7 26 0>; /* GPIO 25 */ debug = <3>; }; }; }; __overrides__ { rotation = <&display>, "rotation:0"; fps = <&display>, "fps:0"; debug = <&display>, "debug:0"; }; }; Below I put information from dmesg : Spoiler [ 2.019202] sun6i-spi 1c05000.spi: Failed to request TX DMA channel [ 2.019219] sun6i-spi 1c05000.spi: Failed to request RX DMA channel [ 2.019374] sun6i-spi 1c05000.spi: cannot register SPI master [ 2.046614] sun6i-spi 1c05000.spi: Failed to request TX DMA channel [ 2.046639] sun6i-spi 1c05000.spi: Failed to request RX DMA channel [ 3.203221] panel-ilitek-ili9341 spi0.0: get optional vcc failed [ 3.213019] [drm] Initialized ili9341 1.0.0 20210716 for spi0.0 on minor 1 [ 4.010262] panel-ilitek-ili9341 spi0.0: [drm] Initialized display serial interface [ 4.219308] panel-ilitek-ili9341 spi0.0: [drm] fb0: ili9341drmfb frame buffer device [ 11.960172] spi_master spi0: spi0.0: timeout transferring 153600 bytes@8000000Hz for 524(500)ms [ 11.961183] panel-ilitek-ili9341 spi0.0: SPI transfer failed: -110 [ 11.961764] spi_master spi0: failed to transfer one message from queue [ 11.962131] spi_master spi0: noqueue transfer failed [ 11.963464] panel-ilitek-ili9341 spi0.0: [drm] *ERROR* Failed to update display -110 [ 12.502597] spi_master spi0: spi0.0: timeout transferring 1 bytes@8000000Hz for 524(500)ms [ 12.502642] panel-ilitek-ili9341 spi0.0: SPI transfer failed: -110 [ 12.502661] spi_master spi0: failed to transfer one message from queue [ 12.502670] spi_master spi0: noqueue transfer failed [ 12.502694] panel-ilitek-ili9341 spi0.0: error -110 when sending command 0x2a [ 13.014611] spi_master spi0: spi0.0: timeout transferring 1 bytes@8000000Hz for 512(500)ms [ 13.014660] panel-ilitek-ili9341 spi0.0: SPI transfer failed: -110 [ 13.014683] spi_master spi0: failed to transfer one message from queue [ 13.014693] spi_master spi0: noqueue transfer failed [ 13.014715] panel-ilitek-ili9341 spi0.0: error -110 when sending command 0x2b [ 13.528719] spi_master spi0: spi0.0: timeout transferring 1 bytes@8000000Hz for 512(500)ms [ 13.529786] panel-ilitek-ili9341 spi0.0: SPI transfer failed: -110 [ 13.530429] spi_master spi0: failed to transfer one message from queue [ 13.531366] spi_master spi0: noqueue transfer failed [ 14.070607] spi_master spi0: spi0.0: timeout transferring 1 bytes@8000000Hz for 512(500)ms [ 14.070653] panel-ilitek-ili9341 spi0.0: SPI transfer failed: -110 [ 14.070673] spi_master spi0: failed to transfer one message from queue [ 14.070683] spi_master spi0: noqueue transfer failed [ 14.070700] panel-ilitek-ili9341 spi0.0: error -110 when sending command 0x2a [ 14.582602] spi_master spi0: spi0.0: timeout transferring 1 bytes@8000000Hz for 512(500)ms [ 14.582656] panel-ilitek-ili9341 spi0.0: SPI transfer failed: -110 [ 14.582677] spi_master spi0: failed to transfer one message from queue [ 14.582686] spi_master spi0: noqueue transfer failed [ 14.582708] panel-ilitek-ili9341 spi0.0: error -110 when sending command 0x2b [ 15.094565] spi_master spi0: spi0.0: timeout transferring 1 bytes@8000000Hz for 512(500)ms [ 15.094599] panel-ilitek-ili9341 spi0.0: SPI transfer failed: -110 [ 15.094617] spi_master spi0: failed to transfer one message from queue [ 15.094626] spi_master spi0: noqueue transfer failed [ 15.606606] spi_master spi0: spi0.0: timeout transferring 1 bytes@8000000Hz for 504(500)ms [ 15.606652] panel-ilitek-ili9341 spi0.0: SPI transfer failed: -110 [ 15.606673] spi_master spi0: failed to transfer one message from queue [ 15.606682] spi_master spi0: noqueue transfer failed [ 15.606701] panel-ilitek-ili9341 spi0.0: error -110 when sending command 0x2a [ 16.119297] spi_master spi0: spi0.0: timeout transferring 1 bytes@8000000Hz for 512(500)ms [ 16.119343] panel-ilitek-ili9341 spi0.0: SPI transfer failed: -110 [ 16.119362] spi_master spi0: failed to transfer one message from queue [ 16.119371] spi_master spi0: noqueue transfer failed [ 16.119392] panel-ilitek-ili9341 spi0.0: error -110 when sending command 0x2b [ 16.634576] spi_master spi0: spi0.0: timeout transferring 1 bytes@8000000Hz for 516(500)ms [ 16.634617] panel-ilitek-ili9341 spi0.0: SPI transfer failed: -110 [ 16.634636] spi_master spi0: failed to transfer one message from queue [ 16.634644] spi_master spi0: noqueue transfer failed [ 17.174760] spi_master spi0: spi0.0: timeout transferring 1 bytes@8000000Hz for 532(500)ms [ 17.174818] panel-ilitek-ili9341 spi0.0: SPI transfer failed: -110 [ 17.174841] spi_master spi0: failed to transfer one message from queue [ 17.174850] spi_master spi0: noqueue transfer failed [ 17.174872] panel-ilitek-ili9341 spi0.0: error -110 when sending command 0x2a [ 17.686826] spi_master spi0: spi0.0: timeout transferring 1 bytes@8000000Hz for 512(500)ms [ 17.686873] panel-ilitek-ili9341 spi0.0: SPI transfer failed: -110 [ 17.686892] spi_master spi0: failed to transfer one message from queue [ 17.686901] spi_master spi0: noqueue transfer failed [ 17.686925] panel-ilitek-ili9341 spi0.0: error -110 when sending command 0x2b [ 18.198675] spi_master spi0: spi0.0: timeout transferring 1 bytes@8000000Hz for 512(500)ms [ 18.198719] panel-ilitek-ili9341 spi0.0: SPI transfer failed: -110 [ 18.198738] spi_master spi0: failed to transfer one message from queue [ 18.198747] spi_master spi0: noqueue transfer failed [ 18.710586] spi_master spi0: spi0.0: timeout transferring 1 bytes@8000000Hz for 504(500)ms [ 18.710632] panel-ilitek-ili9341 spi0.0: SPI transfer failed: -110 [ 18.710652] spi_master spi0: failed to transfer one message from queue [ 18.710661] spi_master spi0: noqueue transfer failed [ 18.710681] panel-ilitek-ili9341 spi0.0: error -110 when sending command 0x2a [ 19.222600] spi_master spi0: spi0.0: timeout transferring 1 bytes@8000000Hz for 512(500)ms [ 19.222648] panel-ilitek-ili9341 spi0.0: SPI transfer failed: -110 [ 19.222669] spi_master spi0: failed to transfer one message from queue [ 19.222678] spi_master spi0: noqueue transfer failed [ 19.222702] panel-ilitek-ili9341 spi0.0: error -110 when sending command 0x2b [ 19.734562] spi_master spi0: spi0.0: timeout transferring 1 bytes@8000000Hz for 512(500)ms [ 19.734604] panel-ilitek-ili9341 spi0.0: SPI transfer failed: -110 [ 19.734623] spi_master spi0: failed to transfer one message from queue [ 19.734631] spi_master spi0: noqueue transfer failed [ 20.246615] spi_master spi0: spi0.0: timeout transferring 1 bytes@8000000Hz for 504(500)ms [ 20.246666] panel-ilitek-ili9341 spi0.0: SPI transfer failed: -110 [ 20.246687] spi_master spi0: failed to transfer one message from queue [ 20.246695] spi_master spi0: noqueue transfer failed [ 20.246721] panel-ilitek-ili9341 spi0.0: error -110 when sending command 0x2a [ 20.758633] spi_master spi0: spi0.0: timeout transferring 1 bytes@8000000Hz for 512(500)ms [ 20.758728] panel-ilitek-ili9341 spi0.0: SPI transfer failed: -110 [ 20.758749] spi_master spi0: failed to transfer one message from queue [ 20.758758] spi_master spi0: noqueue transfer failed [ 20.758778] panel-ilitek-ili9341 spi0.0: error -110 when sending command 0x2b [ 21.270606] spi_master spi0: spi0.0: timeout transferring 1 bytes@8000000Hz for 512(500)ms [ 21.270649] panel-ilitek-ili9341 spi0.0: SPI transfer failed: -110 [ 21.270669] spi_master spi0: failed to transfer one message from queue [ 21.270677] spi_master spi0: noqueue transfer failed [ 21.782700] spi_master spi0: spi0.0: timeout transferring 1 bytes@8000000Hz for 508(500)ms [ 21.782733] panel-ilitek-ili9341 spi0.0: SPI transfer failed: -110 [ 21.782749] spi_master spi0: failed to transfer one message from queue [ 21.782756] spi_master spi0: noqueue transfer failed [ 21.782772] panel-ilitek-ili9341 spi0.0: error -110 when sending command 0x2a [ 22.294588] spi_master spi0: spi0.0: timeout transferring 1 bytes@8000000Hz for 512(500)ms [ 22.294621] panel-ilitek-ili9341 spi0.0: SPI transfer failed: -110 [ 22.294637] spi_master spi0: failed to transfer one message from queue [ 22.294643] spi_master spi0: noqueue transfer failed [ 22.294663] panel-ilitek-ili9341 spi0.0: error -110 when sending command 0x2b [ 22.806580] spi_master spi0: spi0.0: timeout transferring 1 bytes@8000000Hz for 512(500)ms [ 22.806615] panel-ilitek-ili9341 spi0.0: SPI transfer failed: -110 [ 22.806633] spi_master spi0: failed to transfer one message from queue [ 22.806639] spi_master spi0: noqueue transfer failed [ 23.318613] spi_master spi0: spi0.0: timeout transferring 1 bytes@8000000Hz for 508(500)ms [ 23.318658] panel-ilitek-ili9341 spi0.0: SPI transfer failed: -110 [ 23.318677] spi_master spi0: failed to transfer one message from queue [ 23.318686] spi_master spi0: noqueue transfer failed [ 23.318707] panel-ilitek-ili9341 spi0.0: error -110 when sending command 0x2a [ 23.830593] spi_master spi0: spi0.0: timeout transferring 1 bytes@8000000Hz for 512(500)ms [ 23.830643] panel-ilitek-ili9341 spi0.0: SPI transfer failed: -110 [ 23.830662] spi_master spi0: failed to transfer one message from queue [ 23.830671] spi_master spi0: noqueue transfer failed [ 23.830693] panel-ilitek-ili9341 spi0.0: error -110 when sending command 0x2b [ 24.342601] spi_master spi0: spi0.0: timeout transferring 1 bytes@8000000Hz for 512(500)ms [ 24.342644] panel-ilitek-ili9341 spi0.0: SPI transfer failed: -110 [ 24.342746] spi_master spi0: failed to transfer one message from queue [ 24.342756] spi_master spi0: noqueue transfer failed [ 24.854609] spi_master spi0: spi0.0: timeout transferring 1 bytes@8000000Hz for 512(500)ms [ 24.854652] panel-ilitek-ili9341 spi0.0: SPI transfer failed: -110 [ 24.854672] spi_master spi0: failed to transfer one message from queue [ 24.854680] spi_master spi0: noqueue transfer failed [ 24.854699] panel-ilitek-ili9341 spi0.0: error -110 when sending command 0x2a [ 25.367019] spi_master spi0: spi0.0: timeout transferring 1 bytes@8000000Hz for 512(500)ms [ 25.367062] panel-ilitek-ili9341 spi0.0: SPI transfer failed: -110 [ 25.367081] spi_master spi0: failed to transfer one message from queue [ 25.367089] spi_master spi0: noqueue transfer failed [ 25.367111] panel-ilitek-ili9341 spi0.0: error -110 when sending command 0x2b [ 25.878574] spi_master spi0: spi0.0: timeout transferring 1 bytes@8000000Hz for 512(500)ms [ 25.878618] panel-ilitek-ili9341 spi0.0: SPI transfer failed: -110 [ 25.878634] spi_master spi0: failed to transfer one message from queue [ 25.878643] spi_master spi0: noqueue transfer failed [ 27.702605] spi_master spi0: spi0.0: timeout transferring 1 bytes@8000000Hz for 508(500)ms [ 27.702650] panel-ilitek-ili9341 spi0.0: SPI transfer failed: -110 [ 27.702669] spi_master spi0: failed to transfer one message from queue [ 27.702677] spi_master spi0: noqueue transfer failed [ 27.702697] panel-ilitek-ili9341 spi0.0: error -110 when sending command 0x2a [ 28.214628] spi_master spi0: spi0.0: timeout transferring 1 bytes@8000000Hz for 512(500)ms [ 28.214672] panel-ilitek-ili9341 spi0.0: SPI transfer failed: -110 [ 28.214692] spi_master spi0: failed to transfer one message from queue [ 28.214700] spi_master spi0: noqueue transfer failed [ 28.214723] panel-ilitek-ili9341 spi0.0: error -110 when sending command 0x2b [ 28.726613] spi_master spi0: spi0.0: timeout transferring 1 bytes@8000000Hz for 512(500)ms [ 28.726658] panel-ilitek-ili9341 spi0.0: SPI transfer failed: -110 [ 28.726678] spi_master spi0: failed to transfer one message from queue [ 28.726697] spi_master spi0: noqueue transfer failed [ 29.654665] spi_master spi0: spi0.0: timeout transferring 1 bytes@8000000Hz for 512(500)ms [ 29.654708] panel-ilitek-ili9341 spi0.0: SPI transfer failed: -110 [ 29.654726] spi_master spi0: failed to transfer one message from queue [ 29.654734] spi_master spi0: noqueue transfer failed [ 29.654753] panel-ilitek-ili9341 spi0.0: error -110 when sending command 0x2a [ 30.166602] spi_master spi0: spi0.0: timeout transferring 1 bytes@8000000Hz for 512(500)ms [ 30.166644] panel-ilitek-ili9341 spi0.0: SPI transfer failed: -110 [ 30.166662] spi_master spi0: failed to transfer one message from queue [ 30.166671] spi_master spi0: noqueue transfer failed [ 30.166690] panel-ilitek-ili9341 spi0.0: error -110 when sending command 0x2b [ 30.678636] spi_master spi0: spi0.0: timeout transferring 1 bytes@8000000Hz for 512(500)ms [ 30.678681] panel-ilitek-ili9341 spi0.0: SPI transfer failed: -110 [ 30.678699] spi_master spi0: failed to transfer one message from queue [ 30.678708] spi_master spi0: noqueue transfer failed Have you any idea to prepare good configuration ? Edited December 16 by Koliber93 0 Quote
robertoj Posted December 16 Posted December 16 Change: reset-gpios = <&pio 7 27 1>; /* GPIO 24 */ to: reset-gpios = <&pio 7 27 0>; /* GPIO 24 */ Change the SPI speed to 24MHz Format your DTS so we can read it easily. Correct the comments with GPIO nnn because they are confusing. Show a wiring schematic between the BPI M2 Berry and your LCD Use the "Spoiler" (eye) button, so that your long texts don't take so much space. 0 Quote
Koliber93 Posted December 16 Posted December 16 Thank you for quick reply, my current configuration is : MOSI - GPIO10 (PIN19) MISO - GPIO9 (PIN21) SCLK - GPIO 11 (PIN23) CS - GPIO8 (PIN24) DC - GPIO24 (PIN18) RESET - GPIO25 (PIN22) Below I put the picture with 40-pin header description. Spoiler I also found the issue with spi0 on Banana PI M2 Berry and I also try this configuration - for this issue I found another configuration and I tried mixed it together : Spoiler /dts-v1/; /plugin/; / { compatible = "allwinner,sun6i-a31"; fragment@0 { target = <&pio>; __overlay__ { display_pins: display_pins { pins = "PC0", "PC1", "PC2", "PC23", "PH26", "PH27"; function = "spi0", "spi0", "spi0", "gpio_out", "gpio_out", "gpio_out"; }; }; }; fragment@1 { target = <&spi0>; __overlay__ { #address-cells = <1>; #size-cells = <0>; status = "okay"; cs-gpios = <&pio 2 23 0>; /* PC23 for CS */ num-chipselects = <1>; display: display@0 { compatible = "adafruit,yx240qv29", "ilitek,ili9341"; reg = <0>; pinctrl-names = "default"; pinctrl-0 = <&display_pins>; spi-max-frequency = <24000000>; rotation = <270>; bgr = <0>; fps = <10>; buswidth = <8>; height = <240>; width = <320>; reset-gpios = <&pio 7 26 0>; /* PH26 for Reset */ dc-gpios = <&pio 7 27 0>; /* PH27 for Data/Command */ debug = <3>; }; }; }; __overrides__ { rotation = <&display>, "rotation:0"; fps = <&display>, "fps:0"; debug = <&display>, "debug:0"; }; }; The only difference what I noticed is that I had some signals on the output as you can see below from my pulseview: Spoiler D0 - MISO D1 - SCK D2 - MOSI D3 - DC D4 - RESET D5 - CS Another issue what I concern is problem with DMA from dmesg 0 Quote
robertoj Posted December 17 Posted December 17 Try all combinations of (I have no idea why these things sometimes work): * Only define the PH26,PH27 in pins = "PC0", "PC1", "PC2", "PC23", "PH26", "PH27"; * only cs-gpios = <0>; //use default CS instead of cs-gpios = <&pio 2 23 0>; /* PC23 for CS */ Make sure that there are no erorrs in: dmesg|grep spi dmesg|grep mipi Usually these are good signs: lsmod|grep ili shows a loaded kernel module ls /dev/fb* shows a created video device 0 Quote
Ryzer Posted December 17 Posted December 17 Hi Koliber93, Before trying to the ili9341 display working can you confirm that spi0 works with a simple spidev setup then move onto to trying to configure the display. Do not mix up pin functions, you should have a seperate node for the spi pins and additional gpio used for the display. Normaly the spi pins should already defined under the pinctrl node in which case we can simply refer to associated label. for reference please see: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/arch/arm/boot/dts/allwinner/sun8i-r40.dtsi?h=v6.6.66 As suggested by robertoj, I would stick with the hardware cs pin as I have had nothing but problems with gpio defind cs lines in recent kernels. If a simple SPI set works then please feel free to try the following overlay: /dts-v1/; /plugin/; / { compatible = "allwinner,sun8i-h3", "allwinner,sun8i-r40"; fragment@0 { target = <&pio>; __overlay__ { display_pins: display_pins { pins ="PH26", "PH27"; function ="gpio_out", "gpio_out"; }; }; }; fragment@1 { target = <&spi0>; __overlay__ { #address-cells = <1>; #size-cells = <0>; status = "okay"; pinctrl-names = "default", "default"; pinctrl-0 = <&spi0_pc_pins>; pinctrl-1 = <&spi0_cs0_pc_pin>; cs-gpios = <0>; /* PC23 for CS */ num-chipselects = <1>; display: display@0 { compatible = "adafruit,yx240qv29", "ilitek,ili9341"; reg = <0>; pinctrl-names = "default"; pinctrl-0 = <&display_pins>; spi-max-frequency = <24000000>; rotation = <270>; bgr = <0>; fps = <10>; buswidth = <8>; height = <240>; width = <320>; reset-gpios = <&pio 7 26 0>; /* PH26 for Reset */ dc-gpios = <&pio 7 27 0>; /* PH27 for Data/Command */ debug = <3>; }; }; }; __overrides__ { rotation = <&display>, "rotation:0"; fps = <&display>, "fps:0"; debug = <&display>, "debug:0"; }; }; I do find it strange however that you are not getting any activity on the DC line, are you sure you have probes labelled correctly? Best of luck Ryzer 0 Quote
Recommended Posts
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.