SDK 2.2 + "__device_dts_ord_XX" errors

Hi community,

I try to acces gpio0 and adc channels on a icarus board (nRF9160 + SDK 2.2).

On building, i have these errors "__device_dts_ord_94", "__device_dts_ord_95" and "__device_dts_ord_4".

DEVICE_DT_GET seems not accepted.
Any idea to solve this ?
Many thanks !

#define GPIO_NODE DT_NODELABEL(gpio0)
#define ADC_0 DT_CHILD(DT_NODELABEL(adc), channel_0)
#define ADC_5 DT_CHILD(DT_NODELABEL(adc), channel_5)

static const struct device *adc0;
static const struct device *adc5;
static const struct device *gpio;

adc0 = DEVICE_DT_GET(ADC_0);
adc5 = DEVICE_DT_GET(ADC_5);	
gpio = DEVICE_DT_GET(GPIO_NODE);

and overlay

&adc {
	#address-cells = <1>;
	#size-cells = <0>;
	
	channel@0 {
		reg = <0>;
		zephyr,gain = "ADC_GAIN_1_6";
		zephyr,reference = "ADC_REF_INTERNAL";
		zephyr,acquisition-time = <ADC_ACQ_TIME(ADC_ACQ_TIME_MICROSECONDS, 20)>;
		zephyr,input-positive = <NRF_SAADC_AIN0>;
		zephyr,resolution = < 10 >;
	};

	channel@5 {
		reg = <5>;
		zephyr,gain = "ADC_GAIN_1_6";
		zephyr,reference = "ADC_REF_INTERNAL";
		zephyr,acquisition-time = <ADC_ACQ_TIME(ADC_ACQ_TIME_MICROSECONDS, 20)>;
		zephyr,input-positive = <NRF_SAADC_AIN5>;
		zephyr,resolution = < 10 >;
	};
};

Parents
  • Hello

    Could you please share the adc node in your generated device tree in build/zephyr/zephyr.dts?

    You'll need to add a "compatible" property if it isn't already defined.

    I also suspect you might have to add

    #address-cells = <1>;
    #size-cells = <0>;

    to your overlay if you define reg as simply <5>.

    Best regards,

    Einar

  • The adc node

    adc: feather_adc: arduino_adc: adc@e000 {
    				compatible = "nordic,nrf-saadc";
    				reg = < 0xe000 0x1000 >;
    				interrupts = < 0xe 0x1 >;
    				status = "okay";
    				#io-channel-cells = < 0x1 >;
    				#address-cells = < 0x1 >;
    				#size-cells = < 0x0 >;
    				phandle = < 0x10 >;
    				channel@0 {
    					reg = < 0x0 >;
    					zephyr,gain = "ADC_GAIN_1_6";
    					zephyr,reference = "ADC_REF_INTERNAL";
    					zephyr,acquisition-time = < 0x4014 >;
    					zephyr,input-positive = < 0x1 >;
    					zephyr,resolution = < 0xa >;
    				};
    				channel@5 {
    					reg = < 0x5 >;
    					zephyr,gain = "ADC_GAIN_1_6";
    					zephyr,reference = "ADC_REF_INTERNAL";
    					zephyr,acquisition-time = < 0x4014 >;
    					zephyr,input-positive = < 0x6 >;
    					zephyr,resolution = < 0xa >;
    				};
    			};

    the gpio node

    gpio0: gpio@842500 {
    				compatible = "nordic,nrf-gpio";
    				gpio-controller;
    				reg = < 0x842500 0x300 >;
    				#gpio-cells = < 0x2 >;
    				status = "okay";
    				port = < 0x0 >;
    				phandle = < 0xa >;
    			};

  • Thanks, that did have an impact, I now get the same error as you.

    I'll try to see if I can figure out what's causing your device_dts_ord error then.

    -Einar

  • Damned, sorry i wasn't thinking

    Thanks for helping

  • It seems like it's difficult accessing the adc channel subnodes using the DEVICE_DT_GET macro.

    I was able to compile when I exchanged DEVICE_DT_GET with ADC_DT_SPEC_GET_BY_IDX,

    and adc_channel_setup with adc_channel_setup_dt.

    My main.c now looks like this:

    #include <zephyr/kernel.h>				// Noyau
    #include <zephyr/device.h>
    #include <zephyr/drivers/adc.h>			// ADC
    #include <zephyr/drivers/gpio.h>		// GPIO
    #include <stdio.h>						// Calcul
    #include <zephyr/sys/printk.h>			// Affichage
    #include <zephyr/logging/log.h>			// Logging
    
    LOG_MODULE_REGISTER(main);
    
    #define GPIO_NODE DT_NODELABEL(gpio0)
    
    static const struct adc_dt_spec adc_chan0 = ADC_DT_SPEC_GET_BY_IDX(DT_PATH(zephyr_user),0);
    static const struct adc_dt_spec adc_chan5 = ADC_DT_SPEC_GET_BY_IDX(DT_PATH(zephyr_user),1);
    static const struct device *gpio_dev;
    
    bool init_adc_0() {
    	int err;
    
    	err = adc_channel_setup_dt(&adc_chan0);
    	if (err) {
    		return false;
    	}
    	return true;
    }
    
    bool init_adc_5() {
    	int err;
    
    	err = adc_channel_setup_dt(&adc_chan5);
    	if (err) {
    		return false;
    	}
    	return true;
    }
    
    bool init_gpio() {
    	gpio_dev = DEVICE_DT_GET(GPIO_NODE);
    
    	if (!device_is_ready(gpio_dev)) {
    		return false;
    	};
    	return true;
    }
    
    int main(void)
    {
    	init_gpio();
    	init_adc_0();
    	init_adc_5();
    
        return true;
    }

    And I also had to add this to the overlay:

    / {
    	zephyr,user {
    		io-channels = <&adc 0>, <&adc 5>;
    	};
    };

    -Einar

  • Yes, thanks, but then how i can use functions like 

    adc_ref_internal or adc_read ?
    They need "const struct device *dev" as 1st parameter
    I have not seen adc_read_dt or adc_ref_internal_dt...
  • The device structure is actually part of adc_dt_spec.

    So you should be able to for example use adc_chan0.dev as the dev parameter for adc_read.

    -Einar

