Merge pull request #164 from gsmcmullin/cortexa_resume_fix
cortexa: Wait for instruction complete on resume.
This commit is contained in:
commit
cebe4f8f1c
|
@ -449,7 +449,16 @@ void cortexa_detach(target *t)
|
||||||
/* Invalidate cache */
|
/* Invalidate cache */
|
||||||
apb_write(t, DBGITR, MCR | ICIALLU);
|
apb_write(t, DBGITR, MCR | ICIALLU);
|
||||||
|
|
||||||
uint32_t dbgdscr = apb_read(t, DBGDSCR);
|
platform_timeout to;
|
||||||
|
platform_timeout_set(&to, 200);
|
||||||
|
|
||||||
|
/* Wait for instruction to complete */
|
||||||
|
uint32_t dbgdscr;
|
||||||
|
do {
|
||||||
|
dbgdscr = apb_read(t, DBGDSCR);
|
||||||
|
} while (!(dbgdscr & DBGDSCR_INSTRCOMPL) &&
|
||||||
|
!platform_timeout_is_expired(&to));
|
||||||
|
|
||||||
/* Disable halting debug mode */
|
/* Disable halting debug mode */
|
||||||
dbgdscr &= ~(DBGDSCR_HDBGEN | DBGDSCR_ITREN);
|
dbgdscr &= ~(DBGDSCR_HDBGEN | DBGDSCR_ITREN);
|
||||||
apb_write(t, DBGDSCR, dbgdscr);
|
apb_write(t, DBGDSCR, dbgdscr);
|
||||||
|
@ -648,8 +657,17 @@ void cortexa_halt_resume(target *t, bool step)
|
||||||
|
|
||||||
apb_write(t, DBGITR, MCR | ICIALLU); /* invalidate cache */
|
apb_write(t, DBGITR, MCR | ICIALLU); /* invalidate cache */
|
||||||
|
|
||||||
/* Disable DBGITR. Not sure why, but RRQ is ignored otherwise. */
|
platform_timeout to;
|
||||||
uint32_t dbgdscr = apb_read(t, DBGDSCR);
|
platform_timeout_set(&to, 200);
|
||||||
|
|
||||||
|
/* Wait for instruction to complete */
|
||||||
|
uint32_t dbgdscr;
|
||||||
|
do {
|
||||||
|
dbgdscr = apb_read(t, DBGDSCR);
|
||||||
|
} while (!(dbgdscr & DBGDSCR_INSTRCOMPL) &&
|
||||||
|
!platform_timeout_is_expired(&to));
|
||||||
|
|
||||||
|
/* Disable DBGITR. Not sure why, but RRQ is ignored otherwise. */
|
||||||
if (step)
|
if (step)
|
||||||
dbgdscr |= DBGDSCR_INTDIS;
|
dbgdscr |= DBGDSCR_INTDIS;
|
||||||
else
|
else
|
||||||
|
@ -661,7 +679,8 @@ void cortexa_halt_resume(target *t, bool step)
|
||||||
apb_write(t, DBGDRCR, DBGDRCR_CSE | DBGDRCR_RRQ);
|
apb_write(t, DBGDRCR, DBGDRCR_CSE | DBGDRCR_RRQ);
|
||||||
dbgdscr = apb_read(t, DBGDSCR);
|
dbgdscr = apb_read(t, DBGDSCR);
|
||||||
DEBUG("%s: DBGDSCR = 0x%08"PRIx32"\n", __func__, dbgdscr);
|
DEBUG("%s: DBGDSCR = 0x%08"PRIx32"\n", __func__, dbgdscr);
|
||||||
} while (!(dbgdscr & DBGDSCR_RESTARTED));
|
} while (!(dbgdscr & DBGDSCR_RESTARTED) &&
|
||||||
|
!platform_timeout_is_expired(&to));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Breakpoints */
|
/* Breakpoints */
|
||||||
|
|
Loading…
Reference in New Issue