This is an automated email from Gerrit. Ake Rehnman ([email protected]) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/4267
-- gerrit commit 99c3eeb059b6484bd81c6aa1d3b2d50488e5b996 Author: Ake Rehnman <[email protected]> Date: Tue Oct 24 19:32:58 2017 +0200 Changed stm8_reset_deassert to wait for TARGET_HALTED Changed stm8_poll to return ERROR_OK even if reading from csrx fails due to processor reset Change-Id: I2454ef87c87ab97730dd97209a5c1edf4dce2361 Signed-off-by: Ake Rehnman <[email protected]> diff --git a/src/target/stm8.c b/src/target/stm8.c index 3841216..07c16a5 100644 --- a/src/target/stm8.c +++ b/src/target/stm8.c @@ -816,6 +816,10 @@ static int stm8_poll(struct target *target) int retval = ERROR_OK; uint8_t csr1, csr2; +#ifdef LOG_STM8 + LOG_DEBUG("%s target->state=%d", __func__, target->state); +#endif + if (!(target_was_examined(target))) { LOG_WARNING( "Reset is not asserted because the target is not examined."); @@ -825,8 +829,14 @@ static int stm8_poll(struct target *target) /* read dm_csrx control regs */ retval = stm8_read_dm_csrx(target, &csr1, &csr2); - if (retval != ERROR_OK) - return retval; + if (retval != ERROR_OK) { + LOG_DEBUG("%s stm8_read_dm_csrx failed retval=%d", __func__, retval); + /* + We return ERROR_OK here even if we didn't get an answer. + openocd will call target_wait_state until we get target state TARGET_HALTED + */ + return ERROR_OK; + } /* check for processor halted */ if (csr2 & 0x08) { @@ -837,16 +847,20 @@ static int stm8_poll(struct target *target) target->state = TARGET_HALTED; retval = stm8_debug_entry(target); - if (retval != ERROR_OK) - return retval; + if (retval != ERROR_OK) { + LOG_DEBUG("%s stm8_debug_entry failed retval=%d", __func__, retval); + return ERROR_TARGET_FAILURE; + } target_call_event_callbacks(target, TARGET_EVENT_HALTED); } else if (target->state == TARGET_DEBUG_RUNNING) { target->state = TARGET_HALTED; retval = stm8_debug_entry(target); - if (retval != ERROR_OK) - return retval; + if (retval != ERROR_OK) { + LOG_DEBUG("%s stm8_debug_entry failed retval=%d", __func__, retval); + return ERROR_TARGET_FAILURE; + } target_call_event_callbacks(target, TARGET_EVENT_DEBUG_HALTED); } @@ -963,6 +977,16 @@ static int stm8_reset_deassert(struct target *target) */ jtag_add_reset(0, 0); + /* + stm8_poll() will determine proper state... */ + + LOG_DEBUG("%s, target->state=%d", __func__, target->state); + + target_poll(target); + + /* What happens if target state is not halted and resume was + requested ? */ + return target->reset_halt ? ERROR_OK : target_resume(target, 1, 0, 0, 0); } -- ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ OpenOCD-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openocd-devel
