Jump to content

Driving the ili9488 LCD (4.0 inch cheap chinese clone)


Go to solution Solved by robertoj,

Recommended Posts

Posted

Hello, I have a new LCD which I believe is an ili4988 (although the vendor says ili9486 and st7796)

https://www.aliexpress.us/item/3256803856059047.html

 

I have read somewhere, that I can use an ili9341 spi driver, only by changing the resolution and changing the initialization script.

 

I looked in the waveshare website and github, they don't have anything for the ili9488

 

Then, I found some arduino code in http://www.lcdwiki.com/3.5inch_SPI_Module_ILI9488_SKU%3AMSP3520

(look for the "3.5 inch SPI Module Package(ILI9488)" link, then find the LCDWIKI_SPI.cpp

 

The initialization sequence is in line 1697:

  Reveal hidden contents

 

I am currently trying to convert it to a DTS-format init string, so that it fits my ili9341-fb.dts, which I made earlier this year:

  Reveal hidden contents

I am unsure how to start the init line, can someone help me?

 

Then, when I have that init string confirmed, I can use:

https://github.com/notro/panel-mipi-dbi/wiki

https://blog.csdn.net/CNflysky/article/details/125171176

 

To switch to the mipi-dbi driver, which would get me DRM (instead of FB)

Posted

If you want to help, the datasheet PDF is in the lcdwiki download link in the previous post :)

 

I converted the arduino byte sequence into this:

 

  Reveal hidden contents

The 4.0 inch ILI9488 starts up :)  with RGB noise (non moving) in the left 3/4 of the screen, and a blurry, noisy image in the right 1/4 of the screen. :(

 

There's a TFTLCD_DELAY8, 120, which I don't know how to insert in the DTS,

and the original ili9341-fb.dts has a 0x20000ff, which I don't know whether I need it in the ili9488 init string

 

I inserted the:

0x10000b0 0x00  //interface mode control
0x1000011  //sleep out
0x20000ff   //no idea

At the beginning, and there is no effect

 

I have no idea about the parameters buswidth, bgr, regwidth... what do they mean?

 

When I added regwidth=<16> (as shown in https://forum.armbian.com/topic/16536-35-screen-ili9486xpt2046-with-kernel-5914-sunxi/) I have a white-grayish screen

When I change it to regwidth=<24> I get the same RGB noise as without this parameter

 

When I swap the numbers in height and width like this:

height = <320>;
width = <640>;

I get the RGB noise in the left 3/4 of the screen, but the noisy desktop image (partial) in the top right corner of the LCD

 

I HAD A BIG TYPO: not 640, should be 480

height = <480>;
width = <320>;

 

Now, all the screen is mostly black, showing garbled text lines, then a garbled desktop on the top 2/3 of the screen

 

Changing the buswidth to 18 had no effect... I changed the regwidth=16 (made it worse) and txbuflen=32768 (no effect), as seen in https://4pda-to.translate.goog/forum/index.php?showtopic=1041048&st=40&_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=en&_x_tr_pto=wapp

 

Using the ili9486 driver as suggested here: https://github.com/notro/fbtft/issues/582 gave me a white screen

 

IMG_5275.jpeg

Posted

Changin the parameter Interface Pixel Format (3Ah) to 0x55 (DPI=DBI=55=16 bits/pixel FIXED THE COLORS :D

 

Insert this after 0x20000ff (I still have no idea what it is for)

0x100003a 0x55 //pixel format. DBI=DPI=16bits per pixel (from ili9341 init)

Now, the problem is that the desktop image is reversed left to right...

 

I changed the memory access control to vertical refreshed order direction=1

0x1000036 0x28 //memory access control (was 0x08 in arduino code)

No effect, still reversed left to right (or up down if I rotated 180)

 

Is there any difference if this parameter is written twice in the original ili9341 init byte sequence?

IMG_5282.jpeg

 

Ok, it was register B6h Display function control. The bit SS shift direction control was set to 1 in the arduino INO, but it needs to be 0

 

Change 0x10000B6 0x02 0x22 //display function control

0x10000B6 0x02 0x02 //display function control (2nd param SS shift direction was 0x22 from arduino code)

Also, change the rotate DTS parameter from 270 to 90 and the spi speed to 60 MHz

 

Display works correctly in FBTFT mode... but not DRM yet, and not merged with the ADS7846 function (touch screen)

IMG_5289.jpeg

Posted

Posting the FBTFT DTS only... while I am having trouble merging it with ads7846:

 

  Reveal hidden contents

 

Ok, now I was able to merge the ads7946 function:

 

  Reveal hidden contents

 

WARNING: when the touchscreen is touched, a horizontal band (about 8mm) gets color-inverted around the cursor. Lowering the SPI speed does not help it

^ Does anybody have any idea why this is happening? It is bugging me horribly and the color-inversion is lasting until a whole screen refresh and it could stand garbled while doing nothing in lightdm+openbox... is this coming from the touch chip interrupts, or from the cursor animation? Would it go away with the panel-mipi-dbi-spi driver?

 

Next step is to use the panel-mipi-dpi-spi driver as shown here: 

https://github.com/notro/panel-mipi-dbi/wiki ,

https://forums.raspberrypi.com/viewtopic.php?t=358240&hilit=Ili9341#p2165638and

https://blog.csdn.net/CNflysky/article/details/125171176

Posted

My efforts to use the panel-mipi-dbi-spi driver:

 

DTS

  Reveal hidden contents

 

Init sequence panel-mipi-dbi-spi.txt

  Reveal hidden contents

 

compile and install this init command byte sequence (I don't know how to use an arbitrary bin file in the DTS😞

./mipi-dbi-cmd panel-mipi-dbi.bin panel-mipi-dbi-spi.txt
sudo cp panel-mipi-dbi.bin /lib/firmware/

 

Make sure that the DTS was given to the kernel: look for "Applying user provided DT overlay mipi-ili9488-ads7846.dtbo" without errors before starting kernel

Make sure that the panel-mipi-dbi.bin was read by the driver: dmesg|grep mipi , look for no errors like "No config file found for compatible 'ili9488-init,panel-mipi-dbi-spi' (error=-2)"

 

Successfully loaded driver should look lije this:

roberto@orangepizero3:~$ dmesg|grep mipi
[    5.690191] panel-mipi-dbi-spi spi1.0: supply power not found, using dummy regulator
[    5.690338] panel-mipi-dbi-spi spi1.0: supply io not found, using dummy regulator
[    5.713936] [drm] Initialized panel-mipi-dbi 1.0.0 20220103 for spi1.0 on minor 2
[    6.205598] panel-mipi-dbi-spi spi1.0: [drm] fb0: panel-mipi-dbid frame buffer device

 

The panel-mipi-dbi-spi driver in Linux 6.7.12.has the parameters described in:

https://elixir.bootlin.com/linux/v6.7.12/source/Documentation/devicetree/bindings/display/panel/panel-mipi-dbi-spi.yaml

 

Upgrading to Linux 6.11+ has more parameters, like BGR666 color format

https://elixir.bootlin.com/linux/v6.12.4/source/Documentation/devicetree/bindings/display/panel/panel-mipi-dbi-spi.yaml

 

The panel-mipi-dbi-spi wiki: https://github.com/notro/panel-mipi-dbi/wiki

 

This is what I get so far

I think I need to upgrade to Linux 6.12 and experiment with other "Memory Access Control 0x36" bit values in panel-mipi-dbi-spi.txt

IMG_5347.jpeg

  • Solution
Posted

THANKS TO USER KungFuPancake, who showed me his github repo, where he indicates to use the latest Armbian-edge, and provides the a command byte sequence for the ili9488 :)

 

https://github.com/KungfuPancake/v0_ips_touch_display?tab=readme-ov-file

 

If you see inverted colors, edit the panel-mipi-dbi-spi.txt and comment the line #command 0x21 before using the mipi-dbi-cmd

 

If you have the cheap chinese clone LCD (see first post), use this DTS (change the gpio codes as needed):

  Reveal hidden contents

 

 

 

 

 

 

IMG_5447.jpeg

IMG_5448.jpeg

Posted

Is anyone getting a jumpy cursor, and garbled image around the areas of window refresh? (only at times of touching the screen)

 

I suspect it is caused by sharing the SPI bus with the ads7846 (XPT2040)... anyone knows?

 

I don't have this issue when I use the USB mouse.

 

I also experience the LCD going 3/4 black and frozen, when there are no input events. It restores to normal when I touch the screen or move the mouse (with a white washout/flash in the LCD).

My app is continuosly painting pixels, and it happens after a few minutes of no input events.

I already have:

xset s off &
xset s noblank
xset s -dpms

But it seems that I don't have "xset" installed in my debian bookworm. Fixed with apt install x11-xserver-utils

Posted

I found that you can rotate the ili9488 display 180 degrees, by changing the LCD initialization command in panel-mipi-dbi-spi.txt:

 

Change: command 0x36 0xE0

To: command 0x36 0x20

 

(changes memory access control row and column order from:

starting from the corner near the VCC pin, to

starting from the corner opposite from the VCC pin)

 

Then, open /usr/share/X11/xorg.conf.d/99-calibration, and add:

Option "InvertX" "1"

Option "InvertY" "1"

 

Reference:

https://focuslcds.com/wp-content/uploads/Drivers/ILI9488.pdf

https://forums.raspberrypi.com/viewtopic.php?t=173993

 

I hope it helps someone, or to myself in the future :)

 

Posted (edited)

I have the ili9488 working in orange pi zero 3 with my DTS in https://forum.armbian.com/topic/47971-driving-the-ili9488-lcd-40-inch-cheap-chinese-clone/#findComment-208446

 

and the panel-mipi-dbi-spi.txt from https://github.com/KungfuPancake/v0_ips_touch_display?tab=readme-ov-file

 

My DTS file uses the new panel-mipi-dbi-spi driver, which is not fbtft, it is tinydrm.

 

Kernel 6.12, built from https://github.com/NickAlilovic/build

 

I can use X11 completely fine, but I havent tried wayland and h264 acceleration yet. Can you try it?

 

The only problems I see:

Cursor has some "jumpiness" when pressing the touch panel (ads7846).

Graphic pixel noise appears when I am dragging an X11 window with finger. But it returns to normal after the dragging event. (doesn't happen when I drag with USB mouse).

 

I think the noise won't happen if I can make a separate soft-SPI for the touch function.

 

Has anybody tried xrandr? I learned to use it in my laptop, but I don't have my orange pi zero 3 available. Can anyone try:

$ xrandr --output SPI-1 --rotate left

Then replace left with: inverted, right and normal

This should take care of the touch at the same time, but someone needs to try it.

Edited by robertoj
Posted

Hi, sorry for the delay.

 

  On 3/5/2025 at 6:22 PM, robertoj said:

My DTS file uses the new panel-mipi-dbi-spi driver, which is not fbtft, it is tinydrm.

Expand  

 

I can't believe it !

This is just great. 

 

I will give it a try the next few days. Many thanks

Posted

I had time to test xrandr with my ili9488 and mipi-dbi-spi

 

while the LCD is showing X11+lightdm+openbox, I logged in via SSH and typed:

 

roberto@orangepizero3:~$ DISPLAY=:0.0 xrandr -q
xrandr: Failed to get size of gamma for output default
Screen 0: minimum 480 x 320, current 480 x 320, maximum 480 x 320
default connected 480x320+0+0 0mm x 0mm
   480x320        0.00*

roberto@orangepizero3:~$ DISPLAY=:0.0 xrandr --output default --rotate left
xrandr: output default cannot use rotation "left" reflection "none"

 

So, I can't rotate the LCD display with xrandr, and the only option is the 2 actions I shared on March 4

 

Note: the 4 rotate options are normal, right, left and inverted. None of them worked

Posted (edited)

So I've looked into my drawers and, unfortunately, I can't get my hands on the ili9488 display I own. I will order a new one.

But I've got another display of the same type (with the red PCB and 14 pins and resistive touch) with ili9486 driver IC.

 

In LCDWIKI_SPI.cpp, there's an init sequence for that chip, but I'm really confused.

 

  On 12/13/2024 at 5:11 AM, robertoj said:

THANKS TO USER KungFuPancake, who showed me his github repo, where he indicates to use the latest Armbian-edge, and provides the a command byte sequence for the ili9488

Expand  

 

Means that you have use this file: https://github.com/KungfuPancake/v0_ips_touch_display/blob/main/panel-mipi-dbi-spi.txt ?

 

It's really different from what is in LCDWIKI_SPI.cpp around line 1697 (for ili9488)

Edited by le51
Posted

Yes, you must use that panel-mipi-dbi-spi.txt, process it with the python script, copy it to the right folder, and use the DTS I shared last.

 

I havent seen another command byte sequence for ili9488. Can you post the link to the download (to make sure I will see the same thing).

 

Can you make a hypothetical byte sequence from the LCDWIKI_SPI.cpp?

Posted (edited)

This is from panel-mipi-dbi-spi.txt

 

command 0xE0 0x00 0x03 0x09 0x08 0x16 0x0A 0x3F 0x78 0x4C 0x09 0x0A 0x08 0x16 0x1A 0x0F
command 0xE1 0x00 0x16 0x19 0x03 0x0F 0x05 0x32 0x45 0x46 0x04 0x0E 0x0D 0x35 0x37 0x0F

 

This is from LCDWIKI_SPI.cpp for ili9488:

0xE0, 15, 0x00, 0x07, 0x10, 0x09, 0x17, 0x0B, 0x41, 0x89, 0x4B, 0x0A, 0x0C, 0x0E, 0x18, 0x1B, 0x0F,

0xE1, 15, 0x00, 0x17, 0x1A, 0x04, 0x0E, 0x06, 0x2F, 0x45, 0x43, 0x02, 0x0A, 0x09, 0x32, 0x36, 0x0F,

 

They are other commands that differs slightly. 

 

I've found other sources for the init sequence which seems all to be close to panel-mipi-dbi-spi.txt :

 

* Juj fbcp lib: https://github.com/juj/fbcp-ili9341/blob/master/ili9488.cpp#L28

* Bodmer eTFT_SPI lib for microcontrollers : https://github.com/Bodmer/TFT_eSPI/blob/master/TFT_Drivers/ILI9488_Init.h#L11

* Jarret Bucket Adafruit GLX lib : https://github.com/jaretburkett/ILI9488/blob/master/ILI9488.cpp#L378

* this one is for STM32 : https://github.com/RobertoBenjami/stm32_graphics_display_drivers/blob/master/Drivers/lcd/ili9488/ili9488.c#L219


In the same manner, we can found init sequences for other chips in these libraries, eg ili9486.

 

There's already a driver in the kernel source : https://web.git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/drivers/gpu/drm/tiny/ili9486.c?h=linux-6.12.y but it is specific to Waveshare 35a or PiScreen displays (these with 4 kind of shift register ICs onboard).

 

So for now, while waiting for a new ili9488 display arrives home, I'm digging further around the right init sequence for ili9486.

Edited by le51
Posted

Those LCD parameters where you found differences are:

PGAMCTRL (Positive Gamma Control) (E0h)

NGAMCTRL (Negative Gamma Control) (E1h)

 

(See the ILI9488 PDF I posted)

 

I don't know what they do exactly, but I guess they control pixel voltage, given a R, G or B digital value.

 

I think that you can worry about it, after everything else works.

Posted

Excellent news here: I've finally found my ili9488 display and, even better, I've got it to work with https://github.com/KungfuPancake/v0_ips_touch_display/blob/main/panel-mipi-dbi-spi.txt

I had to remove

command 0x21

which is specific for IPS displays (mine is TN) to get a correct color rendering.

 

But unfortunately all my attempts with the ili9486 display ends up with a blank screen (driver is registered, Xorg session start, but nothing on screen. I don't know how to debug further 😪 ...)

 

I'm doing all of this with a Raspberry Pi4b 6.12.18-v8+. I will try to test later on a Radxa 5b

Posted

When the driver is configured correctly for the orange pi zero 3, everything will look correct from inside the operating system and the SPI port will be clocking out bits.

 

But the LCD is a one-way communication device. The orange pi zero 3 will never know something has failed :(

 

The ILI9486 LCD's default byte ordering, color format, etc, may be different from the ILI9488.

 

You should find one example of ILI9486 running in raspberry pi, arduino, etc and find the initial byte command sequence. See how it differs from the KungFuPancake's txt file. Make changes to the txt file one by one line, toward being closer to the ili9486 byte sequence you find elsewhere.

 

If you are starting with a DTS that uses the "ilitek,ilixxxx" driver, and change it to "mipi-dbi-spi", remember to change the RESET pin definition (see my other ILI9431 thread for explanation)

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.

×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines