Try the attached patch. I typed it up, it compiles, but I didn't test it.
The pre_reset script runs while JTAG clk runs at reset speed, but
before anything more happens(including asserting TRST/reexamining
the scan chain).
I didn't rename "reset" to "post_reset", but rather created an alias so you
can write either(not to break scripts out there, which needs some
justification + not breaking them saves work).
--
Øyvind Harboe
http://www.zylin.com/zy1000.html
ARM7 ARM9 XScale Cortex
JTAG debugger and flash programmer
Index: C:/workspace/openocd_trunk/src/target/target.c
===================================================================
--- C:/workspace/openocd_trunk/src/target/target.c (revision 725)
+++ C:/workspace/openocd_trunk/src/target/target.c (working copy)
@@ -215,6 +215,21 @@
return target;
}
+static void execute_script(char *reset_script)
+{
+ FILE *script;
+ script = open_file_from_path(reset_script, "r");
+ if (!script)
+ {
+ LOG_ERROR("couldn't open script file %s", reset_script);
+ return;
+ }
+
+ LOG_INFO("executing reset script '%s'", reset_script);
+ command_run_file(cmd_ctx, script, COMMAND_EXEC);
+ fclose(script);
+}
+
/* Process target initialization, when target entered debug out of reset
* the handler is unregistered at the end of this function, so it's only
called once
*/
@@ -220,7 +235,6 @@
*/
int target_init_handler(struct target_s *target, enum target_event event, void
*priv)
{
- FILE *script;
struct command_context_s *cmd_ctx = priv;
if ((event == TARGET_EVENT_HALTED) && (target->reset_script))
@@ -227,16 +241,7 @@
{
target_unregister_event_callback(target_init_handler, priv);
- script = open_file_from_path(target->reset_script, "r");
- if (!script)
- {
- LOG_ERROR("couldn't open script file %s",
target->reset_script);
- return ERROR_OK;
- }
-
- LOG_INFO("executing reset script '%s'", target->reset_script);
- command_run_file(cmd_ctx, script, COMMAND_EXEC);
- fclose(script);
+ execute_script(target->reset_script);
jtag_execute_queue();
}
@@ -295,6 +300,13 @@
jtag->speed(jtag_speed);
+ target = targets;
+ while (target)
+ {
+ execute_script(target->pre_reset_script);
+ target = target->next;
+ }
+
if ((retval = jtag_init_reset(cmd_ctx)) != ERROR_OK)
return retval;
@@ -1422,6 +1434,7 @@
(*last_target_p)->run_and_halt_time = 1000; /*
default 1s */
(*last_target_p)->reset_script = NULL;
+ (*last_target_p)->pre_reset_script = NULL;
(*last_target_p)->post_halt_script = NULL;
(*last_target_p)->pre_resume_script = NULL;
(*last_target_p)->gdb_program_script = NULL;
@@ -1488,7 +1501,7 @@
return ERROR_COMMAND_SYNTAX_ERROR;
}
- if (strcmp(args[1], "reset") == 0)
+ if ((strcmp(args[1], "reset") == 0)||(strcmp(args[1], "post_reset") ==
0))
{
if (target->reset_script)
free(target->reset_script);
@@ -1494,6 +1507,12 @@
free(target->reset_script);
target->reset_script = strdup(args[2]);
}
+ else if (strcmp(args[1], "pre_reset") == 0)
+ {
+ if (target->pre_reset_script)
+ free(target->pre_reset_script);
+ target->pre_reset_script = strdup(args[2]);
+ }
else if (strcmp(args[1], "post_halt") == 0)
{
if (target->post_halt_script)
Index: C:/workspace/openocd_trunk/src/target/target.h
===================================================================
--- C:/workspace/openocd_trunk/src/target/target.h (revision 725)
+++ C:/workspace/openocd_trunk/src/target/target.h (working copy)
@@ -200,6 +200,7 @@
target_type_t *type; /* target type
definition (name, access functions) */
enum target_reset_mode reset_mode; /* what to do after a reset */
int run_and_halt_time; /* how long the target
should run after a run_and_halt reset */
+ char *pre_reset_script; /* script file
to initialize the target after a reset */
char *reset_script; /* script file
to initialize the target after a reset */
char *post_halt_script; /* script file to
execute after the target halted */
char *pre_resume_script; /* script file to
execute before the target resumed */
_______________________________________________
Openocd-development mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/openocd-development