cmd: Add pause command
PATCH 1/1 cmd: Add pause command
This command is being introduced with the goal of allowing user-friendly "generic use case" U-Boot builds to pause until user input under some situations.
The main use case would be when a boot failure happens, to pause until the user has had time to acknowledge the current state.
Signed-off-by Samuel Dionne-Riel <[email protected]>
--- cmd/Kconfig | 7 +++++++ cmd/Makefile | 1 + cmd/pause.c | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 cmd/pause.c
cmd/Kconfig +7 -0
@@ -1807,6 +1807,13 @@ config CMD_GETTIME milliseconds. See also the 'bootstage' command which provides more flexibility for boot timing. +config CMD_PAUSE + bool "pause command" + default y + help + Delay execution waiting for any user input. + Useful to allow the user to read a failure log. + config CMD_RNG bool "rng command" depends on DM_RNG
cmd/Makefile +1 -0
@@ -98,6 +98,7 @@ obj-$(CONFIG_CMD_MFSL) += mfsl.o obj-$(CONFIG_CMD_MII) += mii.o obj-$(CONFIG_CMD_MISC) += misc.o obj-$(CONFIG_CMD_MDIO) += mdio.o +obj-$(CONFIG_CMD_PAUSE) += pause.o obj-$(CONFIG_CMD_SLEEP) += sleep.o obj-$(CONFIG_CMD_MMC) += mmc.o obj-$(CONFIG_CMD_OPTEE_RPMB) += optee_rpmb.o
cmd/pause.c new file +35 -0
@@ -0,0 +1,35 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* (C) Copyright 2021 +* Samuel Dionne-Riel <[email protected]> +*/ + +#include <command.h> +#include <stdio.h> + +static int do_pause (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]) +{ +char *message ="Press any key to continue..." ; + +if (argc >2 ) +return CMD_RET_USAGE ; + +if (argc ==2 ) + message = argv[1 ]; + +/* No newline, so it sticks to the bottom of the screen */ +printf ("%s" , message); + +/* Wait on "any" key... */ + (void )getchar (); + +/* Since there was no newline, we need it now. */ +printf ("\n" ); + +return CMD_RET_SUCCESS ; +} + +U_BOOT_CMD (pause,2 ,1 , do_pause, +"delay until user input" , +"pause [prompt] - Wait until users presses any key. [prompt] can be used to customize the message.\n" +);
Signature · 6 lines
2.34.0 -- Samuel Dionne-Riel
Quoted 7 lines · Samuel Dionne-Riel
This command is being introduced with the goal of allowing user-friendly "generic use case" U-Boot builds to pause until user input under some situations.
The main use case would be when a boot failure happens, to pause until the user has had time to acknowledge the current state.
Quoted 7 lines
Signed-off-by Samuel Dionne-Riel <[email protected]>--- cmd/Kconfig | 7 +++++++ cmd/Makefile | 1 + cmd/pause.c | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 cmd/pause.c
Sorry for the delay. Please don't make this default, and also please add a test for the command. Thanks.
Signature · 1 line
Tom