From 6efa136d8cec091e1de0f0d5cdf890de8799a74b Mon Sep 17 00:00:00 2001 From: Bjorn Andersson Date: Thu, 9 Apr 2020 16:18:14 -0700 Subject: [PATCH] cdba: Don't default to fastboot endlessly The current scheme of endlessly rebooting means that we spend -t amount of time to boot the device over and over if the device crashes early. Add a new flag -R which does this, but change the default so that if we see the device showing up again in fastboot we consider it rebooted and quits. Signed-off-by: Bjorn Andersson --- cdba.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cdba.c b/cdba.c index fa0a906..34cc2e6 100644 --- a/cdba.c +++ b/cdba.c @@ -48,6 +48,8 @@ #include "list.h" static bool quit; +static bool fastboot_repeat; +static bool fastboot_done; static const char *fastboot_file; @@ -430,8 +432,12 @@ static int handle_message(struct circ_buf *buf) case MSG_FASTBOOT_PRESENT: if (*(uint8_t*)msg->data) { // printf("======================================== MSG_FASTBOOT_PRESENT(on)\n"); - request_fastboot_files(); + if (!fastboot_done || fastboot_repeat) + request_fastboot_files(); + else + quit = true; } else { + fastboot_done = true; // printf("======================================== MSG_FASTBOOT_PRESENT(off)\n"); } break; @@ -488,7 +494,7 @@ int main(int argc, char **argv) int opt; int ret; - while ((opt = getopt(argc, argv, "b:c:C:h:t:T:")) != -1) { + while ((opt = getopt(argc, argv, "b:c:C:h:Rt:T:")) != -1) { switch (opt) { case 'b': board = optarg; @@ -502,6 +508,9 @@ int main(int argc, char **argv) case 'h': host = optarg; break; + case 'R': + fastboot_repeat = true; + break; case 't': timeout = atoi(optarg); timeout_on_inactivity = false;