1 1
ej0rge

any clues for the creation of a dtoverlay for fbtft on 5.4.y?

Recommended Posts

I am trying to figure out how to create a dtoverlay to allow my waveshare 2.8a fbtft screen to work. 

 

I understand that i the 5.x.y kernels, a dtoverlay is required. 

 

I'm starting with the waveshare32b.dts for raspberry pi, found here: 

https://github.com/swkim01/waveshare-dtoverlays

 

Should be compatible with the 2.8a per waveshare wiki. 

 

I'm trying to modify it in sort of the same way as was done in this thread, for another display: 

 

The board I'm using for this is an orangepi pc2. 

 

But i don't' actually know what I'm doing. What I've come up with so far is this: 

 

/*
 * Device Tree overlay for waveshare 3.2inch B and 2.8inch A TFT LCD
 *
 */

/dts-v1/;
/plugin/;

/ {
        compatible = "allwinner,sun8i-h3", "allwinner,sun50i-h5";

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

                        spidev@0{
                                status = "disabled";
                        };

                        spidev@1{
                                status = "disabled";
                        };
                };
        };

        fragment@1 {
                target = <&pio>;
                __overlay__ {
                        waveshare32b_pins: waveshare32b_pins {
                                allwinner,pins = "pa1", "pa0", "pa3" ;
                                allwinner,function = "gpio_in";
                        };
                };
        };

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

                        waveshare32b: waveshare32b@0{
                                compatible = "ilitek,ili9340";
                                reg = <0>;
                                pinctrl-names = "default";
                                pinctrl-0 = <&waveshare32b_pins>;

                                spi-max-frequency = <16000000>;
                                txbuflen = <32768>;
                                rotate = <90>;
                                fps = <25>;
                                bgr = <0>;
                                buswidth = <8>;
                                reset-gpios = <&pio 0 0 0>;
                                dc-gpios = <&pio 0 3 0>;
                                debug = <0>;
                        };

                        waveshare32b_ts: waveshare32b-ts@1 {
                                compatible = "ti,ads7846";
                                reg = <1>;

                                spi-max-frequency = <2000000>;
                                interrupts = <17 2>; /* high-to-low edge triggered */
                                interrupt-parent = <&gpio>;
                                pendown-gpio = <&pio 0 1 0>;
                                ti,x-plate-ohms = /bits/ 16 <60>;
                                ti,pressure-max = /bits/ 16 <255>;
                        };
                };
        };

        __overrides__ {
                speed =         <&waveshare32b>,"spi-max-frequency:0";
                txbuflen =      <&waveshare32b>,"txbuflen:0";
                rotate =        <&waveshare32b>,"rotate:0";
                fps =           <&waveshare32b>,"fps:0";
                bgr =           <&waveshare32b>,"bgr:0";
                debug =         <&waveshare32b>,"debug:0";
                swapxy =        <&waveshare32b_ts>,"ti,swap-xy?";
        };
};

There are no errors from armbian-add-overlay, but when i reboot the screen is not working, fbtft is not loaded, and i see no messages in dmesg that look like they relate to my efforts. 

So, any clues? Does anything jump out as being wrong? 

Share this post


Link to post
Share on other sites

Ok, thanks. 

 

Where should i look for any output generated by this?

Share this post


Link to post
Share on other sites
14 hours ago, ej0rge said:

Where should i look for any output generated by this?

Did you look more thoroughly in "dmesg", maybe there something else missing ...

Share this post


Link to post
Share on other sites
5 hours ago, martinayotte said:

Did you look more thoroughly in "dmesg", maybe there something else missing ...

 

Yeah, nothing that looks like it is directly related. 

 

the only mention of spi is where it complains about not being able to create a device for spi flash that might not exist. 

 

During the uboot part of bootup it complains about no boot.env and that might be related. Maybe it's not reading armbianEnv.txt at all? I think i might hook up the serial console so i can log the whole boot process. 

Share this post


Link to post
Share on other sites

OK, this is probably related: 

 

Quote

Applying user provided DT overlay waveshare_32b_28a_opi.dtbo
failed on fdt_overlay_apply(): FDT_ERR_NOTFOUND
Error applying DT overlays, restoring original DT


 

Is there a way to get a more informative error message? 

Share this post


Link to post
Share on other sites
55 minutes ago, ej0rge said:

Applying user provided DT overlay waveshare_32b_28a_opi.dtbo
failed on fdt_overlay_apply(): FDT_ERR_NOTFOUND
Error applying DT overlays, restoring original DT

Yes, this is an important error, it mean that some parameters inside overlay are not resolved !

57 minutes ago, ej0rge said:

Is there a way to get a more informative error message?

