[NCS v2.6.1] Issue with build ("/soc/pwm@4001c000 defined without sleep state")

Hello Nordic,

I want to power down (at the lowest power consumption state as possible) all the peripherlas.

Already checked below ticket.

 Issues with CONFIG settings not being enabled in NCS V2.6.0 

Below ticket also referenced for turn off peripherals required to reduce power for not using ones.

  NCS v2.4.0: low power by example 

C source code getting device.

#define LED_RED_NODE DT_NODELABEL(red_led_pwm)
const struct pwm_dt_spec led_red_pwm = PWM_DT_SPEC_GET(LED_RED_NODE);

#define LED_GREEN_NODE DT_NODELABEL(green_led_pwm)
const struct pwm_dt_spec led_green_pwm = PWM_DT_SPEC_GET(LED_GREEN_NODE);

#define LED_BLUE_NODE DT_NODELABEL(blue_led_pwm)
const struct pwm_dt_spec led_blue_pwm = PWM_DT_SPEC_GET(LED_BLUE_NODE);

...

.dts (no overlay file used since it's custom board)

&pwm0 {
	status = "okay";
	pinctrl-0 = <&pwm0_default>;
	pinctrl-names = "default";
};

&pinctrl {
	
	...
	
	pwm0_default: pwm0_default {
		group1 {
			psels = <NRF_PSEL(PWM_OUT0, 0, 22)>,
			        <NRF_PSEL(PWM_OUT1, 0, 24)>,
			        <NRF_PSEL(PWM_OUT2, 0, 23)>;
		};
	};
};

.build log

In file included from C:/ncs/v2.6.1/zephyr/include/zephyr/toolchain.h:50,
                 from C:/ncs/v2.6.1/zephyr/include/zephyr/sys/util.h:18,
                 from C:/ncs/v2.6.1/zephyr/include/zephyr/devicetree.h:26,
                 from c:\ncs\v2.6.1\zephyr\modules\hal_nordic\nrfx\nrfx_config.h:10,
                 from C:/ncs/v2.6.1/modules/hal/nordic/nrfx/nrfx.h:37,
                 from C:/ncs/v2.6.1/modules/hal/nordic/nrfx/drivers/include/nrfx_pwm.h:37,
                 from C:/ncs/v2.6.1/zephyr/drivers/pwm/pwm_nrfx.c:6:
C:/ncs/v2.6.1/zephyr/include/zephyr/toolchain/gcc.h:87:36: error: static assertion failed: "/soc/pwm@4001c000 defined without sleep state"
   87 | #define BUILD_ASSERT(EXPR, MSG...) _Static_assert(EXPR, "" MSG)
      |                                    ^~~~~~~~~~~~~~
c:\ncs\v2.6.1\zephyr\soc\arm\nordic_nrf\common\soc_nrf_common.h:235:9: note: in expansion of macro 'BUILD_ASSERT'
  235 |         BUILD_ASSERT(!IS_ENABLED(CONFIG_PM_DEVICE) ||                          \
      |         ^~~~~~~~~~~~
C:/ncs/v2.6.1/zephyr/drivers/pwm/pwm_nrfx.c:344:9: note: in expansion of macro 'NRF_DT_CHECK_NODE_HAS_PINCTRL_SLEEP'
  344 |         NRF_DT_CHECK_NODE_HAS_PINCTRL_SLEEP(PWM(idx));                        \
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/ncs/v2.6.1/zephyr/drivers/pwm/pwm_nrfx.c:380:1: note: in expansion of macro 'PWM_NRFX_DEVICE'
  380 | PWM_NRFX_DEVICE(0);
      | ^~~~~~~~~~~~~~~

The whole system works perfectly and the issue arise when I add below CONFIG in _defconfig.

# CONFIG_PM=y
CONFIG_POWEROFF=y
CONFIG_PM_DEVICE=y
CONFIG_PM_DEVICE_RUNTIME=y

Any suggestions?

  • Hi,

    You might be getting this error because I see that you have not defined any sleep state for the pwm in the dts file. You need to specify a sleep state too, say,

    &pwm0 {
    status = "okay";
    pinctrl-0 = <&pwm0_default>;

    pinctrl-1 = <&pwm0_sleep>;

    pinctrl-names = "default", "sleep";
    };

    &pinctrl {

    ...

    pwm0_default: pwm0_default {
    group1 {
    psels = <NRF_PSEL(PWM_OUT0, 0, 22)>,
    /* Other configurations */
    };
    };

    pwm0_sleep: pwm0_sleep {

    group1 {

    psels = <NRF_PSEL(PWM_OUT0, 0xFFFFFFFF)>,

    /* Other configurations */

    };

    };

    -Priyanka

  • Appreciate!

    Compile works without the error.

    One more question.

    If I execute below api, it will power down not only the cpu but also the whole peripherlas?

    sys_poweroff();
    Below code seems only shundown the CPU not the whole peripherlas.
    // Enter system off mode
    NRF_POWER->SYSTEMOFF = 0x1;
    If the answer is "yes", calling sys_poweroff() is right approach when battery charging state and it would makes for charger to approach I_term as soon as possible.
  • Hi,

    That's right, the sys_poweroff() powers down the CPU and the peripherals such that your device is in the lowest power state. It helps to save maximum energy. 

    NRF_POWER->SYSTEMOFF is more of a lower hardware specific way of using the sys_poweroff()and should do the same. But please note that actually it's only the CPU that is powered off, but since the CPU controls the power state of the peripherals, then the peripherals are shut down too. 

    Calling the sys_poweroff() is the right approach when you want minimal consumption when in battery charging state. But please make sure that the charger and other components responsible for the charging are on an independent power rail so that they are not affected by the system-off mode.

    -Priyanka 

Related