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

I'm in the process of upgrading from V2.2.0 to V2.6.0 of NCS.  Not surpringly, I'm having issues with building firmware that used to "just work".  I've got another ticket open in regards to this, but have moved over to another set of my firmware that used to work in NCS V2.2.0, which now won't successfully build in V2.6.0 because its throwing up a bunch of CONFIG issues

In this firmware, I am impementing the low power SYSTEM_OFF mode.

In my proj.conf I have:

# Enable Power Management
CONFIG_PM=y

# Required to disable default behavior of deep sleep on timeout
CONFIG_PM_DEVICE=y

This enables me to call:

pm_state_force(0u, &(struct pm_state_info){PM_STATE_SOFT_OFF, 0, 0})

when I want to put the device into SYSTEM_OFF mode.  Problem is, the CONFIG_PM=y isn't getting set, and instead I get this warning:

warning: PM (defined at soc/arm/silabs_exx32\efr32bg22\Kconfig.defconfig.series:18,
soc/arm/silabs_exx32\efr32bg27\Kconfig.defconfig.series:18,
soc/arm/silabs_exx32\efr32mg24\Kconfig.defconfig.series:19,
soc/arm/st_stm32\stm32f4\Kconfig.defconfig.series:20, subsys/pm/Kconfig:13) was assigned the value
'y' but got the value 'n'. Check these unsatisfied dependencies: ((SOC_SERIES_EFR32BG22 &&
SOC_FAMILY_EXX32) || (SOC_SERIES_EFR32BG27 && SOC_FAMILY_EXX32) || (SOC_SERIES_EFR32MG24 &&
SOC_FAMILY_EXX32) || SOC_SERIES_STM32F4X || (SYS_CLOCK_EXISTS && HAS_PM)) (=n). See
http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_PM and/or look up PM in the
menuconfig/guiconfig interface. The Application Development Primer, Setting Configuration Values,
and Kconfig - Tips and Best Practices sections of the manual might be helpful too.

I've done a bit of digging, and it looks like in Zephyr 3.5.0 (I think NCS V2.6.0 uses Zephyr 3.5.99) they implemented some changes to how power management is enabled and invoked:

So, that looks like rather than needing to have CONFIG_PM=y in my proj.conf, I need to have CONFIG_POWEROFF=y.  And then, rather than call pm_state_force(), I have to call sys_poweroff().

Problem is, I'm getting this warning when I attempt to build:

C:/Nordic/LPI/Release/LSR-MAX/src/reset/reset_mode.c:163:9: warning: implicit declaration of function 'sys_poweroff' [-Wimplicit-function-declaration]
  163 |         sys_poweroff();
      |         ^~~~~~~~~~~~

Previously, I had included:

#include <zephyr/init.h>
#include <zephyr/pm/pm.h>
#include <zephyr/pm/device.h>

but if I look in any of those, I can't see the new sys_poweroff() API, so there must be another header I need to include.

I'm also getting a bunch of build warnings around including the <zephyr/init.h> header file that I can't make sense of:

[7/41] Building C object CMakeFiles/app.dir/src/main.c.obj
In file included from C:/Nordic/LPI/Release/LSR-MAX/src/main.c:9:
C:/Nordic/v2.6.0/zephyr/include/zephyr/init.h:208:63: warning: initialization of 'int (*)(void)' from incompatible pointer type 'int (*)(const struct device *)' [-Wincompatible-pointer-types]
  208 |                 Z_INIT_ENTRY_NAME(name) = {.init_fn = {.sys = (init_fn_)}}
      |                                                               ^
C:/Nordic/v2.6.0/zephyr/include/zephyr/init.h:190:9: note: in expansion of macro 'SYS_INIT_NAMED'
  190 |         SYS_INIT_NAMED(init_fn, init_fn, level, prio)
      |         ^~~~~~~~~~~~~~
C:/Nordic/LPI/Release/LSR-MAX/src/main.c:171:1: note: in expansion of macro 'SYS_INIT'
  171 | SYS_INIT(detect_wakeup_latch, PRE_KERNEL_2, 0);
      | ^~~~~~~~
C:/Nordic/v2.6.0/zephyr/include/zephyr/init.h:208:63: note: (near initialization for '__init_detect_wakeup_latch.init_fn.sys')
  208 |                 Z_INIT_ENTRY_NAME(name) = {.init_fn = {.sys = (init_fn_)}}
      |                                                               ^
C:/Nordic/v2.6.0/zephyr/include/zephyr/init.h:190:9: note: in expansion of macro 'SYS_INIT_NAMED'
  190 |         SYS_INIT_NAMED(init_fn, init_fn, level, prio)
      |         ^~~~~~~~~~~~~~
C:/Nordic/LPI/Release/LSR-MAX/src/main.c:171:1: note: in expansion of macro 'SYS_INIT'
  171 | SYS_INIT(detect_wakeup_latch, PRE_KERNEL_2, 0);
      | ^~~~~~~~
C:/Nordic/v2.6.0/zephyr/include/zephyr/init.h:208:63: warning: initialization of 'int (*)(void)' from incompatible pointer type 'int (*)(const struct device *)' [-Wincompatible-pointer-types]
  208 |                 Z_INIT_ENTRY_NAME(name) = {.init_fn = {.sys = (init_fn_)}}
      |                                                               ^
C:/Nordic/v2.6.0/zephyr/include/zephyr/init.h:190:9: note: in expansion of macro 'SYS_INIT_NAMED'
  190 |         SYS_INIT_NAMED(init_fn, init_fn, level, prio)
      |         ^~~~~~~~~~~~~~
C:/Nordic/LPI/Release/LSR-MAX/src/main.c:172:1: note: in expansion of macro 'SYS_INIT'
  172 | SYS_INIT(disable_ds_1, PRE_KERNEL_1, 0);
      | ^~~~~~~~
C:/Nordic/v2.6.0/zephyr/include/zephyr/init.h:208:63: note: (near initialization for '__init_disable_ds_1.init_fn.sys')
  208 |                 Z_INIT_ENTRY_NAME(name) = {.init_fn = {.sys = (init_fn_)}}
      |                                                               ^
C:/Nordic/v2.6.0/zephyr/include/zephyr/init.h:190:9: note: in expansion of macro 'SYS_INIT_NAMED'
  190 |         SYS_INIT_NAMED(init_fn, init_fn, level, prio)
      |         ^~~~~~~~~~~~~~
C:/Nordic/LPI/Release/LSR-MAX/src/main.c:172:1: note: in expansion of macro 'SYS_INIT'
  172 | SYS_INIT(disable_ds_1, PRE_KERNEL_1, 0);
      | ^~~~~~~~

Making lots of "reverse progress" this week :-(

Anyone know what I need to do to fix this?

Regards,

Mike

Parents
  • Hello,

    I'm sorry to hear you have had this many challenges with the migration. Support for the PM subsystem was removed in SDK v2.5.0. The reasoning for this change was given in the commit message here: https://github.com/nrfconnect/sdk-zephyr/commit/96b38273138f05dd06cf7a58fa361f401e773e5e. Unfortunately, this change was not mentioned in the release notes or migration documentation.

    So, that looks like rather than needing to have CONFIG_PM=y in my proj.conf, I need to have CONFIG_POWEROFF=y.  And then, rather than call pm_state_force(), I have to call sys_poweroff().

    In addition to enabling CONFIG_POWEROFF, did you include the poweroff.h header (#include <zephyr/sys/poweroff.h>) in the source file that calls the function?

    I'm also getting a bunch of build warnings around including the <zephyr/init.h> header file that I can't make sense o

    The warnings seems to stem from your SYS_INIT() calls, indicating that the initialization functions are not declared with the expected type. Or is detect_wakeup_latch() declared like this: static int detect_wakeup_latch(void)?

    Best regards,

    Vidar

  • Hi Vidar,

    OK, that #include <zephyr/sys/poweroff.h> was what I needed!  That seems to have sorted out the error around the sys_poweroff().

    Those SYS_INIT() calls haven't changed from the version that built OK under NCS V2.2.0.  This is what I have setup:

    /* Grabs contents of RESETREAS and LATCH registers  */
    static int detect_wakeup_latch(const struct device *dev)
    {
    	ARG_UNUSED(dev);
    
    	/* Check status of RESETREAS register to determine what caused exit from System OFF */
    	/* 0x0001 = Reset pin 
    	 * 0x0002 = Watchdog
    	 * 0x0004 = Software
    	 * 0x0008 = CPU Lockup
    	 * 0x10000 = Wakeup from System Off via DETECT from GPIO
    	 * 0x20000 = Wakeup from System Off via ANADETECT from LPCOMP
    	 * 0x40000 = Wakeup from System Off via Debug mode
    	 * 0x80000 = Wakeup from System Off via NFC
    	*/
    	reset_reason = NRF_POWER->RESETREAS;
    	(void)NRF_TIMER0->EVENTS_COMPARE[0];
    
    	/* Record status of LATCH register to check with GPIO triggered exit from System OFF (if applicable) */
    	gpio_trigger = NRF_GPIO->LATCH;
    	
    	/* Disable inputs from affecting the DETECT signal, which should preserve LATCH and prevent spurious interrupts */
    	gpio_pin_trig_disable();
    
    	return (0);
    }
    
    /* Prevent deep sleep (system off) from being entered on long timeouts
     * or `K_FOREVER` due to the default residency policy.
     *
     * This has to be done before anything tries to sleep, which means
     * before the threading system starts up between PRE_KERNEL_2 and
     * POST_KERNEL.  Do it at the start of PRE_KERNEL_2.
     */
    static int disable_ds_1(const struct device *dev)
    {
    	ARG_UNUSED(dev);
    
    	pm_policy_state_lock_get(PM_STATE_SOFT_OFF,PM_ALL_SUBSTATES);
    
    	return 0;
    }
    
    SYS_INIT(detect_wakeup_latch, PRE_KERNEL_2, 0);
    SYS_INIT(disable_ds_1, PRE_KERNEL_1, 0);

    What I'm trying to do is grab details of which GPIO has triggered the device out of SYSTEM_OFF.  The disable_ds_1() function is something I think I blindly copied from somewhere when I was getting the SYSTEM_OFF stuff working 12 months or so ago.

    Regards,

    Mike

  • Hi Mike,

    Changing the function to declaration to 'static int detect_wakeup_latch(void)' and removing the ARG_UNUSED(dev); line should remove the warning.

    Relevant commit:

    https://github.com/nrfconnect/sdk-zephyr/commit/a5fd0d184a15d0af52599e0f5f5af880f353c6d4

    Regards,

    Vidar

  • Fantatic - that's fixed my SYS_INIT issues.

    I probably need to learn how to trawl through Zephyr and NCS commits to keep abreast of changes with each new release as I'd then be able to pre-empt a few of these issues next time I need to upgrade my SDK

    Thanks for your help Vidar

  • Excellent - glad to hear that it fixed it. 

    Mike Austin (LPI) said:
    I probably need to learn how to trawl through Zephyr and NCS commits to keep abreast of changes with each new release as I'd then be able to pre-empt a few of these issues next time I need to upgrade my SDK

    I often use the search function in VS Code. For instance, I found usage examples of the sys_poweroff() function by searching for it across the *.c files in the SDK tree.

       

    I also use the GitLens extension to help find relevant commits.

    Best regards,

    Vidar

Reply
  • Excellent - glad to hear that it fixed it. 

    Mike Austin (LPI) said:
    I probably need to learn how to trawl through Zephyr and NCS commits to keep abreast of changes with each new release as I'd then be able to pre-empt a few of these issues next time I need to upgrade my SDK

    I often use the search function in VS Code. For instance, I found usage examples of the sys_poweroff() function by searching for it across the *.c files in the SDK tree.

       

    I also use the GitLens extension to help find relevant commits.

    Best regards,

    Vidar

Children
No Data
Related