out of tree driver; builds, links but not in map

I have an out of tree driver (vl53l1x) building and linking for an out of tree board which works.  
However, another driver for bmi088, builds, appears to link but does not appear in the map files
which leads to this error when I try and use the sensor --> undefined reference to `__device_dts_ord_127' 

I have a feeling the dts fragment may be the cause but not sure at this point.

source tree looks like this 

- project_root
  - boards
  - dts
  - hello_world
    CMakeLists.txt
    KConfig
    prf.conf
    sample.yaml
  - drivers
    CMakeLists.txt
    KConfig
    - sensor 
      CMakeLists.txt
      KConfig
      - bmi088
        CMakeLists.txt
        KConfig
        <other code files>
      - vl53l1x (functioning)   
  - src
    main.c


Without trying to use the sensor 
[172/184] Linking C static library drivers\sensor\bmi088\lib..__..__..__workvob__xqc__bringup_empty__hello_world__drivers__sensor__bmi088.a
[173/184] Linking C static library zephyr\kernel\libkernel.a
[174/184] Linking C executable zephyr\zephyr_pre0.elf

When I try to use the sensor
[174/185] Linking C static library drivers\sensor\bmi088\lib..__..__..__workvob__xqc__bringup_empty__hello_world__drivers__sensor__bmi088.a
[175/185] Linking C executable zephyr\zephyr_pre0.elf
FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map
c:/ncs/toolchains/v2.2.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/../../../../arm-zephyr-eabi/bin/ld.exe: app/libapp.a(main.c.obj): in function `get_gyro_device':
C:\workvob\xqc\bringup_empty\hello_world\src\main.c:131: undefined reference to `__device_dts_ord_127'

Other functioning sensors left out 
&i2c1 {
    compatible = "nordic,nrf-twim";
    status = "okay";
    clock-frequency = <I2C_BITRATE_FAST>;

    pinctrl-0 = <&i2c1_default>;
    pinctrl-1 = <&i2c1_sleep>;
    pinctrl-names = "default", "sleep";

    gyro: bmi088_gyr@69 {
      compatible = "bosch,bmi088-gyr";
      status = "okay";
      reg = <0x69>;
      // datasheet page 39
      bandwidth = <0x06>; // corner-frequency at 64 Hz
    };
    acc: bmi088_acc@18 {
      compatible = "bosch,bmi088-acc";
      status = "okay";
      reg = <0x18>;
      odr = <0x0B>; // 800 Hz
      osr = <0x08>; // 4 times oversampled
    };
};
Parents
  • Hi,

    It seems something is not enabled, either in your device tree or Kconfig (prj.conf). I suggest you open your build folder and find this file: <build_folder>/zephyr/include/generated/devicetree_generated.h. There you see the numbered nodes. As you got __device_dts_ord_127, 127 is relevant here. That points to a peripheral or similar, and that needs to be enabled/included.

Reply
  • Hi,

    It seems something is not enabled, either in your device tree or Kconfig (prj.conf). I suggest you open your build folder and find this file: <build_folder>/zephyr/include/generated/devicetree_generated.h. There you see the numbered nodes. As you got __device_dts_ord_127, 127 is relevant here. That points to a peripheral or similar, and that needs to be enabled/included.

Children
  • I forgot to mention I had already looked there and everything is defined as far as I can tell as compared to functioning devices. Please note that I added some PWM code to bring up that part of the board so my ordinals have changed.  
    Since this chip has two addresses in it we can just look at the gyro which is ordinal 132 now.

    Snippets from devicetree_generated.h

    I2C depends 
    /* Ordinals for what depends directly on this node: */
    #define DT_N_S_soc_S_peripheral_50000000_S_i2c_9000_SUPPORTS_ORDS \
    131, /* /soc/peripheral@50000000/i2c@9000/bmi088_acc@18 */ \
    132, /* /soc/peripheral@50000000/i2c@9000/bmi088_gyr@69 */ \
    133, /* /soc/peripheral@50000000/i2c@9000/bmm150@10 */ \
    134, /* /soc/peripheral@50000000/i2c@9000/bmp388@76 */ \
    135, /* /soc/peripheral@50000000/i2c@9000/vl53l1x@52 */

    /* Node's dependency ordinal: */
    #define DT_N_S_soc_S_peripheral_50000000_S_i2c_9000_S_bmi088_gyr_69_ORD 132 <--

    /* Ordinals for what this node depends on directly: */
    #define DT_N_S_soc_S_peripheral_50000000_S_i2c_9000_S_bmi088_gyr_69_REQUIRES_ORDS \
    130, /* /soc/peripheral@50000000/i2c@9000 */

    /* Ordinals for what depends directly on this node: */
    #define DT_N_S_soc_S_peripheral_50000000_S_i2c_9000_S_bmi088_gyr_69_SUPPORTS_ORDS /* nothing */

    /* Existence and alternate IDs: */
    #define DT_N_S_soc_S_peripheral_50000000_S_i2c_9000_S_bmi088_gyr_69_EXISTS 1
    #define DT_N_ALIAS_bmigyr DT_N_S_soc_S_peripheral_50000000_S_i2c_9000_S_bmi088_gyr_69
    #define DT_N_INST_0_bosch_bmi088_gyr DT_N_S_soc_S_peripheral_50000000_S_i2c_9000_S_bmi088_gyr_69
    #define DT_N_NODELABEL_gyro DT_N_S_soc_S_peripheral_50000000_S_i2c_9000_S_bmi088_gyr_69

    /* Bus info (controller: '/soc/peripheral@50000000/i2c@9000', type: '['i2c']') */
    #define DT_N_S_soc_S_peripheral_50000000_S_i2c_9000_S_bmi088_gyr_69_BUS_i2c 1
    #define DT_N_S_soc_S_peripheral_50000000_S_i2c_9000_S_bmi088_gyr_69_BUS DT_N_S_soc_S_peripheral_50000000_S_i2c_9000

    /* Macros for properties that are special in the specification: */
    #define DT_N_S_soc_S_peripheral_50000000_S_i2c_9000_S_bmi088_gyr_69_REG_NUM 1
    #define DT_N_S_soc_S_peripheral_50000000_S_i2c_9000_S_bmi088_gyr_69_REG_IDX_0_EXISTS 1
    #define DT_N_S_soc_S_peripheral_50000000_S_i2c_9000_S_bmi088_gyr_69_REG_IDX_0_VAL_ADDRESS 105 /* 0x69 */
    #define DT_N_S_soc_S_peripheral_50000000_S_i2c_9000_S_bmi088_gyr_69_RANGES_NUM 0
    #define DT_N_S_soc_S_peripheral_50000000_S_i2c_9000_S_bmi088_gyr_69_FOREACH_RANGE(fn)
    #define DT_N_S_soc_S_peripheral_50000000_S_i2c_9000_S_bmi088_gyr_69_IRQ_NUM 0
    #define DT_N_S_soc_S_peripheral_50000000_S_i2c_9000_S_bmi088_gyr_69_COMPAT_MATCHES_bosch_bmi088_gyr 1
    #define DT_N_S_soc_S_peripheral_50000000_S_i2c_9000_S_bmi088_gyr_69_COMPAT_VENDOR_IDX_0_EXISTS 1
    #define DT_N_S_soc_S_peripheral_50000000_S_i2c_9000_S_bmi088_gyr_69_COMPAT_VENDOR_IDX_0 "Bosch Sensortec GmbH"
    #define DT_N_S_soc_S_peripheral_50000000_S_i2c_9000_S_bmi088_gyr_69_COMPAT_MODEL_IDX_0_EXISTS 1
    #define DT_N_S_soc_S_peripheral_50000000_S_i2c_9000_S_bmi088_gyr_69_COMPAT_MODEL_IDX_0 "bmi088-gyr"
    #define DT_N_S_soc_S_peripheral_50000000_S_i2c_9000_S_bmi088_gyr_69_STATUS_okay 1

    /* Pin control (pinctrl-<i>, pinctrl-names) properties: */
    #define DT_N_S_soc_S_peripheral_50000000_S_i2c_9000_S_bmi088_gyr_69_PINCTRL_NUM 0


    I did not include property macros but they are there.  Based on what I see, there is no reason it wouldn't be included in the link. 

  • I just found a difference in this header file.  If I compare the in tree devices to my out of tree devices they are different as far as the header comment.  For example 

    /*
    * Devicetree node: /soc/peripheral@50000000/i2c@9000/bmm150@10
    *
    * Node identifier: DT_N_S_soc_S_peripheral_50000000_S_i2c_9000_S_bmm150_10
    *
    * Binding (compatible = bosch,bmm150):
    * $ZEPHYR_BASE\dts\bindings\sensor\bosch,bmm150.yaml
    *
    * (Descriptions have moved to the Devicetree Bindings Index
    * in the documentation.)
    */

    /*
    * Devicetree node: /soc/peripheral@50000000/i2c@9000/bmi088_gyr@69
    *
    * Node identifier: DT_N_S_soc_S_peripheral_50000000_S_i2c_9000_S_bmi088_gyr_69
    */

    Now, I'm not saying that is the issue and I can guarantee the out of tree dts\binding files are there. 
    Its the same for the vl53 out of tree device but it is functioning. 

  • I have some new information that can perhaps help you verify on Nordic side.  


    I was reviewing this web page of Nordics 
    https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/developing/adding_code.html#dm-user-workflows

    So I decided to try this 
    "The ncs-example-application repository is tagged every time a new release of the nRF Connect SDK is launched (starting with v2.3.0), using the same version number. This allows you to select the tag that matches the version of the nRF Connect SDK you intend to use."

    Low and behold I received this error when building that app. 
    FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map
    main.c:46: undefined reference to `__device_dts_ord_4'

  • Hi,

    The error indicate that there is an issue with the devicetree for the board you build for. The ncs-example-application builds for custom_plank out of the box, but for other boards you need to add an overlay. You can refer to this overlay file, and add as similar for the board you are building for. As an example, a overlay for the nRF52840 DK that use P0.0 for the sensor, could look like this:

    / {
    	examplesensor0: examplesensor_0 {
    		compatible = "zephyr,examplesensor";
    		input-gpios = <&gpio0 0 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
    	};
    };
    
    &gpio0 {
    	status = "okay";
    };

Related