Skip to content
This repository has been archived by the owner on Sep 28, 2019. It is now read-only.

Commit

Permalink
cortex_m: fix bug in poll() machine state (external resume awareness)
Browse files Browse the repository at this point in the history
This patch covers the fact that cortex_m could be resumed externally by
Cross Trigger Interface or by direct write to DHSCR ...

To reproduce:
 - halt the target
 - then run the core through DHCSR (mww 0xe000edf0 0xa05f0001)
 => this resumes the core, but target state in OpenOCD remains HALTED.

Change-Id: Ifa1ae18645bfeb863acc78a039bbf04873fd78fe
Signed-off-by: Tarek BOCHKATI <[email protected]>
Reviewed-on: http://openocd.zylin.com/4817
Tested-by: jenkins
Reviewed-by: Tomas Vanek <[email protected]>
  • Loading branch information
tarek-bochkati authored and tom-van committed Jan 16, 2019
1 parent 63aa917 commit d140fb2
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/target/cortex_m.c
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,17 @@ static int cortex_m_poll(struct target *target)
}
}

/* Check that target is truly halted, since the target could be resumed externally */
if ((prev_target_state == TARGET_HALTED) && !(cortex_m->dcb_dhcsr & S_HALT)) {
/* registers are now invalid */
register_cache_invalidate(armv7m->arm.core_cache);

target->state = TARGET_RUNNING;
LOG_WARNING("%s: external resume detected", target_name(target));
target_call_event_callbacks(target, TARGET_EVENT_RESUMED);
retval = ERROR_OK;
}

/* Did we detect a failure condition that we cleared? */
if (detected_failure != ERROR_OK)
retval = detected_failure;
Expand Down

0 comments on commit d140fb2

Please sign in to comment.