DTS error when migrating from NCS 2.0.2 to NCS 2.1.0 or 2.1.1

We have a very simple application with an out-of-tree driver that is working fine with NCS 2.0.2.

However, changing to NCS 2.1.0 or 2.1.1 results in a DTS error:

build/zephyr/include/generated/devicetree_unfixed.h:10719:58: error: 'DT_N_S_soc_S_i2c_40003000_P_label' undeclared here (not in a function); did you mean 'DT_N_S_soc_S_i2c_40003000_P_reg'?
10719 | #define DT_N_S_soc_S_i2c_40003000_S_lps22df_press_5c_BUS DT_N_S_soc_S_i2c_40003000

(the out-of-tree driver is just an LPS22HB driver very slightly modified to work with a different LPS22 variant by just changing the WHOAMI response)

We've tried switching to the in-tree LPS22HB driver and comparing the devicetree_unfixed.h to the one generated when we use the out-of-tree driver, but they're pretty much identical so we don't know why the build is failing.lvgl_dts_test.zip

We'd really like to use 2.1.1 as it has a newer version of zephyr that we need, so help on fixing this build error would be much appreciated.

  • Hi  ,

    I tried to build the sample you sent me, but it failed on both NCS 2.0.2 and NCS 2.1.0 with a lot of very different DTS compilation errors.

    Based on just your log, my best guess is that it is related to a change in NCS 2.1.0, where the label properties are removed. The motivation is the deprecation of the label property itself in Zephyr project.

    So, if your code is getting the node by the label property, please use Node Label instead. Details about the change can be found in the Zephyr project link above.

    If that doesn't work, could you please send me a copy of your project that can replicate your exact problem? It is fine if you take out all your code, but I need to be able to see the issue.

    Best regards,

    Hieu

  • Hi Hieu,

    The sample that I attached *is* the project that compiles (and works) fine in NCS 2.0.2. Please ensure that you use the board in the boards/ folder (it's basically the Nordic NRF52840 DK with Adafruit touch shield mapped to different pins, and an LPS22)

    We're aware of the deprecation of the label property, so we instantiate the device as

    const struct device *dev = DEVICE_DT_GET(DT_INST(0,st_lps22df_press));

    When we use the in-tree LPS22HB driver it builds fine in both 2.0.2 and 2.1.0, even if it produces almost the exact same devicetree_unfixed.h.

  • Hi aonsquared,

    I didn't think to use your custom board. In retrospect that could have been obvious. Sorry about that.

    I have reproduced your issue and found a helpful piece of log a little bit above the point you looked at:

    c:\...\drivers\lps22\zephyr\lps22df.c:160:13: warning: Macro is deprecated
    In file included from C:\ncs\v2.1.0\zephyr\include\zephyr\arch\arm\aarch32\arch.h:20,
                     from C:\ncs\v2.1.0\zephyr\include\zephyr\arch\cpu.h:19,
                     from C:\ncs\v2.1.0\zephyr\include\zephyr\kernel_includes.h:33,
                     from C:\ncs\v2.1.0\zephyr\include\zephyr\kernel.h:17,
                     from C:\ncs\v2.1.0\zephyr\include\zephyr\init.h:11,
                     from C:\ncs\v2.1.0\zephyr\include\zephyr\device.h:29,
                     from C:\ncs\v2.1.0\zephyr\include\zephyr\drivers\sensor.h:23,
                     from c:\_c\c297762_customer_dts\drivers\lps22\zephyr\lps22df.c:11:
    c:\...\build\zephyr\include\generated\devicetree_unfixed.h:10719:58: error: 'DT_N_S_soc_S_i2c_40003000_P_label' undeclared here (not in a function); did you mean 'DT_N_S_soc_S_i2c_40003000_P_reg'?

    If you go into your custom lps22df.c, you can see that at line 160, you have not moved to the new macro yet.

    I just replaced the deprecated macro with its intended replacement, and the project built successfully on 2.1.0:

    	.i2c_master_dev_name = DEVICE_DT_GET(DT_INST_BUS(0)),

    I believe that is the fix? Smiley

    It did result in some new compiler warnings below though. Please remember to fix those

    [21/137] Building C object modules/lps22/CMakeFiles/..__..__..___c__c297762_customer_dts__drivers__lps22__zephyr.dir/lps22df.c.obj
    In file included from C:\ncs\v2.1.0\zephyr\include\zephyr\drivers\sensor.h:23,
                     from c:\_c\c297762_customer_dts\drivers\lps22\zephyr\lps22df.c:11:
    C:\ncs\v2.1.0\zephyr\include\zephyr\device.h:296:32: warning: initialization of 'char *' from incompatible pointer type 'const struct device *' [-Wincompatible-pointer-types]
      296 | #define DEVICE_DT_GET(node_id) (&DEVICE_DT_NAME_GET(node_id))
          |                                ^
    c:\_c\c297762_customer_dts\drivers\lps22\zephyr\lps22df.c:160:25: note: in expansion of macro 'DEVICE_DT_GET'
      160 |  .i2c_master_dev_name = DEVICE_DT_GET(DT_INST_BUS(0)),
          |                         ^~~~~~~~~~~~~
    C:\ncs\v2.1.0\zephyr\include\zephyr\device.h:296:32: note: (near initialization for 'lps22df_config.i2c_master_dev_name')
      296 | #define DEVICE_DT_GET(node_id) (&DEVICE_DT_NAME_GET(node_id))
          |                                ^
    c:\_c\c297762_customer_dts\drivers\lps22\zephyr\lps22df.c:160:25: note: in expansion of macro 'DEVICE_DT_GET'
      160 |  .i2c_master_dev_name = DEVICE_DT_GET(DT_INST_BUS(0)),
          |                         ^~~~~~~~~~~~~

    Best regards,

    Hieu

Related