This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to include Zephyr out of tree driver in modified nRF sample app?

Hello Devzone Community,

I am trying to develop an nRF9160 firmware, based on Nordic's sdk-nrf v1.6.1 code base. This work is a Zephyr RTOS based application. In early research steps a few weeks ago I learned that sensors and peripherals which do not yet have "in tree" Zephyr drivers will generally require developers to create "out of tree" drivers. I wrote a minimal out-of-tree driver which depends on Nordic's nRF SDK. A small Zephyr demo for this driver is hosted at github.com/.../kionix-driver-demo. (I have posted this info for different questions, sorry for the repeat). I can compile, flash and run this demo using the nRF toolchain and `west`.

Presently I face a new need to build and debug using Nordic's Segger Embedded Studio. I installed Nordic SES 5.6 last night, and under "Tools > Options" pointed it to my sdk-nrf v1.6.1 installation. Sample apps compile. An empty project template with a default 'main.c' compiles and runs. But I encounter a build error when I open the above kionix driver demo, via SES top menu bar option "File > Open nRF Connect SDK Project...".

My question: if I cannot resolve this build error in SES, and may only develop further by modifying a Nordic sample app which lives in the sdk-nrf directory structure, what is the correct way to incorporate an out-of-tree driver? What analogous Segger project, or Segger global setting corresponds to a west.yml manifest project entry?

For the out-of-tree driver demo to compile and honor Zephyr's driver paradigm I needed to add a manifest file `west.yml` to that demo. The manifest file is what informs west, cmake and friends where to find the driver code itself.


As for setting up non-SES project configurations by hand, SES Nordic version's special option "File > Open nRF Connect SDK Project..." performs significant project configuration work. Segger code behind this menu option is able to generate correct .emProject files for Nordic's v1.6.1 sample projects. For example, I observe that when first opening the the aws_iot sample project and building, SES generates two .emProject files out in the SDK samples directory. One of these is over 5000 lines long. That's too long to write by hand, or enter in tedious dialogs one path or one setting at a time. For this reason, I am searching and hopeful to find a way to extend a "within SDK" sample project, or succeed in building a project from outside of the SDK, but which in reality depends on one and the same SDK code base.  That is, my demo's west.yml file refers to the same nrf/sdk-nrf code base as is already installed independent of SES, and any other Nordic or Zephyr based projects on my local work station.

Thanks ahead of time for any help on this!

- Ted

Parents Reply Children
  • Hello Oivind,

    The error which I am seeing I have detailed in a separate post here:  https://devzone.nordicsemi.com/f/nordic-q-a/80001/resolving-nrf9160-zephyr-app-build-error-offsets-c-obj-not-found.

    A concerning matter I have found is that I am actually not, within Segger IDE able to compile nRF samples such as aws_iot or other samples.  All samples fail with the same error:

    Building 'zephyr/CMakeFiles/offsets.dir/arch/arm/core/offsets/offsets.c.obj' from solution 'build' in configuration 'Common'
    2> Checking 'offsets.c'
    2> zephyr/CMakeFiles/offsets.dir/arch/arm/core/offsets/offsets.c.obj does not exist.
    2> Compiling 'offsets.c'

    Because the error is the same across multiple samples and a personal project based on the same sdk-nrf v1.6.1 it seems to me this is an error in how Segger's "Open nRF Connect SDK Project..." menu option is working.  The python script create_nordic_project.py is responsible for reading the contents of a sample application like `aws_iot`, and from those files building a couple of .emProject files for Segger, along with a new CMakeLists.txt file and some other build-supporting files in the given sample's build directory.

    Something in this generated recipe, some include path or other configuration detail which `cmake` relies on to successfully build Zephyr is missing or different from the structure that's in place that `west` and a command line build process follow.

    I can build all sample apps with `west` at the command line.  But I can build no samples or other nRF + Zephyr apps when using Segger and its option "File > Open nRF Connect SDK Project...".

    - Ted

  • Correct me if I am mistaken, but Simon is handling that issue in the case you linked, so I will leave that to him.

    My understanding is that this case is about the out-of-tree driver, so let's focus on that. Since you are having issues with SES, but not with building on the command line, are you able to build your application which implements the out-of-tree driver when using 'west' on the command line?

Related