Jump to content

Connecting banana pi m2 zero with ili9341 display over spi on latest armbian image


yaya8888

Recommended Posts

Hello guys,

i'm trying to connect that ili9341 display with my m2 zero but it wont work. My armbian Version:  Armbian_23-02-0-trunk_Bananapim2zero_lunar_edge_6.1.11_xfce_desktop

The display has a pinout that matches  with the raspberry pi, so also the banana pi m2 zero would do the job, since it has the same pinout like the raspberry pi has.

It uses 26 pins to connect to the banana pi m2 zero gpio output pins. 3 buttons and a touch panel are available but i only want to use the lcd for now.

 

I edited the armbianEnv.txt to open the spi port and added my overlay tft.dts to /boot/overlay-user but i cant get a picture on the screen, Its just glowing white.

Am I missing something? Are my gpios numbers in the overlay correct? do i have to install additional software?

 

I would be very happy for tips or help!

 

 

My armbianEnv.txt :

 

 

verbosity=1

bootlogo=false

console=both

disp_mode=1920x1080p60

overlay_prefix=sun8i-h3

rootdev=UUID=39f6ab06-e14f-4885-8454-717c5405f006

rootfstype=ext4

overlays=cpu-clock-1.2GHz-1.3v spi-spidev

param_spidev_spi_bus=0

user_overlays=tft

usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u

 

My overlay tft.dts

 

/dts-v1/;

/plugin/;

 

/ {

compatible = "allwinner,sun4i-a10", "allwinner,sun7i-a20", "allwinner,sun8i-h3", "allwinner,sun50i-a64", "allwinner,sun50i-h5";

 

fragmen@0 {

target = <&pio>;

__overlay__ {

display_pins: display_pins {

pins = "PC0", "PC3";

function = "gpio_out";

};

};

};

 

fragment@1 {

target = <&spi0>;

__overlay__ {

/* needed to avoid dtc warning */

#address-cells = <1>;

#size-cells = <0>;

 

display: display@0 {

compatible = "adafruit,yx240qv29", "ilitek,ili9341";

reg = <0>;

pinctrl-names = "default";

pinctrl-0 = <&display_pins>;

spi-max-frequency = <16000000>;

rotation= <270>;

bgr;

fps = <10>;

buswidth = <8>;

height = <240>;

width = <320>;

reset-gpios = <&pio 0 25 0>; /* GPIOA 6 */

dc-gpios = <&pio 0 24 0>; /* GPIOA 3 */

debug = <3>;

};

};

};

 

__overrides__ {

rotation = <&display>, "rotation:0";

fps = <&display>, "fps:0";

debug = <&display>, "debug:0";

};

};

 

 

 

 

 

Link to comment
Share on other sites

Hi there,

 

I have also been trying to get an ili9341 display to work on my board as well. still learning about overlays but from what I can tell from my own test is that gpio's should be <&pio 0 6 0> and <&pio 0 3 0>  in your case rather than:

On 3/21/2023 at 5:46 PM, yaya8888 said:

reset-gpios = <&pio 0 25 0>; /* GPIOA 6 */

dc-gpios = <&pio 0 24 0>; /* GPIOA 3 */

The first number refers to the bank so A=0 followed by the pin on that bank so 6.

 

did you do a loop back test to see that SPI was at least working first?

 

if so did you the check lsmod to see if the ili9341 module has loaded? should probably look a bit like this:

 

lsmod | grep ili9341
ili9341                16384  0
panel_ilitek_ili9341    20480  0
drm_mipi_dbi           24576  2 ili9341,panel_ilitek_ili9341

 

Admittedly I only got as far as the modules loading but I still had a white display, I can only assume so far that there may be some kind of additional configuration file that has to be setup so that it can be used as a desktop. one other problem I noticed when upgrading my kernel from 5.15 to 6.1 was that the ili9341 driver was no longer include by default other than the fb_ili9341 which I think may be the older fbtft based driver. I ended up have to use the build scripts to include the drm based ili9341 which from what I have read is the newer driver.

 

 

Hopefully this at least provided a helpful starting point and best of luck.

 

 

 

Link to comment
Share on other sites

Hey tried the same thing aswell on a bananapiM2 Armbian 23.05.0-trunk Lunar,  kernel Linux 6.2.13. I'm not too good at coding so I just went ahead an copied most of the code for the overlay and the boot configuration.

