NRF9161DK LVGL DISPLAY

Hi, 

I am trying to use an ST7789 display with the NRF9161DK, I was following this guide but got no luck:

https://devzone.nordicsemi.com/guides/nrf-connect-sdk-guides/b/peripherals/posts/lvgl-on-a-tft-lcd-display-with-the-nrf9160-dk.

I'm lost on the approach, I switched to a zephyr sample LVGL and configured it for the NRF9161DK and the ST7789, but have some errors configuring the diplay;

ncs\v2.6.1\zephyr\samples\subsys\display\lvgl and ncs\v2.6.1\zephyr\samples\modules\lvgl\demos. 

Wich one should I use?

And the most important question, am I on the rigth path? Can I configure one of the LVGL Zephyr samples to work with the ST7789 and the nrf9161DK?

Can you give me some guidance please?

Thank You

Parents
  • Hi Daniel

    The devzone blog is some years old and there has been a lot of changes to Zephyr and our SKD since the time it was written so I would presume some steps are no longer possible to follow. 

    I think I would start with the ncs\v2.6.1\zephyr\samples\modules\lvgl\demos as it is a simple "hello world" sample. Could you post the error you got when you tried to use the sample?

    I think you will need to build your application with the dshield flag like seen here: https://docs.nordicsemi.com/bundle/ncs-latest/page/zephyr/boards/shields/st7789v_generic/doc/index.html 

    What is your VDD_GPIO  configured to? The display need 3V3

    Regards

    Runar

  • Hi runsiv,

    Thank you so much for your help, I followed your instructions and it built and flashed perfectly, now I have another problem, the screen doesn't show anything, I tested two screen and nothing (and both examples). 

    Everything looks fine, i tested the pins and they deliver 3.3v except for p0.11 p0.12 and p0.13, I dont have an oscilloscope in hand, so can't test the spi, the only thing that can be wrong is on P0.13 and P.0.11.

    I don't know where the spi is initialized, but my overlay looks like this:

    and this is the st7789 240x240 overlay I have:

    /*
     * Copyright (c) 2019 Jan Van Winkel <[email protected]>
     * Copyright (c) 2019 PHYTEC Messtechnik GmbH
     *
     * SPDX-License-Identifier: Apache-2.0
     */

    / {
        chosen {
            zephyr,display = &st7789v_st7789v_waveshare_240x240;
        };
    };

    &arduino_spi {
        status = "okay";
        cs-gpios = <&arduino_header 16 GPIO_ACTIVE_LOW>;    /* D10 */

        st7789v_st7789v_waveshare_240x240: st7789v@0 {
            compatible = "sitronix,st7789v";
            spi-max-frequency = <20000000>;
            reg = <0>;
            cmd-data-gpios = <&arduino_header 15 GPIO_ACTIVE_LOW>;  /* D9 */
            reset-gpios = <&arduino_header 14 GPIO_ACTIVE_LOW>; /* D8 */
            width = <240>;
            height = <240>;
            x-offset = <0>;
            y-offset = <0>;
            vcom = <0x19>;
            gctrl = <0x35>;
            vrhs = <0x12>;
            vdvs = <0x20>;
            mdac = <0x00>;
            gamma = <0x01>;
            colmod = <0x05>;
            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];
        };
    };
    the board is set at 3.3v and the backlight of the lcd is on.
    One of the LCDs has pins: GND,VCC,SCL,SDA,RES,DC,BLK (waveshare 240x240)
    The other: GND VCC SCL SDA RES DC CS BLK (240X280)
    Thank you,
    Daniel
  • Hi Daniel

    Can you also show me your pin control related to &arduino_spi? 

    I would expect your overlay to look something like this(for as an example)

    arduino_spi: &spi3 {
    	compatible = "nordic,nrf-spim";
    	status = "okay";
    	cs-gpios = <&arduino_header 16 GPIO_ACTIVE_LOW>, /* D10 */
    		   <&gpio0 20 GPIO_ACTIVE_LOW>;
    	pinctrl-0 = <&spi3_default>;
    	pinctrl-1 = <&spi3_sleep>;
    	pinctrl-names = "default", "sleep";
    
    	gd25wb256: gd25wb256e3ir@1 {
    		compatible = "jedec,spi-nor";
    		status = "disabled";
    		reg = <1>;
    		spi-max-frequency = <8000000>;
    		size = <268435456>;
    		has-dpd;
    		t-enter-dpd = <3000>;
    		t-exit-dpd = <40000>;
    		sfdp-bfp = [
    			e5 20 f3 ff  ff ff ff 0f  44 eb 08 6b  08 3b 42 bb
    			ee ff ff ff  ff ff 00 ff  ff ff 00 ff  0c 20 0f 52
    			10 d8 00 ff  44 7a c9 fe  83 67 26 62  ec 82 18 44
    			7a 75 7a 75  04 c4 d5 5c  00 06 74 00  08 50 00 01
    			];
    		jedec-id = [c8 65 19];
    	};
    };
    

    I would also expect  a status="okay" inside the st7789v_st7789v_waveshare_240x240. I would also verify that you have enabled the peripheral in your prj.conf

    Regards

    Runar

  • This is how my pin control definition looks like (the same apparently):

    arduino_spi: &spi3 {
        compatible = "nordic,nrf-spim";
        status = "okay";
        cs-gpios = <&arduino_header 16 GPIO_ACTIVE_LOW>, /* D10 */
                <&gpio0 20 GPIO_ACTIVE_LOW>;
        pinctrl-0 = <&spi3_default>;
        pinctrl-1 = <&spi3_sleep>;
        pinctrl-names = "default", "sleep";
    
        gd25wb256: gd25wb256e3ir@1 {
            compatible = "jedec,spi-nor";
            status = "disabled";
            reg = <1>;
            spi-max-frequency = <8000000>;
            size = <268435456>;
            has-dpd;
            t-enter-dpd = <3000>;
            t-exit-dpd = <40000>;
            sfdp-bfp = [
                e5 20 f3 ff  ff ff ff 0f  44 eb 08 6b  08 3b 42 bb
                ee ff ff ff  ff ff 00 ff  ff ff 00 ff  0c 20 0f 52
                10 d8 00 ff  44 7a c9 fe  83 67 26 62  ec 82 18 44
                7a 75 7a 75  04 c4 d5 5c  00 06 74 00  08 50 00 01
                ];
            jedec-id = [c8 65 19];
        };
    };
    I also enabled spi in main: #include <zephyr/drivers/spi.h>
     
    , and this is my prj.conf:
    CONFIG_MAIN_STACK_SIZE=4096
    CONFIG_LOG=y
    CONFIG_SHELL=y
    
    CONFIG_LVGL=y
    CONFIG_LV_Z_MEM_POOL_SIZE=49152
    CONFIG_LV_Z_SHELL=y
    CONFIG_LV_USE_MONKEY=y
    
    CONFIG_DISPLAY=y
    CONFIG_INPUT=y
    
    CONFIG_LV_FONT_MONTSERRAT_12=y
    CONFIG_LV_FONT_MONTSERRAT_14=y
    CONFIG_LV_FONT_MONTSERRAT_16=y
    
    # Benchmark Demo
    CONFIG_LV_USE_FONT_COMPRESSED=y
    
    CONFIG_SPI=y
    
    Still no errors, and nothing on screen.
    Thank you,
    Daniel
  • Ah, you are missing 

    CONFIG_ST7789V=y
    Which is needed to enable the driver for the display. 
    Regards
    Runar
  • Hi, I added it but still nothing. I added a log message and it shows it correctly in the terminal.

    Thank You,

    Daniel

