]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
cmd: fastboot: Add keyed abort option
authorSam Day <me@samcday.com>
Thu, 18 Jun 2026 23:55:00 +0000 (09:55 +1000)
committerMattijs Korpershoek <mkorpershoek@kernel.org>
Fri, 26 Jun 2026 09:12:22 +0000 (11:12 +0200)
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@kernel.org>
Tested-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
Reviewed-by: Casey Connolly <casey.connolly@linaro.org>
Signed-off-by: Sam Day <me@samcday.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Link: https://patch.msgid.link/20260619-fastboot-abort-keyed-v2-1-684e53949a42@samcday.com
Signed-off-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
cmd/Kconfig
cmd/fastboot.c
doc/android/fastboot.rst

index d0fb7397067ebc42d172ca275c29881e4894a81b..ca1039f6a03b102c92815e79e820a35c766dccc4 100644 (file)
@@ -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
index e71f873527bcea384dc0ea3e1a9494d3aefb48b4..f3929f88dfae6ec2540dd250ff7c9e2106c165be 100644 (file)
@@ -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);
        }
index 818b8815ebdcfa3642e23f59f7c569aea7cb92f4..96c544ae11be46feac57196916fcd364f1226318 100644 (file)
@@ -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