Reply Children
  • yes, thanks you !

    i find an other solution with your help:

    instead DT_CHILD(DT_NODELABEL(adc), channel_0)
    directly DEVICE_DT_GET(DT_IO_CHANNELS_CTLR_BY_IDX(DT_PATH(zephyr_user),0))
    Ours two solutions still keep errors of type '_device_dts_ord_12' but build and works.
  • Alskandar said:
    instead DT_CHILD(DT_NODELABEL(adc), channel_0)
    directly DEVICE_DT_GET(DT_IO_CHANNELS_CTLR_BY_IDX(DT_PATH(zephyr_user),0))

    Yes I guess that works too, as long as you run adc_channel_setup.

    Alskandar said:
    Ours two solutions still keep errors of type '_device_dts_ord_12' but build and works.

    What do you mean by this exactly?

    I'm not seeing any errors when I build.

    -Einar

  • This is an error of IntelliSense.

    If i modify includePath, librairies are found but i have _device_dts_ord erros

    If not, it not found librairies but i haven't errors like _device_dts_ord.

    In both case, program is built and works.

    This a VSCode problem.

  • Alskandar said:
    If i modify includePath, librairies are found but i have _device_dts_ord erros

    How and why are you modifying includePath?

    I'm not doing this and the program builds without errors.

    -Einar

  • If i do nothing, i have this "errors" (not blocking build operation)

    #include <zephyr/kernel.h>				// Noyau
    #include <zephyr/device.h>
    #include <zephyr/drivers/adc.h>			// ADC
    #include <zephyr/drivers/gpio.h>		// GPIO
    #include <stdio.h>						// Calcul
    #include <zephyr/sys/printk.h>			// Affichage
    #include <zephyr/logging/log.h>			// Logging
    
    all with tilde -> impossible d'ouvrir le fichier source "zephyr/kernel.h"C/C++(1696)

    if i modify in folder .vscode, the file c_cpp_properties.json

    like this (create automatically the file and add a line)

    "includePath": [
                    "${default}",
                    "/opt/nordic/ncs/v2.2.0/zephyr/include",
                    "${workspaceFolder}/**" <-- i have add this
                ],

    i have no errors of include files.

    But 3 errors _device_dts_ord_XX

Related