I am new to the nRF SDK and Zephyr, and I am having a terrible time with my Kconfig!

The setup:
I have an AdaFruit ItsyBitsy nRF52840, and I’m using nRF SDK 2.2.0 located in ~/.local/share/ncs and VS Code as my editor with the nRF plugin, all on Linux.
I can create a project using the plugin, copying any one of the sample projects, and it sets everything up in ~/development/diy_gnss_v2 I can compile and flash the code to my device and all works as expected.

The goal:
I want to add a driver to my project for a UART-based GNSS module, the PX1122R. So following various examples dotted around GitHub, blogs, and YT videos, I have come up with the following directory structure:

├── CMakeLists.txt
├── drivers
│   ├── CMakeLists.txt
│   ├── Kconfig
│   └── px1122r
│       ├── CMakeLists.txt
│       ├── Kconfig
│       └── px1122r.c
├── Kconfig.diy_gnss_v2
├── prj.conf
├── README.rst
├── sample.yaml
├── src
│   └── main.c
├── west.yml
└── zephyr
    └── module.yml

My root Kconfig file Kconfig.diy_gnss_v2 simply includes the various Kconfig files all the way down where the bottom-most one defines a simple config variable:

config WIBBLE
    bool "Wobble"

Which I set in my prj.conf

The problem:
When I go to build, it says that it cannot find CONFIG_WIBBLE:

Parsing /home/merseyviking/.local/share/ncs/v2.2.0/zephyr/Kconfig
Loaded configuration '/home/merseyviking/.local/share/ncs/v2.2.0/zephyr/boards/arm/adafruit_itsybitsy_nrf52840/adafruit_itsybitsy_nrf52840_defconfig'
Merged configuration '/home/merseyviking/development/diy_gnss_v2/prj.conf'

/home/merseyviking/development/diy_gnss_v2/prj.conf:1: warning: attempt to assign the value 'y' to the undefined symbol WIBBLE

error: Aborting due to Kconfig warnings

Looking at the build output, it seems to completely ignore my west.yml and my zephyr/module.yml I can fill them with syntax errors and it doesn’t say anything.
If I rename my top-most Kconfig file to simply Kconfig the build system picks up on it (still ignoring the two YAML files), but then doesn’t load the default ncs one, and so barfs because no other symbols are defined:

Parsing /home/merseyviking/development/diy_gnss_v2/Kconfig
Loaded configuration '/home/merseyviking/.local/share/ncs/v2.2.0/zephyr/boards/arm/adafruit_itsybitsy_nrf52840/adafruit_itsybitsy_nrf52840_defconfig'
Merged configuration '/home/merseyviking/development/diy_gnss_v2/prj.conf'
Traceback (most recent call last):
  File "/home/merseyviking/.local/share/ncs/v2.2.0/zephyr/scripts/kconfig/kconfig.py", line 292, in <module>
    main()
  File "/home/merseyviking/.local/share/ncs/v2.2.0/zephyr/scripts/kconfig/kconfig.py", line 65, in main
    if kconf.syms['WARN_DEPRECATED'].tri_value == 2:
KeyError: 'WARN_DEPRECATED'

So I am at a loss and very confused.

