This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Implementing WS2812 Driver NCS (undefined reference to `__device_dts_ord_61')

I'm trying to implement the WS2812 driver in my own project. I'm referencing the sample code stored in zephyr/samples/drivers/led_ws2812. I have copied over all of the correct configuration files, however, I'm getting an error when I try to define the strip device struct. The line shown here is throwing the error: 

#define STRIP_NODE		DT_ALIAS(led_strip)
#define STRIP_NUM_PIXELS	DT_PROP(DT_ALIAS(led_strip), chain_length)

// I believe this is the problem somehow: 
static const struct device *strip = DEVICE_DT_GET(STRIP_NODE);

The error I'm getting on compile is: 

undefined reference to `__device_dts_ord_61'

I have triple-checked all of my includes, my proj.conf is exactly the same as the sample, and my nrf52dk_nrf52832.overlay has the correct configuration. What am I missing? The sample compiles just fine.

Alternately, how is the *strip definition different than a normal sensor definition? For example, I have initialized my accelerometer as such: 

const struct device *sensor = device_get_binding("LIS3DH");

Is there a way to follow that same convention for my LED strip that would prevent this error I am seeing? Calling device_get_binding("WS2812") results in a NULL device. See below for my overlay file:

&i2c1 {
	compatible = "nordic,nrf-twim";
	status = "okay";
	sda-pin = <30>;
	scl-pin = <31>;
    clock-frequency = <I2C_BITRATE_FAST>;
    
    lis2dh@18 {
        compatible = "st,lis2dh";        
        reg = <0x18>;
        label = "LIS3DH";
    };    
};

#include "../nrf52-bindings.h"

&arduino_spi { /* MOSI on D11 / P0.23 */
	compatible = "nordic,nrf-spim";
	led_strip: ws2812@0 {
		compatible = "worldsemi,ws2812-spi";
		label = "WS2812";

		/* SPI */
		reg = <0>; /* ignored, but necessary for SPI bindings */
		spi-max-frequency = <SPI_FREQ>;

		/* WS2812 */
		chain-length = <10>; /* arbitrary; change at will */
		spi-one-frame = <ONE_FRAME>;
		spi-zero-frame = <ZERO_FRAME>;
	};
};

/ {
	aliases {
		led-strip = &led_strip;
	};
};

Parents Reply Children
  • Yes, I agree with you, it seems like all the dts definitions are generated correctly, so I'm actually not sure what's going on here. 

    I was able to build the sample zephyr/samples/drivers/led_ws2812 using the board nrf52dk_nrf52832. So one approach to figure out what's causing the issue it to start with that sample, and gradually, step by step add stuff from your main sample (from prj.conf, main.c, overlay files and so on). Every time you add something new, build the sample, then you'll eventually figure out what's causing it to fail.

    Please share the solution if you find the cause. If you're not able to figure it out, would you be able to upload your sample in zipped format? Then I could take a look at it.

  • Hey Simon, thanks. I've been through this exercise a few times now. The compile error only occurs when I add code to interact with the strip device. 

    	if (device_is_ready(strip)) {
    		printk("Found LED strip device %s\n", strip->name);
    	} else {
    		printk("LED strip device %s is not ready\n", strip->name);
    		return;
    	}

    Defined as such: 

    #define STRIP_NODE		DT_ALIAS(led_strip)
    #define STRIP_NUM_PIXELS	DT_PROP(DT_ALIAS(led_strip), chain_length)
    
    struct led_rgb pixels[STRIP_NUM_PIXELS];
    
    static const struct device *strip = DEVICE_DT_GET(STRIP_NODE);

    Attached is the zip file directory. I just combined the peripheral_dis sample with the ws812 sample. As noted, the error occurs only after defining the strip node and calling device_is_ready. The WS812 sample compiles fine for me with no modification. But, pulling it into a new project throws the error. 

    dis_led_test.zip 

  • I think it would be interesting to do it the opposite way, start with the WS812 sample and add stuff from the peripheral_dis sample until it breaks. Then you will figure out what in the peripheral_dis sample that causes the issue.

    I can look into it tomorrow.

  • I found the cause of the problem. You forgot to add the file zephyr/samples/drivers/led_ws2812/boards/nrf52dk_nrf52832.conf to dis_led_test/boards.

    When I did that, I no longer got the compile error.

    Best regards,

    Simon

  • Simon,

    My mistake, in my main application I did have the nrf52dk_nrf52832.conf file included which initially gave me this compile error. I missed it for this experiment but, including it just now resulted in the same error as above (same with my main application). I made sure to clean, then build. Still no luck. 

    Could it be an environment problem? 

    Were you able to recreate the compile error without the .conf file? Could I be missing a step you took to make sure the configuration was applied? 

Related