Hi all,
I was wondering how that initial state of target is discovered and
where in the code ?
Is it by calling the target_poll() function ?


I am asking this because issuing the "halt" command on the target in
TARGET_UNKNOWN state will not work for MIPS, and probably for some
other architectures.
This imposes the problem on consequent start of OpenOCD - once it was
started and target halted (DEBUG flag risen), then when OpenOCD is
killed and restarted on the same target configuration script will not
work, as it will not be able to (re)halt the target.

Now, I have seen something like this in src/target/arm7_9_common.c,
where poll forces TARGET_RUNNING state on TARGET_UNKNOWN target, if
DBG flag is risen :

if (target->state == TARGET_UNKNOWN) {
                        /* Starting OpenOCD with target in debug-halt */
                        target->state = TARGET_RUNNING;
                        LOG_DEBUG("DBGACK already set during server startup.");
                }


Git-blame/git-show on the interesting line gets us here :

commit 0686e944f300e433d449eaa5c7bc576c1e65fd1a
Author: ntfreak <ntfreak@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Date:   Tue Feb 26 19:56:45 2008 +0000

    - fix issue when target is already halted

    git-svn-id: svn://svn.berlios.de/openocd/trunk@355
b42882b7-edfa-0310-969c-e2dbd0fdcd60

diff --git a/src/target/arm7_9_common.c b/src/target/arm7_9_common.c
index af0205d..51f4c68 100644
--- a/src/target/arm7_9_common.c
+++ b/src/target/arm7_9_common.c
@@ -700,6 +700,7 @@ int arm7_9_poll(target_t *target)
        DEBUG("DBGACK set, dbg_state->value: 0x%x",
buf_get_u32(dbg_stat->value, 0, 32));
        if (target->state == TARGET_UNKNOWN)
        {
+           target->state = TARGET_RUNNING;
            WARNING("DBGACK set while target was in unknown state.
Reset or initialize target.");
        }
        if ((target->state == TARGET_RUNNING) || (target->state ==
TARGET_RESET))


Something like this does not exist for MIPS architecture, and can be
easily added, but I just wanted to see your opinion is this good
practice and if this function is correct candidate for change.
Moreover, if target is in UNKNOWN state and DEBUG flag is risen, how
can we know if we are in TARGET_RUNNING or in TARGET_DEBUG_RUNNING,
and does it mether on OpenOCD start ?

If this sounds OK, I will post the patch for MIPS architecture to gerrit.

BR,
Drasko

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
OpenOCD-devel mailing list
OpenOCD-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to