From e017c01accab947e44d7998c34f1f0b7f24156b3 Mon Sep 17 00:00:00 2001 From: MrKevinWeiss Date: Tue, 2 Apr 2024 10:19:19 +0200 Subject: [PATCH 1/5] sys/shell/cmds: Guard periph_pm calls It would seem that either we need to require the periph_pm module in shell or make it optional... since we have many other optional modules here and we still may want the RIOT_VERSION command, lets make it optional for now. --- sys/shell/cmds/sys.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/shell/cmds/sys.c b/sys/shell/cmds/sys.c index 56f323ba66..ac428b5125 100644 --- a/sys/shell/cmds/sys.c +++ b/sys/shell/cmds/sys.c @@ -20,7 +20,9 @@ #include +#ifdef MODULE_PERIPH_PM #include "periph/pm.h" +#endif #include "shell.h" #ifdef MODULE_USB_BOARD_RESET @@ -30,6 +32,7 @@ #include "riotboot/slot.h" #endif +#ifdef MODULE_PERIPH_PM static int _reboot_handler(int argc, char **argv) { (void) argc; @@ -41,6 +44,7 @@ static int _reboot_handler(int argc, char **argv) } SHELL_COMMAND(reboot, "Reboot the node", _reboot_handler); +#endif /* MODULE_PERIPH_PM */ #ifdef MODULE_USB_BOARD_RESET static int _bootloader_handler(int argc, char **argv) From bead59e9d1a8ed34babcf455a74d0fcff8c8b62b Mon Sep 17 00:00:00 2001 From: MrKevinWeiss Date: Tue, 2 Apr 2024 11:46:50 +0200 Subject: [PATCH 2/5] sys/newlib_syscalls_default: guard pm_off --- sys/newlib_syscalls_default/syscalls.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/newlib_syscalls_default/syscalls.c b/sys/newlib_syscalls_default/syscalls.c index 322957ed12..93501d2092 100644 --- a/sys/newlib_syscalls_default/syscalls.c +++ b/sys/newlib_syscalls_default/syscalls.c @@ -36,7 +36,9 @@ #include "log.h" #include "modules.h" +#ifdef MODULE_PERIPH_PM #include "periph/pm.h" +#endif #include "sched.h" #include "stdio_base.h" #include "thread.h" @@ -183,7 +185,9 @@ __attribute__((used)) void _fini(void) __attribute__((used)) void _exit(int n) { LOG_INFO("#! exit %i: powering off\n", n); +#ifdef MODULE_PERIPH_PM pm_off(); +#endif while (1) {} } From 35f626772102d8b52a5fa368f13955e49500d1b2 Mon Sep 17 00:00:00 2001 From: MrKevinWeiss Date: Tue, 2 Apr 2024 11:47:30 +0200 Subject: [PATCH 3/5] sys/picolibc_syscalls_default: guard pm_off --- sys/picolibc_syscalls_default/syscalls.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/picolibc_syscalls_default/syscalls.c b/sys/picolibc_syscalls_default/syscalls.c index eb7d450871..a42e7e18c4 100644 --- a/sys/picolibc_syscalls_default/syscalls.c +++ b/sys/picolibc_syscalls_default/syscalls.c @@ -27,7 +27,9 @@ #include "irq.h" #include "log.h" +#ifdef MODULE_PERIPH_PM #include "periph/pm.h" +#endif #include "stdio_base.h" #ifndef NUM_HEAPS @@ -117,7 +119,9 @@ void __attribute__((__noreturn__)) _exit(int n) { LOG_INFO("#! exit %i: powering off\n", n); +#ifdef MODULE_PERIPH_PM pm_off(); +#endif /* MODULE_PERIPH_PM */ for (;;) { } } From 1fcdb107ba15f344a902e58c1f9e6769706afc45 Mon Sep 17 00:00:00 2001 From: MrKevinWeiss Date: Tue, 2 Apr 2024 11:47:46 +0200 Subject: [PATCH 4/5] core/lib: guard pm_off --- core/lib/init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/lib/init.c b/core/lib/init.c index 75abf23dd6..fd0a218424 100644 --- a/core/lib/init.c +++ b/core/lib/init.c @@ -81,7 +81,7 @@ static void *main_trampoline(void *arg) } #endif - if (IS_ACTIVE(CONFIG_CORE_EXIT_WITH_MAIN)) { + if (IS_ACTIVE(CONFIG_CORE_EXIT_WITH_MAIN) && IS_USED(MODULE_PERIPH_PM)) { pm_off(); } From b8c4617768218f281feb5c1233093583b45bfdd1 Mon Sep 17 00:00:00 2001 From: MrKevinWeiss Date: Mon, 8 Apr 2024 11:20:14 +0200 Subject: [PATCH 5/5] sys/*: expose periph/pm.h I guess to reduce clutter we can always have the headers exposed since they are always included even when we are not using them. --- sys/newlib_syscalls_default/syscalls.c | 2 -- sys/picolibc_syscalls_default/syscalls.c | 2 -- sys/shell/cmds/sys.c | 2 -- 3 files changed, 6 deletions(-) diff --git a/sys/newlib_syscalls_default/syscalls.c b/sys/newlib_syscalls_default/syscalls.c index 93501d2092..0796f64fbd 100644 --- a/sys/newlib_syscalls_default/syscalls.c +++ b/sys/newlib_syscalls_default/syscalls.c @@ -36,9 +36,7 @@ #include "log.h" #include "modules.h" -#ifdef MODULE_PERIPH_PM #include "periph/pm.h" -#endif #include "sched.h" #include "stdio_base.h" #include "thread.h" diff --git a/sys/picolibc_syscalls_default/syscalls.c b/sys/picolibc_syscalls_default/syscalls.c index a42e7e18c4..49505881d7 100644 --- a/sys/picolibc_syscalls_default/syscalls.c +++ b/sys/picolibc_syscalls_default/syscalls.c @@ -27,9 +27,7 @@ #include "irq.h" #include "log.h" -#ifdef MODULE_PERIPH_PM #include "periph/pm.h" -#endif #include "stdio_base.h" #ifndef NUM_HEAPS diff --git a/sys/shell/cmds/sys.c b/sys/shell/cmds/sys.c index ac428b5125..0c86ffa692 100644 --- a/sys/shell/cmds/sys.c +++ b/sys/shell/cmds/sys.c @@ -20,9 +20,7 @@ #include -#ifdef MODULE_PERIPH_PM #include "periph/pm.h" -#endif #include "shell.h" #ifdef MODULE_USB_BOARD_RESET