Jump to content

use fb_ili9341 failed


spender

Recommended Posts

I had build armbian 3 days ago, kernel ="5.8.13", with NanopiNEO, I want use a TFT screen, type is ILI9341, when I use "armbian-config" open spi_spidev, no /dev/spi* created, and screen does not work. here is config:

#

# cat /etc/modprobe.d/fbtft.conf
options fbtft
options fb_ili9341 name=fb_ili9341 gpios=rest:0,cs:67,dc:2,led:3 speed=48000000 fps=26 rotate=90 bgr=1 txbuflen=65536 debug=3

here is armbian-hardware-monitor.log

 

Other:  ttyS0 can't login, 

 

Does somebody can help me, thinks very much!

 

armbian-hardware-monitor.log

Link to comment
Share on other sites

After several days of study, I know that the new kernel version has cancelled the fbtft_device.ko method to drive fbtft, and changed it to the DT method. I also learned about the pinctrl subsystem, and tried to write an overlay by myself. After loading, the kernel has been found SPI device. The screen still doesn’t light up after the device is turned off. I don’t know the reason. I’m still looking for it. Can you help me?

dmesg output :

[   12.229733] [drm] Initialized ili9341 1.0.0 20180514 for spi0.0 on minor 0
[   12.706426] ili9341 spi0.0: fb0: ili9341drmfb frame buffer device

This is my overlay file, with DT fs check is OK!

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

        fragment@0 {
                target = <&spi0>;
                __overlay__ {
                        status = "okay";
                        spidev {
                                compatible = "adafruit,yx240qv29", "ilitek,ili9341";
                                reg = <0>;
                                spi-max-frequency = <32000000>;
                                txbuflen = <32768>;
                                rotate = <90>;
                                fps = <33>;
                                bgr = <0>;
                                buswidth = <8>;
                                dc-gpios = <&pio 0 2 1>;         /* PA2 pin13 */
                                reset-gpios = <&pio 0 0 1>;  /* PA0 pin11 */
                                led-gpios = <&pio 0 3 1>;        /* PA3 pin15 */
                                debug = <0>;
                                status="okay";
                        };
                };
        };
};

The Dupont wire connection method just like:

 * wire link:

 * ILI9341_PIN#      NanoPI-NEO_PIN#

 * SCK        <--->  23 GPIOC2

 * SDI/MOSI   <--->  19 GPIOC0

 * SDO/MISO   <--->  21 GPIOC1 

 * CS         <--->  24 [linux gpio=67] gpioC3 

 * DC/RS      <--->  13 [linux gpio=2] GPIOA2

 * RESET      <--->  11 [linux gpio=0] GPIOA0

 * VCC        <--->  4

 * GND        <--->  6

 * LED        <--->  15 [linux gpio=3] GPIOA3

 

Link to comment
Share on other sites

/*
 * Device Tree overlay for ILI9341 LCD

 */

/*

 * wire link:

 * ILI9341_PIN#      NanoPI-NEO_PIN#

 * SCK        <--->  23 GPIOC2

 * SDI/MOSI   <--->  19 GPIOC0

 * SDO/MISO   <--->  21 GPIOC1 

 * CS         <--->  24 gpioC3 spi0_pins 

 * DC/RS      <--->  22 GPIOA1

 * RESET      <--->  7  GPIOG11

 * VCC        <--->  4

 * GND        <--->  6

 * LED        <--->  12 GPIOA6

 *

 * Device Tree overlay for ili9341 2.2inch TFT LCD

 * 5.x 内核

 */

/dts-v1/;

/plugin/;

/ {

        compatible = "allwinner,sun8i-h3";

 

        fragment@0 {

                target = <&spi0>;

                __overlay__ {

                        status = "okay";

                };

        };

 

        fragment@1 {

                target = <&pio>;

                __overlay__ {

                        spi0_cs_pins: spi0_cs_pins {

                                pins = "PC3";

                                function = "gpio_out";

                        };

 

                        opiz_display_pins: opiz_display_pins {

                pins = "PA1", "PG11", "PA6";

                function = "gpio_out";

                        };

                };

        };

 

        fragment@2 {

                target = <&spi0>;

                __overlay__ {

                        /* needed to avoid dtc warning */

                        #address-cells = <1>;

                        #size-cells = <0>;

                        pinctrl-0=<&spi0_pins &spi0_cs_pins>;

                        cs-gpios=<&pio 2 3 1>;

 

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

                                dc-gpios = <&pio 0 1 0>;     /* PIN_22  GPIOA1 */

                                reset-gpios = <&pio 6 11 1 >; /* PIN_7  GPIOG11 */

                                led-gpios=<&pio 0 6 0>;      /* PIN_12  GPIOA6 */

                                debug=<4>;

                                status="okay";

                        };

                };

        };

};

 

image.png

