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

How to get zephyr to use a new .yaml file and .overlay

I am trying to create a description of my peripherals in the device tree.
For example, I want to describe the pins that will control the input type for the ADC. Current input or not.

To do this, I created the gpio-sensors.yaml file and put it along the path ncs\zephyr\dts\bindings\gpio

Here are its contents:

description: GPIO Sensors parent node

include: base.yaml
compatible: "gpio-sensors"

child-binding:
   description: Enabling current input for sensors
   properties:
      sensor1-type:
         type: int
         required: true
      sensor2-type:
         type: int
         required: true
      sensor3-type:
         type: int
         required: true
      sensor4-type:
         type: int
         required: true

In the nrf9160dk_nrf9160ns.overlay file, I added the following:

/ {
	chosen {
		zephyr,bt-uart=&uart2;
	};

	extperipheral {
		compatible = "gpio-sensors";
		sensors-type {
			sensor1-type = <0>;
			sensor2-type = <29>;
			sensor3-type = <28>;
			sensor4-type = <27>;
		};
	};
};

In this configuration, everything works fine. In devicetree_unfixed.h, I see everything that is described in .overlay

But there is a problem when I want to transfer gpio-sensors.yaml to the root of the project. In the devicetree_unfixed.h file, my description of sensor(x)_type disappears. I understand this is due to the fact that the collector can not find gpio-sensors.yaml

The question is, how do I indicate the location of this file in CMakeLists? The documentation found a mention of DTS_ROOT.
adding a line to CmakeLists

set (DTS_ROOT $ {CMAKE_CURRENT_SOURCE_DIR} /)

in devicetree_unfixed.h sensor(x)_type did not appear.
How do I get the build system to use my yaml?

Here is the structure of my project:

firmware:
- ncs
- CMakeLists.txt
- gpio-sensors.yaml
- nrf9160dk_nrf9160ns.overlay
- prj.conf

Thank!

Related