[PATCH 3/3] fastboot: avoid console_countdown_abort for getvar request

Ahmad Fatoum a.fatoum at pengutronix.de
Fri Aug 9 07:19:59 PDT 2024


We currently abort boot countdown on any fastboot communication at all
as we have the expectation that this is what the user wants.

This doesn't hold true on systems with fwupd: The fastboot plugin probes
connected devices:

  getvar:product
  getvar:version
  getvar:version-bootloader
  getvar:serialno
  getvar:secure

to determine whether an update is in-order. The first getvar will
automatically abort barebox boot up, which is likely not what the user
intended.

Therefore, let's abort console countdown only for non-getvar: requests.

Reported-by: Jonas Martin <j.martin at pengutronix.de>
Signed-off-by: Marco Felsch <m.felsch at pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
Cc: lgo at pengutronix.de
Cc: jlu at pengutronix.de
v1 -> v2:
  - add rationale for the change (fwupd)
  - use strstarts instead of strcmp_l1 removed in earlier patch
---
 common/fastboot.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/common/fastboot.c b/common/fastboot.c
index dc66d7123b02..66b59ab9b0d7 100644
--- a/common/fastboot.c
+++ b/common/fastboot.c
@@ -794,6 +794,11 @@ static void cb_erase(struct fastboot *fb, const char *cmd)
 		fastboot_tx_print(fb, FASTBOOT_MSG_OKAY, "");
 }
 
+static bool fastboot_cmd_should_abort(const char *cmdbuf)
+{
+	return !strstarts(cmdbuf, "getvar:");
+}
+
 struct cmd_dispatch_info {
 	char *cmd;
 	void (*cb)(struct fastboot *fb, const char *opt);
@@ -805,7 +810,8 @@ static void fb_run_command(struct fastboot *fb, const char *cmdbuf,
 	const struct cmd_dispatch_info *cmd;
 	int i;
 
-	console_countdown_abort("fastboot");
+	if (fastboot_cmd_should_abort(cmdbuf))
+		console_countdown_abort("fastboot");
 
 	for (i = 0; i < num_commands; i++) {
 		size_t cmdlen;
-- 
2.39.2




More information about the barebox mailing list