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?
Parents
  • 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.

Reply
  • 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.

Children
  • 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.

  • Hello again

    Brendel V. said:
    in-tree driver needs to add sources inside nRFconnect zephyr folder. It's a bad approch i think

    I disagree.

    If you are making a driver with the intention of making it a part of the official Zephyr repository then of course it should be out of tree. But if you are only adding a driver for your own project then I think it's perfectly fine to have it as part of your app sources.

    Brendel V. said:

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

    west build -b nrf52dk_nrf52832 app

    How exactly have you installed NCS? It looks like you have everything installed inside your "code/" folder, have you used the Toolchain Manager in nRF Connect for Desktop to install it?

    Brendel V. said:

    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. 

    Can you give more context for what's going on here? From the error it seems like a simple error like you're missing a semicolon or something.

    -Einar

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

    "There are two methods of adding a driver to Zephyr. The first is to add the relevant files to the OS directory internally, such as in the sensors folder you see on the main Zephyr repo. The second is to add the driver into a directory structure outside of Zephyr, known as Out-of-Tree.

    Working “In-Tree” (IT) is the most straightforward: the sensor driver lives in the official Zephyr repository as if it was native to Zephyr the day the project started. Any hardware vendor hoping to get their device driver In-Tree would need to submit a Pull Request (PR) to the Zephyr project to be included on every computer compiling Zephyr in the future. This is also a benefit for my learning: there are many examples of how to do this in the main repository from all the PRs. I can go to GitHub and track down the change that incorporated any particular sensor. This serves as a guide, with relevant file additions and existing file modifications.

    Working in an “Out-of-Tree” (OOT) context means we will develop driver code independent of the central Zephyr repository, so no upstream changes are required. I think this helps to clarify the driver binding process and hierarchy. There are use cases for retaining the driver code alongside application code and not incorporating the driver within the OS, especially for projects that have customization or need to keep some aspect of driver code out of the public repositories."

    I thougth IT drivers are for official Zephyr repo. OOT drivers are for personal use.

    I installed NrfConnect for Destop from here:

    https://www.nordicsemi.com/Products/Development-tools/nRF-Connect-for-Desktop/Download#infotabs

    I did use Toolchain Manager to install NCS.

    NCS instalation path: C:\code\v2.3.0

    My project with OOT driver: C:\code\out_of_tree_driver_test2

    Zephyr example application path:

    C:\code\example-application-main

    "Can you give more context for what's going on here? From the error it seems like a simple error like you're missing a semicolon or something."

    Tryin to compile https://github.com/zephyrproject-rtos/example-application i got the same error as for my custom project (archive added in first message).

    I suppose the error arises due to KConfig system. Kconfig return 0 instead of pointer to device initialization functiom.

    I added https://github.com/zephyrproject-rtos/example-application to show that problem not only with my custom project. I installed fresh NCS, downloaded example-application sources, extracted. Go to NRConnect for Desktop -> Toolchain Manager-> open bash-> west build -b nrf52dk_nrf52832 app-> got error 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)

    The same error i got on compile time for my custom project (on build time i got warning: No sources..).

    To narrow the trouble, i propose to use https://github.com/zephyrproject-rtos/example-application with NCS v2.3.0.

    The problem is that i can't compile this official Zephyr example project with NCS. The same error for https://github.com/nrfconnect/ncs-example-application.

    Fresh installed NCS, fresh example application from Zephyr or Nordic -> west build -b nrf52dk_nrf52832 app -> error. I suppose that example application should work, because it shows most use cases for developers (including custom dts file and oot driver).

    Brendel V.

  • Hi

    Brendel V. said:
    I thougth IT drivers are for official Zephyr repo. OOT drivers are for personal use.

    You are correct, I got the terms mixed up.

    Brendel V. said:
    Tryin to compile https://github.com/zephyrproject-rtos/example-application i got the same error as for my custom project

    I tried replicating this but I am not able to see the same type of error you are seeing.

    I would suggest sticking with samples that are bundled with the SDK instead of downloading external examples when debugging something like this. You want to make sure you're not introducing unnecessary extra complexity.

    -Einar 

Related