ST7796 SPI Display on RockPi 4c+

Hi,

I am trying to set up a Klipper install on my RockPi. I am running Armbian Linux 6.12.13-current-rockchip64 and have managed to get spi accelerometers and w1 digital thermometers running. However, now I’m stuck trying to get the screen to work.

The display appears to be a Sitronix st7796 and I’ve found a tutorial for a Raspberry Pi:


which in turn is based on this:

Now, i couldn’t quite figure out how to compile the driver - I would just get lots of errors like these and my attempt to just set it to armv8 didn’t work:
c++: error: unrecognized argument in option ‘-mabi=aapcs-linux’
c++: note: valid arguments to ‘-mabi=’ are: ilp32 lp64
c++: error: unrecognized argument in option ‘-mtls-dialect=gnu2’
c++: note: valid arguments to ‘-mtls-dialect=’ are: desc trad
c++: error: unrecognized argument in option ‘-mabi=aapcs-linux’
c++: note: valid arguments to ‘-mabi=’ are: ilp32 lp64

Next i attempted to just write a overlay - since klipper screen just runs on a external monitor without any configuration, i figured i might as well try it. What I ended up with is this:

/dts-v1/;
/plugin/;
/ {
	metadata {
		title = "Enable st7796 LCD (C) on SPI1";
		compatible = "rockchip,rk3399";
		category = "misc";
		exclusive = "GPIO1_B0", "GPIO1_A7", "GPIO1_B1", "GPIO1_B2", "GPIO4_D2", "GPIO4_D4", "GPIO4_D5" ;
		description = "Enable st7796 LCD (C) on SPI1.";
	};
};



&spi1 {
	status = "okay";
	#address-cells = <1>;
	#size-cells = <0>;
	pinctrl-names = "default", "high_speed";
	pinctrl-0 = <&spi1_clk &spi1_cs0 &spi1_rx &spi1_tx>;
	st7796: st7796@0 {
		compatible = "sitronix,st7796";
		reg = <0>;
		spi-max-frequency = <80000000>;
		#txbuflen = <32768>;
		rotate = <0>;
		#bgr = <0>;
		fps = <30>;
		buswidth = <8>;
		#regwidth = <16>;
		debug = <1>;
		reset-gpios = <&gpio4 29 0>;
		dc-gpios = <&gpio4 28 1>;
	};
};

When I enable this overlay, i get with sudo dmesg | grep spi:

[ 6.671760] SPI driver fb_st7796 has no spi_device_id for ilitek,st7796

Which to me sounds like there is a dirver available, just that something isn’t configured quite right. I’m also wondering why it says ilitek in the error message and not sitronix.

It wokrs now! with some modification the the overlay file from @mrkprdo, the display now displays stuff!

/dts-v1/;
/plugin/;

/ {
        	metadata {
		title = "Enable st7789 LCD (C) on SPI1";
		compatible = "rockchip,rk3399";
		category = "misc";
		exclusive = "GPIO1_B0", "GPIO1_A7", "GPIO1_B1", "GPIO1_B2", "GPIO4_D4", "GPIO4_D5" ;
		description = "Enable st7789v LCD (C) on SPI1.";
	};

        fragment@0 {
                target = <&spi1>;
                __overlay__ {
                        #address-cells = <1>;
                        #size-cells = <0>;
                        pinctrl-0 = <&spi1_clk &spi1_cs0 &spi1_rx &spi1_tx>;
                        pinctrl-names = "default";
                        st7789v@0 {
	                        compatible = "sitronix,st7789v";
         	               status = "okay";
                 		       reg = <0>;
	                        spi-max-frequency = <10000000>;
         	               width = <240>;
                 		       height = <320>;
	                        buswidth = <8>;
         	               fps = <60>;
                 		       rotate = <270>;
	                        debug = <1>; // 等级0~7 越高信息越多
	                        reset-gpios = <&gpio4 29 1>;
				dc-gpios = <&gpio4 28 0>;
                 		       //led-gpios = <0x2b 73 0>;        // pin 18
                        };
                };
        };
};