Jump to content

Driving the ili9488 LCD (4.0 inch cheap chinese clone)


Go to solution Solved by robertoj,

Recommended Posts

Posted

hello! i was trying to hook up a 3.5" display to my orange pi zero 2w, but when i try to use the DTS, all i get is black and white stripes. does anyone know a fix or what this even means? 

Posted (edited)

It probably means that you are close to having it work.

75% of the effort (or good luck) results in the LCD displaying noise or bad image.

 

What model LCD?

Photos?

Confirm the wiring matches the default SPI terminals and the custom GPIO I included in the DTS.

Are you connecting the touch chip terminals?

LInux and armbian version? Downloaded or self compiled?

Run the tests I have shown in several of my LCD threads: ili9341, ili9488.

Edited by robertoj
Posted

its an ili9488 3.5" cheap red SPI display, pretty much right after posting the comment i got it to output a garbled image, i did change the pins to match my pin connections. i was running orange pi branded debian, doing stuff on armbian doesn't work for some reason, im going to try to compile it myself. i completely removed touch from the DTS because i dont really need it. i am on orange pi zero 2w btw. for some reason i cant upload an image

Posted

My DTS is for the Orange Pi Zero 3.

 

There's another thread that shows the correct GPIO wiring and DTS GPIO definitions for Orange Pi Zero 2w.

Posted

hello again, i searched around and pretty much everything links back to this thread. this is the best result i could get on latest armbian, does anyone know what i can change? i think the problem is that the image is kinda shifted down and then goes back up? im pretty sure i need to change some kind of offset, but other than that im stumped
IMG_20250806_162936.thumb.jpg.4d7b274d0b6a3d26fc7b8d157c2780ac.jpg

Posted (edited)

Try a lower SPI frequency and use direct wires from the orange pi zero 2w to the LCD

 

There might be something in the panel-mipi-dbi-spi.bin firmware to improve the display of the received bytes, but first do these two improvements (first try the direct wires)

 

Opiz2w cases:

https://forum.armbian.com/topic/52880-orangepi-zero-2w-wrong-color-display-on-mpi3501/

https://forum.armbian.com/topic/44191-orangepi-zero-lts-ili9341-tft-lcd-and-later-orangepi-zero-3/page/2/

https://forum.armbian.com/topic/46824-orange-pi-zero-3-ili9486-tft-lcd/

 

Edited by robertoj
Posted (edited)

thanks! direct wiring has definitely changed something, i guess ill keep changing stuff and update if i get something
upd: the direct wiring has definitely made an improvement, but it still looks offset, i have no idea how to fix this, changing stuff in panel-timing just.. does stuff randomly, and i have no idea how to pick the right one. does anyone know the solution to this kind of weirdness?

this is the best i could get it:

 

IMG_20250806_232404.jpg

Edited by p a s h
Posted (edited)

post the link of the online store where you bought your LCD.

 

Why do you describe your problem as "offset", if your problem is a big rectangle that covers 25% of your screen?

Edited by robertoj
Posted

now that i think of it, i think you're right; the data being displayed is not offset its just straight up not displayed in some regions and wraps around for some reason. i bought the display here. its very likely resold from aliexpress.

Posted (edited)

