[PATCH v3 2/2] cli: flush stdin before enabling cli

Simon Glass sjg at chromium.org
Sat Apr 11 18:41:00 CEST 2026


Hi Gregor,

On 2026-04-07T06:33:10, Gregor Herburger <gregor.herburger at linutronix.de> wrote:
> cli: flush stdin before enabling cli
>
> Currently there is no possibility to flush stdin after autocommands are
> executed. If in the bootcmd the stdin is changed, e.g. from nulldev to
> serial, it could happen that junk characters sit in the fifo and appear
> on the cli.
>
> Add a option to clear stdin before starting the CLI.
>
> Signed-off-by: Gregor Herburger <gregor.herburger at linutronix.de>
>
> cmd/Kconfig  | 8 ++++++++
>  common/cli.c | 4 ++++
>  2 files changed, 12 insertions(+)

> diff --git a/cmd/Kconfig b/cmd/Kconfig
> @@ -47,6 +47,14 @@ config HUSH_SELECTABLE
> +config CMDLINE_FLUSH_STDIN
> +     bool "Enable flushing input before starting cli"
> +         When this option is enabled the stdin buffer will be flushed before
> +         starting the CLI. This is useful when stdin is changed during boot
> +         (e.g. from nulldev to serial) and junk characters may be pending
> +         in the buffer.

Thanks for expanding the help text!

Reviewed-by: Simon Glass <sjg at chromium.org>


More information about the U-Boot mailing list