From 91ee23ae86d2a73abfdacd58f8ac70b35c9db9f5 Mon Sep 17 00:00:00 2001 From: Bjorn Andersson Date: Tue, 13 Aug 2019 12:40:19 -0700 Subject: [PATCH] cdba: Add -C argument for power-cycle on success only When using cdba to bisect for intermittent issues related to boot lockups or crashes taking us to download mode it's only useful to power-cycle on success (as a failure case shows the intermittent problem). Add a special version of the existing power cycle code, that stops the power cycling loop if a timeout criteria is hit, cutting down on unnecessary reboots of a broken kernel. Signed-off-by: Bjorn Andersson --- cdba.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cdba.c b/cdba.c index b4418c5..9c7cf73 100644 --- a/cdba.c +++ b/cdba.c @@ -467,6 +467,7 @@ static void usage(void) int main(int argc, char **argv) { + bool power_cycle_on_timeout = true; bool timeout_on_inactivity = true; struct termios *orig_tios; struct work *next; @@ -487,11 +488,14 @@ int main(int argc, char **argv) int opt; int ret; - while ((opt = getopt(argc, argv, "b:c:h:t:T:")) != -1) { + while ((opt = getopt(argc, argv, "b:c:C:h:t:T:")) != -1) { switch (opt) { case 'b': board = optarg; break; + case 'C': + power_cycle_on_timeout = false; + /* FALLTHROUGH */ case 'c': power_cycles = atoi(optarg); break; @@ -537,6 +541,9 @@ int main(int argc, char **argv) if (!power_cycles) break; + if (reached_timeout && !power_cycle_on_timeout) + break; + printf("power cycle (%d left)\n", power_cycles); fflush(stdout);