The online store link doesnt work :(

 

Did you try lowering the SPI frequency?

 

Are you using the panel-mipi-dbi-spi driver?

 

I have no idea about the timing parameters in the firmware bin file. Are you familiar with notro's python script that turns a txt into a firmware bin file?

 

There's a chance that your LCD is bad. Try buying an extra LCD.

 

Future note for when you succeed with the driver: X11 will not work. There's a driver issue. If you can compile MESA3D you might get the needed updated driver. I have been using wayland+labwc... and I am currently in the effort to add a wayland greeter for the display manager (lightdm or greetd). (search my threads)

Edited by robertoj
Posted

oh so THAT'S why Xfce didnt launch, good to know. i did try lowering the SPI frequency but the result is pretty much the same. i am using the panel-mipi-dbi-spi driver, i will check the script later and see how it actually works. i am 100% sure the display is not defective, it works perfectly fine through tft_eSPI on an esp32, i will try getting an another unit and see if it changes anything.

Posted

Hmmm ok Now I am out of ideas.

 

Are you using a downloaded armbian image? I have been using only self-compiled armbian images... (I need features of the latest linux-edge)

 

It also prevents some problems if you uninstall or disable plymouth (interferes with loading the firmware file).

Posted

i am using a downloaded image, trying to compile armbian has been an awful experience, i guess ill keep trying different settings and see if anything changes

Posted (edited)
Quote

what specific issues did you run into?

ok so, i tried to replicate the issues i had but they just... didnt happen? everything just... works perfectly fine????? i have no idea if it was just that i was particularly unlucky or something, but i just compiled a working image fairly easily.
edit: nevermind, when i retried after a restart i got a

Failed to update binfmts [ update-binfmts --enable qemu-arm ]


error, googling yielded almost no information (host: fedora 42)

Quote

Make sure to power the VCC and LED with 3.3v, not 5v 


i did!

Quote

The online store link doesnt work

its a russian store, so it probably has a bunch of countries region blocked (for me it works, even through VPN)
 

Edited by p a s h
Posted (edited)

Share your DTS, maybe you missed something

 

Run:

 

dmesg | grep -E 'spi|panel' and post the result

 

I already saw the online store... it is the same LCD that I use (I have both 3.5" and 4.0" and they work with the same DTS and bin file)

Edited by robertoj
Posted

Are you using the same GPIO wiring as I am?

 

Previously, I was using different GPIO for the chip select, and touch wasn't working... now with my current GPIO in my DTS, it works perfectly.

Posted
Quote

we need full logs of your compilation.  Run like "./compile.sh [...] SHARE_LOG=yes"

 

here: https://paste.armbian.com/oyozunowab (running through docker on fedora 42 latest everything after a restart, the same issue happens on a fresh download too)

Quote

Share your DTS, maybe you missed something

Spoiler

/dts-v1/;
/plugin/;
/ {
    compatible = "allwinner,sun50i-h616";
    fragment@0 {
        target = <&spi1>;
        __overlay__ {
            status = "okay";
            cs-gpios = <&pio 7 5 0>; 
            panel: panel@0 {
                compatible = "panel-mipi-dbi-spi";
                reg = <0>;
                spi-max-frequency = <40000000>;
                width-mm=<79>;
                height-mm=<54>;
                reset-gpios = <&pio 8 6 0>;
                dc-gpios = <&pio 7 4 0>; 
                write-only;
                format = "b6x2g6x2r6x2";
                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>;
                };
            };
        };
    };
};

Quote

dmesg | grep -E 'spi|panel

i dont have it available atm, i will include it as soon as i can get access to it, but last time i checked dmesg there was pretty much no errors

Quote

Are you using the same GPIO wiring as I am?

no, not really, i changed the pins for D/C and reset iirc

Posted

Your gpios lines are declaring reset="i6" and dc="h4"... is that correct?

image.png.b0b73a28e014925d7bee612b871fce6a.png

At this point, we can see that all pins are correctly defined and connected.

 

Maybe wire length issue? Bad terminal connection? My wires are 15cm long... directly connected with dupont connectors.

Posted
Quote

Your gpios lines are declaring reset="i6" and dc="h4"... is that correct?

yep, thats how i connected them

Quote

Maybe wire length issue? Bad terminal connection?

i think it might be that? ill try to get some fresh wires and see if it helps

Posted (edited)

I noticed this problem a long time ago, but now I feel it is important to fix it:

 

I get a slim black bar on the left side, and a portion of the pixels on the right get "cropped" because they don't fit in the LCD display area?

 

I get the left 2 pixels of the screen "cropped", so in console, the first left-side are always missing the left pixels.

 

Do you get the same in your LCD? Do you know a way to fix it? I am talking about this LCD: RED PCB LCD https://www.aliexpress.us/item/3256802847521952.html?

Edited by robertoj
Posted

Hello!

 

First of all, thank you robertoj for this treasure trove of information - truly, I searched so much of the internet before finding this, because seemingly nobody is sharing DTS files for tft screens at all that aren't on a raspberry pi (which uses a different system afaik).

 