Reply Children
  • Could you add a status="okay"; for the displey in your overlay? 

    Also when you build your application. Do you build it the with the cmake argument -DSHIELD=st7789v_waveshare_240x240 ?

    When you compile your application, is there any warning during the build process? 

    Regards

    Runar

  • This is the command I'm using: 

    west build -b nrf9161dk_nrf9161_ns -- -DSHIELD=st7789v_waveshare_240x240;

    I added the status okay, is it here?

    &arduino_spi {
    	status = "okay";
    	cs-gpios = <&arduino_header 16 GPIO_ACTIVE_LOW>;	/* D10 */
    
    	st7789v_st7789v_waveshare_240x240: st7789v@0 {
    		status="okay";
    		compatible = "sitronix,st7789v";
    		spi-max-frequency = <20000000>;
    		reg = <0>;
    		cmd-data-gpios = <&arduino_header 15 GPIO_ACTIVE_LOW>;	/* D9 */
    		reset-gpios = <&arduino_header 14 GPIO_ACTIVE_LOW>;	/* D8 */
    		width = <240>;
    		height = <240>;
    		x-offset = <0>;
    		y-offset = <0>;
    		vcom = <0x19>;
    		gctrl = <0x35>;
    		vrhs = <0x12>;
    		vdvs = <0x20>;
    		mdac = <0x00>;
    		gamma = <0x01>;
    		colmod = <0x05>;
    		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];
    	};
    };
    

    build:

    Loading Zephyr default modules (Zephyr base (cached)).
    -- Application: C:/ncs/v2.6.1/zephyr/samples/modules/lvgl/demos
    -- CMake version: 3.21.0
    -- Using NCS Toolchain 2.6.20240304.889616714482 for building. (C:/ncs/toolchains/cf2149caf2/cmake)
    -- Cache files will be written to: C:/ncs/v2.6.1/zephyr/.cache
    -- Zephyr version: 3.5.99 (C:/ncs/v2.6.1/zephyr)
    -- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
    -- Board: nrf9161dk_nrf9161_ns, Revision: 0.9.0
    -- Shield(s): st7789v_waveshare_240x240
    -- Found host-tools: zephyr 0.16.5 (C:/ncs/toolchains/cf2149caf2/opt/zephyr-sdk)
    -- Found toolchain: zephyr 0.16.5 (C:/ncs/toolchains/cf2149caf2/opt/zephyr-sdk)
    -- Found BOARD.dts: C:/ncs/v2.6.1/zephyr/boards/arm/nrf9161dk_nrf9161/nrf9161dk_nrf9161_ns.dts
    -- Found devicetree overlay: C:/ncs/v2.6.1/zephyr/boards/shields/st7789v_generic/st7789v_waveshare_240x240.overlay
    -- Generated zephyr.dts: C:/ncs/v2.6.1/zephyr/samples/modules/lvgl/demos/build/zephyr/zephyr.dts
    -- Generated devicetree_generated.h: C:/ncs/v2.6.1/zephyr/samples/modules/lvgl/demos/build/zephyr/include/generated/devicetree_generated.h
    -- Including generated dts.cmake file: C:/ncs/v2.6.1/zephyr/samples/modules/lvgl/demos/build/zephyr/dts.cmake
    Parsing C:/ncs/v2.6.1/zephyr/samples/modules/lvgl/demos/Kconfig
    Loaded configuration 'C:/ncs/v2.6.1/zephyr/samples/modules/lvgl/demos/build/zephyr/.config'
    No change to configuration in 'C:/ncs/v2.6.1/zephyr/samples/modules/lvgl/demos/build/zephyr/.config'
    No change to Kconfig header in 'C:/ncs/v2.6.1/zephyr/samples/modules/lvgl/demos/build/zephyr/include/generated/autoconf.h'
    Dropping partition 'nrf_modem_lib_trace' since its size is 0.
    Dropping partition 'nonsecure_storage' since it is empty.
    -- Configuring done
    -- Generating done
    -- Build files have been written to: C:/ncs/v2.6.1/zephyr/samples/modules/lvgl/demos/build
    -- west build: building application
    [0/242] Performing build step for 'tfm'
    [33/37] Linking C executable bin\tfm_s.axf
    Memory region         Used Size  Region Size  %age Used
               FLASH:       32096 B        32 KB     97.95%
                 RAM:       10416 B        32 KB     31.79%
    [37/37] Generating ../bin/tfm_s.hex
    [235/237] Linking C executable zephyr\zephyr.elf
    Memory region         Used Size  Region Size  %age Used
               FLASH:      640960 B       992 KB     63.10%
                 RAM:       81616 B     211608 B     38.57%
            IDT_LIST:          0 GB        32 KB      0.00%
    [237/237] Generating zephyr/merged.hex

    flash:

    -- west flash: rebuilding
    [0/16] Performing build step for 'tfm'
    ninja: no work to do.
    -- west flash: using runner nrfjprog
    -- runners.nrfjprog: reset after flashing requested
    -- runners.nrfjprog: Flashing file: C:\ncs\v2.6.1\zephyr\samples\modules\lvgl\demos\build\zephyr\merged.hex
    [ #################### ]  20.895s | Erase file - Done erasing
    [ #################### ]   4.445s | Program file - Done programming
    [ #################### ]   4.501s | Verify file - Done verifying
    Applying pin reset.-- runners.nrfjprog: Board with serial number flashed successfully.

    Thank you,

    Daniel

  • Hm I can't really see anything wrong there. 

    I compared your settings to some I found on the Zephyr discord and it looks fine

    You could try to add the Chosen part to your overlay to see if it helps(I don't think so since you don't get any devicetree errors

    Just some extra resources that might be helpful 

    https://github.com/zephyrproject-rtos/lvgl/blob/1557cb3e4d5c8dc7bb2e8610b686b5acb157903c/docs/get-started/quick-overview.md 

    https://forum.lvgl.io/

    I'm checking if we have any displays laying around so that I can test it on my end. 

    Regards

    Runar

Related