fbtft with device tree overlay on mainline


Recommended Posts

Finally I got my lcd (some of them) to work with armbian on mainline kernel (5.4) using device tree overlay. It should be working on 4.19 kernel too.

I test mine on orange pi zero. The one I am able to get working is ili9341 and st7735 based lcd.

I'll add more detail later but for now I'd like to get this out.

 

edit 1 :
Adding ssd1306 and nokia 5110 overlay to the repo

 

device tree overlay

Link to post
Share on other sites
Armbian is a community driven open source project. Do you like to contribute your code?

ili9225 : cant make it work

Havent been able to make this lcd working properly. There seem to be driver for this in tinydrm, but after reading the source, I feel the driver is wrong. For one, it use 0x2A,0x2B etc to set RAM address, while ili9225 datasheet use 0x20 0x21 . There is flexfb support for this lcd, but the scanning looks bad and no matter what parameter I change , I cant fix it. So I'll give up on this lcd.

 

video showing this : ili9225 test

 

reference : https://crimier.wordpress.com/2019/12/03/ili9225-and-fbtft/

 

 

 

 

 

Link to post
Share on other sites

Hello, I also tried to use the mainline(5.8.14) to drive my ILI9341 screen. I tried to write an overlay (see attachment) and added a similar description to the booted armbianEnv.txt. My current situation is: the screen is on but not displaying Any content. Can you check it for me? My cable connection method is as follows:

ILI9341                     NanoPI_NEO Pin#

SCK     --------------- 23

SCI/MOSI ----------- 19

SDO/MISO ---------- 21

CS  -------------------- 24

DC/RS ----------------13  [GPIOA2 ]

RESET --------------- 11 [ GPIOA0 ]

VCC ------------------ 4(5V)

GND ------------------ 6

LED --------------------15 [GPIOA3]

 

This is my overlay source:

 

/dts-v1/;
/plugin/;
/ {
        compatible = "allwinner,sun8i-h3";

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

        fragment@1 {
                target = <&pio>;
                __overlay__ {
                        opiz_display_pins: opiz_display_pins {
                pins = "PA0", "PA2", "PA3"; 
                function = "gpio_out";
                        };
                };
        };

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

                        opizdisplay: opiz-display@0{
                                compatible = "ilitek,ili9341";
                                reg = <0>;  /* Chip Select 0 */
                                pinctrl-names = "default";
                                pinctrl-0 = <&opiz_display_pins>;

                                spi-max-frequency = <32000000>;
                                rotate = <90>;
                                bgr = <0>;
                                fps = <33>;
                                buswidth = <8>;
                                reset-gpios = <&pio 0 0 1 >; /* PIN_11  GPIOA0 */
                                dc-gpios = <&pio 0 2 0>;     /* PIN_13  GPIOA2 */
                                led-gpios=<&pio 0 3 0>;      /* PIN_15  GPIOA3 */
                                debug=<4>;
                                status="okay";
                        };
                };
        };
};

 

This is my "armbianEnv.txt"

verbosity=1
bootlogo=false
console=serial
disp_mode=1920x1080p60
overlay_prefix=sun8i-h3
overlays=cir spi-spidev usbhost1 usbhost2
rootdev=UUID=56420990-38dc-4f7e-a480-72cf6af39e27
rootfstype=ext4
user_overlays=sun8i-h3-I2S-out sun8i-h3-ili9341-v3
usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u

 

And dmesg | grep spi, output:

[   11.955745] fb_ili9341 spi0.0: fbtft_property_value: buswidth = 8
[   11.955766] fb_ili9341 spi0.0: fbtft_property_value: debug = 1
[   11.955774] fb_ili9341 spi0.0: fbtft_property_value: rotate = 90
[   11.955785] fb_ili9341 spi0.0: fbtft_property_value: fps = 33
[   11.956170] fb_ili9341 spi0.0: fbtft_request_one_gpio: 'reset' GPIO
[   11.956211] fb_ili9341 spi0.0: fbtft_request_one_gpio: 'dc' GPIO
[   11.956251] fb_ili9341 spi0.0: fbtft_request_one_gpio: 'rd' GPIO
[   11.956300] fb_ili9341 spi0.0: fbtft_request_one_gpio: 'wr' GPIO
[   11.956348] fb_ili9341 spi0.0: fbtft_request_one_gpio: 'cs' GPIO
[   11.956374] fb_ili9341 spi0.0: fbtft_request_one_gpio: 'latch' GPIO
[   11.956420] fb_ili9341 spi0.0: fbtft_request_one_gpio: 'db' GPIO
<font color=red>repeate n times</font>
[   11.956478] fb_ili9341 spi0.0: fbtft_request_one_gpio: 'led' GPIO
[   11.956523] fb_ili9341 spi0.0: fbtft_request_one_gpio: 'aux' GPIO
[   11.956550] fb_ili9341 spi0.0: fbtft_request_one_gpio: 'db' GPIO
[   11.956575] fb_ili9341 spi0.0: fbtft_request_one_gpio: 'led' GPIO
[   11.956611] fb_ili9341 spi0.0: fbtft_request_one_gpio: 'aux' GPIO
[   11.956647] fb_ili9341 spi0.0: fbtft_request_one_gpio: 'db' GPIO
[   11.956699] fb_ili9341 spi0.0: fbtft_request_one_gpio: 'led' GPIO
[   11.956725] fb_ili9341 spi0.0: fbtft_request_one_gpio: 'aux' GPIO
[   11.956749] fb_ili9341 spi0.0: fbtft_request_one_gpio: 'db' GPIO
[   11.956776] fb_ili9341 spi0.0: fbtft_request_one_gpio: 'led' GPIO
[   11.956799] fb_ili9341 spi0.0: fbtft_request_one_gpio: 'aux' GPIO
[   11.956823] fb_ili9341 spi0.0: fbtft_request_one_gpio: 'db' GPIO
[   11.956848] fb_ili9341 spi0.0: fbtft_request_one_gpio: 'led' GPIO
[   11.956871] fb_ili9341 spi0.0: fbtft_request_one_gpio: 'aux' GPIO
[   11.956898] fb_ili9341 spi0.0: fbtft_request_one_gpio: 'db' GPIO
[   11.956922] fb_ili9341 spi0.0: fbtft_request_one_gpio: 'led' GPIO
[   11.956945] fb_ili9341 spi0.0: fbtft_request_one_gpio: 'aux' GPIO
[   11.956968] fb_ili9341 spi0.0: fbtft_request_one_gpio: 'db' GPIO
[   11.956993] fb_ili9341 spi0.0: fbtft_request_one_gpio: 'led' GPIO
[   11.957017] fb_ili9341 spi0.0: fbtft_request_one_gpio: 'aux' GPIO
[   11.957041] fb_ili9341 spi0.0: fbtft_request_one_gpio: 'db' GPIO
[   11.957065] fb_ili9341 spi0.0: fbtft_request_one_gpio: 'led' GPIO
[   11.957088] fb_ili9341 spi0.0: fbtft_request_one_gpio: 'aux' GPIO
[   11.957111] fb_ili9341 spi0.0: fbtft_request_one_gpio: 'db' GPIO
<a font=red>end of repeat</a>
[   12.263909] graphics fb0: fb_ili9341 frame buffer, 320x240, 150 KiB video memory, 16 KiB buffer memory, fps=35, spi0.0 at 32 MHz

 

 