I am using a rockpi 4bplus, trying to get an ili9488/86 tft screen to work, and struggling. I've used your latest DTS from page 1, using panel-mipi, verified it loads into initramfs using your other threads, compiled my own armbian edge on kernel 6.18 (and tried on kernel 6.12), corrected all FDT err not found errors on the DTS for my use case (my gpio numbers were out of scope)... still, all I get on my display is a blank white screen with no dmesg errors or comments about spi, panel etc... ;-; Not sure what else to try at this point.

 

I'll post my files below, along with translated gpio pin numbers: 

 

/dts-v1/; 
/plugin/; 
/{
    compatible = "radxa,rockpi4b-plus", "radxa,rockpi4", "rockchip,rk3399";
    fragment@0 {
        target = <&spi1>;
        __overlay__ {
            #address-cells = <1>;
            #size-cells = <0>; 
            pinctrl-names = "default"; /* new for linux 6.13 */
            pinctrl-0 = <&spi1_clk &spi1_cs0 &spi1_rx &spi1_tx>; /* new for linux 6.13 */
            cs-gpios = <&spi1_cs0>, <&gpio4 26 0>; /* lcd, touch chip select */
            panel: panel@0 {
                compatible = "panel-mipi-dbi-spi";
                status = "okay";
                reg = <0>;
                spi-max-frequency = <40000000>;
                width-mm=<84>;
                height-mm=<56>;
                reset-gpios = <&gpio4 29 1>; /* taken from rock3c setup, then modified for armbian */
                dc-gpios = <&gpio4 28 0>; /* 1 is low, 0 is high */
                write-only;
                format = "b6x2g6x2r6x2";
                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: ads7846@1 {
                   compatible = "ti,ads7846";
                   reg = <1>;
                   pinctrl-names = "default";
                   spi-max-frequency = <1000000>;
                   interrupt-parent = <&gpio4>;
                   interrupts = <21 2>;  /* 2 is IRQ_TYPE_EDGE_FALLING
                   pendown-gpio = <&gpio4 21 0>; /* same as interrupt, pulled high */
                   vcc-supply = <&vcc5v0_sys>; /* Fill in the voltage according to the actual power supply c>

        /* OPTIONS */
                   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 <0XFFF>;
                   ti,x-plate-ohms = /bits/ 16 <400>;
                   ti,swap-xy = <1>;
            };
        };
    };
};

 

rock pi 4b Actual Pin Names.png

Posted (edited)

If you already checked "dmesg|grep panel-mipi" and "dmesg|grep spi", check this:

 

* share which LCD you are using. Half of those LCDs are waveshare clones, which need a different driver. My DTS works in the RED LCDs.

 

* Look at the uboot messages in the serial port output. Does it confirm it is finding your dtbo and using it?

 

* verify that panel-mipi-dbi.ko exists in the modules folder. I know it is not preselected by default within the linux configuration menu

 

* Search the word "pinctrl" in this thread https://forum.armbian.com/topic/44191-orangepi-zero-lts-ili9341-tft-lcd-and-later-orangepi-zero-3/#comment-204741

 

To confirm that the kernel driver is using the gpio and spi pins

 

* send link of the rock3c DTS you are referencing, to see an example of how GPIOs are configured

 

* correct the gpio pin map you shared. Instead of tx/rx, use MOSI, MISO. Highlight and label clearly the CS0, CS1, RESET, DC, IRQ

 

* explain how those gpio numbers gpioX,XX transform into the DTS gpioX XX 1/0

 

If you at least get noise in the LCD, you are 50% done :) (and maybe you will get lucky in the last 50%)

Edited by robertoj
Posted

Thanks for the reply! I'll address everything one by one:

 

  1. I am using the generic red ili9488 3.5inch TFT available everywhere, in this case at this link. I also have a generic red ili9341 2.4 inch TFT I purchased years ago to also test with. Neither seem to work with the DTS. It is definitely not the blue 3.5 inch waveshare screen which looks significantly different.
  2. Yes, uboot messages through serial console confirm my dtbo is found and applied without errors.  No FDT errors.
    Applying user provided DT overlay spi1-correctedgpio.dtbo
  3. panel-mipi-dbi.ko exists in /lib/modules on the custom compiled armbian running kernel 6.18, but not on the unmodified armbian provided image running kernel 6.12. When building armbian for panel-mipi I confirmed it was selected and it was marked "M" according to the github instructions.
  4. Here's the interesting one - basically every GPIO is unclaimed including the ones I have hooked up for the display when doing 
  5. Here's the link to the rock3c DTS I'm referencing. The Rock 3 pins are named very differently so I translated as best as I could to my rock 4, but I believe they are correct as I found that Radxa distributes a waveshare clone DTS for the rock pi 4 and the pins are named as I have named them. I've pasted the waveshare clone DTS distributed by Radxa below for reference.
  6. Using MOSI and MISO do not work, and according to the waveshare DTS I should be using spi_tx and spi_rx. Will continue trying MISO and MOSI in future edits though as it doesn't hurt.

 

You mentioning the waveshare display made me look into the DTBO distributed by radxa OS, I copied it to armbian and tried using it with the red display, and while it expectedly does not work, the pins I expect show up EXCEPT for touch IRQ, which is still unclaimed. I labelled touch, DC/RS, and reset pins for ease of reading in parenthesis. This makes me think I might have success formatting your ili9486 DTS to be similar with the waveshare DTS to get panel-mipi-dbi working on my red LCD. I get dmesg messages so its definitely closer.

Spoiler

 

rockpi-4bplus ~ sudo cat /sys/kernel/debug/pinctrl/pinctrl-rockchip-pinctrl/pinmux-pins
pin 39 (gpio1-7): ff1d0000.spi (GPIO UNCLAIMED) function spi1 group spi1-rx
pin 40 (gpio1-8): ff1d0000.spi (GPIO UNCLAIMED) function spi1 group spi1-tx
pin 41 (gpio1-9): ff1d0000.spi (GPIO UNCLAIMED) function spi1 group spi1-clk
pin 42 (gpio1-10): ff1d0000.spi gpio1:42 function spi1 group spi1-cs0
pin 146 (gpio4-18): (MUX UNCLAIMED) (GPIO UNCLAIMED) (touch IRQ)
pin 154 (gpio4-26): (MUX UNCLAIMED) gpio4:154 (touch CS)
pin 156 (gpio4-28): (MUX UNCLAIMED) gpio4:156 (DC/RS)
pin 157 (gpio4-29): (MUX UNCLAIMED) gpio4:157 (reset)

rockpi-4bplus ~ sudo dmesg | grep spi
[    8.462475] [drm] Initialized ili9486 1.0.0 for spi1.0 on minor 1
[    9.514457] ili9486 spi1.0: [drm] fb0: ili9486drmfb frame buffer device
[    9.529159] SPI driver fb_ili9486 has no spi_device_id for ilitek,ili9486

 

Here's the full waveshare DTS, note because I decompiled the DTBO with the dtc command, it looks like it lost the target pointers so I'm unsure (but can guess) what they point to. The GPIO pins are also lost but I know what pins they refer to as their pin number is in hex and I can narrow them down to the only pins available according to the pinout diagram. This doesn't affect the DTBO function as I paste the DTBO directly without decompiling, so in theory that should be unchanged and fully functional. At the very least, it claims the GPIO correctly.
 

Spoiler
/dts-v1/;

/ {

        fragment@0 {
                target = <0xffffffff>;

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

                        ili9486@0 {
                                compatible = "ilitek,ili9486";
                                reg = <0x00>;
                                spi-max-frequency = <0xf42400>;
                                txbuflen = <0x8000>;
                                rotate = <0x5a>;
                                bgr = <0x00>;
                                fps = <0x1e>;
                                buswidth = <0x08>;
                                regwidth = <0x10>;
                                debug = <0x00>;
                                reset-gpios = <0xffffffff 0x1d 0x01>;
                                dc-gpios = <0xffffffff 0x1c 0x00>;
                                phandle = <0x01>;
                        };

                        ads7846@1 {
                                compatible = "ti,ads7846";
                                status = "okay";
                                reg = <0x01>;
                                id = <0x01>;
                                spi-max-frequency = <0x1e8480>;
                                ti,x-plate-ohms = [00 3c];
                                ti,pressure-max = [00 ff];
                                ti,swap-xy = <0x00>;
                                ti,invert-y = <0x01>;
                                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_>
                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";
        };
};

 

 

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