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
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.