[v2,2/2] cli: flush stdin before enabling cli

Simon Glass sjg at chromium.org
Thu Apr 2 02:15:26 CEST 2026


Hi Gregor,

On 2026-04-01T12:40:44, Gregor Herburger <gregor.herburger at linutronix.de> wrote:
> cli: flush stdin before enabling cli
> 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>

> diff --git a/cmd/Kconfig b/cmd/Kconfig
> @@ -47,6 +47,12 @@ config HUSH_SELECTABLE
> +config CMDLINE_FLUSH_STDIN
> +     bool "Enable flushing input before starting cli"
> +     help
> +       When this option is enabled the stdin buffer will be flushed before
> +       starting the CLI.

Just to check, does this option also need 'depends on !SANDBOX' like
AUTOBOOT_FLUSH_STDIN does? That option notes that flushing stdin
breaks autoboot unit tests. I suspect the CLI entry path might not be
exercised by those tests, but it would be good to confirm.

Also, please can you expand the help text to mention the use case? For
example, 'This is useful when stdin is changed during boot (e.g. from
nulldev to serial) and junk characters may be pending in the buffer.'

Regards,
Simon


More information about the U-Boot mailing list