Jump to content

Driving the ili9488 LCD (4.0 inch cheap chinese clone)


Go to solution Solved by robertoj,

Recommended Posts

Posted

Good to know. I'm interested in getting the red LCD's to work as they are cheaper and more available, I purchased the waveshare only to test my SPI, SBC, and DTS formatting were functional. Now that I confirmed how to translate DTS to work with my SBC, I can work on the red ili9486/8 without worrying about it being a formatting issue.

Posted (edited)

I think I have a partial success but I'm struggling to get anything but white on the red display! Will update when I have more results. panel-mipi is loading, and Card-1-SPI appears under /sys/class/drm/ which is very promising. Verified that /lib/firmware/panel-mipi-dbi-spi is still present, still patched with Kungfupancake's init, and is loaded according to lsmod (as well as dmesg)

 

Spoiler

 

sudo dmesg | grep drm
[    4.002790] rockchip-drm display-subsystem: bound ff900000.vop (ops vop_component_ops [rockchipdrm])
[    4.004049] rockchip-drm display-subsystem: bound ff8f0000.vop (ops vop_component_ops [rockchipdrm])
[    4.028685] rockchip-drm display-subsystem: bound ff940000.hdmi (ops dw_hdmi_rockchip_ops [rockchipdrm])
[    4.030113] [drm] Initialized rockchip 1.0.0 for display-subsystem on minor 0
[    4.030278] rockchip-drm display-subsystem: [drm] Cannot find any crtc or sizes
[    4.030440] rockchip-drm display-subsystem: [drm] Cannot find any crtc or sizes
[    6.796700] systemd[1]: Starting modprobe@drm.service - Load Kernel Module drm...
[    6.863822] systemd[1]: modprobe@drm.service: Deactivated successfully.
[    6.864868] systemd[1]: Finished modprobe@drm.service - Load Kernel Module drm.
[    8.238975] [drm] Initialized panel-mipi-dbi 1.0.0 for spi1.0 on minor 1
[    8.345046] [drm] Initialized panfrost 1.4.0 for ff9a0000.gpu on minor 2
[    9.048179] panel-mipi-dbi-spi spi1.0: [drm] fb0: panel-mipi-dbid frame buffer device

sudo dmesg | grep mipi
[    8.230250] panel-mipi-dbi-spi spi1.0: supply power not found, using dummy regulator
[    8.230448] panel-mipi-dbi-spi spi1.0: supply io not found, using dummy regulator
[    8.238975] [drm] Initialized panel-mipi-dbi 1.0.0 for spi1.0 on minor 1
[    9.048179] panel-mipi-dbi-spi spi1.0: [drm] fb0: panel-mipi-dbid frame buffer device

sudo dmesg | grep spi
[    8.074489] OF: /spi@ff1d0000/ads7846@1: Read of boolean property 'ti,swap-xy' with a value.
[    8.076419] ads7846 spi1.1: touchscreen, irq 77
[    8.078736] input: ADS7846 Touchscreen as /devices/platform/ff1d0000.spi/spi_master/spi1/spi1.1/input/input0
[    8.230250] panel-mipi-dbi-spi spi1.0: supply power not found, using dummy regulator
[    8.230448] panel-mipi-dbi-spi spi1.0: supply io not found, using dummy regulator
[    8.238975] [drm] Initialized panel-mipi-dbi 1.0.0 for spi1.0 on minor 1
[    9.048179] panel-mipi-dbi-spi spi1.0: [drm] fb0: panel-mipi-dbid frame buffer device

