From 4b2fffc7f98e735d99eea790342113fd82fcd66b Mon Sep 17 00:00:00 2001 From: Wojciech Slenska Date: Fri, 21 Oct 2022 12:05:45 +0200 Subject: [PATCH] shell: added SHELL_AUTOSTART configuration option In some applications, there is a need to don't start the shell by default, but run it later on some special condition. When SHELL_AUTOSTART is set to n, the shell is not started after boot but can be enabled later from the application code. Signed-off-by: Wojciech Slenska --- subsys/shell/Kconfig | 5 +++++ subsys/shell/shell.c | 10 ++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/subsys/shell/Kconfig b/subsys/shell/Kconfig index 6187501dc73..5ec89ce50fc 100644 --- a/subsys/shell/Kconfig +++ b/subsys/shell/Kconfig @@ -245,6 +245,11 @@ config SHELL_LOG_FORMAT_TIMESTAMP help Enable timestamp formatting. +config SHELL_AUTOSTART + bool "Auto-start shell at boot" + default y + help + If enabled, shell will be automatically started. source "subsys/shell/modules/Kconfig" diff --git a/subsys/shell/shell.c b/subsys/shell/shell.c index c4d1177b445..1311f1cafed 100644 --- a/subsys/shell/shell.c +++ b/subsys/shell/shell.c @@ -1321,10 +1321,12 @@ void shell_thread(void *shell_handle, void *arg_log_backend, log_level); } - /* Enable shell and print prompt. */ - err = shell_start(shell); - if (err != 0) { - return; + if (IS_ENABLED(CONFIG_SHELL_AUTOSTART)) { + /* Enable shell and print prompt. */ + err = shell_start(shell); + if (err != 0) { + return; + } } while (true) {