undefined reference to device

Hello everyone,

for my project I had to develop a new driver for the Kinetic 2026 LED driver.

I have attached the driver to my project like this in the Device Tree like this:

&i2c0 {
	clock-frequency = <I2C_BITRATE_FAST>;
	compatible = "nordic,nrf-twi";
	status = "okay";
	pinctrl-0 = <&i2c0_default>;
	pinctrl-1 = <&i2c0_sleep>;
	pinctrl-names = "default", "sleep";
	
	/* other devices */
	...
	
	ktd2026:ktd2026@30 {
		compatible = "kinetic,ktd2026";
		reg = < 0x30 >;
	};
};

aliases {
	led-ktd2026 = &ktd2026;
};

I then tried to use the driver like this in the application:

#include <zephyr/device.h>
#include <zephyr/kernel.h>
#include <zephyr/drivers/i2c.h>
#include <zephyr/drivers/led.h>

#include "rgb_led.hpp"

...

static const device *led_driver = DEVICE_DT_GET(DT_ALIAS(led_ktd2026));

bool init()
{
	/* Check for device ready status */
	return (bool)device_is_ready(led_driver);
}

bool setColor(const color_t color, const uint8_t brightness)
{
		/* Return value */
	bool result = true;
	uint8_t colorArray[MAX_LEDS] = {color.r, color.g, color.b};
	/* Limit brightness to the maximum value */
	__ASSERT(brightness <= MAX_BRIGHTNESS, "Max LED brightness is 100");
	led_set_brightness(led_driver, 0, brightness);
	led_set_color(led_driver, 0, MAX_LEDS, colorArray);
	led_on(led_driver, 0);
	/* Return result */
	return result;
}

bool turnOff()
{
	return led_off(led_driver, 0);
}

For every call to the API I get the following error:

:/Users/.../ncs/zephyr/include/zephyr/device.h:737: undefined reference to `__device_dts_ord_92'

I have already checked the following:

  • The appropriate KConfig is activated (CONFIG_I2C, CONFIG_LED and CONFIG_KTD2026), as seen in the compiled KConfig (in .config) and in the autoconf.h
  • In Zephyr.dts the I2C device is listed with status "okay"
  • In devicetree_generated.h the device is listed with the appropriate number
  • No errors while compiling the KConfig
  • The naming (dashes to underscores) I have also checked

I have checked it against the suggestions on this Zephyr site: https://docs.zephyrproject.org/latest/build/dts/troubleshooting.html

The only thing I didn't check yet is the preprocessor output (-DCONFIG_COMPILER_SAVE_TEMPS=y) because I'm unsure how I can force this in the Nordic SDK in VS Code.

I'd appreciate any help I can get. I have built the driver to be similar to other drivers in the project and I have no idea why only this brings so much trouble.

I have attached the driver as well as relevant files from the build process.

ledDriverBuildFiles.zipledDriver.zip

Parents Reply Children
Related