LVGL in Zephyr application using ST7789 display

Description

I am trying to use LVGL to display text in application which run on Zephyr.
I found the driver available for display: zephyr/drivers/display/display_st7789v.c at main · zephyrproject-rtos/zephyr · GitHub
My application is compiled and running, however I cannot see any text display.
I tested display earlier without library and working fine.
Anything missing in prj.conf and DTS file (Refer below section for DTS node and prj.conf)?
Do I need to call any initialization function before calling example function?

What MCU/Processor/Board and compiler are you using?

MCU : STM32H5 series, Display: ST7789

What do you want to achieve?

I wanted to run LVGL in Zephyr application and display simple text.

What have you tried so far?

I followed below steps for integration:

  1. Added below configuration in prj.conf:
CONFIG_DISPLAY=y
CONFIG_LVGL=y
CONFIG_LV_Z_MEM_POOL_SIZE=8192
CONFIG_LV_FONT_MONTESERRAT_12=y
  1. Added Display node in SPI node as display is connected to MCU over SPI.
    DTS node:
chosen {
		zephyr,display = &display;
	};
&spi5{
      status = "okay";
      pinctrl-names = "default";
      display:st7789v@0{
         compatible = "sitronix,st7789v";
         reg = <0>;
         spi-max-frequency = <5000000>;
         width = <320>;
         height = <240>;
         .
         .
         .
         All required properties here
     };
};

3. compile and flash the application code.

Code to reproduce

/**

  • Basic example to create a “Hello world” label
    */
    void lv_example_get_started_1(void)
    {
    /Change the active screen’s background color/
    lv_obj_set_style_bg_color(lv_screen_active(), lv_color_hex(0x003a57), LV_PART_MAIN);

    /Create a white label, set its text and align it to the center/
    lv_obj_t * label = lv_label_create(lv_screen_active());
    lv_label_set_text(label, “Hello world”);
    lv_obj_set_style_text_color(lv_screen_active(), lv_color_hex(0xffffff), LV_PART_MAIN);
    lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
    }


## Screenshot and/or video
If possible, add screenshots and/or videos about the current state.

