Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EB6E2C433F5 for ; Tue, 21 Dec 2021 03:49:56 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 37867837A6; Tue, 21 Dec 2021 04:49:54 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=dionne-riel.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=dionne-riel-com.20210112.gappssmtp.com header.i=@dionne-riel-com.20210112.gappssmtp.com header.b="wISEt3kG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AC370837A6; Tue, 21 Dec 2021 04:49:52 +0100 (CET) Received: from mail-qv1-xf2f.google.com (mail-qv1-xf2f.google.com [IPv6:2607:f8b0:4864:20::f2f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A643882F63 for ; Tue, 21 Dec 2021 04:49:49 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=dionne-riel.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=samuel@dionne-riel.com Received: by mail-qv1-xf2f.google.com with SMTP id kj16so7308170qvb.2 for ; Mon, 20 Dec 2021 19:49:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dionne-riel-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:subject:message-id:mime-version :content-transfer-encoding; bh=rJFSrEDUeBCyJHtV8cE9e7lBqyVTgVVXOpVPHb78xk0=; b=wISEt3kGzaIbXx9cdPgyn46EBhvXlYmw3auMU08T88JZUW9xkH0hivZnry31TRUFLq 0ZHPMeEIQ7cTxICVid/C6sguyAL45nUPj6KkuIxzyYEsuxALxthskZVSKqstvSInRmpv IoapJN5AAKahLzjm/+hEk3FmyF1KtJcxQUmOpwVChOKYker6VRfXqA1GcSd7zI0TKlXL QoDWdMLAQrXRa6rEhfMbr+Vgf078fwM0Ah0+mPIkH8hwz3u10i1dOq59lWLbPU9yP9XP kUKD6LRrgBIqPvU2GwPO2g/iPcIkfu34vYPlm5X5j5+8E5Q7hghm+89l4VEo8Sv+e3lv 5JfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-transfer-encoding; bh=rJFSrEDUeBCyJHtV8cE9e7lBqyVTgVVXOpVPHb78xk0=; b=m6Q2fq7sD7X/RkzFqZgRRok93kGmNEQKO5gwuN9B0uExKRrkUXSKmjiqm3B46gXMGx B/LUvHxKZrbcszPYiqL6ftOT4GbIPYrQK84rXkmW0kecviibOcRAT9X++pbbLpAGaV1x eKAaMJFlcAVUb66NxvOmt7+B+YVm2zQNG9QNRiy142Ml7Jg6hx7vd+5vufcmseE4o0lH Jsobs30eQbD86pa2SsL2c7mUxLjw32tbnrxkUSaK8PVqT5b5IFHvXE9z7VCuGak6W0zU HtsZ3GxUnGlGbL7SzfbBd3i6D1jft3//mmUtpDgv/uXLCfki+J6dvZkEWFnc2DO63gNs 6YWw== X-Gm-Message-State: AOAM533VyJ1o0241yvODVZuF0GxHwig4Jic/P5V8lfFZZs6RvOoEZVWa aNb3wJI87RmzqPJ9bflaN/Qe3z57fAXfZA== X-Google-Smtp-Source: ABdhPJw7Z1yq3VAOFvsg8WkGek4ZFl8U/SSU7QD6BSzbQEvEkoE9APfL1SEHwGOdFqYJkQGpn+JygQ== X-Received: by 2002:ad4:5aeb:: with SMTP id c11mr850169qvh.25.1640058588211; Mon, 20 Dec 2021 19:49:48 -0800 (PST) Received: from DUFFMAN (135-23-195-85.cpe.pppoe.ca. [135.23.195.85]) by smtp.gmail.com with ESMTPSA id h2sm13365623qkn.136.2021.12.20.19.49.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Dec 2021 19:49:48 -0800 (PST) Date: Mon, 20 Dec 2021 22:49:46 -0500 From: Samuel Dionne-Riel To: Subject: [PATCH] cmd: Add pause command Message-ID: <20211220224946.033b3f99.samuel@dionne-riel.com> X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean 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 --- cmd/Kconfig | 7 +++++++ cmd/Makefile | 1 + cmd/pause.c | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 cmd/pause.c diff --git a/cmd/Kconfig b/cmd/Kconfig index 5b30b13e43..26d5707f75 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -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 diff --git a/cmd/Makefile b/cmd/Makefile index 891819ae0f..6c4db4ed2e 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -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 diff --git a/cmd/pause.c b/cmd/pause.c new file mode 100644 index 0000000000..0a7ea35ebe --- /dev/null +++ b/cmd/pause.c @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * (C) Copyright 2021 + * Samuel Dionne-Riel + */ + +#include +#include + +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" +); -- 2.34.0 -- Samuel Dionne-Riel