console: Add option to keep it silent until env is loaded

Add a config-option which forces the console to stay silent until the
proper environment is loaded from flash.

This is important when the default environment does not silence the
console but no output must be printed when 'silent' is set in the flash
environment.

After the environment from flash is loaded, the console will be
silenced/unsilenced depending on it.  If PRE_CONSOLE_BUFFER is also
used, the buffer will now be flushed if the console should not be
silenced.

Signed-off-by: Harald Seiler <hws@denx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Harald Seiler 2022-07-06 13:19:10 +02:00 committed by Tom Rini
parent f58885d002
commit 33965c7e18
2 changed files with 15 additions and 0 deletions

View File

@ -164,6 +164,16 @@ config SILENT_CONSOLE_UPDATE_ON_RELOC
(e.g. NAND). This option makes the value of the 'silent' (e.g. NAND). This option makes the value of the 'silent'
environment variable take effect at relocation. environment variable take effect at relocation.
config SILENT_CONSOLE_UNTIL_ENV
bool "Keep console silent until environment is loaded"
depends on SILENT_CONSOLE
help
This option makes sure U-Boot will never use the console unless the
environment from flash does not contain the 'silent' variable. If
set, the console is kept silent until after the environment was
loaded. Use this in combination with PRE_CONSOLE_BUFFER to print out
earlier messages after loading the environment when allowed.
config PRE_CONSOLE_BUFFER config PRE_CONSOLE_BUFFER
bool "Buffer characters before the console is available" bool "Buffer characters before the console is available"
help help

View File

@ -970,6 +970,11 @@ static bool console_update_silent(void)
if (!IS_ENABLED(CONFIG_SILENT_CONSOLE)) if (!IS_ENABLED(CONFIG_SILENT_CONSOLE))
return false; return false;
if (IS_ENABLED(CONFIG_SILENT_CONSOLE_UNTIL_ENV) && !(gd->flags & GD_FLG_ENV_READY)) {
gd->flags |= GD_FLG_SILENT;
return false;
}
if (env_get("silent")) { if (env_get("silent")) {
gd->flags |= GD_FLG_SILENT; gd->flags |= GD_FLG_SILENT;
return false; return false;