Unfortunately, there is no way to get it more verbose during that boot phase.

But, it is a bit easier to debug using dynamic loading :

mkdir /sys/kernel/config/device-tree/overlays/waveshare
cat waveshare.dtbo > /sys/kernel/config/device-tree/overlays/wave/dtbo

Then, "dmesg" reveal a more verbose "OF: resolver: overlay phandle fixup failed: -22" .

It is probably that the line "interrupt-parent = <&gpio>;" should be "interrupt-parent = <&pio>;" instead ...

Share this post


Link to post
Share on other sites
22 minutes ago, martinayotte said:

Yes, this is an important error, it mean that some parameters inside overlay are not resolved !

Unfortunately, there is no way to get it more verbose during that boot phase.

But, it is a bit easier to debug using dynamic loading :


mkdir /sys/kernel/config/device-tree/overlays/waveshare
cat waveshare.dtbo > /sys/kernel/config/device-tree/overlays/wave/dtbo

Then, "dmesg" reveal a more verbose "OF: resolver: overlay phandle fixup failed: -22" .

It is probably that the line "interrupt-parent = <&gpio>;" should be "interrupt-parent = <&pio>;" instead ...

 

Thanks for that. - i was unsure about whether that line needed to change. 

 

It loads now, but the screen is still white, so i guess i have more troubleshooting to do. 

 

The touch device also is not working. 

[    8.040102] ads7846: probe of spi1.1 failed with error -22
[    8.041249] fbtft: module is from the staging directory, the quality is unknown, you have been warned.
[    8.060153] fb_ili9340: module is from the staging directory, the quality is unknown, you have been warned.
[    8.062524] fbtft_of_value: buswidth = 8
[    8.062534] fbtft_of_value: debug = 0
[    8.062537] fbtft_of_value: rotate = 90
[    8.062539] fbtft_of_value: fps = 25
[    8.062542] fbtft_of_value: txbuflen = 32768
 

I should clarify, while I'm not a programmer, I have been using linux for roughly as long as it has existed, and in a previous life i worked for a now-long-dead embedded linux vendor in QA. But that was almost 20 years ago and if i knew anything about uboot at the time i have forgotten it. I am also not sure device trees were a thing in 2001. 

 

Maybe i should say, as far as my embedded hacking skills are concerned, I have yet to find if there is anything under the rust. 

Share this post


Link to post
Share on other sites

Got it.  TFT at least. reset_gpios needed to be 0 0 1 instead of 0 0 0. Yes i should really find where the referece is for what the syntax means instead of trying to intuit it. 

 

I'll see if i can tease the touch into working though i don't really need it for my application.  Edit: probably gonna start with copypasta from this but with the correct gpio pins: https://github.com/armbian/sunxi-DT-overlays/blob/master/examples/spi-ads7846.dts

 

So far I have only tested this on my orange pi pc2 running 5.4.20

 

 

20200303_151349.jpg

waveshare_32b_28a_opi.dts

Share this post


Link to post
Share on other sites
5 hours ago, martinayotte said:

Most probably "active_high" vs "active_low" ...

 

my guess as well

Share this post


Link to post
Share on other sites

I have the waveshare 2.8 A tft and touch panel working on the Orange Pi PC2 with one long dtoverlay. 

 

Some of my inspiration came from here: 

 

Like i said one dtoverlay, both fbtft and the touch panel, no other overlays needed. 

 

I admit i am a neophyte and it might be possible to trim this one slightly and use it in combination with the CS1 dtoverlay but it wasn't clear to me how that would work. 

 

I am using a 6 inch hand-made cable to connect my waveshare 2.8 A but it is wired straight through on only the needed wires for touch and tft. 

 

As I've said before it should work just the same with a 3.2 B. 

 

May work on PC Prime as-is, should work on other orange pi boards with minor changes (compatible arch and the assignment of pin 26 varies from board to board).

For orange pi zero, zero plus (H3 and H5), maybe some others, instances of PA21 should be changed to PA10. Check your pinouts to be sure. 

 

The spi speed of 1.6mhz for the tft is a safe example, I have run up to 4mhz without issues and might be able to go higher but i am leaving the safe default in place for this post.

 

one caveat: as i said i don't have a use for the touch panel in my application. I tested it by catting /dev/input/mouse1 and running a fingernail over the touch panel. I got output. yay. More tweaks might be needed, but the driver is fundamentally working and all the overrides are included in the dts

 

waveshare_32b_28a_opipc2.dts

Share this post


Link to post
Share on other sites

With small changes it also works with Orange Pi Plus 2e, pin names are the same and only thing that needs to be changed is find/replace spi1 to spi0

Share this post


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