Handle timeout exceptions during scans and report to the user.
This commit is contained in:
parent
d6225eec76
commit
d0a03f55a6
|
@ -23,6 +23,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "general.h"
|
#include "general.h"
|
||||||
|
#include "exception.h"
|
||||||
#include "command.h"
|
#include "command.h"
|
||||||
#include "gdb_packet.h"
|
#include "gdb_packet.h"
|
||||||
#include "jtag_scan.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)
|
static bool cmd_jtag_scan(target *t, int argc, char **argv)
|
||||||
{
|
{
|
||||||
(void)t;
|
(void)t;
|
||||||
uint8_t *irlens = NULL;
|
uint8_t irlens[argc];
|
||||||
|
|
||||||
gdb_outf("Target voltage: %s\n", platform_target_voltage());
|
gdb_outf("Target voltage: %s\n", platform_target_voltage());
|
||||||
|
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
/* Accept a list of IR lengths on command line */
|
/* Accept a list of IR lengths on command line */
|
||||||
irlens = alloca(argc);
|
|
||||||
for (int i = 1; i < argc; i++)
|
for (int i = 1; i < argc; i++)
|
||||||
irlens[i-1] = atoi(argv[i]);
|
irlens[i-1] = atoi(argv[i]);
|
||||||
irlens[argc-1] = 0;
|
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) {
|
if(devs < 0) {
|
||||||
gdb_out("JTAG device scan failed!\n");
|
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());
|
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");
|
gdb_out("SW-DP scan failed!\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//gdb_outf("SW-DP detected IDCODE: 0x%08X\n", adiv5_dp_list->idcode);
|
|
||||||
|
|
||||||
cmd_targets(NULL);
|
cmd_targets(NULL);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue