summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2017-02-11 20:57:52 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2017-02-14 08:47:37 +0100
commit9de72c2e4f84b345b11b09e25de0ca6f2675340b (patch)
tree19b061423e9cf60b78e41e0331b250519d288d63 /scripts
parent67fafb1230763433cb2ee5cb75e03dc6d75f0641 (diff)
downloadbarebox-9de72c2e4f84b345b11b09e25de0ca6f2675340b.tar.gz
barebox-9de72c2e4f84b345b11b09e25de0ca6f2675340b.tar.xz
scripts/kwboot: new parameter -n to skip a number of NAKs
On some machines the CPU resets twice and so kwboot must hit the second window to enter debug or boot mode. For this scenario it helps to ignore a number of NAKs. If you choose a number too high for booting, the process is only slowed down because when the CPU enters UART boot mode it sends NAKs when not getting any input. This new option also helps when there are voltage fluctuations due to the power up sequence which might be interpreted as valid chars. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/kwboot.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/scripts/kwboot.c b/scripts/kwboot.c
index 3ab26cd936..4c6b19aa21 100644
--- a/scripts/kwboot.c
+++ b/scripts/kwboot.c
@@ -264,10 +264,11 @@ out:
}
static int
-kwboot_bootmsg(int tty, void *msg)
+kwboot_bootmsg(int tty, void *msg, unsigned num_nacks)
{
int rc;
char c;
+ unsigned saw_nacks = 0;
if (msg == NULL)
kwboot_printv("Please reboot the target into UART boot mode...");
@@ -295,11 +296,13 @@ kwboot_bootmsg(int tty, void *msg)
kwboot_printv("\\x%02hhx", c);
rc = kwboot_tty_recv(tty, &c, 1, KWBOOT_MSG_RSP_TIMEO);
+
+ saw_nacks = 0;
}
- } while (rc || c != NAK);
+ } while (rc || c != NAK || (++saw_nacks < num_nacks));
- kwboot_printv("\nGot expected NAK\n");
+ kwboot_printv("\nGot expected NAKs\n");
return rc;
}
@@ -736,6 +739,7 @@ main(int argc, char **argv)
void *bootmsg;
void *debugmsg;
void *img;
+ unsigned num_nacks = 1;
size_t size;
speed_t speed;
@@ -752,7 +756,7 @@ main(int argc, char **argv)
kwboot_verbose = isatty(STDOUT_FILENO);
do {
- int c = getopt(argc, argv, "b:dfhtB:D:");
+ int c = getopt(argc, argv, "b:dfhtn:B:D:");
if (c < 0)
break;
@@ -779,6 +783,10 @@ main(int argc, char **argv)
force = 1;
break;
+ case 'n':
+ num_nacks = atoi(optarg);
+ break;
+
case 'B':
speed = kwboot_tty_speed(atoi(optarg));
if (speed == -1)
@@ -828,7 +836,7 @@ main(int argc, char **argv)
goto out;
}
} else {
- rc = kwboot_bootmsg(tty, bootmsg);
+ rc = kwboot_bootmsg(tty, bootmsg, num_nacks);
if (rc) {
perror("bootmsg");
goto out;