From c78b4fe426c35f638e5575b59ec89d0e794263af Mon Sep 17 00:00:00 2001 From: oharboe Date: Fri, 7 Mar 2008 21:49:16 +0000 Subject: - Improves error handling upon GDB connect - switch to synchronous halt during connect. This fixes the bug where poll() was not invoked between halt() and servicing the 'g' register packet - halt() no longer returns error code when target is already halted, just logs a warning. Only the halt() implementation can say anything meaningful about why a halt() failed, so error messages are pushed up to halt() - fixed soft_reset_halt infinite loop bug in arm7_9_common.c. The rest of the implementations are still busted. - by using USER() instead of command_print() the log gets the source + line #. Nice. - no longer invoke exit() if soft_reset_halt fails. A reset can often fix the problem. git-svn-id: svn://svn.berlios.de/openocd/trunk@475 b42882b7-edfa-0310-969c-e2dbd0fdcd60 --- src/target/arm7_9_common.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'src/target/arm7_9_common.c') diff --git a/src/target/arm7_9_common.c b/src/target/arm7_9_common.c index e31b0151..a7d756a3 100644 --- a/src/target/arm7_9_common.c +++ b/src/target/arm7_9_common.c @@ -860,16 +860,26 @@ int arm7_9_soft_reset_halt(struct target_s *target) reg_t *dbg_stat = &arm7_9->eice_cache->reg_list[EICE_DBG_STAT]; reg_t *dbg_ctrl = &arm7_9->eice_cache->reg_list[EICE_DBG_CTRL]; int i; + int retval; - if (target->state == TARGET_RUNNING) - { - target->type->halt(target); - } + if ((retval=target->type->halt(target))!=ERROR_OK) + return retval; - while (buf_get_u32(dbg_stat->value, EICE_DBG_STATUS_DBGACK, 1) == 0) + for (i=0; i<10; i++) { + if (buf_get_u32(dbg_stat->value, EICE_DBG_STATUS_DBGACK, 1) != 0) + break; embeddedice_read_reg(dbg_stat); - jtag_execute_queue(); + if ((retval=jtag_execute_queue())!=ERROR_OK) + return retval; + /* do not eat all CPU, time out after 1 se*/ + usleep(100*1000); + + } + if (i==10) + { + ERROR("Failed to halt CPU after 1 sec"); + return ERROR_TARGET_TIMEOUT; } target->state = TARGET_HALTED; @@ -962,7 +972,7 @@ int arm7_9_halt(target_t *target) if (target->state == TARGET_HALTED) { WARNING("target was already halted"); - return ERROR_TARGET_ALREADY_HALTED; + return ERROR_OK; } if (target->state == TARGET_UNKNOWN) -- cgit v1.2.3