Running: lsmod |grep ili9341 results in the same as previously mentioned.

lsmod | grep ili9341
ili9341                16384  0
panel_ilitek_ili9341    20480  0
drm_mipi_dbi           24576  2 ili9341,panel_ilitek_ili9341

 

However checking dmesg for the spi entires reveals that ther might be a problem with the used port param_spidev_spi_bus=0

Running dmesg | grep spi results in the following:

 dmesg | grep spi
[    3.073618] sun8i-h3-pinctrl 1c20800.pinctrl: pin PC0 already requested by 1c68000.spi; cannot claim for spi0.1
[    3.073657] sun8i-h3-pinctrl 1c20800.pinctrl: pin-64 (spi0.1) status -22
[    3.073689] panel-ilitek-ili9341 spi0.1: Error applying setting, reverse things back
[    3.076126] sun8i-h3-pinctrl 1c20800.pinctrl: pin PC0 already requested by 1c68000.spi; cannot claim for spi0.1
[    3.076166] sun8i-h3-pinctrl 1c20800.pinctrl: pin-64 (spi0.1) status -22
[    3.076196] ili9341 spi0.1: Error applying setting, reverse things back

 

So I think the problem lies in the selected spi bus rahter than in the code itself, since on start up the panel is reversed. Or do you have different opinion/idea? :huh:

Link to comment
Share on other sites

Hi there,

 

I see that you have enabled spidev which isn't necessary. you just need to enable just the SPI bus which can be done within the overlay. overwise it will just conflict with the ili9341. slightly amended overlay:

dts-v1/;
/plugin/;

/{

    compatible = "allwinner,sun4i-a10", "allwinner,sun7i-a20", "allwinner,sun8i-h3", "allwinner,sun50i-a64", "allwinner,sun50i-h5";

    fragmen@0 {

        target = <&pio>;

        __overlay__ {

            display_pins: display_pins {

            pins = "PI11", "PI12";

            function = "gpio_out";

                        };

                        display_cs_pin: display_cs_pin {

                pins = "PB2";

                function = "gpio_out";

                output-high;

            };

        };

    };

    fragment@1 {

        target = <&spi0>;

        __overlay__ {

            /* needed to avoid dtc warning */

            #address-cells = <1>;

            #size-cells = <0>;

            status="okay";

            num-chipselects = <1>;

            display: display@0 {

                compatible = "adafruit,yx240qv29", "ilitek,ili9341";

                reg = <1>;

                spi-max-frequency = <32000000>;

                pinctrl-names = "default";

                pinctrl-0 = <&display_pins>;

                rotation= <90>;

                bgr;

                fps = <25>;

                buswidth = <8>;

                height = <240>;

                width = <320>;

                /*reset-gpios = <&pio 0 25 0>; */ /* GPIOA 6 */

                dc-gpios = <&pio 8 3 0>; /* GPIOA 3 */

                cs-gpios = <0>,<&pio 1 2 0>; /* PB2 - Linksprite shield TFT cs pin */

                debug = <3>;

            };

        };

    };

    

 

Just remember to change the pins back to those used bananapiM2 as the current configuration is for my Pcduino.

 

Also could you include a datasheet for your particular display, it would be helpful to know what pins are used for dc and cs.

 

Link to comment
Share on other sites

thx for the great new input, will try out fruchtzwergs and ryzers suggestions in the weekend. i also had the info that that pc0 was already requested. the pinout in the wiki doc is also a bit faulty, the (only) pwm pin isnt  pin 7 but the rx pin of the uart. more feedback will follow.

Link to comment
Share on other sites

Hello there :)

 

Thx a lot for all the informations I am finally getting closer to really understand what I am doing and how everything is working. I manage to properly initalise my screen in the lastest armbian lunar version:

 dmesg | grep ili9341
[    2.899560] panel-ilitek-ili9341 spi0.1: get optional vcc failed
[    2.908867] [drm] Initialized ili9341 1.0.0 20210716 for spi0.1 on minor 1
[    3.746474] panel-ilitek-ili9341 spi0.1: [drm] Initialized display serial interface
[    3.969566] panel-ilitek-ili9341 spi0.1: [drm] fb0: ili9341drmfb frame buffer device

Still no picture on the screen but personally a hugh success for me and a motivational boost ;) 

I found a usfull link to a good description unfortunatly it is in german but I can translate it if needed.
German Guide Spi lcd ili9431

I am using a different screen on from adafruit https://www.adafruit.com/product/2423 I took a look at the pcb and could Identify almost all the required pin appart from the reset pin and they are the same as this setup from the german guide:

xk00mrvux6mlo4zkbqpevsgofkg.png

 

therefore I used the following code overlay and managed to at least initiate the display.

/dts-v1/;

/plugin/;



/ {

compatible = "allwinner,sun4i-a10", "allwinner,sun7i-a20", "allwinner,sun8i-h3", "allwinner,sun50i-a64", "allwinner,sun50i-h5";



fragmen@0 {

target = <&pio>;

__overlay__ {

display_pins: display_pins {

pins = "PD4", "PC0";

function = "gpio_out", "gpio_out";

};

};

};



fragment@1 {

target = <&spi1>;

__overlay__ {

/* needed to avoid dtc warning */

#address-cells = <1>;

#size-cells = <0>;

status="okay";

cs-gpios = <&pio 3 0 0>;

num-chipselects = <1>;

display: display@0 {

compatible = "adafruit,yx240qv29", "ilitek,ili9341";

reg = <1>;

pinctrl-names = "default";

pinctrl-0 = <&display_pins>;

spi-max-frequency = <8000000>;

rotation= <270>;

bgr = <0>;

fps = <10>;

buswidth = <8>;

height = <240>;

width = <320>;

reset-gpios = <&pio 3 4 1>; /* GPIO 24 */

dc-gpios = <&pio 2 0 0>; /* GPIO 25 */

debug = <3>;

};

};

};



__overrides__ {

rotation = <&display>, "rotation:0";

fps = <&display>, "fps:0";

debug = <&display>, "debug:0";

};

};

Lots of text and I hope it can help 

Edited by Fruchtzerg
typo
Link to comment
Share on other sites

Hi There,

 

Small progress is still progress :) . Thanks for the offer but not need, auto translate was good enough apart from one or two sentences. Indeed it is very good guide that surprising doesn't refer to the old fb driver or the FBCP library that works on the Raspberry PI only due to direct register interactions. Still not have a lot of luck with my display, still just a white screen just like yours. I wonder if it could perhaps be related to the chip select. Luckily the Pcduino has an led attached to the SPI clock line so I can see clear that data is being sent to the display but nothing else is happening. The display is made by Linksprite but it's basically a clone of the older generation of a display made by Adafruit: https://learn.adafruit.com/adafruit-2-8-tft-touch-shield-v2.

 

Anyway, your overlay looks good. I would just suggest changing the pins used, the guide refers to the BPI-M64 which has different pin map to that used on your BPI-M2. Please see: https://wiki.banana-pi.org/Banana_Pi_BPI-M2_ZERO. If you replace chip select with PA13 and the data control with PC4 then hopefully it should work. You can also change the reset pin to PA2 although I am not sure if the reset line is strictly necessary.

 

Best of luck

Link to comment
Share on other sites

Finally it works or at least I can see the console here's the overlay I used

 sudo vim /boot/dtb/overlay/bananapitft.dts
/dts-v1/;

/plugin/;



/ {

compatible = "allwinner,sun4i-a10", "allwinner,sun7i-a20", "allwinner,sun8i-h3", "allwinner,sun50i-a64", "allwinner,sun50i-h5";



fragmen@0 {

target = <&pio>;

__overlay__ {

display_pins: display_pins {

pins = "PC4", "PA2";

function = "gpio_out", "gpio_out";

};

};

};



fragment@1 {

target = <&spi0>;

__overlay__ {

/* needed to avoid dtc warning */

#address-cells = <1>;

#size-cells = <0>;

status="okay";

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

num-chipselects = <1>;

display: display@0 {

compatible = "adafruit,yx240qv29", "ilitek,ili9341";

reg = <0>;

pinctrl-names = "default";

pinctrl-0 = <&display_pins>;

spi-max-frequency = <8000000>;

rotation= <270>;

bgr = <0>;

fps = <10>;

buswidth = <8>;

height = <240>;

width = <320>;

reset-gpios = <&pio 2 4 1>; /* GPIO 24 */

dc-gpios = <&pio 0 2 0>; /* GPIO 25 */

debug = <3>;

};

};

};



__overrides__ {

rotation = <&display>, "rotation:0";

fps = <&display>, "fps:0";

debug = <&display>, "debug:0";

};

};

I did a stupid copy paste mistake and targeted spi1 insead of spi0

 

also manually compiling the .dts gave me warnings that didn't show up while using the armbian-add-overlay maybe that makes a difference as well but right now I am too lasy to check that.

 

Thank you all for your help wouldn't been able to do it without it :)))

Display.jpeg

Link to comment
Share on other sites

Hi there,

 

@FruchtzergGlad to here you got it up and running. Much appreciated, I also learned from you that my cs-gpio node was in the wrong position and correcting got mine up and running. So here is the final revision of my dts overlay:

 

/dts-v1/;
/plugin/;
/{

    compatible = "allwinner,sun4i-a10", "allwinner,sun7i-a20", "allwinner,sun8i-h3", "allwinner,sun50i-a64", "allwinner,sun50i-h5";

    
	fragment@0 {

	    target = <&pio>;
	
	    __overlay__{
	
	        display_pins: display_pins {

                pins = "PB2", "PI3";

                function = "gpio_out", "gpio_out";

            };

        };

	};

	fragment@1 {

        target = <&spi0>;

        __overlay__ {

            /* needed to avoid dtc warning */

            #address-cells = <1>;

            #size-cells = <0>;

            status="okay";

            pinctrl-names = "default";

            pinctrl-0 = <&spi0_pi_pins>; /* Mux the PI to make sure they are set in spi Mode*/

            cs-gpios = <&pio 1 2 0>; /* PB2 (D5) - Linksprite shield TFT CS pin */

            num-chipselects = <1>;

            display: display@0 {

                compatible = "adafruit,yx240qv29", "ilitek,ili9341";

                pinctrl-names = "default";

                pinctrl-1 = <&display_pins>;

                reg = <0>;

                spi-max-frequency = <12000000>;

                rotation = <270>;

                bgr = <0>;

                fps = <15>;

                buswidth = <8>;

                height = <240>;

                width = <320>;

                reset-gpios = <&pio 7 9 0>; /* PH9 (D7) */

                dc-gpios = <&pio 8 3 0>; /* PI3 (D6) - Data control pin */

                debug = <3>;

            };
            

        };

    };


    __overrides__ {
		rotate =  <&display>,"rotate:0";
		fps =     <&display>,"fps:0";
		debug =   <&display>,"debug:0";
        };

};

    

 

 

OCSI9444.thumb.JPG.122f80dab0a41eb49bd11edf0127cb25.JPG

 

 

 

 

Would have been interesting to see what they where, not that it ultimately matters now that its working.

 

To get the desktop working you will need to tinker around with the Xorg/Xserver configuration. I have tried to manual trigger it to start but it keeps failing for a reason I have yet to identify other than this currently cryptic error '(EE) FBDEV(0): FBIOPUTCMAP: Device or resource busy' appearing a lot in /var/log/Xorg.0.log

 

Well at least get the the touchscreen to work should be a lot easier now. From what I can see it is I2C based so you can easily get some form of identification from i2c-tools. Again it is configured in the device tree in a similar way to SPI but instead of spidev you have i2c-dev acting as the dummy receiver device. Looking forward to seeing an update with the display working and hopefully the touch panel working.

 

All the best 

 

Ryzer

 

 

 

 

Link to comment
Share on other sites

Yep so I got the Xorg running and it show the armbian screen but I have a similar error message in the Xorg.0.log as you got (==) FBDEV(0): Backing store enabled
[   199.430] (EE) FBDEV(0): FBIOPUTCMAP: Invalid argument

For my bananapi the HDMI is deactivated if there is no cable on startup so my lcd display becomes fb0 maybe you are trying to start on the wrong device? But from here on I can only make some guesses since i have never before worked with Xorg 

 (==) FBDEV(0): Backing store enabled
[   199.430] (EE) FBDEV(0): FBIOPUTCMAP: Invalid argument

 

This seems not to cause any problem however connecting a mouse or a keyboard always fails. This is then probably related to the xorg config file which I created following the previously mentioned guide.

 

Then I just execute sudo startxfce4 an I get the desktop on my display.  

desktop.jpeg

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