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 >;
    			};

Reply
  • 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 >;
    			};

Children
  • The #address-cells and #size-cells should be under the channel@x sub-nodes as they give info about the reg properties

    -Einar

  • I take example from this documentation

    In my overlay i have only that:

    &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 >;
    	};
    };

    GPIO haven't overlay, and no works too. same error.

    If i put #address-cells and #size-cells, errors happened.
    I also test to put compatible property, failed too.

  • Can you please share your project so I can try to replicate?

    -Einar

  • Yes, i simplified to get only errors:

    CONFIG_ADC=y
    CONFIG_GPIO=y

    #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)
    #define ADC_0 DT_CHILD(DT_NODELABEL(adc), channel_0)
    #define ADC_5 DT_CHILD(DT_NODELABEL(adc), channel_5)
    
    static const struct device *adc_0;
    static const struct device *adc_5;
    static const struct device *gpio_dev;
    
    static const struct adc_channel_cfg m_1st_channel_cfg = 
    	ADC_CHANNEL_CFG_DT(DT_CHILD(DT_NODELABEL(adc), channel_0));
    
    static const struct adc_channel_cfg m_5th_channel_cfg = 
    	ADC_CHANNEL_CFG_DT(DT_CHILD(DT_NODELABEL(adc), channel_5));
    
    bool init_adc_0() {
    	int err;
    
    	adc_0 = DEVICE_DT_GET(ADC_0);
    	
    	if (!device_is_ready(adc_0)) {
    		return false;
    	}
    
    	err = adc_channel_setup(adc_0, &m_1st_channel_cfg);
    	if (err) {
    		return false;
    	}
    	return true;
    }
    
    bool init_adc_5() {
    	int err;
    
    	adc_5 = DEVICE_DT_GET(ADC_5);
    	
    	if (!device_is_ready(adc_5)) {
    		return false;
    	}
    
    	err = adc_channel_setup(adc_5, &m_5th_channel_cfg);
    	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();
    }

    and the overlay

    &sim_select {
    	sim = "external";
    };
    
    / {
    	charger_enable: charger-enable {
    		compatible = "actinius-charger-enable";
    		charger = "disabled";
    	};
    };
    
    &adc {
    	compatible = "nordic,nrf-saadc";
    	#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 >;
    	};
    };
    
    /* Disable uart1 in nonsecure since it is used by the TFM secure app. */
    &uart1 {
    	status = "disabled";
    };

    If i comment init_adc_0 and 5, just leaving init_gpio, its works -> still the error (__device_dts_ord_xx) but build ok.

    Otherwise, nothing works.

  • Trying to build for nrf9160dk_nrf9160_ns I get undefined node label 'sim_select' from your overlay.

    What board do you build for?

    -Einar

Related