ST7735s lcd custom driver with NRFconnect.

Hello.
i'm trying to implement st7735s 3pin SPI driver based on existing st7735r driver.
I used NrfConnect SDK v2.1.0 zephyr/out-of-tree driver example. 
Adding custom display driver gives such error: No SOURCES given to Zephyr library: drivers__display on project build stage.
Devicetree app.overlay fragment:
lcd_spi: &spi2 {
    compatible = "nordic,nrf-spi";
    status = "okay";
    cs-gpios = <&gpio0 16 GPIO_ACTIVE_LOW>;
    pinctrl-0 = <&spi2_default>;
    pinctrl-1 = <&spi2_sleep>;
    pinctrl-names = "default", "sleep";
    st7735s_160x80: st7735s@0 {
        compatible = "sitronix,st7735s";
        spi-max-frequency = <100000>;
        reg = <0>;
        lcd-logic-power-gpios = <&gpio0 15 GPIO_ACTIVE_HIGH>;  
        lcd-backlight-power-gpios = <&gpio0 14 GPIO_ACTIVE_HIGH>;  
        cmd-data-gpios = <&gpio0 17 GPIO_ACTIVE_LOW>;  
        reset-gpios = <&gpio0 22  GPIO_ACTIVE_LOW>;
        width = <160>;
        height = <80>;
        x-offset = <0>;
        y-offset = <0>;
        madctl = <0x60>;
        colmod = <0x55>;
        caset = [00 00 00 4F];
        raset = [00 00 00 9F];
        vmctr1 = <0x0e>;
        invctr = <0x07>;
        pwctr1 = [a2 02 84];
        pwctr2 = [c5];
        pwctr3 = [0a 00];
        pwctr4 = [8a 2a];
        pwctr5 = [8a ee];
        frmctr1 = [01 2c 2d];
        frmctr2 = [01 2c 2d];
        frmctr3 = [01 2c 2d 01 2c 2d];
        gamctrp1 = [02 1c 07 12 37 32 29 2d 29 25 2b 39 00 01 03 10];
        gamctrn1 = [03 1d 07 06 2e 2c 29 2d 2e 2e 37 3f 00 00 02 10];
        //inversion-on;
    };
};
prj.conf fragment:
CONFIG_SPI=y
CONFIG_DISPLAY=y
CONFIG_ST7735S=y
Driver Cmake and Kconfig files are similar as given in example.
Main trouble is that Zephyr display module do not recognize my custom OOT driver.
My tests to build app with existing drivers in Zephyr root folder (ST7735r for example) are OK.  
Build command output:
-- west build: generating a build system
Loading Zephyr default modules (Zephyr base).
-- Application: C:/code/nrf52832/out_of_tree_driver
-- Found Python3: C:/code/ncs/v210/toolchains/v2.1.0/opt/bin/python.exe (found suitable exact version "3.8.2") found components: Interpreter
-- Cache files will be written to: C:/code/ncs/v210/v2.1.0/zephyr/.cache
-- Zephyr version: 3.1.99 (C:/code/ncs/v210/v2.1.0/zephyr)
-- Found west (found suitable version "0.14.0", minimum required is "0.7.1")
-- Board: nrf52dk_nrf52832
-- Found host-tools: zephyr 0.14.1 (C:/code/ncs/v210/toolchains/v2.1.0/opt/zephyr-sdk)
-- Found dtc: C:/code/ncs/v210/toolchains/v2.1.0/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6")
-- Found toolchain: zephyr 0.14.1 (C:/code/ncs/v210/toolchains/v2.1.0/opt/zephyr-sdk)
-- Found BOARD.dts: C:/code/ncs/v210/v2.1.0/zephyr/boards/arm/nrf52dk_nrf52832/nrf52dk_nrf52832.dts
-- Found devicetree overlay: c:/code/nrf52832/out_of_tree_driver/nrf52dk_nrf52832.overlay
-- Generated zephyr.dts: C:/code/nrf52832/out_of_tree_driver/build/zephyr/zephyr.dts
-- Generated devicetree_unfixed.h: C:/code/nrf52832/out_of_tree_driver/build/zephyr/include/generated/devicetree_unfixed.h
-- Generated device_extern.h: C:/code/nrf52832/out_of_tree_driver/build/zephyr/include/generated/device_extern.h
-- Including generated dts.cmake file: C:/code/nrf52832/out_of_tree_driver/build/zephyr/dts.cmake
Parsing C:/code/ncs/v210/v2.1.0/zephyr/Kconfig
Loaded configuration 'C:/code/ncs/v210/v2.1.0/zephyr/boards/arm/nrf52dk_nrf52832/nrf52dk_nrf52832_defconfig'
Merged configuration 'c:/code/nrf52832/out_of_tree_driver/prj.conf'
Configuration saved to 'C:/code/nrf52832/out_of_tree_driver/build/zephyr/.config'
Kconfig header saved to 'C:/code/nrf52832/out_of_tree_driver/build/zephyr/include/generated/autoconf.h'
-- The C compiler identification is GNU 10.3.0
-- The CXX compiler identification is GNU 10.3.0
-- The ASM compiler identification is GNU
-- Found assembler: C:/code/ncs/v210/toolchains/v2.1.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
CMake Warning at C:/code/ncs/v210/v2.1.0/zephyr/CMakeLists.txt:831 (message):
No SOURCES given to Zephyr library: drivers__display

