zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.48k stars 6.41k forks source link

tests/subsys/power/power_mgmt/subsys.power.device_pm fails to build on nrf5340dk_nrf5340_cpunet & nrf5340pdk_nrf5340_cpunet #31627

Closed galak closed 3 years ago

galak commented 3 years ago
scripts/twister -p nrf5340dk_nrf5340_cpunet -p nrf5340pdk_nrf5340_cpunet -s tests/subsys/power/power_mgmt/subsys.power.device_pm

Gets:

FAILED: CMakeFiles/app.dir/src/main.c.obj 
ccache /opt/sdk/zephyr-sdk-0.12.2/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc -DBUILD_VERSION=v2.5.0-rc1-16-g085d2eda8d2b -DKERNEL -DNRF5340_XXAA_NETWORK -D_FORTIFY_SOURCE=2 -D__PROGRAM_START -D__ZEPHYR__=1 -I/workdir/zephyr/kernel/include -I/workdir/zephyr/arch/arm/include -I/workdir/zephyr/include -Izephyr/include/generated -I/workdir/zephyr/soc/arm/nordic_nrf/nrf53 -I/workdir/zephyr/subsys/testsuite/include -I/workdir/zephyr/subsys/testsuite/ztest/include -I/var/lib/buildkite-agent/zephyr-module-cache/modules/hal/cmsis/CMSIS/Core/Include -I/workdir/modules/hal/nordic/nrfx -I/workdir/modules/hal/nordic/nrfx/drivers/include -I/workdir/modules/hal/nordic/nrfx/mdk -I/workdir/zephyr/modules/hal_nordic/nrfx/. -isystem /workdir/zephyr/lib/libc/minimal/include -isystem /opt/sdk/zephyr-sdk-0.12.2/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/10.2.0/include -isystem /opt/sdk/zephyr-sdk-0.12.2/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/10.2.0/include-fixed -Os -imacros /workdir/zephyr/twister-out/nrf5340pdk_nrf5340_cpunet/tests/subsys/power/power_mgmt/subsys.power.device_pm/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -mcpu=cortex-m33+nodsp -mthumb -mabi=aapcs -imacros /workdir/zephyr/include/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Wno-address-of-packed-member -Wno-unused-but-set-variable -Werror=implicit-int -Werror -fno-asynchronous-unwind-tables -fno-pie -fno-pic -fno-strict-overflow -fno-reorder-functions -fno-defer-pop -fmacro-prefix-map=/workdir/zephyr/tests/subsys/power/power_mgmt=CMAKE_SOURCE_DIR -fmacro-prefix-map=/workdir/zephyr=ZEPHYR_BASE -fmacro-prefix-map=/workdir=WEST_TOPDIR -ffunction-sections -fdata-sections -std=c99 -nostdinc -MD -MT CMakeFiles/app.dir/src/main.c.obj -MF CMakeFiles/app.dir/src/main.c.obj.d -o CMakeFiles/app.dir/src/main.c.obj   -c /workdir/zephyr/tests/subsys/power/power_mgmt/src/main.c
/workdir/zephyr/tests/subsys/power/power_mgmt/src/main.c: In function 'pm_policy_low_power_devices':
/workdir/zephyr/tests/subsys/power/power_mgmt/src/main.c:64:9: error: implicit declaration of function 'pm_is_sleep_state' [-Werror=implicit-function-declaration]
   64 |  return pm_is_sleep_state(state);
      |         ^~~~~~~~~~~~~~~~~
In file included from /workdir/zephyr/subsys/testsuite/ztest/include/ztest.h:60,
                 from /workdir/zephyr/tests/subsys/power/power_mgmt/src/main.c:10:
/workdir/zephyr/tests/subsys/power/power_mgmt/src/main.c: In function 'pm_policy_next_state':
/workdir/zephyr/tests/subsys/power/power_mgmt/src/main.c:74:31: error: 'struct z_kernel' has no member named 'idle'
   74 |  zassert_true(ticks == _kernel.idle, NULL);
      |                               ^