sudo ls -al /sys/class/drm/
total 0
drwxr-xr-x  2 root root    0 Dec 31  1969 .
drwxr-xr-x 73 root root    0 Dec 31  1969 ..
lrwxrwxrwx  1 root root    0 Dec  5 01:28 card0 -> ../../devices/platform/display-subsystem/drm/card0
lrwxrwxrwx  1 root root    0 Dec  5 01:28 card0-HDMI-A-1 -> ../../devices/platform/display-subsystem/drm/card0/card0-HDMI-A-1
lrwxrwxrwx  1 root root    0 Dec  5 01:29 card1 -> ../../devices/platform/ff1d0000.spi/spi_master/spi1/spi1.0/drm/card1
lrwxrwxrwx  1 root root    0 Dec  5 01:28 card1-SPI-1 -> ../../devices/platform/ff1d0000.spi/spi_master/spi1/spi1.0/drm/card1/card1-SPI-1
lrwxrwxrwx  1 root root    0 Dec  5 01:29 card2 -> ../../devices/platform/ff9a0000.gpu/drm/card2
lrwxrwxrwx  1 root root    0 Dec  5 01:29 renderD128 -> ../../devices/platform/ff9a0000.gpu/drm/renderD128

 

 

My current DTS:

Spoiler

/dts-v1/;

/ {

    fragment@0 {
        target = <0xffffffff>;

        __overlay__ {
            status = "okay";
            #address-cells = <0x01>;
            #size-cells = <0x00>;

            ili9486@0 {
                compatible = "panel-mipi-dbi-spi";
                reg = <0>;
                spi-max-frequency = <40000000>;
                reset-gpios = <0xffffffff 0x1d 0x00>;
                dc-gpios = <0xffffffff 0x1c 0x00>;
                                write-only;
                                format = "b6x2g6x2r6x2";
                                width-mm= <84>;
                                height-mm=<56>;
                                panel-timing {
                                        hactive = <480>;
                                        vactive = <320>;
                                        hback-porch = <0>;
                                        vback-porch = <0>;
                                        clock-frequency = <0>;
                                        hfront-porch = <0>;
                                        hsync-len = <0>;
                                        vfront-porch = <0>;
                                        vsync-len = <0>;
                                };
            };

            ads7846@1 {
                compatible = "ti,ads7846";
                status = "okay";
                reg = <1>;
                id = <1>;
                spi-max-frequency = <2000000>;
                ti,x-plate-ohms = [00 3c];
                ti,pressure-max = [00 ff];
                ti,swap-xy = <0>;
                ti,invert-y = <1>;
                vcc-supply = <0xffffffff>;
                interrupts = <0x12 0x02>;
                interrupt-parent = <0xffffffff>;
                pendown-gpio = <0xffffffff 0x12 0x00>;
                phandle = <0x02>;
            };
        };
    };

    metadata {
        title = "Enable ili9486/8 Red LCD 3.5inch on SPI1";
        compatible = "rockchip,rk3399";
        category = "misc";
        exclusive = "GPIO1_B0\0GPIO1_A7\0GPIO1_B1\0GPIO1_B2\0GPIO4_D2\0GPIO4_D4\0GPIO4_D5";
        description = "Enable Waveshare 3.5inch RPi LCD (C) on SPI1.";
    };

    fragment@1 {
        target = <0xffffffff>;

        __overlay__ {
            num-cs = <0x02>;
            cs-gpios = <0xffffffff 0x0a 0x00 0xffffffff 0x1a 0x00>;
            pinctrl-names = "default\0high_speed";
            pinctrl-0 = <0xffffffff 0xffffffff 0xffffffff>;
        };
    };

    __symbols__ {
        ili9486 = "/fragment@0/__overlay__/ili9486@0";
        ads7846 = "/fragment@0/__overlay__/ads7846@1";
    };

    __fixups__ {
        spi1 = "/fragment@0:target:0\0/fragment@1:target:0";
        gpio4 = "/fragment@0/__overlay__/ili9486@0:reset-gpios:0\0/fragment@0/__overlay__/ili9486@0:dc-gpios:0\0/fragment@0/__overlay__/ads7846@1:interrupt-parent:0\0/fragment@0/__overlay__/ads7846@1:pendown-gpio:0\0/fragment@1/__overlay__:cs-gpios:12";
        vcc5v0_sys = "/fragment@0/__overlay__/ads7846@1:vcc-supply:0";
        gpio1 = "/fragment@1/__overlay__:cs-gpios:0";
        spi1_clk = "/fragment@1/__overlay__:pinctrl-0:0";
        spi1_rx = "/fragment@1/__overlay__:pinctrl-0:4";
        spi1_tx = "/fragment@1/__overlay__:pinctrl-0:8";
    };
};

 

 

