undefined reference to `__device_dts_ord_131' error when building bme280 sample on nrf5340dk

Hello

I'm attempting to build the following sample bme280 programme on a nRF5340dk development board.

- ncs\v2.3.0\zephyr\samples\sensor\bme280

However, I'm getting the following error:

undefined reference to `__device_dts_ord_131'

I've started with a 'basic/blinky' template using the 'nRF5340dk_nRF5340_cpuapp_ns' board.

With blinky working I've added/changed the project with code from the bme280 sample as follows:

- prj.conf

- the sample only had 'CONFIG_GPIO=y' which was greyed out

- overlay

- created “nrf5340dk_nrf5340_cpuapp_ns.overlay” and added the following contents from "ncs\v2.3.0\zephyr\samples\sensor\bme280\arduino_spi.overlay"

&arduino_spi {
  status = "okay";
  cs-gpios = <&arduino_header 16 GPIO_ACTIVE_LOW>;
  bme280@0 {
    compatible = "bosch,bme280";
    reg = <0>;
    spi-max-frequency = <1000000>; /* conservatively set to 1MHz */
  };
};

- main.c

- copied the contents from "ncs\v2.3.0\zephyr\samples\sensor\bme280\src\main.c" to the new project's "main.c"

When I build I get the following error:

[232/244] Linking C executable zephyr\zephyr_pre0.elf
FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map
.

C:\Workspace\nrf\5340\exSPI\008_bme280\src\main.c:46: undefined reference to `__device_dts_ord_131'

How might I get over this issue?

Thanks

RoW

Parents
  • Hi RoW,

    You need to enable sensor drivers by setting CONFIG_SENSOR=y in prj.conf.

    Errors on the form "undefined reference to `__device_dts_ord_131'" indicates that a devicetree node is not correctly defined. Causes can be a Kconfig option missing (such as CONFIG_SENSOR here), or that something is incorrect in devicetree, such as the device not being defined at all, or that it is missing status="okay".

    Best regards,
    Marte

  • Hello Marte

    Thanks for your reply.

    It works with that line included.

    Not sure how I missed that - I must have had another "prj.conf" open at the same time and copied that instead.

    I'm interested to know: is there anyway to debug from the `__device_dts_ord_xxx' errors?

    Regards

    Ron

  • Hi Ron,

    There are some tips in Zephyr's devicetree documentation here: Troubleshooting devicetree.

    I can also share some tips about what I usually look for.

    The first thing I do is to look at the line referenced in the error message. For example, if I add things from the bme280 sensor sample to blinky as you did (without adding CONFIG_SENSOR) I get the following error:

    ncs/zephyr/samples/basic/blinky/src/main.c:83: undefined reference to `__device_dts_ord_131'

    Sometimes this points to a line where the device is used directly. Then I will immediately know which device the issue is with and can start looking into configurations and devicetree for the device. Other times, as in this case, the line will be the end of a function where the device is used. This is not as helpful, but it might help you narrow down the possible devices.

    If I cannot figure out the device using the method above, I look in the generated devicetree files in the build directory for the device number from the error. In zephyr/samples/basic/blinky/build/zephyr/include/generated/devicetree_generated.h you can find a list of the nodes. In this case, the file shows me this:

     *   128 /soc/peripheral@40000000/qspi@2b000
     *   129 /soc/peripheral@40000000/qspi@2b000/mx25r6435f@0
     *   130 /soc/peripheral@40000000/spi@a000
     *   131 /soc/peripheral@40000000/spi@a000/bme280@0

    So here I immediately see that device 131 is bme280, and thus I know that this must be the device causing the issue.

    After figuring out the device, the next thing is to figure out what the issue is. Then I look at the devicetree files to see if anything is missing. This could, for example, be that the device is not defined or the status is not "okay". For this, I look at zephyr/samples/basic/blinky/build/zephyr/zephyr.dts, which contains the complete generated devicetree for the build, and sometimes compare it with the board and overlay files. If everything looks fine in the devicetree, I look at the configurations instead and figure out which configurations are needed and which are missing.

    I hope this helps!

    Best regards,
    Marte

Reply
  • Hi Ron,

    There are some tips in Zephyr's devicetree documentation here: Troubleshooting devicetree.

    I can also share some tips about what I usually look for.

    The first thing I do is to look at the line referenced in the error message. For example, if I add things from the bme280 sensor sample to blinky as you did (without adding CONFIG_SENSOR) I get the following error:

    ncs/zephyr/samples/basic/blinky/src/main.c:83: undefined reference to `__device_dts_ord_131'

    Sometimes this points to a line where the device is used directly. Then I will immediately know which device the issue is with and can start looking into configurations and devicetree for the device. Other times, as in this case, the line will be the end of a function where the device is used. This is not as helpful, but it might help you narrow down the possible devices.

    If I cannot figure out the device using the method above, I look in the generated devicetree files in the build directory for the device number from the error. In zephyr/samples/basic/blinky/build/zephyr/include/generated/devicetree_generated.h you can find a list of the nodes. In this case, the file shows me this:

     *   128 /soc/peripheral@40000000/qspi@2b000
     *   129 /soc/peripheral@40000000/qspi@2b000/mx25r6435f@0
     *   130 /soc/peripheral@40000000/spi@a000
     *   131 /soc/peripheral@40000000/spi@a000/bme280@0

    So here I immediately see that device 131 is bme280, and thus I know that this must be the device causing the issue.

    After figuring out the device, the next thing is to figure out what the issue is. Then I look at the devicetree files to see if anything is missing. This could, for example, be that the device is not defined or the status is not "okay". For this, I look at zephyr/samples/basic/blinky/build/zephyr/zephyr.dts, which contains the complete generated devicetree for the build, and sometimes compare it with the board and overlay files. If everything looks fine in the devicetree, I look at the configurations instead and figure out which configurations are needed and which are missing.

    I hope this helps!

    Best regards,
    Marte

Children
No Data
Related