nPM1300 LEDs not recognized by CAF LED module - "No LEDs defined" error

I'm encountering an issue while trying to use the CAF LED module with the nPM1300 PMIC. Despite configuring the Device Tree, prj.conf, and led_state_def.h, I'm still getting a "No LEDs defined" error during compilation. I'd appreciate any help or insights from the community.
Error message:
C:/ncs/v2.8.0/nrf/subsys/caf/modules/leds.c: In function 'leds_init':
C:/ncs/v2.8.0/zephyr/include/zephyr/toolchain/gcc.h:87:36: error: static assertion failed: "No LEDs defined"
 87 | #define BUILD_ASSERT(EXPR, MSG...) _Static_assert((EXPR), "" MSG)
 | ^~~~~~~~~~~~~~
C:/ncs/v2.8.0/nrf/subsys/caf/modules/leds.c:182:9: note: in expansion of macro 'BUILD_ASSERT'
 182 | BUILD_ASSERT(DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) > 0, "No LEDs defined");
My setup:
  1. Device Tree Configuration (excerpt):
&i2c1 {
    npm1300_ek_pmic: pmic@6b {
    compatible = "nordic,npm1300";
    reg = <0x6b>;
   
    npm1300_ek_leds: leds {
        compatible = "nordic,npm1300-led";
        nordic,led0-mode = "host";
        nordic,led1-mode = "host";
        nordic,led2-mode = "host";
        };
    };
};
  1. prj.conf Configuration:
# CAF LEDs Configuration
CONFIG_CAF_LEDS=y
CONFIG_LED=y
 
# nPM1300 specific LED configuration
CONFIG_LED_NPM1300=y
 
# Necessary drivers for nPM1300
CONFIG_I2C=y
CONFIG_REGULATOR=y
CONFIG_REGULATOR_NPM1300=y
CONFIG_GPIO_NPM1300=y
 
# Other nPM1300 related configurations
CONFIG_GPIO=y
CONFIG_INPUT=y
  1. led_state_def.h Configuration:
tatic const uint8_t led_map[LED_ID_COUNT] = {
    [LED_ID_SYSTEM_STATE] = 0,
    [LED_ID_PEER_STATE] = 1
};


static const struct led_effect led_system_state_effect[LED_SYSTEM_STATE_COUNT] = {
    [LED_SYSTEM_STATE_IDLE]     = LED_EFFECT_LED_ON(LED_COLOR(255, 0, 0)),
    [LED_SYSTEM_STATE_CHARGING] = LED_EFFECT_LED_ON(LED_COLOR(0, 255, 0)),
    [LED_SYSTEM_STATE_ERROR]    = LED_EFFECT_LED_BLINK(200, LED_COLOR(255, 0, 0)),
};

static const struct led_effect led_peer_state_effect[LED_PEER_COUNT][LED_PEER_STATE_COUNT] = {
    {
        [LED_PEER_STATE_DISCONNECTED]   = LED_EFFECT_LED_OFF(),
        [LED_PEER_STATE_CONNECTED]      = LED_EFFECT_LED_ON(LED_COLOR(0, 0, 255)),
        [LED_PEER_STATE_PEER_SEARCH]    = LED_EFFECT_LED_BLINK(50, LED_COLOR(0, 0, 255)),
    }
};
I've tried the following:
  1. Adjusted the Device Tree configuration for nPM1300 LEDs.
  2. Updated prj.conf with the required configurations for CAF LEDs and nPM1300.
  3. Adapted led_state_def.h to the limitations of the nPM1300 (no PWM, only on/off states).
  4. Multiple reviews and cleanups of the configurations to avoid conflicts.
Despite these adjustments, I'm still getting the "No LEDs defined" error. It seems that the system is not recognizing the LED definitions.
Has anyone encountered a similar issue or can provide guidance on what I might be missing? Any help would be greatly appreciated!
Thank you in advance for your assistance.

Parents
  • The condition of the assert in leds.c is:
    DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)

    DT_DRV_COMPAT is #defined at the top of leds.c:

    #ifdef CONFIG_CAF_LEDS_PWM
    #define DT_DRV_COMPAT pwm_leds
    #elif defined(CONFIG_CAF_LEDS_GPIO)
    #define DT_DRV_COMPAT gpio_leds
    #else
    #error "LED driver must be specified in configuration"
    #endif

    I don't see any signs that you're using PWM LEDs so DT_DRV_COMPAT should likely be gpio_leds.

    Search in your <build_dir>/zephyr/zephyr.dts file for nodes with compatible = "gpio-leds" -- does one exist and have status = "okay"? That's what the DT_HAS_COMPAT_STATUS_OKAY macro is testing for.

Reply
  • The condition of the assert in leds.c is:
    DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)

    DT_DRV_COMPAT is #defined at the top of leds.c:

    #ifdef CONFIG_CAF_LEDS_PWM
    #define DT_DRV_COMPAT pwm_leds
    #elif defined(CONFIG_CAF_LEDS_GPIO)
    #define DT_DRV_COMPAT gpio_leds
    #else
    #error "LED driver must be specified in configuration"
    #endif

    I don't see any signs that you're using PWM LEDs so DT_DRV_COMPAT should likely be gpio_leds.

    Search in your <build_dir>/zephyr/zephyr.dts file for nodes with compatible = "gpio-leds" -- does one exist and have status = "okay"? That's what the DT_HAS_COMPAT_STATUS_OKAY macro is testing for.

Children
  • Hi, yes now I understand.
    The core issue was that the CAF LED module isn't configured to work with the nPM1300's specific LED driver. It expects either PWM or GPIO-based LEDs, but the nPM1300 uses its own unique LED driver.
    While modifying the CAF LED implementation could be a solution, I've decided to build a solution using Zephyr directly instead. This approach will bypass the CAF LED module entirely and utilize Zephyr's native LED APIs to interact with the nPM1300 LED driver.
    It would still be beneficial if Nordic could update the LED module in future SDK versions to natively support the Nordic nPM1300 LED driver. This would simplify the integration of nPM1300 into projects using the CAF LED module for those who prefer to use it.

    Thanks
  • Thanks for the update. I will pass the feedback on internally as I don't see any reason why it should be be added

    Regards

    Runar

Related