Edit: I installed XFCE to test, and strangely this has caused dmesg to throw errors related to panel-mipi. I had these same errors when panel-mipi was missing from /lib/firmware but it is still present there.

Spoiler

sudo dmesg | grep mipi

[ 4.601157] panel-mipi-dbi-spi spi1.0: supply power not found, using dummy regulator

[ 4.601515] panel-mipi-dbi-spi spi1.0: supply io not found, using dummy regulator

[ 4.601904] panel-mipi-dbi-spi spi1.0: Direct firmware load for panel-mipi-dbi-spi.bin failed wit

h error -2

[ 4.601941] panel-mipi-dbi-spi spi1.0: No config file found for compatible 'panel-mipi-dbi-spi' (

error=-2)

[ 4.601960] panel-mipi-dbi-spi spi1.0: probe with driver panel-mipi-dbi-spi failed with error -2

 

Edited by forumtrekker
Posted (edited)

Can you share the DTS you used, to have success with the waveshare LCD? The only thing we need to extract from it are the gpio pins.

 

And I am curious how you made a waveshare LCD work.

 

The gpio formatting in your DTS looks very weird. Can you start with the DTS I shared?

 

Share also which armbian and Linux version you are using. (I can only help with a Linux 6.11 or newer).

 

If you only get a white LCD screen, it means that the LCD is not getting the right control signals in the correct pins. You don't need to try XFCE at this point. It won't work.

Edited by robertoj
Posted (edited)

My latest post on page two shows the waveshare clone LCD DTS, working under FBTFT not DRM. The gpio formatting is strange, but it is what I lifted from Radxa provided DTS for a different waveshare LCD that I'm adapting for the displays here. This DTS I have is functional, and I'm certain the pins are correct as the Red ili9488 display shows purple / blue lines using FBTFT (probably incorrect init sequence, since it shows purple and red using your FBTFT init sequence under ili9341 driver instead of ili9486. fb_ili9486 does not work as you also experienced), and the Blue waveshare clone display works perfectly.

 

Current working red DTS:

Spoiler
/dts-v1/;

/ {

    fragment@0 {
        target = <0xffffffff>;

        __overlay__ {
            status = "okay";
            #address-cells = <0x01>;
            #size-cells = <0x00>;

            ili9486@0 {
                compatible = "panel-mipi-dbi-spi";

                /* compatible = "ilitek,ili9341"; Don't forget to include init sequence and modprobe fbtft for this to semi-function. Add regwidth 16, buswidth 8, txbuflen 32768 for fbtft*/
                reg = <0>;
                spi-max-frequency = <40000000>;
                reset-gpios = <0xffffffff 0x1d 0x00>;
                dc-gpios = <0xffffffff 0x1c 0x00>;
                                write-only;
                                format = "b6x2g6x2r6x2";
                                width-mm= <84>;
                                height-mm=<56>;
                                panel-timing {
                                        hactive = <480>;
                                        vactive = <320>;
                                        hback-porch = <0>;
                                        vback-porch = <0>;
                                        clock-frequency = <0>;
                                        hfront-porch = <0>;
                                        hsync-len = <0>;
                                        vfront-porch = <0>;
                                        vsync-len = <0>;
                                };
            };

            ads7846@1 {
                compatible = "ti,ads7846";
                status = "okay";
                reg = <1>;
                id = <1>;
                spi-max-frequency = <2000000>;
                ti,x-plate-ohms = [00 3c];
                ti,pressure-max = [00 ff];
                ti,swap-xy = <0>;
                ti,invert-y = <1>;
                vcc-supply = <0xffffffff>;
                interrupts = <0x12 0x02>;
                interrupt-parent = <0xffffffff>;
                pendown-gpio = <0xffffffff 0x12 0x00>;
                phandle = <0x02>;
            };
        };
    };

    metadata {
        title = "Enable Waveshare 3.5inch RPi LCD (C) on SPI1";
        compatible = "rockchip,rk3399";
        category = "misc";
        exclusive = "GPIO1_B0\0GPIO1_A7\0GPIO1_B1\0GPIO1_B2\0GPIO4_D2\0GPIO4_D4\0GPIO4_D5";
        description = "Enable Waveshare 3.5inch RPi LCD (C) on SPI1.";
    };

    fragment@1 {
        target = <0xffffffff>;

        __overlay__ {
            num-cs = <0x02>;
            cs-gpios = <0xffffffff 0x0a 0x00 0xffffffff 0x1a 0x00>;
            pinctrl-names = "default\0high_speed";
            pinctrl-0 = <0xffffffff 0xffffffff 0xffffffff>;
        };
    };

    __symbols__ {
        ili9486 = "/fragment@0/__overlay__/ili9486@0";
        ads7846 = "/fragment@0/__overlay__/ads7846@1";
    };

    __fixups__ {
        spi1 = "/fragment@0:target:0\0/fragment@1:target:0";
        gpio4 = "/fragment@0/__overlay__/ili9486@0:reset-gpios:0\0/fragment@0/__overlay__/ili9486@0:dc-gpios:0\0/fragment@0/__overlay__/ads7846@1:interrupt-parent:0\0/fragment@0/__overlay__/ads7846@1:pendown-gpio:0\0/fragment@1/__overlay__:cs-gpios:12";
        vcc5v0_sys = "/fragment@0/__overlay__/ads7846@1:vcc-supply:0";
        gpio1 = "/fragment@1/__overlay__:cs-gpios:0";
        spi1_clk = "/fragment@1/__overlay__:pinctrl-0:0";
        spi1_rx = "/fragment@1/__overlay__:pinctrl-0:4";
        spi1_tx = "/fragment@1/__overlay__:pinctrl-0:8";
    };
};

 

 

 