Link to comment
Share on other sites

I don't understand "The screen still doesn’t light up after the device is turned off. "

 

My screen is on order and I hope to have it work with Duo2 and am looking at the spi drivers and the ili9341 code. Hopefully you get it to work so I can follow your example.

 

See /build/cache/sources/linux-mainline/orange-pi-5.9/drivers/gpu/drm/tiny/ili9341.c to see if any DT items you may have missed or not configured correctly. 

 

If you download the source take a look at ili9341_probe( struct spi_device *spi)

       ... devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);

       ...  devm_gpiod_get_optional(dev, "dc", GPIOD_OUT_LOW);

       ... devm_of_find_backlight(dev);

       ... device_property_read_u32(dev, "rotation", &rotation);

       ...  mipi_dbi_dev_init(spi, dbi, dc);

 

This is what the probe does. Your DT seems to have the right elements. Maybe try stripping your wiring down to the absolute minimum needed?

 

Link to comment
Share on other sites

[    7.798092] [drm] Initialized ili9341 1.0.0 20180514 for spi1.0 on minor 1
I have an ili9341 lcd 

After loading, the kernel has been found SPI device. But the log ing screen can not seen. It is just waitng there 

 

How did you solve the problems 

My DT-overlay is shown below and I ma using beaglebone black

 

 

/*
 * Copyright (C) 2013 CircuitCo
 * Copyright (C) 2018 Drew Fustini <drew@beagleboard.org>
 * Copyright (C) 2019 Mark A. Yoder <mark.a.yoder@beagleboard.org>
 *
 * Adafruit 2.4" TFT LCD on SPI1 bus using tinydrm ili9341 driver
 *
 * LICENSE:
 * --------
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * DOCUMENTATION:
 * --------------
 * This file was copied from src/arm/BB-SPIDEV1-00A0.dts and modified
 * by Drew Fustini based on an exmample from David Lechner.
 * Later modified by Mark A. Yoder for the 2.4" LCD.
 *
 * This is the Adafruit 2.4" TFT LCD:
 * https://www.adafruit.com/product/2478
 *
 * It should be connected to BeagleBone SPI1 bus:
 *
 *   P9.16 <--> lite (pwm) [OPTIONAL]
 *   P9.23 <--> lite (gpio) [OPTIONAL]
 *   P9.25 <--> reset
 *   P9.27 <--> dc
 *   P9.28 <--> tft_cs
 *   P9.29 <--> miso
 *   P9.30 <--> mosi
 *   P9.31 <--> clk
 *
 * This overlay will load the mainline tinydrm ili9341 driver by David Lechner:
 * https://github.com/torvalds/linux/blob/master/drivers/gpu/drm/tiny/ili9341.c
 *
 * Tested with 4.19.59-ti-r26 kernel on Debian 10.1 image
 *
 * Run libdrm modetest for colorbar test based on instructions from:
 * https://github.com/notro/tinydrm/wiki/Development#modetest
 *
 * modetest -M "ili9341" -c #this will display connector id
 * modetest -M "ili9341" -s 28:128x160 #connector id and resolution
 * # you should now see a color bar on the LCD
 *
 * Mailing list post with more information:
 * https://groups.google.com/d/msg/beagleboard/GuMQIP_XCW0/b3lxbx_8AwAJ
 *
 * Discussion with notro on how to test tinydrm driver:
 * https://github.com/notro/tinydrm/issues/1#issuecomment-367279037
 */

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/pinctrl/am33xx.h>
#include <dt-bindings/board/am335x-bbw-bbb-base.h>

/dts-v1/;
/plugin/;

