Jump to content

SPI touchscreen hangs


dock1100

Recommended Posts

I'm trying to make working 3.5" 320*480 TFT SPI display with touch screen on NanoPi K1 Plus with Armbian 20.05.2 (kernel 5.4.43). 

For now it works, but the touchscreen has issues.

In empty `startx` session cursor works for few minutes and then hangs, restarting `startx` make it working again for a while.

If I try to run x session with chrome,  the cursor hangs immediately. 

openbox-session & chromium --no-first-run --disable --disable-translate --disable-infobars --disable-suggestions-service --disable-save-password-bubble --start-maximized --kiosk --disable-session-crashed-bubble

Any ideas how to fix it?

 

 

Screen image

Spoiler

 

s-l1600.jpg

 

Configuration steps:

1. Enable 2 spi

Spoiler

git clone https://github.com/armbian/sunxi-DT-overlays.git
cd ./sunxi-DT-overlays/examples/
armbian-add-overlay spi-double-spidev-cs.dts

and add to /boot/armbianEnv.txt


overlays=analog-codec spi-spidev
param_spidev_spi_bus=0
param_spidev_max_freq=20000000
user_overlays=spi-double-spidev-cs

after reboot I have w spi devices /dev/spidev0.0 and /dev/spidev0.1

 

2. Screen and touchpanel dts, based on https://github.com/adafruit/adafruit-rpi-fbtft/blob/master/dts/overlays/rpi/piscreen-overlay.dts

Spoiler

content of myili9486.dts


/dts-v1/; 
/plugin/;

/ {
    compatible = "allwinner,sun50i-h5";

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

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

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


    fragment@1 {
        target = <&pio>;
        __overlay__ {
            ili9486_pins: ili9486_pins {
                allwinner,pins = "PA1", "PG9"; /* GPIOA1 (RST pin 25), GPIOG9 (LCD_RS pin 18) */
                allwinner,function = "gpio_in";
            };
        };
    };

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

            ili9486: ili9486@0 {
                compatible = "ilitek,ili9486";
                reg = <0>;
                pinctrl-names = "default";
                pinctrl-0 = <&ili9486_pins>;

                spi-max-frequency = <16000000>;
                txbuflen = <32768>;
                rotate = <90>;
                fps = <30>;
                bgr = <0>;
                buswidth = <8>;
                regwidth = <16>;
                reset-gpios = <&pio 0 1 1>;  /* GPIOA1 (RST) */
                dc-gpios = <&pio 0 201 0>; /* GPIOG9 (LCD_RS) */
                debug = <0>;

                init = <0x10000b0 0x00
                        0x1000011
                        0x20000ff
                        0x100003a 0x55
                        0x1000036 0x28
                        0x10000c2 0x44
                        0x10000c5 0x00 0x00 0x00 0x00
                        0x10000e0 0x0f 0x1f 0x1c 0x0c 0x0f 0x08 0x48 0x98 0x37 0x0a 0x13 0x04 0x11 0x0d 0x00
                        0x10000e1 0x0f 0x32 0x2e 0x0b 0x0d 0x05 0x47 0x75 0x37 0x06 0x10 0x03 0x24 0x20 0x00
                        0x10000e2 0x0f 0x32 0x2e 0x0b 0x0d 0x05 0x47 0x75 0x37 0x06 0x10 0x03 0x24 0x20 0x00
                        0x1000036 0x28
                        0x1000011
                        0x1000029>;
            };
        };
    };  

    fragment@3 {
        target = <&pio>;
        __overlay__ {
            ili9486_ts_pins: ili9486_ts_pins {
                allwinner,pins = "PA0" ;   /* GPIOA0 (TP_IRQ pin 11) */
                allwinner,function = "irq" ;
            };
        };
    };

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

            ili9486_ts: ili9486-ts@1 {
                compatible = "ti,ads7846";
                reg = <1>;
                pinctrl-names = "default";
                pinctrl-0 = <&ili9486_ts_pins>;
                spi-max-frequency = <2000000>;
                interrupts = <0 0 2>;  /* GPIOA0 (TP_IRQ) IRQ_TYPE_EDGE_FALLING */
                interrupt-parent = <&pio>; 
                pendown-gpio = <&pio 0 0 0>; /* GPIOA0 (TP_IRQ) */

                /* for GPIOA1, if gpio number is 1:
                    interrupts = <0 1 2>;
                    pendown-gpio = <&pio 0 1 0>;
                */

                ti,swap-xy = <1>;
                ti,x-min = /bits/ 16 <0>;
                ti,y-min = /bits/ 16 <0>;
                ti,x-max = /bits/ 16 <0x0F3C>;
                ti,y-max = /bits/ 16 <0x0F3C>;
                ti,pressure-min = /bits/ 16 <0>;
                ti,pressure-max = /bits/ 16 <0xFFFF>; 
                ti,x-plate-ohms = /bits/ 16 <400>; 
            };
        };
    };

};

compile and attach driver


armbian-add-overlay myili9486.dts

Add display description
nano /usr/share/X11/xorg.conf.d/99-fbdev.conf


Section "Device"  
  Identifier "ili9486"
  Driver "fbdev"
  Option "fbdev" "/dev/fb0"
EndSection


After reboot screen works

 

Touchscreen calibration


echo "DISPLAY=:0.0 xinput --set-prop 'ADS7846 Touchscreen' 'Coordinate Transformation Matrix' -1.06 0 1.06 0 1.06 -0.06 0 0 1" >> ~/.xsessionrc

 


3. Install software

apt-get install xserver-xorg xorg xserver-xorg-legacy xinit xinput openbox chromium

 

Edited by dock1100
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines