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 <wsl@trackunit.com>
This commit is contained in:
Wojciech Slenska 2022-10-21 12:05:45 +02:00 committed by Carles Cufí
commit 4b2fffc7f9
2 changed files with 11 additions and 4 deletions

View file

@ -245,6 +245,11 @@ config SHELL_LOG_FORMAT_TIMESTAMP
help help
Enable timestamp formatting. 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" source "subsys/shell/modules/Kconfig"

View file

@ -1321,11 +1321,13 @@ void shell_thread(void *shell_handle, void *arg_log_backend,
log_level); log_level);
} }
if (IS_ENABLED(CONFIG_SHELL_AUTOSTART)) {
/* Enable shell and print prompt. */ /* Enable shell and print prompt. */
err = shell_start(shell); err = shell_start(shell);
if (err != 0) { if (err != 0) {
return; return;
} }
}
while (true) { while (true) {
/* waiting for all signals except SHELL_SIGNAL_TXDONE */ /* waiting for all signals except SHELL_SIGNAL_TXDONE */