[PATCH v2 1/2] cmd: fastboot: Add keyed abort option

Sam Day via B4 Relay devnull+me.samcday.com at kernel.org
Fri Jun 19 01:55:00 CEST 2026


From: Sam Day <me at samcday.com>

Works the same as CONFIG_CMD_UMS_ABORT_KEYED does: any keypress will
abort fastboot mode (rather than only ctrl-c).

Reviewed-by: Mattijs Korpershoek <mkorpershoek at kernel.org>
Tested-by: Mattijs Korpershoek <mkorpershoek at kernel.org>
Reviewed-by: Casey Connolly <casey.connolly at linaro.org>
Signed-off-by: Sam Day <me at samcday.com>
---
 cmd/Kconfig              | 7 +++++++
 cmd/fastboot.c           | 9 ++++++++-
 doc/android/fastboot.rst | 4 ++++
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/cmd/Kconfig b/cmd/Kconfig
index c71c6824a19..ee932cc25f1 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -1208,6 +1208,13 @@ config CMD_FASTBOOT
 
 	  See doc/android/fastboot.rst for more information.
 
+config CMD_FASTBOOT_ABORT_KEYED
+	bool "fastboot abort with any key"
+	depends on CMD_FASTBOOT && USB_FUNCTION_FASTBOOT
+	help
+	  Allow interruption of USB fastboot mode by any key presses,
+	  rather than just Ctrl-c.
+
 config CMD_FLASH
 	bool "flinfo, erase, protect"
 	default y
diff --git a/cmd/fastboot.c b/cmd/fastboot.c
index e71f873527b..f3929f88dfa 100644
--- a/cmd/fastboot.c
+++ b/cmd/fastboot.c
@@ -103,8 +103,15 @@ static int do_fastboot_usb(int argc, char *const argv[],
 	while (1) {
 		if (g_dnl_detach())
 			break;
-		if (ctrlc())
+		if (IS_ENABLED(CONFIG_CMD_FASTBOOT_ABORT_KEYED)) {
+			if (tstc()) {
+				getchar();
+				puts("\rOperation aborted.\n");
+				break;
+			}
+		} else if (ctrlc()) {
 			break;
+		}
 		schedule();
 		dm_usb_gadget_handle_interrupts(udc);
 	}
diff --git a/doc/android/fastboot.rst b/doc/android/fastboot.rst
index 818b8815ebd..96c544ae11b 100644
--- a/doc/android/fastboot.rst
+++ b/doc/android/fastboot.rst
@@ -217,6 +217,10 @@ It's possible to interrupt the fastboot command using Ctrl-c::
    => fastboot usb 0
    Operation aborted.
 
+``CONFIG_CMD_FASTBOOT_ABORT_KEYED`` can be enabled so that *any* keypress
+will interrupt the fastboot command, rather than just Ctrl-c. This can be
+quite useful on mobile devices which lack a means to input Ctrl-c.
+
 You can also specify a kernel image to boot. You have to either specify
 the an image in Android format *or* pass a binary kernel and let the
 fastboot client wrap the Android suite around it. On OMAP for instance you

-- 
2.54.0




More information about the U-Boot mailing list