This is an automated email from Gerrit.

Esben Haabendal (es...@haabendal.dk) just uploaded a new patch set to Gerrit, 
which you can find at http://openocd.zylin.com/3076

-- gerrit

commit 653624812015ce9fd369ed042c32ef2cf6b6e548
Author: Esben Haabendal <es...@haabendal.dk>
Date:   Thu Oct 29 11:07:57 2015 +0100

    Add -defer-examine option to target create command
    
    The '-defer-examine' option to target create allows declaring targets
    that are present on the chain, but not fully functional.  They will
    be skipped by the initial arp_examine as well as arp_examine after
    reset.
    
    Manual examine using 'arp_examine' is needed to examine them, with the
    idea that some kind of actions is neeed to bring them to a state where
    examine will succeed (if at all possible).
    
    Change-Id: I9bf4e8d27eb6476dd9353d15f48965a8cfd5c122
    Signed-off-by: Esben Haabendal <es...@haabendal.dk>

diff --git a/src/target/startup.tcl b/src/target/startup.tcl
index cf2813b..2bd6e2b 100644
--- a/src/target/startup.tcl
+++ b/src/target/startup.tcl
@@ -65,7 +65,7 @@ proc ocd_process_reset_inner { MODE } {
        foreach t $targets {
                if {![using_jtag] || [jtag tapisenabled [$t cget 
-chain-position]]} {
                        $t invoke-event examine-start
-                       set err [catch "$t arp_examine"]
+                       set err [catch "$t arp_examine allow-defer"]
                        if { $err == 0 } {
                                $t invoke-event examine-end
                        }
diff --git a/src/target/target.c b/src/target/target.c
index 19e5d65..c097d50 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -729,6 +729,9 @@ int target_examine(void)
                        continue;
                }
 
+               if (target->defer_examine)
+                       continue;
+
                retval = target_examine_one(target);
                if (retval != ERROR_OK)
                        return retval;
@@ -4285,6 +4288,7 @@ enum target_cfg_param {
        TCFG_CHAIN_POSITION,
        TCFG_DBGBASE,
        TCFG_RTOS,
+       TCFG_DEFER_EXAMINE,
 };
 
 static Jim_Nvp nvp_config_opts[] = {
@@ -4299,6 +4303,7 @@ static Jim_Nvp nvp_config_opts[] = {
        { .name = "-chain-position",   .value = TCFG_CHAIN_POSITION },
        { .name = "-dbgbase",          .value = TCFG_DBGBASE },
        { .name = "-rtos",             .value = TCFG_RTOS },
+       { .name = "-defer-examine",    .value = TCFG_DEFER_EXAMINE },
        { .name = NULL, .value = -1 }
 };
 
@@ -4573,6 +4578,14 @@ no_params:
                        }
                        /* loop for more */
                        break;
+
+               case TCFG_DEFER_EXAMINE:
+                       /* DEFER_EXAMINE */
+                       {
+                               target->defer_examine = true;
+                       }
+                       /* loop for more */
+                       break;
                }
        } /* while (goi->argc) */
 
@@ -4843,14 +4856,34 @@ static int jim_target_tap_disabled(Jim_Interp *interp)
 
 static int jim_target_examine(Jim_Interp *interp, int argc, Jim_Obj *const 
*argv)
 {
-       if (argc != 1) {
-               Jim_WrongNumArgs(interp, 1, argv, "[no parameters]");
+       bool allow_defer = false;
+
+       Jim_GetOptInfo goi;
+       Jim_GetOpt_Setup(&goi, interp, argc - 1, argv + 1);
+       if (goi.argc > 1) {
+               const char *cmd_name = Jim_GetString(argv[0], NULL);
+               Jim_SetResultFormatted(goi.interp,
+                               "usage: %s ['allow-defer']", cmd_name);
                return JIM_ERR;
        }
+       if (strcmp(Jim_GetString(argv[1], NULL), "allow-defer") == 0) {
+               /* consume it */
+               struct Jim_Obj *obj;
+               int e = Jim_GetOpt_Obj(&goi, &obj);
+               if (e != JIM_OK)
+                       return e;
+               allow_defer = true;
+       }
+
        struct target *target = Jim_CmdPrivData(interp);
        if (!target->tap->enabled)
                return jim_target_tap_disabled(interp);
 
+       if (allow_defer && target->defer_examine) {
+               LOG_DEBUG("deferring arp_examine");
+               return JIM_OK;
+       }
+
        int e = target->type->examine(target);
        if (e != ERROR_OK)
                return JIM_ERR;
@@ -5137,6 +5170,7 @@ static const struct command_registration 
target_instance_command_handlers[] = {
                .mode = COMMAND_EXEC,
                .jim_handler = jim_target_examine,
                .help = "used internally for reset processing",
+               .usage = "arp_examine ['allow-defer']",
        },
        {
                .name = "arp_halt_gdb",
diff --git a/src/target/target.h b/src/target/target.h
index 4faf311..16a8b3f 100644
--- a/src/target/target.h
+++ b/src/target/target.h
@@ -132,6 +132,9 @@ struct target {
        struct jtag_tap *tap;                           /* where on the jtag 
chain is this */
        int32_t coreid;                                         /* which device 
on the TAP? */
 
+       /** Should we defer examine to later */
+       bool defer_examine;
+
        /**
         * Indicates whether this target has been examined.
         *

-- 

------------------------------------------------------------------------------
_______________________________________________
OpenOCD-devel mailing list
OpenOCD-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to