I know many people have suffered from similar problems, and I am sure it’s a PEBKAC, but no amount of Googling has told me what I need to do to fix it. Or maybe it has, but at this point I have tried so many things, I don’t know what works and what doesn’t.

    You’re very close MerseyViking

    What’s the contents of your Kconfig and module.yml? Those are critical for pulling in your module dependencies. I also recommend placing all your application based stuff in a folder call app (or something similar) to keep it separated from the other stuff.

    You may want to check out how I did it here: https://github.com/circuitdojo/nrf9160-feather-examples-and-drivers

      Thanks for the faith jaredwolff !
      My zephyr/module.yml is:

      build:
        cmake: .
        kconfig: Kconfig
        settings:
          board_root: .

      My root Kconfig is:

      menu "DIY GNSS v2"
      rsource "drivers/Kconfig"
      endmenu

      The drivers one is:

      menu "Drivers"
      rsource "px1122r/Kconfig"
      endmenu

      and the px1122r one is:

      config WIBBLE
          bool "Wobble"

      My CMakeLists.txt files are all as you’d expect, simply including subdirectories until the bottom one which sets up a zephyr library.

      What I mostly don’t understand is that west isn’t picking up my west.yml or my module.yml Could this be a VSCode problem?
      The output on terminal when I invoke a pristine build from VSCode is:

      Building diy_gnss_v2
      west build --build-dir /home/merseyviking/tmp_development/diy_gnss_v2/build /home/merseyviking/tmp_development/diy_gnss_v2 --pristine --board adafruit_itsybitsy_nrf52840 -- -DNCS_TOOLCHAIN_VERSION:STRING="NONE" -DDTC_OVERLAY_FILE:STRING="/home/merseyviking/tmp_development/diy_gnss_v2/adafruit_itsybitsy_nrf52840.overlay" -DCONF_FILE:STRING="/home/merseyviking/tmp_development/diy_gnss_v2/prj.conf"

      OK, I may be missing something here. In your readme you say I need to run Zephyr Init - which I am guessing is now west init? If so, doesn’t that clone the SDK into the current directory? I was under the impression that the whole point of an out-of-tree build is that the SDK can live somewhere else than the application directory.

      If you’re using my VSCode extension, it will pull the version of Zephyr you need for your exact project and keep it up to date. It can get hair pretty fast if you’re using one central install of Zephyr (but not impossible, the extension simply does not cater to those people 😇 since it’s a bit more advanced)

      One main glaring problem is that you should have your project CMakeLists separated from your app CMakeLists. It’s also entirely possible that your repository is not initialized correctly. Can you share the contents of your .west folder? This should be telling how your Zephyr install was configured.

      I don’t quite get what you mean about separating out my CMakeLists - my project is my app. Isn’t it?
      I’ve pushed the code as it stands here: https://github.com/GeoSpark/DIY-GNSS-v2 if that helps.

      I’m not using your VSCode extension, just the Nordic one. Everything has been installed through the NRF Connect Desktop/Toolchain Manager.

      The contents of my .west folder (which lives separately in /home/merseyviking/.local/share/ncs/v2.2.0/) has just a config file in it with the contents:

      [manifest]
      path = nrf
      file = west.yml
      
      [zephyr]
      base = zephyr

      My main motivation for having one central NCS/Zephyr SDK is that I don’t want to have to clone 3.6Gb of SDK every time I create a new project, and on the other hand it seems odd to put your own projects within the SDK folder structure. I suspect I’m thinking of this with the wrong mindset - I am looking at this like I am developing a Linux application: the header files live in /usr/include, libs in /usr/lib or wherever, and I create an application in my home directory and tell the toolchain which includes and libs I want to link against in my project.

      Ahh ok.

      If you want to compile your driver using a module, then you’ll need to move your application code in a separate folder. What’s happening is that you’re indicating to Zephyr that you have a module which points to the CMakeLists but that CMakeLists is for your application.

      Here’s an out of tree driver that I wrote: https://github.com/circuitdojo/pcf85063a The Kconfig structure seems to match yours but CMake-wise not-so-much. You can have an out of tree driver included in your application if you organize it correctly.

      I also did a video on rolling your own drivers. Check it out here: https://www.youtube.com/watch?v=qalO_vmipJk

        jaredwolff I think I see.
        So my OOT driver lives in say ~/development/my_driver/ and follows the general structure of your pcf85063a repo. My application can live in ~/development/my_app/ and can be created via the VSCode wizard.
        But then I have to modify the west.yml file that lives in my SDK folder ~/.local/share/ncs/v2.2.0/whatever ? Kinda makes sense, but still seems odd to me to modify the SDK. I guess it’s no different to installing Python packages to your global installation.
        I watched your video (in fact I’ve watch many of your videos - they’re really good!), but I guess I still wasn’t grokking the general structure.

          MerseyViking there’s no reason to change the existing install. So if you’re doing that you may have to take a second look.

          In general I’m not sure with Nordics flow is since I haven’t used their extension much. I still use NCS/Vanilla Zephyr just in a different way. (Using my extension)

          You may want to reach out to Nordic or watch more of their great educational content if you want to continue using their extension.

          Thanks for all your help Jared! I still can’t figure out where I should put my west.yml then, and why west isn’t picking it up.
          Where can I find your VSCode extension?

            I have it working! I should have looked at the NCS samples more closely because there’s an out-of-tree module example 🤦
            I almost had it right, the main issue was that a module has to be in a directory called zephyr for cmake to pick it up. In a previous attempt I had tried appending to ZEPHYR_EXTRA_MODULES in the top-level CMakeLists.txt file, and it baulked. Now I know why.
            So currently the driver is a sub-directory of the main application - my next experiment is to move it out into a separate directory, which should just be a case of modifying the top-most CMakeLists.txt file 🤷
            Thanks again for your help Jared, it definitely got me thinking along the right tracks. Now to binge more of your videos 😄

              MerseyViking Where can I find your VSCode extension?

              Search for Zephyr Tools in VSCode. It should come up.

              MerseyViking So currently the driver is a sub-directory of the main application - my next experiment is to move it out into a separate directory, which should just be a case of modifying the top-most CMakeLists.txt file 🤷
              Thanks again for your help Jared, it definitely got me thinking along the right tracks. Now to binge more of your videos 😄

              Awesome! Glad you got it going. Enjoy!

              Terms and Conditions | Privacy Policy