/workdir/zephyr/subsys/testsuite/ztest/include/ztest_assert.h:93:12: note: in definition of macro 'zassert'
   93 |  z_zassert(cond, msg ? ("(" default_msg ")") : (default_msg), \
      |            ^~~~
/workdir/zephyr/tests/subsys/power/power_mgmt/src/main.c:74:2: note: in expansion of macro 'zassert_true'
   74 |  zassert_true(ticks == _kernel.idle, NULL);
      |  ^~~~~~~~~~~~
/workdir/zephyr/tests/subsys/power/power_mgmt/src/main.c: In function 'test_main':
/workdir/zephyr/tests/subsys/power/power_mgmt/src/main.c:214:9: error: variable 'notifier' has initializer but incomplete type
  214 |  struct pm_notifier notifier = {
      |         ^~~~~~~~~~~
/workdir/zephyr/tests/subsys/power/power_mgmt/src/main.c:215:4: error: 'struct pm_notifier' has no member named 'state_entry'
  215 |   .state_entry = notify_pm_state_entry,
      |    ^~~~~~~~~~~
/workdir/zephyr/tests/subsys/power/power_mgmt/src/main.c:215:18: error: excess elements in struct initializer [-Werror]
  215 |   .state_entry = notify_pm_state_entry,
      |                  ^~~~~~~~~~~~~~~~~~~~~
/workdir/zephyr/tests/subsys/power/power_mgmt/src/main.c:215:18: note: (near initialization for 'notifier')
/workdir/zephyr/tests/subsys/power/power_mgmt/src/main.c:216:4: error: 'struct pm_notifier' has no member named 'state_exit'
  216 |   .state_exit = notify_pm_state_exit,
      |    ^~~~~~~~~~
/workdir/zephyr/tests/subsys/power/power_mgmt/src/main.c:216:17: error: excess elements in struct initializer [-Werror]
  216 |   .state_exit = notify_pm_state_exit,
      |                 ^~~~~~~~~~~~~~~~~~~~
/workdir/zephyr/tests/subsys/power/power_mgmt/src/main.c:216:17: note: (near initialization for 'notifier')
/workdir/zephyr/tests/subsys/power/power_mgmt/src/main.c:214:21: error: storage size of 'notifier' isn't known
  214 |  struct pm_notifier notifier = {
      |                     ^~~~~~~~
/workdir/zephyr/tests/subsys/power/power_mgmt/src/main.c:219:2: error: implicit declaration of function 'pm_notifier_register' [-Werror=implicit-function-declaration]
  219 |  pm_notifier_register(&notifier);
      |  ^~~~~~~~~~~~~~~~~~~~
/workdir/zephyr/tests/subsys/power/power_mgmt/src/main.c:231:2: error: implicit declaration of function 'pm_notifier_unregister' [-Werror=implicit-function-declaration]
  231 |  pm_notifier_unregister(&notifier);
      |  ^~~~~~~~~~~~~~~~~~~~~~
/workdir/zephyr/tests/subsys/power/power_mgmt/src/main.c:214:21: error: unused variable 'notifier' [-Werror=unused-variable]
  214 |  struct pm_notifier notifier = {
      |                     ^~~~~~~~
cc1: all warnings being treated as errors
[16/142] Building C object zephyr/CMakeFiles/zephyr.dir/li
galak commented 3 years ago

@carlescufi please re-assign this as needed.

nashif commented 3 years ago

@ceolin you should not be filter hardware in subsystems, this needs to be done on the test level

diff --git a/subsys/power/Kconfig b/subsys/power/Kconfig
index 84e180ffca..c3e676da6f 100644
--- a/subsys/power/Kconfig
+++ b/subsys/power/Kconfig
@@ -13,7 +13,7 @@ config SYS_POWER_MANAGEMENT
 menuconfig PM
        bool "System Power management"
        select TICKLESS_IDLE
-       depends on SYS_CLOCK_EXISTS && !SOC_NRF5340_CPUNET_QKAA
+       depends on SYS_CLOCK_EXISTS
        help
          This option enables the board to implement extra power management
          policies whenever the kernel becomes idle. The kernel informs the
nashif commented 3 years ago

this boils down to this board failing when CONFIG_PM is enabled (which enables build of soc/arm/nordic_nrf/nrf53/power.c with the following failure:

/home/nashif/Work/zephyrproject/modules/hal/nordic/nrfx/hal/nrf_regulators.h:138:50: error: unknown type name 'NRF_REGULATORS_Type'; did you mean 'NRF_REGULATORS_H__'?
  138 | NRF_STATIC_INLINE void nrf_regulators_dcdcen_set(NRF_REGULATORS_Type * p_reg, bool enable);
      |                                                  ^~~~~~~~~~~~~~~~~~~
      |                                                  NRF_REGULATORS_H__
/home/nashif/Work/zephyrproject/modules/hal/nordic/nrfx/hal/nrf_regulators.h:150:50: error: unknown type name 'NRF_REGULATORS_Type'; did you mean 'NRF_REGULATORS_H__'?
  150 | NRF_STATIC_INLINE void nrf_regulators_system_off(NRF_REGULATORS_Type * p_reg);
      |                                                  ^~~~~~~~~~~~~~~~~~~
      |                                                  NRF_REGULATORS_H__
/home/nashif/Work/zephyrproject/modules/hal/nordic/nrfx/hal/nrf_regulators.h:234:50: error: unknown type name 'NRF_REGULATORS_Type'; did you mean 'NRF_REGULATORS_H__'?
  234 | NRF_STATIC_INLINE void nrf_regulators_dcdcen_set(NRF_REGULATORS_Type * p_reg, bool enable)
      |                                                  ^~~~~~~~~~~~~~~~~~~
      |                                                  NRF_REGULATORS_H__
/home/nashif/Work/zephyrproject/modules/hal/nordic/nrfx/hal/nrf_regulators.h:243:50: error: unknown type name 'NRF_REGULATORS_Type'; did you mean 'NRF_REGULATORS_H__'?
  243 | NRF_STATIC_INLINE void nrf_regulators_system_off(NRF_REGULATORS_Type * p_reg)
      |                                                  ^~~~~~~~~~~~~~~~~~~
      |                                                  NRF_REGULATORS_H__
/home/nashif/Work/zephyrproject/zephyr/soc/arm/nordic_nrf/nrf53/power.c: In function 'pm_power_state_set':
/home/nashif/Work/zephyrproject/zephyr/soc/arm/nordic_nrf/nrf53/power.c:20:3: warning: implicit declaration of function 'nrf_regulators_system_off' [-Wimplicit-function-declaration]
   20 |   nrf_regulators_system_off(NRF_REGULATORS);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~
/home/nashif/Work/zephyrproject/zephyr/soc/arm/nordic_nrf/nrf53/power.c:20:29: error: 'NRF_REGULATORS' undeclared (first use in this function); did you mean 'NRF_REGULATORS_H__'?
   20 |   nrf_regulators_system_off(NRF_REGULATORS);
      |                             ^~~~~~~~~~~~~~
      |                             NRF_REGULATORS_H__
/home/nashif/Work/zephyrproject/zephyr/soc/arm/nordic_nrf/nrf53/power.c:20:29: note: each undeclared identifier is reported only once for each function it appears in

Should building of power.c in the SoC depend on something else to prevent that or to correctly pull in regulator support? @pabigot ?

pabigot commented 3 years ago

patch incoming.

ceolin commented 3 years ago

@ceolin you should not be filter hardware in subsystems, this needs to be done on the test level

diff --git a/subsys/power/Kconfig b/subsys/power/Kconfig
index 84e180ffca..c3e676da6f 100644
--- a/subsys/power/Kconfig
+++ b/subsys/power/Kconfig
@@ -13,7 +13,7 @@ config SYS_POWER_MANAGEMENT
 menuconfig PM
        bool "System Power management"
        select TICKLESS_IDLE
-       depends on SYS_CLOCK_EXISTS && !SOC_NRF5340_CPUNET_QKAA
+       depends on SYS_CLOCK_EXISTS
        help
          This option enables the board to implement extra power management
          policies whenever the kernel becomes idle. The kernel informs the

gotcha, but IMHO tit is not just exclude this target from the test as the proposed patch, but also remove CONFIG_PM for this target.

ceolin commented 3 years ago

https://github.com/zephyrproject-rtos/zephyr/issues/31627 should complement #31714