From 6b3c3d34734be82a8dd17e0db3232586a5979f2a Mon Sep 17 00:00:00 2001 From: Gareth McMullin Date: Thu, 9 Jun 2016 10:56:31 +1200 Subject: [PATCH] cortexa: Add timeout to reset spin. --- src/cortexa.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cortexa.c b/src/cortexa.c index 4e47b774..5f783e64 100644 --- a/src/cortexa.c +++ b/src/cortexa.c @@ -441,12 +441,16 @@ static void cortexa_reset(target *t) platform_srst_set_val(false); /* Spin until Xilinx reconnects us */ + platform_timeout timeout; + platform_timeout_set(&timeout, 1000); volatile struct exception e; do { TRY_CATCH (e, EXCEPTION_ALL) { apb_read(t, DBGDIDR); } - } while (e.type == EXCEPTION_ERROR); + } while (!platform_timeout_is_expired(&timeout) && e.type == EXCEPTION_ERROR); + if (e.type == EXCEPTION_ERROR) + raise_exception(e.type, e.msg); platform_delay(100);