robertoj Posted December 8 Posted December 8 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: Spoiler 0xF7, 4, 0xA9, 0x51, 0x2C, 0x82, 0xC0, 2, 0x11, 0x09, 0xC1, 1, 0x41, 0xC5, 3, 0x00, 0x0A, 0x80, 0xB1, 2, 0xB0, 0x11, 0xB4, 1, 0x02, 0xB6, 2, 0x02, 0x22, 0xB7, 1, 0xC6, 0xBE, 2, 0x00, 0x04, 0xE9, 1, 0x00, 0x36, 1, 0x08, 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, 0x11, 0, TFTLCD_DELAY8, 120, 0x29, 0 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: Spoiler /* OrangePi Zero 3 -> ILI9341 LCD connections SPI CLOCK = PH6 SPI DO (LCD MISO) = PH8 (OPIZ MISO) SPI DI (LCD MOSI) = PH7 (OPIZ MOSI) LCD DATA/CONTROL = PC7 * LCD RESET = PC14 * could be any GPIO pin I want CHIP SELECT = PH9 VCC = 3.3V PIN 17 GND = GND PIN 20 */ /dts-v1/; /plugin/; /{ compatible = "allwinner,sun50i-h616"; /*what is the H618*/ fragment@0 { target = <&pio>; __overlay__{ display_pins: display_pins { pins = "PC7", "PC14"; /* reset, DC pins, order does not matter*/ function = "gpio_out", "gpio_out"; }; }; }; fragment@1 { target = <&spi1>; __overlay__ { /* needed to avoid dtc warning */ #address-cells = <1>; #size-cells = <0>; status="okay"; pinctrl-names = "default"; pinctrl-0 = <&spi1_pins>; /* Mux the PI to make sure they are set in spi Mode */ cs-gpios = <&pio 7 9 0>; /* PH9 chip select, H=7 */ num-chipselects = <1>; display: display@0 { /*compatible = "adafruit,yx240qv29","ilitek,ili9341";*/ compatible = "ilitek,ili9341"; reg = <0>; pinctrl-names = "default"; pinctrl-1 = <&display_pins>; spi-max-frequency = <40000000>; rotate = <270>; /* rotate for ili9341, rotation for yx240qv29 */ bgr=<0>; fps = <15>; buswidth = <8>; height = <640>; width = <320>; reset-gpios = <&pio 2 14 1>; /* PC14 reset pin*/ dc-gpios = <&pio 2 7 0>; /* PC7 Data control pin */ debug = <3>; 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>; }; }; }; __overrides__ { rotate = <&display>,"rotate:0"; fps = <&display>,"fps:0"; debug = <&display>,"debug:0"; }; }; 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) 0 Quote
robertoj Posted December 8 Author Posted December 8 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: Spoiler init = < 0x10000F7 0xA9 0x51 0x2C 0x82 //adjust control 3 0x10000C0 0x11 0x09 //power control 1 0x10000C1 0x41 //power control 2 0x10000C5 0x00 0x0A 0x80 //voltage common control 0x10000B1 0xB0 0x11 //frame rate control 0x10000B4 0x02 //display inversion control 0x10000B6 0x02 0x22 //display function control 0x10000B7 0xC6 //entry mode set 0x10000BE 0x00 0x04 //HS lanes control 0x10000E9 0x00 //set image function 0x1000036 0x08 //memory access control 0x10000E0 0x00 0x07 0x10 0x09 0x17 0x0B 0x41 0x89 0x4B 0x0A 0x0C 0x0E 0x18 0x1B 0x0F //PGAMCTR positive gamma control 0x10000E1 0x00 0x17 0x1A 0x04 0x0E 0x06 0x2F 0x45 0x43 0x02 0x0A 0x09 0x32 0x36 0x0F //NGAMCTRL negative gamma control 0x1000011 //sleep out command 0x1000029>; //display on 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 0 Quote
robertoj Posted December 8 Author Posted December 8 Changin the parameter Interface Pixel Format (3Ah) to 0x55 (DPI=DBI=55=16 bits/pixel FIXED THE COLORS 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? 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) 0 Quote
robertoj Posted December 9 Author Posted December 9 Posting the FBTFT DTS only... while I am having trouble merging it with ads7846: Spoiler /* OrangePi Zero 3 -> ILI9341 LCD connections SPI CLOCK = PH6 SPI DO (LCD MISO) = PH8 (OPIZ MISO) SPI DI (LCD MOSI) = PH7 (OPIZ MOSI) LCD DATA/CONTROL = PC7 * LCD RESET = PC14 * could be any GPIO pin I want CHIP SELECT = PH9 VCC = 3.3V PIN 17 GND = GND PIN 20 */ /dts-v1/; /plugin/; /{ compatible = "allwinner,sun50i-h616"; /*what is the H618*/ fragment@0 { target = <&pio>; __overlay__{ display_pins: display_pins { pins = "PC7", "PC14"; /* reset, DC pins, order does not matter*/ function = "gpio_out", "gpio_out"; }; }; }; fragment@1 { target = <&spi1>; __overlay__ { /* needed to avoid dtc warning */ #address-cells = <1>; #size-cells = <0>; status="okay"; pinctrl-names = "default"; pinctrl-0 = <&spi1_pins>; /* Mux the PI to make sure they are set in spi Mode */ cs-gpios = <&pio 7 9 0>; /* PH9 chip select, H=7 */ num-chipselects = <1>; display: display@0 { /*compatible = "adafruit,yx240qv29","ilitek,ili9341";*/ compatible = "ilitek,ili9341"; //compatible = "ilitek,ili9486"; reg = <0>; pinctrl-names = "default"; pinctrl-1 = <&display_pins>; spi-max-frequency = <60000000>; //txbuflen = <32768>; rotate = <90>; /* rotate for ili9341, rotation for yx240qv29 */ bgr=<1>; fps = <15>; buswidth = <8>; regwidth = <8>; height = <480>; width = <320>; reset-gpios = <&pio 2 14 1>; /* PC14 reset pin*/ dc-gpios = <&pio 2 7 0>; /* PC7 Data control pin */ debug = <3>; init = < 0x10000b0 0x00 //interface mode control 0x1000011 //sleep out command 0x20000ff //no idea what this does 0x100003a 0x55 //pixel format. DBI=DPI=16bits per pixel (from ili9341 init) 0x10000F7 0xA9 0x51 0x2C 0x82 //adjust control 3 0x10000C0 0x11 0x09 //power control 1 0x10000C1 0x41 //power control 2 0x10000C5 0x00 0x0A 0x80 //voltage common control 0x10000B1 0xB0 0x11 //frame rate control 0x10000B4 0x02 //display inversion control 0x10000B6 0x02 0x02 //display function control (2nd param SS shift direction was 0x22 from arduino code) 0x10000B7 0xC6 //entry mode set 0x10000BE 0x00 0x04 //HS lanes control 0x10000E9 0x00 //set image function 0x1000036 0x08 //memory access control 0x10000E0 0x00 0x07 0x10 0x09 0x17 0x0B 0x41 0x89 0x4B 0x0A 0x0C 0x0E 0x18 0x1B 0x0F //PGAMCTR positive gamma control 0x10000E1 0x00 0x17 0x1A 0x04 0x0E 0x06 0x2F 0x45 0x43 0x02 0x0A 0x09 0x32 0x36 0x0F //NGAMCTRL negative gamma control 0x1000011 //sleep out command 0x1000029>; //display on }; }; }; __overrides__ { rotate = <&display>,"rotate:0"; fps = <&display>,"fps:0"; debug = <&display>,"debug:0"; }; }; Ok, now I was able to merge the ads7946 function: Spoiler roberto@orangepizero3:~/ili9341$ cat ili9488-ads7846.dts /dts-v1/; /plugin/; / { compatible = "allwinner,sun50i-h616"; fragment@0 { target = <&spi1>; __overlay__ { status = "okay"; cs-gpios = <&pio 7 9 0>,<&pio 2 15 0>; //PH9=CS0 for lcd, PC15=CS1 for touch. ili9488: ili9488@0 { compatible = "ilitek,ili9341"; reg = <0>; pinctrl-names = "default"; spi-max-frequency = <60000000>; rotate = <90>; bgr = <1>; fps = <15>; buswidth = <8>; regwidth = <8>; height = <480>; width = <320>; reset-gpios = <&pio 2 14 1>; // PC14 dc-gpios = <&pio 2 7 0>; // PHC7 debug = <3>; init = < 0x10000b0 0x00 //interface mode control 0x1000011 //sleep out command 0x20000ff //no idea what this does 0x100003a 0x55 //pixel format. DBI=DPI=16bits per pixel (from ili9341 init) 0x10000F7 0xA9 0x51 0x2C 0x82 //adjust control 3 0x10000C0 0x11 0x09 //power control 1 0x10000C1 0x41 //power control 2 0x10000C5 0x00 0x0A 0x80 //voltage common control 0x10000B1 0xB0 0x11 //frame rate control 0x10000B4 0x02 //display inversion control 0x10000B6 0x02 0x02 //display function control (2nd param SS shift direction was 0x22 from arduino code) 0x10000B7 0xC6 //entry mode set 0x10000BE 0x00 0x04 //HS lanes control 0x10000E9 0x00 //set image function 0x1000036 0x08 //memory access control 0x10000E0 0x00 0x07 0x10 0x09 0x17 0x0B 0x41 0x89 0x4B 0x0A 0x0C 0x0E 0x18 0x1B 0x0F //PGAMCTR positive gamma control 0x10000E1 0x00 0x17 0x1A 0x04 0x0E 0x06 0x2F 0x45 0x43 0x02 0x0A 0x09 0x32 0x36 0x0F //NGAMCTRL negative gamma control 0x1000011 //sleep out command 0x1000029>; //display on }; ads7846: ads7846@1 { compatible = "ti,ads7846"; reg = <1>; pinctrl-names = "default"; spi-max-frequency = <1000000>; interrupt-parent = <&pio>; interrupts = <2 10 2>; // PC10 - IRQ pendown-gpio = <&pio 2 10 1>; // PC10 // 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>; }; }; }; }; 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 0 Quote
robertoj Posted December 10 Author Posted December 10 My efforts to use the panel-mipi-dbi-spi driver: DTS Spoiler roberto@orangepizero3:~/mipi-dbi$ cat mipi-ili9488-ads7846.dts /dts-v1/; /plugin/; / { compatible = "allwinner,sun50i-h616"; fragment@0 { target = <&spi1>; __overlay__ { status = "okay"; cs-gpios = <&pio 7 9 0>,<&pio 2 15 0>; /*PH9=CS0 for lcd, PC15=CS1 for touch. Trying <0> instead of <&pio 7 9 0> */ panel: panel@0 { compatible = "panel-mipi-dbi-spi"; reg = <0>; spi-max-frequency = <40000000>; width-mm=<84>; height-mm=<56>; reset-gpios = <&pio 2 14 0>; // PC14 dc-gpios = <&pio 2 7 0>; // PHC7 write-only; debug = <3>; 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 = <&pio>; interrupts = <2 10 2>; /* PC10 - IRQ */ pendown-gpio = <&pio 2 10 1>; /* PC10 */ /* 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>; }; }; }; }; Init sequence panel-mipi-dbi-spi.txt Spoiler command 0xB0 0x00 #interface mode control command 0x11 #sleep out command command 0x3A 0x55 #interface pixel format. DBI=DPI=16bits per pixel (from ili9341 init) command 0xF7 0xA9 0x51 0x2C 0x82 #adjust control 3 command 0xC0 0x11 0x09 #power control 1 command 0xC1 0x41 #power control 2 command 0xC5 0x00 0x0A 0x80 #voltage common control command 0xB1 0xB0 0x11 #frame rate control command 0xB4 0x02 #display inversion control command 0xB6 0x02 0x02 #display function control command 0xB7 0xC6 #entry mode set command 0xBE 0x00 0x04 #HS lanes control command 0xE9 0x00 #set image function command 0x36 0x28 #memory access control command 0xE0 0x00 0x07 0x10 0x09 0x17 0x0B 0x41 0x89 0x4B 0x0A 0x0C 0x0E 0x18 0x1B 0x0F #PGAMCTR command 0xE1 0x00 0x17 0x1A 0x04 0x0E 0x06 0x2F 0x45 0x43 0x02 0x0A 0x09 0x32 0x36 0x0F #NGAMCTRL command 0x11 #sleep out command delay 120 command 0x29 #display on 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 0 Quote
Solution robertoj Posted December 13 Author Solution Posted December 13 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): Spoiler roberto@orangepizero3:~/mipi-ili9488/v0_ips_touch_display$ cat orangepi-zero3-ads7846.dts /dts-v1/; /plugin/; / { compatible = "allwinner,sun50i-h616"; fragment@0 { target = <&spi1>; __overlay__ { status = "okay"; cs-gpios = <&pio 7 9 0>,<&pio 2 15 0>; // PH9=CS0 for lcd, PC15=CS1 for touch panel: panel@0 { compatible = "panel-mipi-dbi-spi"; reg = <0>; spi-max-frequency = <40000000>; width-mm=<84>; height-mm=<56>; reset-gpios = <&pio 2 14 0>; // PC14 dc-gpios = <&pio 2 7 0>; // PHC7 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 = <&pio>; interrupts = <2 10 2>; /* PC10 - IRQ */ pendown-gpio = <&pio 2 10 1>; /* PC10 */ /* 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>; }; }; }; }; 0 Quote
robertoj Posted December 14 Author Posted December 14 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 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.