Creating an out-of-tree zephyr driver with bindings...

icp20100.7z

I'm trying to create a Zephyr driver for a pressure sensor.

I've seen the other examples, but one doesn't use any dts bindings, and the other builds under west, and I need to build under VSCode, so neither one is being much help.

I've gotten it close, but I'm stuck on:

Traceback (most recent call last):
  File "C:/ncs/v2.3.0/zephyr/scripts/kconfig/kconfig.py", line 292, in <module>
    main()
  File "C:/ncs/v2.3.0/zephyr/scripts/kconfig/kconfig.py", line 65, in main
    if kconf.syms['WARN_DEPRECATED'].tri_value == 2:
KeyError: 'WARN_DEPRECATED'
CMake Error at C:/ncs/v2.3.0/zephyr/cmake/modules/kconfig.cmake:328 (message):
  command failed with return code: 1
Call Stack (most recent call first):
  C:/ncs/v2.3.0/nrf/cmake/modules/kconfig.cmake:29 (include)
  C:/ncs/v2.3.0/zephyr/cmake/modules/zephyr_default.cmake:108 (include)
  C:/ncs/v2.3.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
  C:/ncs/v2.3.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
  CMakeLists.txt:8 (find_package)


-- Configuring incomplete, errors occurred!
FATAL ERROR: command exited with status 1: 'c:\ncs\toolchains\v2.3.0\opt\bin\cmake.EXE' '-DWEST_PYTHON=c:\ncs\toolchains\v2.3.0\opt\bin\python.exe' '-Bc:\TestApps\icp20100\build' -GNinja -DBOARD=nrf52dk_nrf52832 -DNCS_TOOLCHAIN_VERSION:STRING=NONE -DBOARD_ROOT:STRING=c:/TestApps/icp20100 -DDTC_OVERLAY_FILE:STRING=c:/TestApps/icp20100/boards/nrf52dk_nrf52832.overlay -DCONF_FILE:STRING=c:/TestApps/icp20100/prj.conf '-Sc:\TestApps\icp20100'


I'm not even sure what it's complaining about, much less how to fix it.

It broke when I added the KConfig file at the root level, which seems to be needed to point to the KConfig file in the driver.
If I remove the KConfig driver at the top level, it builds, but none of the new KConfig options get set, so that driver file isn't being used.

The driver still needs a bunch of work on my end, but if you can help me get it building properly, that would be super helpful!

Parents Reply
  • keith.henrickson said:
    I see these samples, but they're not helpful, because I'm not building with west, so I don't have a zephyr module to modify.

    I need something that works under VSCode, where the zephyr directory does not exist.

    VS Code uses west under the hood.

    If you press "Build", VS Code will run "west build ...". You can check the log in the Terminal to see the full command used.

    You can still create the folder structure and files required for an out-of-tree module using VS Code.

    As far as I know, we do not have an official guide on how to add out-of-tree drivers with dts files.
    Jaredwolff is skilled, so the guide posted by Victor is likely good.

    As an alternative, I have seen this unofficial blog on this: https://iwasz.pl/electronics/2021-06-18-out-of-tree-zephyr-module.md/.

    Regards,
    Sigurd Hellesvik

Children
  • I tried two things:

    1. I just use the project as it was. CMake gave me an error:

    -- The C compiler identification is unknown
    -- The CXX compiler identification is unknown
    CMake Error in CMakeLists.txt:
      No CMAKE_C_COMPILER could be found.
    
      Tell CMake where to find the compiler by setting either the environment
      variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
      the compiler, or to the compiler name if it is in the PATH.
    
    
    CMake Error in CMakeLists.txt:
      No CMAKE_CXX_COMPILER could be found.
    
      Tell CMake where to find the compiler by setting either the environment
      variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
      to the compiler, or to the compiler name if it is in the PATH.
    
    
    CMake Warning (dev) in CMakeLists.txt:
      No cmake_minimum_required command is present.  A line of code such as
    
        cmake_minimum_required(VERSION 3.20)
    
      should be added at the top of the file.  The version specified may be lower
      if you wish to support older CMake versions for this project.  For more
      information run "cmake --help-policy CMP0000".
    

    I tried altering the CMakeLists.txt to what I thought it might be looking for:

    #
    # Copyright (c) 2022 Circuit Dojo LLC
    #
    # SPDX-License-Identifier: Apache-2.0
    #
    
    cmake_minimum_required(VERSION 3.20.0)
    find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
    project(adc1219)
    
    zephyr_include_directories(include)
    
    add_subdirectory(drivers/adc)

    And I get the same error I did when I tried with my project:

    Traceback (most recent call last):
      File "C:/ncs/v2.3.0/zephyr/scripts/kconfig/kconfig.py", line 292, in <module>
        main()
      File "C:/ncs/v2.3.0/zephyr/scripts/kconfig/kconfig.py", line 65, in main
        if kconf.syms['WARN_DEPRECATED'].tri_value == 2:
    KeyError: 'WARN_DEPRECATED'
    CMake Error at C:/ncs/v2.3.0/zephyr/cmake/modules/kconfig.cmake:328 (message):
      command failed with return code: 1
    Call Stack (most recent call first):
      C:/ncs/v2.3.0/nrf/cmake/modules/kconfig.cmake:29 (include)
      C:/ncs/v2.3.0/zephyr/cmake/modules/zephyr_default.cmake:108 (include)
      C:/ncs/v2.3.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
      C:/ncs/v2.3.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:97 (include_boilerplate)
      CMakeLists.txt:8 (find_package)
    

  • I think I have made progress!

    There are a view samples that have their own KConfig files in the NCS samples. For instance:

    C:\ncs\v2.3.0\nrf\samples\caf_sensor_manager

    I noticed that there's a line in each of these:
    source "Kconfig.zephyr"

    I'm not sure why the pure west samples do not need that line, but I think it's getting it going under VSCode. The defines are now set as I'd expect, and code is being compiled (or rather, attempting to be as I still have much work to do) that's only compiled if certain defines are set.

Related