Re: [Openocd-development] jim_mcrmrc: no command context @iMX35

2010-05-03 Thread Øyvind Harboe
This patch should fix the problem.

The patch is against openocd/master

As this post was made back in January, I'm including a reference to the
original discussion here...

http://www.mail-archive.com/openocd-development@lists.berlios.de/msg11864.html

-- 
Meet Zylin at ESC 2010 San Jose
April 26 - 30. 2010
http://www.zylin.com/events_esc2010.html


Øyvind Harboe
US toll free 1-866-980-3434 / International +47 51 63 25 00
http://www.zylin.com/zy1000.html
ARM7 ARM9 ARM11 XScale Cortex
JTAG debugger and flash programmer
From 091a31d12f221348838ed3448dcf22cf4e134d23 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?=C3=98yvind=20Harboe?= 
Date: Mon, 3 May 2010 17:01:53 +0200
Subject: [PATCH] command context: fix errors when running certain commands on startup
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

Various commands, e.g. "arm mcr " would fail if invoked upon startup
since it there was no command context defined for the jim interpreter
in that case.

A Jim interpreter is now associated with a command context(telnet,
gdb server's) or the default global command context.

Signed-off-by: Øyvind Harboe 
---
 src/helper/command.c |8 ++--
 src/helper/command.h |4 
 src/jtag/tcl.c   |4 ++--
 src/target/armv4_5.c |8 +++-
 src/target/target.c  |   29 +++--
 5 files changed, 30 insertions(+), 23 deletions(-)

diff --git a/src/helper/command.c b/src/helper/command.c
index 3625508..be262f2 100644
--- a/src/helper/command.c
+++ b/src/helper/command.c
@@ -167,14 +167,18 @@ static const char **script_command_args_alloc(
 	return words;
 }
 
-static struct command_context *current_command_context(Jim_Interp *interp)
+struct command_context *current_command_context(Jim_Interp *interp)
 {
 	/* grab the command context from the associated data */
 	struct command_context *cmd_ctx = Jim_GetAssocData(interp, "context");
 	if (NULL == cmd_ctx)
 	{
 		/* Tcl can invoke commands directly instead of via command_run_line(). This would
-		 * happen when the Jim Tcl interpreter is provided by eCos.
+		 * happen when the Jim Tcl interpreter is provided by eCos or if we are running
+		 * commands in a startup script.
+		 *
+		 * A telnet or gdb server would provide a non-default command context to
+		 * handle piping of error output, have a separate current target, etc.
 		 */
 		cmd_ctx = global_cmd_ctx;
 	}
diff --git a/src/helper/command.h b/src/helper/command.h
index 8a418d3..2c19241 100644
--- a/src/helper/command.h
+++ b/src/helper/command.h
@@ -311,6 +311,10 @@ void command_set_output_handler(struct command_context* context,
 
 int command_context_mode(struct command_context *context, enum command_mode mode);
 
+/* Return the current command context associated with the Jim interpreter or
+ * alternatively the global default command interpreter
+ */
+struct command_context *current_command_context(Jim_Interp *interp);
 /**
  * Creates a new command context using the startup TCL provided and
  * the existing Jim interpreter, if any. If interp == NULL, then command_init
diff --git a/src/jtag/tcl.c b/src/jtag/tcl.c
index 579ca9e..ea6d07e 100644
--- a/src/jtag/tcl.c
+++ b/src/jtag/tcl.c
@@ -684,7 +684,7 @@ static int jim_jtag_arp_init(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
 		Jim_WrongNumArgs(goi.interp, 1, goi.argv-1, "(no params)");
 		return JIM_ERR;
 	}
-	struct command_context *context = Jim_GetAssocData(interp, "context");
+	struct command_context *context = current_command_context(interp);
 	int e = jtag_init_inner(context);
 	if (e != ERROR_OK) {
 		Jim_SetResult_sprintf(goi.interp, "error: %d", e);
@@ -701,7 +701,7 @@ static int jim_jtag_arp_init_reset(Jim_Interp *interp, int argc, Jim_Obj *const
 		Jim_WrongNumArgs(goi.interp, 1, goi.argv-1, "(no params)");
 		return JIM_ERR;
 	}
-	struct command_context *context = Jim_GetAssocData(interp, "context");
+	struct command_context *context = current_command_context(interp);
 	int e = jtag_init_reset(context);
 	if (e != ERROR_OK) {
 		Jim_SetResult_sprintf(goi.interp, "error: %d", e);
diff --git a/src/target/armv4_5.c b/src/target/armv4_5.c
index eeb6694..1a84a5f 100644
--- a/src/target/armv4_5.c
+++ b/src/target/armv4_5.c
@@ -820,11 +820,9 @@ static int jim_mcrmrc(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
 	struct arm *arm;
 	int retval;
 
-	context = Jim_GetAssocData(interp, "context");
-	if (context == NULL) {
-		LOG_ERROR("%s: no command context", __func__);
-		return JIM_ERR;
-	}
+	context = current_command_context(interp);
+	assert( context != NULL);
+
 	target = get_current_target(context);
 	if (target == NULL) {
 		LOG_ERROR("%s: no current target", __func__);
diff --git a/src/target/target.c b/src/target/target.c
index a3a1b0a..d17bb74 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -3236,12 +3236,9 @@ static int jim_mem2array(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
 	struct command_context *context;
 	struct target *tar

Re: [Openocd-development] jim_mcrmrc: no command context @iMX35

2010-01-26 Thread Alexei Babich
> Broken 
Nevertheless, in the telnet session, the command will proceed without error.

-- 
Regards,
Alexei Babich, circuit design engineer, Rezonans plc., Chelyabinsk, Russia
http://www.rez.ru
Jabber ID: imp...@jabber.ru
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] jim_mcrmrc: no command context @iMX35

2010-01-26 Thread David Brownell
On Tuesday 26 January 2010, Alexei Babich wrote:
> > THat MCR thing looks odd, but also:
> Hmm ... Why odd?

Broken 

___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] jim_mcrmrc: no command context @iMX35

2010-01-26 Thread Alexei Babich
> THat MCR thing looks odd, but also:
Hmm ... Why odd?

> > Open On-Chip Debugger 0.4.0-rc1-dev-00118-gdab9297-dirty (2010-01-26-09:08)
> 
> "git show dab9297" says more or less "what" ... looks like you have some
> nostandard patches in your git tree.
Nothing interesting. My local commit with changes in the NAND-flash driver.

> Does this problem reproduce with mainline code?
Yes:
---
[imp...@kb33 openocd]$ src/openocd -f /home/impatt/openocd.cfg
Open On-Chip Debugger 0.4.0-rc1-dev-00151-g3036588 (2010-01-27-09:33)
For bug reports, read
http://openocd.berlios.de/doc/doxygen/bugs.html
jtag_nsrst_assert_width: 10
jtag_nsrst_delay: 50
jtag_ntrst_assert_width: 10
jtag_ntrst_delay: 10
Warn : imx35.sdma: nonstandard IR value
Warn : imx35.sdma: nonstandard IR mask
trst_and_srst separate srst_gates_jtag trst_open_drain srst_open_drain
Info : clock speed 500 kHz
Info : JTAG tap: imx35.etb tap/device found: 0x2b900f0f (mfg: 0x787, part: 
0xb900, ver: 0x2)
Info : JTAG tap: imx35.cpu tap/device found: 0x07b3601d (mfg: 0x00e, part: 
0x7b36, ver: 0x0)
Info : TAP imx35.sdma does not have IDCODE
Info : JTAG tap: imx35.sjc tap/device found: 0x0882601d (mfg: 0x00e, part: 
0x8826, ver: 0x0)
Info : found ARM1136
Info : imx35.cpu: hardware has 6 breakpoints, 2 watchpoints
Warn : ETMv2+ support is incomplete
Info : ETM v3.1
Info : JTAG tap: imx35.etb tap/device found: 0x2b900f0f (mfg: 0x787, part: 
0xb900, ver: 0x2)
Info : JTAG tap: imx35.cpu tap/device found: 0x07b3601d (mfg: 0x00e, part: 
0x7b36, ver: 0x0)
Info : TAP imx35.sdma does not have IDCODE
Info : JTAG tap: imx35.sjc tap/device found: 0x0882601d (mfg: 0x00e, part: 
0x8826, ver: 0x0)
Info : found ARM1136
Warn : imx35.cpu: ran after reset and before halt ...
target state: halted
target halted in ARM state due to debug-request, current mode: Supervisor
cpsr: 0x01d3 pc: 0xa006c930
Error: jim_mcrmrc: no command context
---


-- 
Regards,
Alexei Babich, circuit design engineer, Rezonans plc., Chelyabinsk, Russia
http://www.rez.ru
Jabber ID: imp...@jabber.ru
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] jim_mcrmrc: no command context @iMX35

2010-01-26 Thread David Brownell
THat MCR thing looks odd, but also:

On Monday 25 January 2010, Alexei Babich wrote:
> Open On-Chip Debugger 0.4.0-rc1-dev-00118-gdab9297-dirty (2010-01-26-09:08)

"git show dab9297" says more or less "what" ... looks like you have some
nostandard patches in your git tree.  Plus the "-dirty" says you have some
additional patches (not checked in).

Does this problem reproduce with mainline code?

- Dave

___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


[Openocd-development] jim_mcrmrc: no command context @iMX35

2010-01-25 Thread Alexei Babich
Hello all.
When I run OpenOCD as follows:
[imp...@kb33 openocd]$ src/openocd -f /home/impatt/openocd.cfg

I get the following output on the console, including the error message:

Open On-Chip Debugger 0.4.0-rc1-dev-00118-gdab9297-dirty (2010-01-26-09:08)
For bug reports, read
http://openocd.berlios.de/doc/doxygen/bugs.html
jtag_nsrst_assert_width: 10
jtag_nsrst_delay: 50
jtag_ntrst_assert_width: 10
jtag_ntrst_delay: 10
Warn : imx35.sdma: nonstandard IR value
Warn : imx35.sdma: nonstandard IR mask
trst_and_srst separate srst_gates_jtag trst_open_drain srst_open_drain
Info : clock speed 500 kHz
Info : JTAG tap: imx35.etb tap/device found: 0x2b900f0f (mfg: 0x787, part: 
0xb900, ver: 0x2)
Info : JTAG tap: imx35.cpu tap/device found: 0x07b3601d (mfg: 0x00e, part: 
0x7b36, ver: 0x0)
Info : TAP imx35.sdma does not have IDCODE
Info : JTAG tap: imx35.sjc tap/device found: 0x0882601d (mfg: 0x00e, part: 
0x8826, ver: 0x0)
Info : found ARM1136
Info : imx35.cpu: hardware has 6 breakpoints, 2 watchpoints
Warn : ETMv2+ support is incomplete
Info : ETM v3.1
Info : JTAG tap: imx35.etb tap/device found: 0x2b900f0f (mfg: 0x787, part: 
0xb900, ver: 0x2)
Info : JTAG tap: imx35.cpu tap/device found: 0x07b3601d (mfg: 0x00e, part: 
0x7b36, ver: 0x0)
Info : TAP imx35.sdma does not have IDCODE
Info : JTAG tap: imx35.sjc tap/device found: 0x0882601d (mfg: 0x00e, part: 
0x8826, ver: 0x0)
Info : found ARM1136
Warn : imx35.cpu: ran after reset and before halt ...
target state: halted
target halted in ARM state due to debug-request, current mode: Supervisor
cpsr: 0x01d3 pc: 0xa006d000
Error: jim_mcrmrc: no command context


File openocd.cfg contains the following:
--
source /home/impatt/openocd/parport.cfg
source /home/impatt/openocd/imx35.cfg
reset_config trst_and_srst trst_open_drain
init
reset halt
$_TARGETNAME arm mcr 15 0x0 0x1 0x0 0x0 0x00050078
--

An attempt to execute the command 'arm mcr' causes an error, as seen from the 
log.
But the command from the telnet-session is successful.

Q: What kind of context, says the error message? How to create a context and 
execute the commands 'arm mcr'?

Thank you.
-- 
Regards,
Alexei Babich, circuit design engineer, Rezonans plc., Chelyabinsk, Russia
http://www.rez.ru
Jabber ID: imp...@jabber.ru
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development