Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Incorrect assert in pwr_mgmt lib?

I am debugging my applications transitions to SYSTEM_OFF and back again. I am connected to the debugger so I am presumably testing with "emulated system off" which is just a loop. Things seems to be working well but I was thrown off by an error reported by the pwr_mgmt lib when entering system off. 

[00:00:00.000,000] <error> app: ERROR 3735928559 [Unknown error code] at ...components/libraries/pwr_mgmt/nrf_pwr_mgmt.c:418

This line has contains the following: ASSERT((ret_code == NRF_SUCCESS) || (ret_code == NRF_ERROR_SOFTDEVICE_NOT_ENABLED)); and each time I enter SYSTEM_OFF this assert fails which then raises a 0xDEADBEEF error, which is printed to my debugger.

I believe this assert is incorrect because the SDK documentation states that sd_power_system_off() should return NRF_ERROR_SOC_POWER_OFF_SHOULD_NOT_RETURN not NRF_SUCCESS. I am assuming that this function will not actually return if I am not in debugging mode which would mask this issue, but it is hard to tell if the SD is throwing an error or if this is simply a mistake in the SDK. changing NRF_SUCCESS to NRF_ERROR_SOC_POWER_OFF_SHOULD_NOT_RETURN seems to solve the issue for me. 

Related