Hi @FW_developer,
recently I used st7789v and LVGL library under Zephyr and it works, so I can say that you have wrong device-tree definition.
st7789v uses mipi-dbi bus instead of SPI (in simple words mipi-dbi is SPI with additional pins).
In my case device-tree definition looks as follows:

	mipi_dbi1 {
		compatible = "zephyr,mipi-dbi-spi";
		reset-gpios = <&portb 5 GPIO_ACTIVE_LOW>;
		dc-gpios = <&portb 4 GPIO_ACTIVE_HIGH>;
		spi-dev = <&sercom4>;
		write-only;
		#address-cells = <1>;
		#size-cells = <0>;

		chart_display: st7789v@0 {
			compatible = "sitronix,st7789v";
			mipi-max-frequency = <30000000>;
			reg = <0>;
			width = <320>;
			height = <240>;
			x-offset = <0>;
			y-offset = <0>;
			vcom = <0x19>;
			gctrl = <0x35>;
			vrhs = <0x12>;
			vdvs = <0x20>;
			mdac = <0x60>;  // rotates by 270 degrees
			gamma = <0x01>;
			colmod = <0x55>;
			lcm = <0x2c>;
			porch-param = [0c 0c 00 33 33];
			cmd2en-param = [5a 69 02 01];
			pwctrl1-param = [a4 a1];
			pvgam-param = [D0 04 0D 11 13 2B 3F 54 4C 18 0D 0B 1F 23];
			nvgam-param = [D0 04 0C 11 13 2C 3F 44 51 2F 1F 1F 20 23];
			ram-param = [00 F0];
			rgb-param = [CD 08 14];
			mipi-mode = <MIPI_DBI_MODE_SPI_4WIRE>;
			status = "okay";

@Rik Thanks for response and it worked on SPI as well with changes mdac = <0x60>; // rotates by 270 degrees.
Only issue I can see is my screen background is flickering which is easily noticeable.
What could be the reason? Is it something related to LVGL settings?
I checked refresh period ( LV_DEF_REFR_PERIOD ), and it is default and 30 msec.

@FW_developer - I’d suggest to fix your dts file. You should define st7789v under MIPI-DBI node as in my example. In your current implementation there is no definition for RESET and DC pin which may lead to unexpected behaviors (as flickering screen background).

@Rik Ok I will try this. Another question, I have started zephyr recently, where I need to refer node label “mipi_dbi1” in my DTS. I can create this node in DTS file but not getting how to utilize it so that MIPI-DBI will be used instead of SPI ?

@Rik what did your &sercom4 node look like. I have a st7789 display running in zephyr on nordic for a lower toolchain, but can’t get it running using mipi_dbi. I think all my st7789 settings should be correct (as they are working in the non-mipi example with only spi).

Hello, I have a similar problem with sst7789v (with mipi) and lvgl. I can build and flash my project on zephyr (nrf connect/ nrf5340dk) but I have a blank screen. I can use the backlight but the message “screen ok” avec lv_init(); in my display.c doesn’t work. here is the COM message :

*** Booting nRF Connect SDK v3.2.0-5dcc6bd39b0f ***
*** Using Zephyr OS v4.2.99-a57ad913cf4e ***
[00:00:00.588,714] os: ***** MPU FAULT *****
[00:00:00.588,714] os: Data Access Violation
[00:00:00.588,745] os: MMFAR Address: 0xc
[00:00:00.588,745] os: r0/a1: 0x00000000 r1/a2: 0x00000009 r2/a3: 0x00000004
[00:00:00.588,745] os: r3/a4: 0x00000000 r12/ip: 0x00000000 r14/lr: 0x00026edd
[00:00:00.588,775] os: xpsr: 0x69000000
[00:00:00.588,775] os: Faulting instruction address (r15/pc): 0x00039a88
[00:00:00.588,806] os: >>> ZEPHYR FATAL ERROR 19: Unknown error on CPU 0
[00:00:00.588,836] os: Current thread: 0x20001d38 (unknown)
[00:00:00.658,599] os: Halting system

and this is my overlay (ncs 3.2.0) : #include <zephyr/dt-bindings/mipi_dbi/mipi_dbi.h>

/ {
chosen {
zephyr,display = &st7789;
zephyr,console = &uart0;
};
};

/* SPI1 pour l’écran */
&spi1 {
status = “okay”;
pinctrl-0 = <&spi1_default>;
pinctrl-names = “default”;
cs-gpios = <&gpio1 12 GPIO_ACTIVE_LOW>;
};

/* PWM0 */
&pwm0 {
status = “okay”;
};

&uart0 {
status = “okay”;
};

/* Pinctrl SPI1 + PWM */
&pinctrl {
spi1_default: spi1_default {
group1 {
psels = <
NRF_PSEL(SPIM_SCK, 1, 15)
NRF_PSEL(SPIM_MOSI, 1, 13)
NRF_PSEL(SPIM_MISO, 1, 14)
>;
};
};

pwm0_default: pwm0_default {
    group1 {
        psels = <
            NRF_PSEL(PWM_OUT1, 1, 9)
        >;
    };
};

};

/* Backlight LED */
&{/} {
backlight_pwm: backlight_pwm {
compatible = “pwm-leds”;
led_pwm {
pwms = <&pwm0 1 PWM_MSEC(1) PWM_POLARITY_NORMAL>;
};
};
};

/* Pipeline MIPI‑DBI */
/ {
mipi_dbi1 {
compatible = “zephyr,mipi-dbi-spi”;
status = “okay”;

spi-dev = <&spi1>;
reset-gpios = <&gpio1 1 GPIO_ACTIVE_LOW>;
dc-gpios    = <&gpio1 11 GPIO_ACTIVE_HIGH>;

#address-cells = <1>;
#size-cells = <0>;

st7789: st7789v@0 {
    compatible = "sitronix,st7789v";
    status = "okay";
    reg = <0>;

    mipi-mode = "MIPI_DBI_MODE_SPI_4WIRE";
    mipi-max-frequency = <8000000>;

    width = <240>;
    height = <320>;
    x-offset = <0>;
    y-offset = <0>;

    vcom = <0x28>;
    gctrl = <0x35>;
    lcm = <0x2C>;
    colmod = <0x55>;
    mdac = <0xA8>;
    gamma = <0x01>;

    porch-param = [0C 0C 00 33 33];
    cmd2en-param = [5A 69 02 00];
    pwctrl1-param = [A4 A1];
    pvgam-param = [D0 00 02 07 05 18 25 44 42 06 0E 12 14 17];
    nvgam-param = [D0 00 02 07 05 18 25 54 47 0E 1C 17 1B 1E];
    ram-param = [00 F0];
    rgb-param = [00 02 14];

    };
};

};

Hi all,

I suggest checking this blog :

You probably found something helpful to integrate into your project.