Current working waveshare fbtft, laggy (waveshare LCD is a parallel display with shift register hacks and kind of bad, so lag is expected.) Haven't tried DMA or fbcp since fbtft is outdated anyway. I've commented what each line / hexadecimal represents, to make it easy to follow.

Spoiler
/dts-v1/;

/ {

	fragment@0 {
		target = <0xffffffff>; /* spi1 */

		__overlay__ {
			status = "okay";
			#address-cells = <0x01>;
			#size-cells = <0x00>;

			ili9486@0 {
				compatible = "fb_ili9486";
				reg = <0x00>; /* CS0 */
				spi-max-frequency = <0xf42400>; /* 16 MHz, higher or lower than this doesn't work on waveshare clone */
				txbuflen = <0x8000>; /* 32768 */
				rotate = <0x5a>; /* 90 */
				bgr = <0x00>; /* I have no idea */
				fps = <0x1e>; /* 30. Lags despite fps */
				buswidth = <0x08>; /* Only 8 works on red lcd */
				regwidth = <0x10>; /* 16 */
				debug = <0x00>;
				reset-gpios = <0xffffffff 0x1d 0x01>; /* gpio4 29 1 */
				dc-gpios = <0xffffffff 0x1c 0x00>; /* gpio4 28 0 */
				phandle = <0x01>; /* unsure, unable to compile without, phandle errors with. still works */
			};

			ads7846@1 {
				compatible = "ti,ads7846";
				status = "okay";
				reg = <0x01>; /* CS1 */
				id = <0x01>;
				spi-max-frequency = <0x1e8480>; /* 2MHz */
				ti,x-plate-ohms = [00 3c];
				ti,pressure-max = [00 ff];
				ti,swap-xy = <0x00>;
				ti,invert-y = <0x01>;
				vcc-supply = <0xffffffff>; /* vcc5v0_sys */
				interrupts = <0x12 0x02>; /* gpio4 18 2 */
				interrupt-parent = <0xffffffff>; /* gpio4 */
				pendown-gpio = <0xffffffff 0x12 0x00>; /* gpio4 18 0 */
				phandle = <0x02>;
			};
		};
	};

	metadata {
		title = "Enable Waveshare 3.5inch RPi LCD (C) on SPI1";
		compatible = "rockchip,rk3399";
		category = "misc";
		exclusive = "GPIO1_B0\0GPIO1_A7\0GPIO1_B1\0GPIO1_B2\0GPIO4_D2\0GPIO4_D4\0GPIO4_D5";
		description = "Enable Waveshare 3.5inch RPi LCD (C) on SPI1.";
	};

	fragment@1 {
		target = <0xffffffff>; /* spi1 */

		__overlay__ {
			num-cs = <0x02>;
			cs-gpios = <0xffffffff 0x0a 0x00 0xffffffff 0x1a 0x00>; /* gpio1 10 0, gpio4 26 0 */
			pinctrl-names = "default\0high_speed";
			pinctrl-0 = <0xffffffff 0xffffffff 0xffffffff>; /* spi_clk, spi_rx, spi_tx */
		};
	};

	__symbols__ {
		ili9486 = "/fragment@0/__overlay__/ili9486@0";
		ads7846 = "/fragment@0/__overlay__/ads7846@1";
	};

	__fixups__ {
		spi1 = "/fragment@0:target:0\0/fragment@1:target:0";
		gpio4 = "/fragment@0/__overlay__/ili9486@0:reset-gpios:0\0/fragment@0/__overlay__/ili9486@0:dc-gpios:0\0/fragment@0/__overlay__/ads7846@1:interrupt-parent:0\0/fragment@0/__overlay__/ads7846@1:pendown-gpio:0\0/fragment@1/__overlay__:cs-gpios:12";
		vcc5v0_sys = "/fragment@0/__overlay__/ads7846@1:vcc-supply:0";
		gpio1 = "/fragment@1/__overlay__:cs-gpios:0";
		spi1_clk = "/fragment@1/__overlay__:pinctrl-0:0";
		spi1_rx = "/fragment@1/__overlay__:pinctrl-0:4";
		spi1_tx = "/fragment@1/__overlay__:pinctrl-0:8";
	};
};

 

