Error while using the CAF LEDs module

Hi, 

I tried to implement the CAF LEDs module as described here. But when added the Kconfig variable CONFIG_LED_PWM=y I got the error message "CONFIG_LED_PWM was assigned the value y, but got the value n. Missing dependencies: DT_HAS_PWM_LEDS_ENABLED"

How do I enable the PWM LEDs? My dts file looks similar to the description of the CAF LEDs module. 

pwmleds0 {
		compatible = "pwm-leds";
		status = "okay";
	
		red_pwm_led: red_pwm_led {
				status = "okay";
				pwms = <&pwm0 0 PWM_MSEC(1) PWM_POLARITY_INVERTED>;
				label = "LED0 red";
		};
	
		green_pwm_led: green_pwm_led {
				status = "okay";
				pwms = <&pwm0 1 PWM_MSEC(1) PWM_POLARITY_INVERTED>;
				label = "LED0 green";
		};
	
		blue_pwm_led: blue_pwm_led {
				status = "okay";
				pwms = <&pwm0 2 PWM_MSEC(1) PWM_POLARITY_INVERTED>;
				label = "LED0 blue";
		};
	};

Best regards,

Christian

Parents Reply Children
  • Hi Hieu,

    when I re-opened VS Code today the initial error message was gone. But now I get other errors when compiling my application.

     

    c:/ncs/toolchains/ce3b5ff664/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: zephyr/libzephyr.a(app_event_manager.c.obj): in function `app_event_manager_alloc':
    C:/ncs/v2.7.0/nrf/subsys/app_event_manager/app_event_manager.c:119: undefined reference to `k_malloc'
    c:/ncs/toolchains/ce3b5ff664/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: modules/nrf/subsys/caf/modules/lib..__nrf__subsys__caf__modules.a(leds.c.obj): in function `app_event_handler':
    C:/ncs/v2.7.0/nrf/subsys/caf/modules/leds.c:306: undefined reference to `__module_main'

    The first error disappeared when I added the config parameter CONFIG_HEAP_MEM_POOL_SIZE=2048 like discussed here. Unfortunately this wasn't mentioned in the documentation. 

    For the second error I found this case, but I don't know how to change a module name. Maybe you can explain to me what I have to do to solve this issue. 

    Best regards, 

    Christian

  • Hi Christian,

    ilockit_CFR said:
    The first error disappeared when I added the config parameter CONFIG_HEAP_MEM_POOL_SIZE=2048 like discussed here. Unfortunately this wasn't mentioned in the documentation. 

    From a search, I acknowledge that setting CONFIG_HEAP_MEM_POOL_SIZE fixes it for you and other people, but it makes no sense at all that it does. Could you please get me the compiled Kconfig files before and after setting CONFIG_HEAP_MEM_POOL_SIZE to see what the whole changes are?

    If you are using sysbuild, it is located in <build dir>/<app name>/zephyr/.config. Otherwise, it is located in <build dir>/zephyr/.config.

    ilockit_CFR said:
    For the second error I found this case, but I don't know how to change a module name. Maybe you can explain to me what I have to do to solve this issue. 

    You just need to define the macro MODULE in your main application source file. Refer: 
    https://github.com/nrfconnect/sdk-nrf/blob/v2.7.0/applications/nrf_desktop/src/main.c#L9
    https://docs.nordicsemi.com/bundle/ncs-2.7.0/page/nrf/libraries/caf/caf_overview.html#c.module_state_event

    Best regards,

    Hieu

  • Hi Hieu,

    thanks for your answer. The application compiles, but can you please explain why I have to include the 

    module_state_event.h header and define this module name?
    I attached two files with and withoude the heap config. The only thing that differs is CONFIG_HEAP_MEM_POOL_SIZE.
    Hope this helps,
    Christian
  • Hi Christian,

    ilockit_CFR said:
    I attached two files with and withoude the heap config. The only thing that differs is CONFIG_HEAP_MEM_POOL_SIZE.

    Thank you for the file. Apparently, k_malloc will not be compiled if HEAP_MEM_POOL_SIZE is 0, and that config is defaulted to 0. I still feel like the direct dependency is a bit unintuitive, but I suppose it makes sense.

    ilockit_CFR said:

    thanks for your answer. The application compiles, but can you please explain why I have to include the 

    module_state_event.h header and define this module name?

    I meant to send two links in my last reply but looks like it got merged into one. This is explained in the lost link:

    Common Application Framework overview (nordicsemi.com)

    Preprocessors are used to create a C symbol for each module, which is used for sending and receiving events. Due to the implementation, MODULE has to be defined before module_state_event.h header.

    If you are interested, the macro is resolved in this part of the code: sdk-nrf/include/caf/events/module_state_event.h at v2.7.0 · nrfconnect/sdk-nrf (github.com).

    Best regards,

    Hieu

Related