/ {
    /*
     * Helper to show loaded overlays under: /proc/device-tree/chosen/overlays/
     */
    fragment@0 {
        target-path="/";
        __overlay__ {

            chosen {
                overlays {
                    BB-LCD-ADAFRUIT-24-SPI1-00A0 = __TIMESTAMP__;
                };
            };
        };
    };

    /*
     * Free up the pins used by the cape from the pinmux helpers.
     */
    fragment@1 {
        target = <&ocp>;
        __overlay__ {
            P9_25_pinmux { status = "disabled"; };    /* lcd reset */
            P9_16_pinmux { status = "disabled"; };  /* lcd pwm backlight (OPTIONAL) */
            P9_27_pinmux { status = "disabled"; };    /* lcd dc */
        //    P9_23_pinmux { status = "disabled"; };    /* lcd gpio backlight (OPTIONAL) */
            P9_28_pinmux { status = "disabled"; };    /* spi1_cs0 */
            P9_29_pinmux { status = "disabled"; };    /* spi1_d0 */
            P9_30_pinmux { status = "disabled"; };    /* spi1_d1 */
            P9_31_pinmux { status = "disabled"; };    /* spi1_sclk */
        };
    };

    fragment@2 {
        target = <&am33xx_pinmux>;
        __overlay__ {
            /* default state has all gpios released and mode set to uart1 */
            /* See page 1446 of am35xx TRM */
            bb_spi1_pins: pinmux_bb_spi1_pins {
                pinctrl-single,pins = <
                    BONE_P9_31 0x33    /* mcasp0_aclkx.spi1_sclk,  INPUT_PULLUP | MODE3 */
                    BONE_P9_29 0x33    /* mcasp0_fsx.spi1_d0,      INPUT_PULLUP | MODE3 */
                    BONE_P9_30 0x13    /* mcasp0_axr0.spi1_d1,    OUTPUT_PULLUP | MODE3 */
                    BONE_P9_28 0x13    /* mcasp0_ahclkr.spi1_cs0, OUTPUT_PULLUP | MODE3 */
                    BONE_P9_27 0x17    /* gpio, dc,               OUTPUT_PULLUP | MODE07*/
                    BONE_P9_25 0x17    /* gpio, reset,            OUTPUT_PULLUP | MODE07*/
                    // BONE_P9_42A 0x12    /* eCAP0_in_PWM0_out.spi1_cs1 OUTPUT_PULLUP | MODE2 */
                >;
            };

            backlight_pwm_pins: pinmux_backlight_pwm_pins {
                pinctrl-single,pins = <
                    BONE_P9_16 0x06 /* gpmc_a2.ehrpwm1b, OMAP_MUX_MODE6 | AM33XX_PIN_OUTPUT */
                >;
            };  /* gpmc_a2.ehrpwm1b */
        };
    };

    fragment@3 {
        target = <&epwmss1>;
        __overlay__ {
            status = "okay";
        };
    };

    fragment@4 {
        target = <&ehrpwm1>;
        __overlay__ {
            pinctrl-names = "default";
            pinctrl-0 = <&backlight_pwm_pins>;
            status = "okay";
        };
    };

    fragment@5 {
        target-path = "/";
        __overlay__ {

            bl_reg: backlight-regulator {
                compatible = "regulator-fixed";
                regulator-name = "backlight";
                regulator-always-on;
                regulator-boot-on;
            };

            /* backlight is optional */
            backlight_gpio: backlight_gpio {
                compatible = "gpio-backlight";
                gpios = <&gpio1 17 0>;
                // connect lcd lite pin to P9.23 which is gpio1[17]
                // refer to https://elinux.org/Beagleboard:Cape_Expansion_Headers
            };

            /*
             * Turn the PWM backlight on by setting bl_power to 0:
             * echo 0 > /sys/class/backlight/backlight_pwm/bl_power
             */
            backlight_pwm: backlight_pwm {
                // P9.16 <--> lite (pwm-backlight EHRPWM1B)
                status = "okay";
                compatible = "pwm-backlight";
                pwms = <&ehrpwm1 1 500000 0>;    // First digit: 0 for A side of pwm, 1 for B side
                                                // 500000 is the PWM period in ns
                                                // https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/pwm/pwm.txt
                brightness-levels = <
                    0  1  2  3  4  5  6  7  8  9
                    10 11 12 13 14 15 16 17 18 19
                    20 21 22 23 24 25 26 27 28 29
                    30 31 32 33 34 35 36 37 38 39
                    40 41 42 43 44 45 46 47 48 49
                    50 51 52 53 54 55 56 57 58 59
                    60 61 62 63 64 65 66 67 68 69
                    70 71 72 73 74 75 76 77 78 79
                    80 81 82 83 84 85 86 87 88 89
                    90 91 92 93 94 95 96 97 98 99
                    100
                >;
                default-brightness-level = <100>;
                power-supply = <&bl_reg>;
            };
        };
    };

    fragment@6 {
        target = <&spi1>;
        __overlay__ {
            #address-cells = <1>;
            #size-cells = <0>;

            status = "okay";
            pinctrl-names = "default";
            pinctrl-0 = <&bb_spi1_pins>;

            display@0{
                status = "okay";
                compatible = "adafruit,yx240qv29", "ilitek,ili9341";
                reg = <0>;
                spi-max-frequency = <32000000>;
                dc-gpios    = <&gpio3 19 0>;   // lcd dc    P9.27 gpio3[19]
                reset-gpios = <&gpio3 21 1>;   // lcd reset P9.25 gpio3[21]
                // backlight is optional
                // choose either pwm or gpio control
                //backlight = <&backlight_gpio>; // lcd lite  P9.23 gpio1[17]
                backlight = <&backlight_pwm>;    // lcd lite  P9.16 gpmc_a2.ehrpwm1b
                // refer to https://elinux.org/Beagleboard:Cape_Expansion_Headers
                // rotation is optional
                rotation = <270>;
            };
        };
    };
};

Link to comment
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...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines