aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGareth McMullin2015-02-28 20:56:03 -0800
committerGareth McMullin2015-03-22 12:26:45 -0700
commitd0a03f55a6e66907f73d046adb6f211da2544d29 (patch)
tree4902f1cf181d8c7e4d6d610be17be8fd2da6d4f6
parentd6225eec763bd49ef3cb8edac5138df9e524a073 (diff)
Handle timeout exceptions during scans and report to the user.
-rw-r--r--src/command.c36
1 files changed, 30 insertions, 6 deletions
diff --git a/src/command.c b/src/command.c
index f271085..2c2a198 100644
--- a/src/command.c
+++ b/src/command.c
@@ -23,6 +23,7 @@
*/
#include "general.h"
+#include "exception.h"
#include "command.h"
#include "gdb_packet.h"
#include "jtag_scan.h"
@@ -138,19 +139,30 @@ bool cmd_help(target *t)
static bool cmd_jtag_scan(target *t, int argc, char **argv)
{
(void)t;
- uint8_t *irlens = NULL;
+ uint8_t irlens[argc];
gdb_outf("Target voltage: %s\n", platform_target_voltage());
if (argc > 1) {
/* Accept a list of IR lengths on command line */
- irlens = alloca(argc);
for (int i = 1; i < argc; i++)
irlens[i-1] = atoi(argv[i]);
irlens[argc-1] = 0;
}
- int devs = jtag_scan(irlens);
+ int devs = -1;
+ volatile struct exception e;
+ TRY_CATCH (e, EXCEPTION_ALL) {
+ devs = jtag_scan(argc > 1 ? irlens : NULL);
+ }
+ switch (e.type) {
+ case EXCEPTION_TIMEOUT:
+ gdb_outf("Timeout during scan. Is target stuck in WFI?\n");
+ break;
+ case EXCEPTION_ERROR:
+ gdb_outf("Exception: %s\n", e.msg);
+ break;
+ }
if(devs < 0) {
gdb_out("JTAG device scan failed!\n");
@@ -174,13 +186,25 @@ bool cmd_swdp_scan(void)
{
gdb_outf("Target voltage: %s\n", platform_target_voltage());
- if(adiv5_swdp_scan() < 0) {
+ int devs = -1;
+ volatile struct exception e;
+ TRY_CATCH (e, EXCEPTION_ALL) {
+ devs = adiv5_swdp_scan();
+ }
+ switch (e.type) {
+ case EXCEPTION_TIMEOUT:
+ gdb_outf("Timeout during scan. Is target stuck in WFI?\n");
+ break;
+ case EXCEPTION_ERROR:
+ gdb_outf("Exception: %s\n", e.msg);
+ break;
+ }
+
+ if(devs < 0) {
gdb_out("SW-DP scan failed!\n");
return false;
}
- //gdb_outf("SW-DP detected IDCODE: 0x%08X\n", adiv5_dp_list->idcode);
-
cmd_targets(NULL);
return true;