Creating own device tree node doesn't work

Hello,

I try to create and use my own device tree node.

For that I created a very basic yaml file:

compatible: "bat-measurement"

properties:
   channel1:
      type: int
      required: true

which I use in by dts file as:

/ {
    batmeasure {
        compatible = "bat-measurement";
        channel1 = <4>;
    };
};

Compiling this leads to no error. In devicetree-unfixed.h I found the node batmeasure. But I would expect to find there also something for channel1, which is not the case.

Even changing my dts file to a combination that should not work, doesn't lead to a compiler error (required parameter is not there).

/ {
    batmeasure {
        compatible = "bat-measurement";
        newValue = <5>;
    };
};

Where is my mistake?

Erwin

Parents Reply Children
  • I guess you are mostly Right. Only the proposed path cannot be used in our case. We have one application Folder with one prj.conf but different boards.

    myRoot
    |__ boards
    |    |__ arm
    |         |__ ourBoardA
    |         |     |__ A_app.dts
    |         |     |__ A_app.yaml
    |         |     |__ A_app_defconfig
    |         |__ ourBoardB
    |               |__ B_app.dts
    |               |__ B_app.yaml
    |               |__ B_app_defconfig                
    |__ PrjData
         |__ CMakeLists.txt
         |__ prj.conf
         |__ build_A
         |     |__ all the build stuff with board A
         |__ build_B
               |__ all the build stuff with board B
         

    When I Build with west I give the Parameter -DBOARD_ROOT:STRING="myRoot"

    I thought I can put my new yaml file into the same Directory where my board is. But that is wrong as even in docs.zephyrproject.org/.../bindings.html is stated (I overlooked the dts/bindings):

    The build system looks for bindings in dts/bindings subdirectories of the following places:
        the zephyr repository
        your application source directory
        your board directory
        any directories in the DTS_ROOT CMake variable
        any module that defines a dts_root in its Build settings

    So I guess I could use the Folder structur:

    myRoot
    |__ boards
    |    |__ arm
    |         |__ ourBoardA
    |         |     |__ A_app.dts
    |         |     |__ A_app.yaml
    |         |     |__ A_app_defconfig
    |         |__ ourBoardB
    |               |__ B_app.dts
    |               |__ B_app.yaml
    |               |__ B_app_defconfig                
    |__ PrjData
    |    |__ CMakeLists.txt
    |    |__ prj.conf
    |    |__ build_A
    |    |     |__ all the build stuff with board A
    |    |__ build_B
    |          |__ all the build stuff with board B
    |
    |__ dts
         |__ bindings
              |__ bat-measurement.yaml

    I will try it.

    Thanks

  • My Explanation was wrong. Of Course the dts can be loaded below my PrjData. 

    When trying the Folder structure described in my first answer, I got again no error, Nothing.

    But moving below PrjData I get an error, that the description is missing. That Looks promising.

  • I now get even an error when the required channel1 property is not given in my dts file. So yaml and dts seems to be parsed.

    Unfortunately I don't see and channel 1 line in devicetree_unfixed.h. There are 33 occasions of batmeasure. All from the node. But shouldn't there be something for my channel1 Parameter? Later I will use some macros to get the value 4 in my Code. 

    Or do I lack some understanding?

  • I have to say sorry!

    There are the lines

    #define DT_N_S_batmeasure_P_channel1 5
    #define DT_N_S_batmeasure_P_channel1_EXISTS 1
    in devicetree_unfixed.h I should have looked more carefully
    So everything works!!
Related