Now, only backlight is white. no any information on screen.

please help me!

 

Link to post
Share on other sites

Hi @spender, looking at your configuration, I dont see anything obviously wrong, I check your wiring at it seem correct . There is some difference with my setting (like I disable spidev on the dts and not enable spidev on armbienEnv.txt) but I am not sure it is the problem since based on your dmesg, look like the kernel driver still successfully loaded. Unfortunately it seem you have to dig at the hardware level to troubleshoot.

 

Here is my suggestion , not in particular order :

- Use older kernel in which fbtft_device still exist (I think 4.19, I am sure there is armbian image with that kernel) to test the lcd. It easier using fbtft_device because you dont need to restart to test it. If you can make it work here great, that mean the wiring actually correct and your lcd work, then its a matter of making the mainline kernel work.

- Test with logic analyzer, cheap saleae clone and sigrok goes really far. Make sure the signal is actually generated and WITH correct POLARITY.  I found out that I have to reverse the reset signal polarity in the dts by doing this. If correct signal is generated but your lcd doesnt display anything, I am afraid your lcd is toast.

- Make sure the lcd and driver are in same mode. Ili9341 can work with 8 bit or 9 bit spi, your module might only work with either setting or provide jumper to change the mode. However ili9341 kernel driver only work with 9 bit spi mode, so if you can't make the lcd work in 9 bit mode, I am afraid you cant use it with kernel driver.

Edited by Nuha Arina Rafiuddin
missing negative
Link to post
Share on other sites
/dts-v1/;
/plugin/;

/ {
        compatible = "radxa,rockpi4b", "radxa,rockpi4", "rockchip,rk3399";

        fragment@0 {
                target = <&spi2>;
                __overlay__ {
                        status = "okay";
                };
        };
        fragment@3 {
                target = <&pinctrl>;
                __overlay__ {
                    st7735rdisplay {
                        st7735r_display_pins: st7735r_display_pins {
                            rockchip,pins = 
                            <4 26 1 &pcfg_pull_none>,   //GPIO4_D2 (A->1 ... D->4 , D2 -> 4*8+2 = 26)
                            <4 28 1 &pcfg_pull_none>;   //GPIO4_D4 (A->1 ... D->4 , D4 -> 4*8+4 = 28)
                        };
                    };
                };
        };
        fragment@5 {
                target = <&spi2>;
                __overlay__ {
                        /* needed to avoid dtc warning */
                        #address-cells = <1>;
                        #size-cells = <0>;
                        
                        st7735rdisplay: st7735r-display@0{
                                compatible = "jianda,jd-t18003-t01", "sitronix,st7735r";
                                reg = <0>;
                                pinctrl-names = "default";
                                pinctrl-0 = <&st7735r_display_pins>;
                                spi-max-frequency = <40000000>;
                                rotation = <90>;
                                fps = <20>;
                                height = <160>;
                                width = <128>;
                                buswidth = <8>;
                                reset-gpios = <&gpio4 26 0>;    //Refer to previous one
                                dc-gpios = <&gpio4 28 0>;
                                debug = <0>;
                        };

                };
        };
        __overrides__ {
                speed =     <&st7735rdisplay>,"spi-max-frequency:0";
                rotate =    <&st7735rdisplay>,"rotation:0";
                fps =       <&st7735rdisplay>,"fps:0";
                debug =     <&st7735rdisplay>,"debug:0";
        };
};

This is my working dts config of a st7735 lcd on a rock pi 4. It uses spi2 and should be working on any rk3399 based boards with little editing.

Link to post
Share on other sites

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...