I spent several weeks trying variations of the DTS you provided, and I was never able to get it to work properly. I only got positive results when I started using the formatting I am now. The formatting is semi-understandable, every gpio and spi is just referenced at the end of the file by line name and position in increases of 4 (0 refers to the first item in a line, 4 to the second, 8 to the third etc), instead of being directly called in their location. For example, the target of fragment0 is 0xfffffff, which at the bottom of the DTS in the fixups section, is referred to as spi1. The cs-gpios are referred to in fixups in both gpio4  and gpio1.

 

I am using latest armbian compiled per your instructions / forum posts, running edge compiled armbian with kernel 6.18.0-rc6, with panel-mipi selected at kernel build time according to the KungfuPancake github, firmware placed in lib/firmware, and drm verified to be loaded and semi functioning. I've essentially followed all your forum posts but have not had the success you have had. I'm now wondering if I have to tell armbian how to use the display with DRM, because I read somewhere that fbtft will draw constantly to your screen, but DRM will only draw when called and by default stays a white screen until called by the system. I tried adding a line in /boot/armbian.conf which should use the /dev/fb0 device as a display when /sys/class/drm/card1-spi is present (which it is), but it doesn't change anything. Edit: it seems adding this is not necessary if plymouth is installed.

extras="fbcon=map:1"

 

I appreciate your help!

 

EDIT: I went through the first page of this thread again to check I haven't missed anything. since I've done multiple reinstall's etc... and realized after installing xfce this time, I didn't go through the updating of initramfs to ensure panel-mipi loads properly with plymouth installed. Panel-mipi seemed to still load fine and be present, but I went through the steps in your thread here and it fixed the following error I was having since installing XFCE, AND the screen is showing blue and black bars. The evidence seems to be pointing to the drm driver being initialized and used properly, so i'm going to make sure my gpio pin polarity is correct in my DTS since DRM expects flipped values in some cases compared to FBTFT, then I will check my wiring and shorten them in case it is physics / interference problem, and finally I'll try other init sequences from lcdwiki.

 [ 4.601941] panel-mipi-dbi-spi spi1.0: No config file found for compatible 'panel-mipi-dbi-spi' (error=-2) 

 

Edited by forumtrekker
fixed formatting of code, fixed kernel version
Posted (edited)

I got the display to work! I left out a phandle = <0x01> line in my ili9486@0 section, adding it made it work. DTS was fine otherwise. It's a little glitchy and laggy so I need to tinker with it more, but I see plymouth displaying properly! I can't seem to get into tty or XFCE, but I believe I'm not running wayland and it sounds like thats a requirement for tinydrm? I'll figure it out, but the hard part is over. Once I get everything polished I'll write a summary of my steps so its easy for others to follow.

 

Working DTS for the red ili9488 display using tinydrm driver:

Spoiler
/dts-v1/;

/ {

        fragment@0 {
                target = <0xffffffff>;

                __overlay__ {
                        status = "okay";
                        #address-cells = <0x01>;
                        #size-cells = <0x00>;

                        ili9486@0 {
                                compatible = "panel-mipi-dbi-spi";
                                reg = <0>;
                                spi-max-frequency = <40000000>;
                                reset-gpios = <0xffffffff 0x1d 0x00>;
                                dc-gpios = <0xffffffff 0x1c 0x00>;
                                write-only;
                                format = "b6x2g6x2r6x2";
                                width-mm= <84>;
                                height-mm=<56>;
                                phandle = <0x01>;
                                panel-timing {
                                        hactive = <480>;
                                        vactive = <320>;
                                        hback-porch = <0>;
                                        vback-porch = <0>;
                                        clock-frequency = <0>;
                                        hfront-porch = <0>;
                                        hsync-len = <0>;
                                        vfront-porch = <0>;
                                        vsync-len = <0>;
                                };
                        };

                        ads7846@1 {
                                compatible = "ti,ads7846";
                                status = "okay";
                                reg = <1>;
                                id = <1>;
                                spi-max-frequency = <2000000>;
                                ti,x-plate-ohms = [00 3c];
                                ti,pressure-max = [00 ff];
                                ti,swap-xy = <0>;
                                ti,invert-y = <1>;
                                vcc-supply = <0xffffffff>;
                                interrupts = <0x12 0x02>;
                                interrupt-parent = <0xffffffff>;
                                pendown-gpio = <0xffffffff 0x12 0x00>;
                                phandle = <0x02>;
                        };
                };
        };

        metadata {
                title = "Enable Waveshare 3.5inch RPi LCD (C) on SPI1";
                compatible = "rockchip,rk3399";
                category = "misc";
                exclusive = "GPIO1_B0\0GPIO1_A7\0GPIO1_B1\0GPIO1_B2\0GPIO4_D2\0GPIO4_D4\0GPIO4_D5";
                description = "Enable Waveshare 3.5inch RPi LCD (C) on SPI1.";
        };

        fragment@1 {
                target = <0xffffffff>;

                __overlay__ {
                        num-cs = <0x02>;
                        cs-gpios = <0xffffffff 0x0a 0x00 0xffffffff 0x1a 0x00>;
                        pinctrl-names = "default\0high_speed";
                        pinctrl-0 = <0xffffffff 0xffffffff 0xffffffff>;
                };
        };

        __symbols__ {
                ili9486 = "/fragment@0/__overlay__/ili9486@0";
                ads7846 = "/fragment@0/__overlay__/ads7846@1";
        };

        __fixups__ {
                spi1 = "/fragment@0:target:0\0/fragment@1:target:0";
                gpio4 = "/fragment@0/__overlay__/ili9486@0:reset-gpios:0\0/fragment@0/__overlay__/ili9486@0:dc-gpios:0\0/fragment@0/__overlay__/ads7846@1:interrupt-parent:0\0/fragment@0/__overlay__/ads7846@1:pendown-gpio:0\0/fragment@1/__overlay__:cs-gpios:12";
                vcc5v0_sys = "/fragment@0/__overlay__/ads7846@1:vcc-supply:0";
                gpio1 = "/fragment@1/__overlay__:cs-gpios:0";
                spi1_clk = "/fragment@1/__overlay__:pinctrl-0:0";
                spi1_rx = "/fragment@1/__overlay__:pinctrl-0:4";
                spi1_tx = "/fragment@1/__overlay__:pinctrl-0:8";
        };
};

 

 

Edited by forumtrekker

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