Excluding target from build.


CMake Warning at C:/code/ncs/v210/v2.1.0/zephyr/CMakeLists.txt:1839 (message):
__ASSERT() statements are globally ENABLED


-- Configuring done
-- Generating done
-- Build files have been written to: C:/code/nrf52832/out_of_tree_driver/build
-- west build: building application
[1/358] Generating include/generated/version.h
-- Zephyr version: 3.1.99 (C:/code/ncs/v210/v2.1.0/zephyr), build: v3.1.99-ncs1
...
My project:
I there a way to enable custom out-of-tree lcd driver working with zephyr displayAPI for freestanding application?
  • Hello

    Looks very similar to this case:

     CMake warning: No SOURCES given to Zephyr library: drivers__eeprom 

    Maybe you need to add CONFIG_DISPLAY=y to your prj.conf?

    Best regards,

    Einar

  • prj.conf fragment:
    CONFIG_SPI=y
    CONFIG_DISPLAY=y
    CONFIG_ST7735S=y
  • Looking further into this, I was able to replicate your error.

    When using the existing st7735r driver instead I was able to compile, which confirms that your error is caused by something in your custom driver.

    I was also able to build the basic out of tree sample without your modifications with no issues.

    It seems like the main difference between the basic Zephyr sample and what you are trying to do; is that you want to add a driver to the display module, instead of adding a completely free-standing module, and I believe this is the source of your issue.

    You should probably look over these parts of Zephyr's CMake documentation, you might find some hints there to what is going on:

    https://docs.zephyrproject.org/3.1.0/develop/modules.html#module-integration-files-external

    https://docs.zephyrproject.org/3.1.0/develop/modules.html#integrate-modules-in-zephyr-build-system

    I believe the the key to this is figuring out how to make the display module find your st7735s driver, maybe it could be easier to add your driver in-tree?

    -Einar

  • Thanks for you support, Einar.

    I was trying to solve this isue for a month. No luck.

    The main problem is that CMake provide too little debug information. 

    I suppose that "No SOURCES given to Zephyr library: drivers__display" arries due to that Cmake can't find .c sources because of some nRFconnect build system bug.

    I suppose that in-tree driver needs to add sources inside nRFconnect zephyr folder. It's a bad approch i think, because i want my git contain only app sources, not zephyr sources.

    On current state, i just stuck. All exapmples i found 

    https://blog.golioth.io/adding-an-out-of-tree-sensor-driver-to-zephyr/

    https://github.com/zephyrproject-rtos/example-application

    https://zephyrproject.org/how-to-build-drivers-for-zephyr-rtos/

    have some differences from my case.

    For example trying to build https://github.com/zephyrproject-rtos/example-application i got:

    west build -b nrf52dk_nrf52832 app


    -- west build: generating a build system
    Loading Zephyr default modules (Zephyr base (cached)).
    -- Application: C:/code/example-application-main/app
    -- Using NCS Toolchain 2.3.0 for building. (C:/code/toolchains/v2.3.0/cmake)
    -- Cache files will be written to: C:/code/v2.3.0/zephyr/.cache
    -- Zephyr version: 3.2.99 (C:/code/v2.3.0/zephyr)
    -- Found west (found suitable version "0.14.0", minimum required is "0.7.1")
    -- Board: nrf52dk_nrf52832
    -- Found host-tools: zephyr 0.15.2 (C:/code/toolchains/v2.3.0/opt/zephyr-sdk)
    -- Found toolchain: zephyr 0.15.2 (C:/code/toolchains/v2.3.0/opt/zephyr-sdk)
    -- Found Dtc: C:/code/toolchains/v2.3.0/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6")
    -- Found BOARD.dts: C:/code/v2.3.0/zephyr/boards/arm/nrf52dk_nrf52832/nrf52dk_nrf52832.dts
    -- Generated zephyr.dts: C:/code/example-application-main/build/zephyr/zephyr.dts
    -- Generated devicetree_generated.h: C:/code/example-application-main/build/zephyr/include/generated/devicetree_generated.h
    -- Including generated dts.cmake file: C:/code/example-application-main/build/zephyr/dts.cmake
    Parsing C:/code/example-application-main/app/Kconfig
    Loaded configuration 'C:/code/v2.3.0/zephyr/boards/arm/nrf52dk_nrf52832/nrf52dk_nrf52832_defconfig'
    Merged configuration 'C:/code/example-application-main/app/prj.conf'
    Configuration saved to 'C:/code/example-application-main/build/zephyr/.config'
    Kconfig header saved to 'C:/code/example-application-main/build/zephyr/include/generated/autoconf.h'
    -- The C compiler identification is GNU 12.1.0
    -- The CXX compiler identification is GNU 12.1.0
    -- The ASM compiler identification is GNU
    -- Found assembler: C:/code/toolchains/v2.3.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
    -- Configuring done
    -- Generating done
    -- Build files have been written to: C:/code/example-application-main/build
    -- west build: building application
    [1/166] Generating include/generated/version.h
    -- Zephyr version: 3.2.99 (C:/code/v2.3.0/zephyr), build: v3.2.99-ncs2
    [65/166] Building C object CMakeFiles/app.dir/src/main.c.obj
    FAILED: CMakeFiles/app.dir/src/main.c.obj
    C:\code\toolchains\v2.3.0\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe -DKERNEL -DNRF52832_XXAA -DUSE_PARTITION_MANAGER=0 -D__PROGRAM_START -D__ZEPHYR__=1 -Iapp/include -IC:/code/example-application-main/app/src -IC:/code/v2.3.0/zephyr/include -Izephyr/include/generated -IC:/code/v2.3.0/zephyr/soc/arm/nordic_nrf/nrf52 -IC:/code/v2.3.0/zephyr/soc/arm/nordic_nrf/common/. -IC:/code/v2.3.0/nrf/include -IC:/code/v2.3.0/nrf/tests/include -IC:/code/v2.3.0/modules/hal/cmsis/CMSIS/Core/Include -IC:/code/v2.3.0/modules/hal/nordic/nrfx -IC:/code/v2.3.0/modules/hal/nordic/nrfx/drivers/include -IC:/code/v2.3.0/modules/hal/nordic/nrfx/mdk -IC:/code/v2.3.0/zephyr/modules/hal_nordic/nrfx/. -IC:/code/v2.3.0/modules/debug/segger/SEGGER -IC:/code/v2.3.0/modules/debug/segger/Config -IC:/code/v2.3.0/zephyr/modules/segger/. -isystem C:/code/v2.3.0/zephyr/lib/libc/minimal/include -isystem c:/code/toolchains/v2.3.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/include -isystem c:/code/toolchains/v2.3.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/include-fixed -fno-strict-aliasing -Os -imacros C:/code/example-application-main/build/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m4 -mthumb -mabi=aapcs -mfp16-format=ieee --sysroot=C:/code/toolchains/v2.3.0/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi -imacros C:/code/v2.3.0/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-pic -fno-pie -fno-asynchronous-unwind-tables -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=C:/code/example-application-main/app=CMAKE_SOURCE_DIR -fmacro-prefix-map=C:/code/v2.3.0/zephyr=ZEPHYR_BASE -fmacro-prefix-map=C:/code/v2.3.0=WEST_TOPDIR -ffunction-sections -fdata-sections -std=c99 -nostdinc -MD -MT CMakeFiles/app.dir/src/main.c.obj -MF CMakeFiles\app.dir\src\main.c.obj.d -o CMakeFiles/app.dir/src/main.c.obj -c C:/code/example-application-main/app/src/main.c
    In file included from C:/code/v2.3.0/zephyr/include/zephyr/toolchain/gcc.h:89,
    from C:/code/v2.3.0/zephyr/include/zephyr/toolchain.h:50,
    from C:/code/v2.3.0/zephyr/include/zephyr/kernel_includes.h:19,
    from C:/code/v2.3.0/zephyr/include/zephyr/kernel.h:17,
    from C:/code/example-application-main/app/src/main.c:6:
    C:/code/example-application-main/app/src/main.c: In function 'main':
    C:/code/v2.3.0/zephyr/include/zephyr/device.h:83:41: error: '__device_dts_ord_DT_N_NODELABEL_examplesensor0_ORD' undeclared (first use in this function)
    83 | #define DEVICE_NAME_GET(dev_id) _CONCAT(__device_, dev_id)
    | ^~~~~~~~~
    C:/code/v2.3.0/zephyr/include/zephyr/toolchain/common.h:132:26: note: in definition of macro '_DO_CONCAT'
    132 | #define _DO_CONCAT(x, y) x ## y
    | ^
    C:/code/v2.3.0/zephyr/include/zephyr/device.h:83:33: note: in expansion of macro '_CONCAT'
    83 | #define DEVICE_NAME_GET(dev_id) _CONCAT(__device_, dev_id)
    | ^~~~~~~
    C:/code/v2.3.0/zephyr/include/zephyr/device.h:209:37: note: in expansion of macro 'DEVICE_NAME_GET'
    209 | #define DEVICE_DT_NAME_GET(node_id) DEVICE_NAME_GET(Z_DEVICE_DT_DEV_ID(node_id))
    | ^~~~~~~~~~~~~~~
    C:/code/v2.3.0/zephyr/include/zephyr/device.h:226:34: note: in expansion of macro 'DEVICE_DT_NAME_GET'
    226 | #define DEVICE_DT_GET(node_id) (&DEVICE_DT_NAME_GET(node_id))
    | ^~~~~~~~~~~~~~~~~~
    C:/code/example-application-main/app/src/main.c:21:18: note: in expansion of macro 'DEVICE_DT_GET'
    21 | sensor = DEVICE_DT_GET(DT_NODELABEL(examplesensor0));
    | ^~~~~~~~~~~~~
    C:/code/v2.3.0/zephyr/include/zephyr/device.h:83:41: note: each undeclared identifier is reported only once for each function it appears in
    83 | #define DEVICE_NAME_GET(dev_id) _CONCAT(__device_, dev_id)
    | ^~~~~~~~~
    C:/code/v2.3.0/zephyr/include/zephyr/toolchain/common.h:132:26: note: in definition of macro '_DO_CONCAT'
    132 | #define _DO_CONCAT(x, y) x ## y
    | ^
    C:/code/v2.3.0/zephyr/include/zephyr/device.h:83:33: note: in expansion of macro '_CONCAT'
    83 | #define DEVICE_NAME_GET(dev_id) _CONCAT(__device_, dev_id)
    | ^~~~~~~
    C:/code/v2.3.0/zephyr/include/zephyr/device.h:209:37: note: in expansion of macro 'DEVICE_NAME_GET'
    209 | #define DEVICE_DT_NAME_GET(node_id) DEVICE_NAME_GET(Z_DEVICE_DT_DEV_ID(node_id))
    | ^~~~~~~~~~~~~~~
    C:/code/v2.3.0/zephyr/include/zephyr/device.h:226:34: note: in expansion of macro 'DEVICE_DT_NAME_GET'
    226 | #define DEVICE_DT_GET(node_id) (&DEVICE_DT_NAME_GET(node_id))
    | ^~~~~~~~~~~~~~~~~~
    C:/code/example-application-main/app/src/main.c:21:18: note: in expansion of macro 'DEVICE_DT_GET'
    21 | sensor = DEVICE_DT_GET(DT_NODELABEL(examplesensor0));
    | ^~~~~~~~~~~~~
    [70/166] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/rb.c.obj
    ninja: build stopped: subcommand failed.
    FATAL ERROR: command exited with status 1: 'C:\code\toolchains\v2.3.0\opt\bin\cmake.EXE' --build 'C:\code\example-application-main\build'

    So even example application with oot driver can't be build by nRFconnect build system. The reason i supose the same - build system do not see sources on some reason.

    Brendel V.

  • Futher digging into this isuue.

    It seems my first suggestions that problem related to CMake is not correct.

    CMake does see custom drivers sources. More likely problem related with Kconfig system. Kconfig do not iclude needed sorces, so driver compile fails with 

    c:\code\out_of_tree_driver_test2\build\zephyr\include\generated\devicetree_generated.h:11592:54: error: expected declaration specifiers or '...' before numeric constant
    11592 | #define DT_FOREACH_OKAY_INST_sitronix_st7735s(fn) fn(0)

    where fn(0) means what driver does not inited. 

    So actually driver sources tries to compile, but has wrong values from Kconfig system.

Related