summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorSamuel Dionne-Riel <samuel@dionne-riel.com>2022-08-18 22:44:04 +0300
committerTom Rini <trini@konsulko.com>2022-09-02 20:40:42 +0300
commitdc0d17c26a3a03634994c59adb0b657807827183 (patch)
tree991b387d3fcb0fd43082033fc0fc040ea756ef4d /cmd
parentd88260710b212815ae1f461aec24ad926c668d36 (diff)
downloadu-boot-dc0d17c26a3a03634994c59adb0b657807827183.tar.xz
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. Tested using: make && ./u-boot -v -T -c 'ut lib lib_test_hush_pause' Signed-off-by: Samuel Dionne-Riel <samuel@dionne-riel.com> Cc: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/Kconfig6
-rw-r--r--cmd/Makefile1
-rw-r--r--cmd/pause.c32
3 files changed, 39 insertions, 0 deletions
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 211ebe9c87..67c7d2512f 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -1971,6 +1971,12 @@ config CMD_GETTIME
milliseconds. See also the 'bootstage' command which provides more
flexibility for boot timing.
+config CMD_PAUSE
+ bool "pause command"
+ 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
diff --git a/cmd/Makefile b/cmd/Makefile
index 6e87522b62..7abe1d3630 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -102,6 +102,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
diff --git a/cmd/pause.c b/cmd/pause.c
new file mode 100644
index 0000000000..c97833c0d7
--- /dev/null
+++ b/cmd/pause.c
@@ -0,0 +1,32 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2021
+ * Samuel Dionne-Riel <samuel@dionne-riel.com>
+ */
+
+#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)
+ 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",
+ "[prompt] - Wait until users presses any key. [prompt] can be used to customize the message.\n"
+);