You can subscribe to this list here.
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(75) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2009 |
Jan
(70) |
Feb
(20) |
Mar
(52) |
Apr
(149) |
May
(387) |
Jun
(466) |
Jul
(133) |
Aug
(87) |
Sep
(122) |
Oct
(140) |
Nov
(185) |
Dec
(105) |
| 2010 |
Jan
(85) |
Feb
(45) |
Mar
(75) |
Apr
(17) |
May
(41) |
Jun
(52) |
Jul
(33) |
Aug
(29) |
Sep
(36) |
Oct
(15) |
Nov
(26) |
Dec
(34) |
| 2011 |
Jan
(26) |
Feb
(25) |
Mar
(26) |
Apr
(29) |
May
(20) |
Jun
(27) |
Jul
(15) |
Aug
(32) |
Sep
(13) |
Oct
(64) |
Nov
(60) |
Dec
(10) |
| 2012 |
Jan
(64) |
Feb
(63) |
Mar
(39) |
Apr
(43) |
May
(54) |
Jun
(11) |
Jul
(30) |
Aug
(45) |
Sep
(11) |
Oct
(70) |
Nov
(24) |
Dec
(23) |
| 2013 |
Jan
(17) |
Feb
(8) |
Mar
(35) |
Apr
(40) |
May
(20) |
Jun
(24) |
Jul
(36) |
Aug
(25) |
Sep
(42) |
Oct
(40) |
Nov
(9) |
Dec
(21) |
| 2014 |
Jan
(29) |
Feb
(24) |
Mar
(60) |
Apr
(22) |
May
(22) |
Jun
(46) |
Jul
(11) |
Aug
(23) |
Sep
(26) |
Oct
(10) |
Nov
(14) |
Dec
(2) |
| 2015 |
Jan
(28) |
Feb
(47) |
Mar
(33) |
Apr
(58) |
May
(5) |
Jun
(1) |
Jul
|
Aug
(8) |
Sep
(12) |
Oct
(25) |
Nov
(58) |
Dec
(21) |
| 2016 |
Jan
(12) |
Feb
(40) |
Mar
(2) |
Apr
(1) |
May
(67) |
Jun
(2) |
Jul
(5) |
Aug
(36) |
Sep
|
Oct
(24) |
Nov
(17) |
Dec
(50) |
| 2017 |
Jan
(14) |
Feb
(16) |
Mar
(2) |
Apr
(35) |
May
(14) |
Jun
(16) |
Jul
(3) |
Aug
(3) |
Sep
|
Oct
(19) |
Nov
|
Dec
(16) |
| 2018 |
Jan
(55) |
Feb
(11) |
Mar
(34) |
Apr
(14) |
May
(4) |
Jun
(20) |
Jul
(39) |
Aug
(16) |
Sep
(17) |
Oct
(16) |
Nov
(20) |
Dec
(30) |
| 2019 |
Jan
(29) |
Feb
(24) |
Mar
(37) |
Apr
(26) |
May
(19) |
Jun
(21) |
Jul
(2) |
Aug
(3) |
Sep
(9) |
Oct
(12) |
Nov
(12) |
Dec
(12) |
| 2020 |
Jan
(47) |
Feb
(36) |
Mar
(54) |
Apr
(44) |
May
(37) |
Jun
(19) |
Jul
(32) |
Aug
(13) |
Sep
(16) |
Oct
(24) |
Nov
(32) |
Dec
(11) |
| 2021 |
Jan
(14) |
Feb
(5) |
Mar
(40) |
Apr
(32) |
May
(42) |
Jun
(31) |
Jul
(29) |
Aug
(47) |
Sep
(38) |
Oct
(17) |
Nov
(74) |
Dec
(33) |
| 2022 |
Jan
(11) |
Feb
(15) |
Mar
(40) |
Apr
(21) |
May
(39) |
Jun
(44) |
Jul
(19) |
Aug
(46) |
Sep
(79) |
Oct
(35) |
Nov
(21) |
Dec
(15) |
| 2023 |
Jan
(56) |
Feb
(13) |
Mar
(43) |
Apr
(28) |
May
(60) |
Jun
(15) |
Jul
(29) |
Aug
(28) |
Sep
(32) |
Oct
(21) |
Nov
(42) |
Dec
(39) |
| 2024 |
Jan
(35) |
Feb
(17) |
Mar
(28) |
Apr
(7) |
May
(14) |
Jun
(35) |
Jul
(30) |
Aug
(35) |
Sep
(30) |
Oct
(28) |
Nov
(38) |
Dec
(18) |
| 2025 |
Jan
(21) |
Feb
(28) |
Mar
(36) |
Apr
(35) |
May
(34) |
Jun
(58) |
Jul
(9) |
Aug
(54) |
Sep
(47) |
Oct
(15) |
Nov
(58) |
Dec
|
|
From: <zw...@ma...> - 2009-06-16 01:54:15
|
Author: zwelch
Date: 2009-06-16 01:54:09 +0200 (Tue, 16 Jun 2009)
New Revision: 2242
Added:
trunk/tcl/board/omap2420_h4.cfg
trunk/tcl/target/omap2420.cfg
Log:
David Brownell <da...@pa...>:
Add another board ... OMAP2420 "H4" board. This won't be very widely
used with OpenOCD, but with mainline support in both U-Boot and Linux
it at least makes for a more complete set (and another testcase).
This is incomplete support in several respects. The ARM11 support is
not very deep yet; most registers aren't available, and the ETM can't
be hooked up. Plus, there's no script for OMAP-specific stuff like
setting up the SDRAM controller. Eventually the same NAND controller
driver should work with OMAP2 and OMAP3.
Added: trunk/tcl/board/omap2420_h4.cfg
===================================================================
--- trunk/tcl/board/omap2420_h4.cfg 2009-06-15 14:22:13 UTC (rev 2241)
+++ trunk/tcl/board/omap2420_h4.cfg 2009-06-15 23:54:09 UTC (rev 2242)
@@ -0,0 +1,14 @@
+# OMAP2420 SDP board ("H4")
+
+source [find target/omap2420.cfg]
+
+# NOTE: this assumes you're *NOT* using a TI-14 connector.
+reset_config trst_and_srst separate
+
+# Board configs can vary a *LOT* ... parts, jumpers, etc.
+# This GP board boots from cs0 using NOR (2x32M), and also
+# has 64M NAND on cs6.
+flash bank cfi 0x04000000 0x02000000 2 2 $_TARGETNAME
+flash bank cfi 0x06000000 0x02000000 2 2 $_TARGETNAME
+
+# vim:syntax tcl
Property changes on: trunk/tcl/board/omap2420_h4.cfg
___________________________________________________________________
Name: svn:eol-style
+ native
Added: trunk/tcl/target/omap2420.cfg
===================================================================
--- trunk/tcl/target/omap2420.cfg 2009-06-15 14:22:13 UTC (rev 2241)
+++ trunk/tcl/target/omap2420.cfg 2009-06-15 23:54:09 UTC (rev 2242)
@@ -0,0 +1,61 @@
+# Texas Instruments OMAP 2420
+# http://www.ti.com/omap
+
+if { [info exists CHIPNAME] } {
+ set _CHIPNAME $CHIPNAME
+} else {
+ set _CHIPNAME omap2420
+}
+if { [info exists ENDIAN] } {
+ set _ENDIAN $ENDIAN
+} else {
+ set _ENDIAN little
+}
+
+# NOTE: likes slowish clock on reset (1.5 MBit/s or less) or use RCLK
+
+# Subsidiary TAP: ARM7TDMIr4 plus imaging ... must add via ICEpick (addr 6).
+jtag newtap $_CHIPNAME iva -irlen 4 -ircapture 0x1 -irmask 0x3f -disable
+
+# Subsidiary TAP: C55x DSP ... must add via ICEpick (addr 2).
+jtag newtap $_CHIPNAME dsp -irlen 38 -ircapture 0x1 -irmask 0x3f -disable
+
+# Subsidiary TAP: ARM ETB11, with scan chain for 4K of ETM trace buffer
+if { [info exists ETB_TAPID ] } {
+ set _ETB_TAPID $ETB_TAPID
+} else {
+ set _ETB_TAPID 0x2b900f0f
+}
+jtag newtap $_CHIPNAME etb -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_ETB_TAPID
+
+# Subsidiary TAP: ARM1136jf-s with scan chains for ARM Debug, EmbeddedICE-RT, ETM.
+if { [info exists CPU_TAPID ] } {
+ set _CPU_TAPID $CPU_TAPID
+} else {
+ set _CPU_TAPID 0x07b3602f
+}
+jtag newtap $_CHIPNAME arm -irlen 5 -ircapture 0x1 -irmask 0x1f -expected-id $_CPU_TAPID
+
+# Primary TAP: ICEpick-B (JTAG route controller) and boundary scan
+if { [info exists JRC_TAPID ] } {
+ set _JRC_TAPID $JRC_TAPID
+} else {
+ set _JRC_TAPID 0x01ce4801
+}
+jtag newtap $_CHIPNAME jrc -irlen 2 -ircapture 0x1 -irmask 0x3 -expected-id $_JRC_TAPID
+
+# GDB target: the ARM.
+set _TARGETNAME $_CHIPNAME.arm
+target create $_TARGETNAME arm11 -endian $_ENDIAN -chain-position $_TARGETNAME
+
+# scratch: framebuffer, may be initially unavailable in some chips
+$_TARGETNAME configure -work-area-phys 0x40210000
+$_TARGETNAME configure -work-area-size 0x00081000
+$_TARGETNAME configure -work-area-backup 0
+
+# trace setup
+# REVISIT ... as of 12-June-2009, OpenOCD's ETM code can't talk to ARM11 cores.
+#etm config $_TARGETNAME 16 normal full etb
+#etb config $_TARGETNAME $_CHIPNAME.etb
+
+# vim:syntax tcl
Property changes on: trunk/tcl/target/omap2420.cfg
___________________________________________________________________
Name: svn:eol-style
+ native
|
|
From: oharboe at B. <oh...@ma...> - 2009-06-15 16:22:14
|
Author: oharboe Date: 2009-06-15 16:22:13 +0200 (Mon, 15 Jun 2009) New Revision: 2241 Modified: trunk/src/helper/types.h Log: fix eCos build problems w/latest parse_ulong() stuff Modified: trunk/src/helper/types.h =================================================================== --- trunk/src/helper/types.h 2009-06-13 08:38:57 UTC (rev 2240) +++ trunk/src/helper/types.h 2009-06-15 14:22:13 UTC (rev 2241) @@ -137,22 +137,27 @@ } #ifdef __ECOS + /* eCos plain lacks this definition... */ typedef CYG_ADDRWORD intptr_t; typedef int64_t intmax_t; typedef uint64_t uintmax_t; #define INT8_MAX 0x7f #define INT8_MIN (-INT8_MAX - 1) -#define UINT8_MAX (__CONCAT(INT8_MAX, U) * 2U + 1U) +# define UINT8_MAX (255) #define INT16_MAX 0x7fff #define INT16_MIN (-INT16_MAX - 1) -#define UINT16_MAX (__CONCAT(INT16_MAX, U) * 2U + 1U) +# define UINT16_MAX (65535) #define INT32_MAX 0x7fffffffL #define INT32_MIN (-INT32_MAX - 1L) -#define UINT32_MAX (__CONCAT(INT32_MAX, U) * 2UL + 1UL) +# define UINT32_MAX (4294967295U) #define INT64_MAX 0x7fffffffffffffffLL #define INT64_MIN (-INT64_MAX - 1LL) #define UINT64_MAX (__CONCAT(INT64_MAX, U) * 2ULL + 1ULL) + + + + #endif #endif /* TYPES_H */ |
|
From: <zw...@ma...> - 2009-06-13 10:39:03
|
Author: zwelch
Date: 2009-06-13 10:38:57 +0200 (Sat, 13 Jun 2009)
New Revision: 2240
Modified:
trunk/doc/openocd.texi
trunk/src/server/gdb_server.c
trunk/src/server/tcl_server.c
trunk/src/server/telnet_server.c
Log:
David Brownell <da...@pa...>:
OpenOCD doesn't actually *need* to be keeping all TCP ports
active ... creating security issues in some network configs.
Instead, let config file specify e.g. "tcl_port 0" (or gdb_port,
telnet_port) to disable that particular remote access method.
Modified: trunk/doc/openocd.texi
===================================================================
--- trunk/doc/openocd.texi 2009-06-13 00:34:31 UTC (rev 2239)
+++ trunk/doc/openocd.texi 2009-06-13 08:38:57 UTC (rev 2240)
@@ -1422,10 +1422,17 @@
@cindex TCP port
@cindex server
@cindex port
+@cindex security
The OpenOCD server accepts remote commands in several syntaxes.
Each syntax uses a different TCP/IP port, which you may specify
only during configuration (before those ports are opened).
+For reasons including security, you may wish to prevent remote
+access using one or more of these ports.
+In such cases, just specify the relevant port number as zero.
+If you disable all access through TCP/IP, you will need to
+use the command line @option{-pipe} option.
+
@deffn {Command} gdb_port (number)
@cindex GDB server
Specify or query the first port used for incoming GDB connections.
@@ -1433,6 +1440,7 @@
first target will be gdb_port, the second target will listen on gdb_port + 1, and so on.
When not specified during the configuration stage,
the port @var{number} defaults to 3333.
+When specified as zero, this port is not activated.
@end deffn
@deffn {Command} tcl_port (number)
@@ -1442,6 +1450,7 @@
Intended as a machine interface.
When not specified during the configuration stage,
the port @var{number} defaults to 6666.
+When specified as zero, this port is not activated.
@end deffn
@deffn {Command} telnet_port (number)
@@ -1450,6 +1459,7 @@
This port is intended for interaction with one human through TCL commands.
When not specified during the configuration stage,
the port @var{number} defaults to 4444.
+When specified as zero, this port is not activated.
@end deffn
@anchor{GDB Configuration}
Modified: trunk/src/server/gdb_server.c
===================================================================
--- trunk/src/server/gdb_server.c 2009-06-13 00:34:31 UTC (rev 2239)
+++ trunk/src/server/gdb_server.c 2009-06-13 08:38:57 UTC (rev 2240)
@@ -44,7 +44,7 @@
static enum breakpoint_type gdb_breakpoint_override_type;
extern int gdb_error(connection_t *connection, int retval);
-static unsigned short gdb_port;
+static unsigned short gdb_port = 3333;
static const char *DIGITS = "0123456789abcdef";
static void gdb_log_callback(void *priv, const char *file, int line,
@@ -2198,8 +2198,8 @@
if (gdb_port == 0 && server_use_pipes == 0)
{
- LOG_DEBUG("no gdb port specified, using default port 3333");
- gdb_port = 3333;
+ LOG_INFO("gdb port disabled");
+ return ERROR_OK;
}
if (server_use_pipes)
Modified: trunk/src/server/tcl_server.c
===================================================================
--- trunk/src/server/tcl_server.c 2009-06-13 00:34:31 UTC (rev 2239)
+++ trunk/src/server/tcl_server.c 2009-06-13 08:38:57 UTC (rev 2240)
@@ -34,7 +34,7 @@
int tc_outerror; /* flag an output error */
} tcl_connection_t;
-static unsigned short tcl_port = 0;
+static unsigned short tcl_port = 6666;
/* commands */
static int handle_tcl_port_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
@@ -165,8 +165,8 @@
if (tcl_port == 0)
{
- LOG_DEBUG("no tcl port specified, using default port 6666");
- tcl_port = 6666;
+ LOG_INFO("tcl port disabled");
+ return ERROR_OK;
}
retval = add_service("tcl", CONNECTION_TCP, tcl_port, 1, tcl_new_connection, tcl_input, tcl_closed, NULL);
Modified: trunk/src/server/telnet_server.c
===================================================================
--- trunk/src/server/telnet_server.c 2009-06-13 00:34:31 UTC (rev 2239)
+++ trunk/src/server/telnet_server.c 2009-06-13 08:38:57 UTC (rev 2240)
@@ -30,7 +30,7 @@
#include "telnet_server.h"
#include "target_request.h"
-static unsigned short telnet_port = 0;
+static unsigned short telnet_port = 4444;
int handle_exit_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
int handle_telnet_port_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
@@ -596,8 +596,8 @@
if (telnet_port == 0)
{
- LOG_DEBUG("no telnet port specified, using default port 4444");
- telnet_port = 4444;
+ LOG_INFO("telnet port disabled");
+ return ERROR_OK;
}
telnet_service->banner = banner;
|
|
From: <zw...@ma...> - 2009-06-13 02:53:14
|
Author: zwelch
Date: 2009-06-13 02:33:48 +0200 (Sat, 13 Jun 2009)
New Revision: 2233
Modified:
trunk/src/target/target.c
Log:
Improve handle_dump_image_command argument parsing:
- Use parse_u32 to ensure address and size parse properly.
Modified: trunk/src/target/target.c
===================================================================
--- trunk/src/target/target.c 2009-06-13 00:33:42 UTC (rev 2232)
+++ trunk/src/target/target.c 2009-06-13 00:33:48 UTC (rev 2233)
@@ -2266,10 +2266,8 @@
{
fileio_t fileio;
- u32 address;
- u32 size;
u8 buffer[560];
- int retval=ERROR_OK, retvaltemp;
+ int retvaltemp;
duration_t duration;
char *duration_text;
@@ -2282,9 +2280,16 @@
return ERROR_OK;
}
- address = strtoul(args[1], NULL, 0);
- size = strtoul(args[2], NULL, 0);
+ u32 address;
+ int retval = parse_u32(args[1], &address);
+ if (ERROR_OK != retval)
+ return retval;
+ u32 size;
+ retval = parse_u32(args[2], &size);
+ if (ERROR_OK != retval)
+ return retval;
+
if (fileio_open(&fileio, args[0], FILEIO_WRITE, FILEIO_BINARY) != ERROR_OK)
{
return ERROR_OK;
|
|
From: <zw...@ma...> - 2009-06-13 02:35:56
|
Author: zwelch
Date: 2009-06-13 02:33:42 +0200 (Sat, 13 Jun 2009)
New Revision: 2232
Modified:
trunk/src/target/target.c
Log:
Improve handle_load_image_command argument parsing:
- Use parse_u32 to ensure base/min/max addresses parse properly.
Modified: trunk/src/target/target.c
===================================================================
--- trunk/src/target/target.c 2009-06-13 00:33:34 UTC (rev 2231)
+++ trunk/src/target/target.c 2009-06-13 00:33:42 UTC (rev 2232)
@@ -2153,8 +2153,12 @@
/* a base address isn't always necessary, default to 0x0 (i.e. don't relocate) */
if (argc >= 2)
{
+ u32 addr;
+ retval = parse_u32(args[1], &addr);
+ if (ERROR_OK != retval)
+ return ERROR_COMMAND_SYNTAX_ERROR;
+ image.base_address = addr;
image.base_address_set = 1;
- image.base_address = strtoul(args[1], NULL, 0);
}
else
{
@@ -2166,11 +2170,17 @@
if (argc>=4)
{
- min_address=strtoul(args[3], NULL, 0);
+ retval = parse_u32(args[3], &min_address);
+ if (ERROR_OK != retval)
+ return ERROR_COMMAND_SYNTAX_ERROR;
}
if (argc>=5)
{
- max_address=strtoul(args[4], NULL, 0)+min_address;
+ retval = parse_u32(args[4], &max_address);
+ if (ERROR_OK != retval)
+ return ERROR_COMMAND_SYNTAX_ERROR;
+ // use size (given) to find max (required)
+ max_address += min_address;
}
if (min_address>max_address)
|
|
From: <zw...@ma...> - 2009-06-13 02:35:56
|
Author: zwelch
Date: 2009-06-13 02:33:34 +0200 (Sat, 13 Jun 2009)
New Revision: 2231
Modified:
trunk/src/target/target.c
Log:
Improve handle_mw_command argument handling:
- Change: All local variable types are now unsigned.
- Use parse_u32 to ensure address and value parse properly.
- Use parse_uint to ensure count parses properly.
- Move variables to location of first use.
Modified: trunk/src/target/target.c
===================================================================
--- trunk/src/target/target.c 2009-06-13 00:33:25 UTC (rev 2230)
+++ trunk/src/target/target.c 2009-06-13 00:33:34 UTC (rev 2231)
@@ -2074,22 +2074,30 @@
static int handle_mw_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
{
- u32 address = 0;
- u32 value = 0;
- int count = 1;
- int i;
- int wordsize;
- target_t *target = get_current_target(cmd_ctx);
- u8 value_buf[4];
-
if ((argc < 2) || (argc > 3))
return ERROR_COMMAND_SYNTAX_ERROR;
- address = strtoul(args[0], NULL, 0);
- value = strtoul(args[1], NULL, 0);
+ u32 address;
+ int retval = parse_u32(args[0], &address);
+ if (ERROR_OK != retval)
+ return retval;
+
+ u32 value;
+ retval = parse_u32(args[1], &value);
+ if (ERROR_OK != retval)
+ return retval;
+
+ unsigned count = 1;
if (argc == 3)
- count = strtoul(args[2], NULL, 0);
+ {
+ retval = parse_uint(args[2], &count);
+ if (ERROR_OK != retval)
+ return retval;
+ }
+ target_t *target = get_current_target(cmd_ctx);
+ unsigned wordsize;
+ u8 value_buf[4];
switch (cmd[2])
{
case 'w':
@@ -2107,9 +2115,9 @@
default:
return ERROR_COMMAND_SYNTAX_ERROR;
}
- for (i=0; i<count; i++)
+ for (unsigned i = 0; i < count; i++)
{
- int retval = target_write_memory(target,
+ retval = target_write_memory(target,
address + i * wordsize, wordsize, 1, value_buf);
if (ERROR_OK != retval)
return retval;
|
|
From: <zw...@ma...> - 2009-06-13 02:35:54
|
Author: zwelch
Date: 2009-06-13 02:34:10 +0200 (Sat, 13 Jun 2009)
New Revision: 2236
Modified:
trunk/src/target/target.c
Log:
Cleanup and improve handle_wp_command and handle_rwp_command:
- Simplify argument parsing logic using switch statement.
- Use parse_u32 to ensure all values parse properly.
- Return syntax error when mode argument fails to parse.
Modified: trunk/src/target/target.c
===================================================================
--- trunk/src/target/target.c 2009-06-13 00:34:03 UTC (rev 2235)
+++ trunk/src/target/target.c 2009-06-13 00:34:10 UTC (rev 2236)
@@ -2582,7 +2582,6 @@
static int handle_wp_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
{
target_t *target = get_current_target(cmd_ctx);
- int retval;
if (argc == 0)
{
@@ -2593,52 +2592,65 @@
command_print(cmd_ctx, "address: 0x%8.8x, len: 0x%8.8x, r/w/a: %i, value: 0x%8.8x, mask: 0x%8.8x", watchpoint->address, watchpoint->length, watchpoint->rw, watchpoint->value, watchpoint->mask);
watchpoint = watchpoint->next;
}
+ return ERROR_OK;
}
- else if (argc >= 2)
+
+ enum watchpoint_rw type = WPT_ACCESS;
+ u32 addr = 0;
+ u32 length = 0;
+ u32 data_value = 0x0;
+ u32 data_mask = 0xffffffff;
+ int retval;
+
+ switch (argc)
{
- enum watchpoint_rw type = WPT_ACCESS;
- u32 data_value = 0x0;
- u32 data_mask = 0xffffffff;
-
- if (argc >= 3)
+ case 5:
+ retval = parse_u32(args[4], &data_mask);
+ if (ERROR_OK != retval)
+ return retval;
+ // fall through
+ case 4:
+ retval = parse_u32(args[3], &data_value);
+ if (ERROR_OK != retval)
+ return retval;
+ // fall through
+ case 3:
+ switch(args[2][0])
{
- switch(args[2][0])
- {
- case 'r':
- type = WPT_READ;
- break;
- case 'w':
- type = WPT_WRITE;
- break;
- case 'a':
- type = WPT_ACCESS;
- break;
- default:
- command_print(cmd_ctx, "usage: wp <address> <length> [r/w/a] [value] [mask]");
- return ERROR_OK;
- }
+ case 'r':
+ type = WPT_READ;
+ break;
+ case 'w':
+ type = WPT_WRITE;
+ break;
+ case 'a':
+ type = WPT_ACCESS;
+ break;
+ default:
+ LOG_ERROR("invalid watchpoint mode ('%c')", args[2][0]);
+ return ERROR_COMMAND_SYNTAX_ERROR;
}
- if (argc >= 4)
- {
- data_value = strtoul(args[3], NULL, 0);
- }
- if (argc >= 5)
- {
- data_mask = strtoul(args[4], NULL, 0);
- }
+ // fall through
+ case 2:
+ retval = parse_u32(args[1], &length);
+ if (ERROR_OK != retval)
+ return retval;
+ retval = parse_u32(args[0], &addr);
+ if (ERROR_OK != retval)
+ return retval;
+ break;
- if ((retval = watchpoint_add(target, strtoul(args[0], NULL, 0),
- strtoul(args[1], NULL, 0), type, data_value, data_mask)) != ERROR_OK)
- {
- LOG_ERROR("Failure setting breakpoints");
- }
- }
- else
- {
+ default:
command_print(cmd_ctx, "usage: wp <address> <length> [r/w/a] [value] [mask]");
+ return ERROR_COMMAND_SYNTAX_ERROR;
}
- return ERROR_OK;
+ retval = watchpoint_add(target, addr, length, type,
+ data_value, data_mask);
+ if (ERROR_OK != retval)
+ LOG_ERROR("Failure setting watchpoints");
+
+ return retval;
}
static int handle_rwp_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
@@ -2646,8 +2658,13 @@
if (argc != 1)
return ERROR_COMMAND_SYNTAX_ERROR;
+ u32 addr;
+ int retval = parse_u32(args[0], &addr);
+ if (ERROR_OK != retval)
+ return retval;
+
target_t *target = get_current_target(cmd_ctx);
- watchpoint_remove(target, strtoul(args[0], NULL, 0));
+ watchpoint_remove(target, addr);
return ERROR_OK;
}
|
|
From: <zw...@ma...> - 2009-06-13 02:35:16
|
Author: zwelch
Date: 2009-06-13 02:33:55 +0200 (Sat, 13 Jun 2009)
New Revision: 2234
Modified:
trunk/src/target/target.c
Log:
Improve handle_verify_image_command_internal command argument handling:
- Use parse_u32 to ensure address parses properly.
Modified: trunk/src/target/target.c
===================================================================
--- trunk/src/target/target.c 2009-06-13 00:33:48 UTC (rev 2233)
+++ trunk/src/target/target.c 2009-06-13 00:33:55 UTC (rev 2234)
@@ -2366,8 +2366,12 @@
if (argc >= 2)
{
+ u32 addr;
+ retval = parse_u32(args[1], &addr);
+ if (ERROR_OK != retval)
+ return ERROR_COMMAND_SYNTAX_ERROR;
+ image.base_address = addr;
image.base_address_set = 1;
- image.base_address = strtoul(args[1], NULL, 0);
}
else
{
|
|
From: <zw...@ma...> - 2009-06-13 02:35:06
|
Author: zwelch Date: 2009-06-13 02:34:17 +0200 (Sat, 13 Jun 2009) New Revision: 2237 Modified: trunk/src/target/target.c Log: Improve handle_virt2phys_command argument parsing: - Use parse_u32 to ensure virtual address parses properly. Modified: trunk/src/target/target.c =================================================================== --- trunk/src/target/target.c 2009-06-13 00:34:10 UTC (rev 2236) +++ trunk/src/target/target.c 2009-06-13 00:34:17 UTC (rev 2237) @@ -2682,11 +2682,14 @@ if (argc != 1) return ERROR_COMMAND_SYNTAX_ERROR; - target_t *target = get_current_target(cmd_ctx); - u32 va = strtoul(args[0], NULL, 0); + u32 va; + int retval = parse_u32(args[0], &va); + if (ERROR_OK != retval) + return retval; u32 pa; - int retval = target->type->virt2phys(target, va, &pa); + target_t *target = get_current_target(cmd_ctx); + retval = target->type->virt2phys(target, va, &pa); if (retval == ERROR_OK) command_print(cmd_ctx, "Physical address 0x%08x", pa); |
|
From: <zw...@ma...> - 2009-06-13 02:35:03
|
Author: zwelch
Date: 2009-06-13 02:34:03 +0200 (Sat, 13 Jun 2009)
New Revision: 2235
Modified:
trunk/src/target/target.c
Log:
Improve and simplify handle_bp_command and handle_rbp_command:
- Bug fix: return syntax error if remove called without one argument.
- Use parse_u32 to ensure address and length arguments parse properly.
Modified: trunk/src/target/target.c
===================================================================
--- trunk/src/target/target.c 2009-06-13 00:33:55 UTC (rev 2234)
+++ trunk/src/target/target.c 2009-06-13 00:34:03 UTC (rev 2235)
@@ -2541,9 +2541,16 @@
return ERROR_COMMAND_SYNTAX_ERROR;
}
- u32 addr = strtoul(args[0], NULL, 0);
- u32 length = strtoul(args[1], NULL, 0);
+ u32 addr;
+ int retval = parse_u32(args[0], &addr);
+ if (ERROR_OK != retval)
+ return retval;
+ u32 length;
+ retval = parse_u32(args[1], &length);
+ if (ERROR_OK != retval)
+ return retval;
+
int hw = BKPT_SOFT;
if (argc == 3)
{
@@ -2558,11 +2565,17 @@
static int handle_rbp_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
{
+ if (argc != 1)
+ return ERROR_COMMAND_SYNTAX_ERROR;
+
+ u32 addr;
+ int retval = parse_u32(args[0], &addr);
+ if (ERROR_OK != retval)
+ return retval;
+
target_t *target = get_current_target(cmd_ctx);
+ breakpoint_remove(target, addr);
- if (argc > 0)
- breakpoint_remove(target, strtoul(args[0], NULL, 0));
-
return ERROR_OK;
}
|
|
From: <zw...@ma...> - 2009-06-13 02:35:00
|
Author: zwelch
Date: 2009-06-13 02:34:31 +0200 (Sat, 13 Jun 2009)
New Revision: 2239
Modified:
trunk/src/target/target.c
Log:
Factor load_image argument parsing to parse_load_image_command_args:
- Make fast_load_image use the helper coverage the standard load_image.
- Improve whitespace in the moved lines.
Modified: trunk/src/target/target.c
===================================================================
--- trunk/src/target/target.c 2009-06-13 00:34:24 UTC (rev 2238)
+++ trunk/src/target/target.c 2009-06-13 00:34:31 UTC (rev 2239)
@@ -2128,66 +2128,70 @@
}
-static int handle_load_image_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
+static int parse_load_image_command_args(char **args, int argc,
+ image_t *image, u32 *min_address, u32 *max_address)
{
- u8 *buffer;
- u32 buf_cnt;
- u32 image_size;
- u32 min_address=0;
- u32 max_address=0xffffffff;
- int i;
- int retval, retvaltemp;
-
- image_t image;
-
- duration_t duration;
- char *duration_text;
-
- target_t *target = get_current_target(cmd_ctx);
-
- if ((argc < 1)||(argc > 5))
- {
+ if (argc < 1 || argc > 5)
return ERROR_COMMAND_SYNTAX_ERROR;
- }
- /* a base address isn't always necessary, default to 0x0 (i.e. don't relocate) */
+ /* a base address isn't always necessary,
+ * default to 0x0 (i.e. don't relocate) */
if (argc >= 2)
{
u32 addr;
- retval = parse_u32(args[1], &addr);
+ int retval = parse_u32(args[1], &addr);
if (ERROR_OK != retval)
return ERROR_COMMAND_SYNTAX_ERROR;
- image.base_address = addr;
- image.base_address_set = 1;
+ image->base_address = addr;
+ image->base_address_set = 1;
}
else
- {
- image.base_address_set = 0;
- }
+ image->base_address_set = 0;
+ image->start_address_set = 0;
- image.start_address_set = 0;
-
- if (argc>=4)
+ if (argc >= 4)
{
- retval = parse_u32(args[3], &min_address);
+ int retval = parse_u32(args[3], min_address);
if (ERROR_OK != retval)
return ERROR_COMMAND_SYNTAX_ERROR;
}
- if (argc>=5)
+ if (argc == 5)
{
- retval = parse_u32(args[4], &max_address);
+ int retval = parse_u32(args[4], max_address);
if (ERROR_OK != retval)
return ERROR_COMMAND_SYNTAX_ERROR;
// use size (given) to find max (required)
- max_address += min_address;
+ *max_address += *min_address;
}
- if (min_address>max_address)
- {
+ if (*min_address > *max_address)
return ERROR_COMMAND_SYNTAX_ERROR;
- }
+ return ERROR_OK;
+}
+
+static int handle_load_image_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
+{
+ u8 *buffer;
+ u32 buf_cnt;
+ u32 image_size;
+ u32 min_address = 0;
+ u32 max_address = 0xffffffff;
+ int i;
+ int retvaltemp;
+
+ image_t image;
+
+ duration_t duration;
+ char *duration_text;
+
+ int retval = parse_load_image_command_args(args, argc,
+ &image, &min_address, &max_address);
+ if (ERROR_OK != retval)
+ return retval;
+
+ target_t *target = get_current_target(cmd_ctx);
duration_start_measure(&duration);
if (image_open(&image, args[0], (argc >= 3) ? args[2] : NULL) != ERROR_OK)
@@ -4316,46 +4320,17 @@
u32 min_address=0;
u32 max_address=0xffffffff;
int i;
- int retval;
image_t image;
duration_t duration;
char *duration_text;
- if ((argc < 1)||(argc > 5))
- {
- return ERROR_COMMAND_SYNTAX_ERROR;
- }
+ int retval = parse_load_image_command_args(args, argc,
+ &image, &min_address, &max_address);
+ if (ERROR_OK != retval)
+ return retval;
- /* a base address isn't always necessary, default to 0x0 (i.e. don't relocate) */
- if (argc >= 2)
- {
- image.base_address_set = 1;
- image.base_address = strtoul(args[1], NULL, 0);
- }
- else
- {
- image.base_address_set = 0;
- }
-
-
- image.start_address_set = 0;
-
- if (argc>=4)
- {
- min_address=strtoul(args[3], NULL, 0);
- }
- if (argc>=5)
- {
- max_address=strtoul(args[4], NULL, 0)+min_address;
- }
-
- if (min_address>max_address)
- {
- return ERROR_COMMAND_SYNTAX_ERROR;
- }
-
duration_start_measure(&duration);
if (image_open(&image, args[0], (argc >= 3) ? args[2] : NULL) != ERROR_OK)
|
|
From: <zw...@ma...> - 2009-06-13 02:34:58
|
Author: zwelch
Date: 2009-06-13 02:34:24 +0200 (Sat, 13 Jun 2009)
New Revision: 2238
Modified:
trunk/src/target/target.c
Log:
Improve handle_profile_command argument parsing:
- Use parse_uint to ensure timeout value parses properly.
Modified: trunk/src/target/target.c
===================================================================
--- trunk/src/target/target.c 2009-06-13 00:34:17 UTC (rev 2237)
+++ trunk/src/target/target.c 2009-06-13 00:34:24 UTC (rev 2238)
@@ -2823,13 +2823,13 @@
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
- char *end;
- timeval_add_time(&timeout, strtoul(args[0], &end, 0), 0);
- if (*end)
- {
- return ERROR_OK;
- }
+ unsigned offset;
+ int retval = parse_uint(args[0], &offset);
+ if (ERROR_OK != retval)
+ return retval;
+ timeval_add_time(&timeout, offset, 0);
+
command_print(cmd_ctx, "Starting profiling. Halting and resuming the target as often as we can...");
static const int maxSample=10000;
@@ -2838,7 +2838,6 @@
return ERROR_OK;
int numSamples=0;
- int retval=ERROR_OK;
/* hopefully it is safe to cache! We want to stop/restart as quickly as possible. */
reg_t *reg = register_get_by_name(target->reg_cache, "pc", 1);
|
|
From: <zw...@ma...> - 2009-06-13 02:34:55
|
Author: zwelch
Date: 2009-06-13 02:33:25 +0200 (Sat, 13 Jun 2009)
New Revision: 2230
Modified:
trunk/src/target/target.c
Log:
Improve handle_md_command argument handling:
- Use parse_u32 and parse_uint for address and count, respectively.
Modified: trunk/src/target/target.c
===================================================================
--- trunk/src/target/target.c 2009-06-13 00:33:18 UTC (rev 2229)
+++ trunk/src/target/target.c 2009-06-13 00:33:25 UTC (rev 2230)
@@ -2046,16 +2046,23 @@
default: return ERROR_COMMAND_SYNTAX_ERROR;
}
- u32 address = strtoul(args[0], NULL, 0);
+ u32 address;
+ int retval = parse_u32(args[0], &address);
+ if (ERROR_OK != retval)
+ return retval;
unsigned count = 1;
if (argc == 2)
- count = strtoul(args[1], NULL, 0);
+ {
+ retval = parse_uint(args[1], &count);
+ if (ERROR_OK != retval)
+ return retval;
+ }
u8 *buffer = calloc(count, size);
target_t *target = get_current_target(cmd_ctx);
- int retval = target_read_memory(target,
+ retval = target_read_memory(target,
address, size, count, buffer);
if (ERROR_OK == retval)
handle_md_output(cmd_ctx, target, address, size, count, buffer);
|
|
From: <zw...@ma...> - 2009-06-13 02:34:48
|
Author: zwelch
Date: 2009-06-13 02:33:18 +0200 (Sat, 13 Jun 2009)
New Revision: 2229
Modified:
trunk/src/target/target.c
Log:
Use parse_u32 in handle_resume_command and handle_step_command.
Modified: trunk/src/target/target.c
===================================================================
--- trunk/src/target/target.c 2009-06-13 00:33:11 UTC (rev 2228)
+++ trunk/src/target/target.c 2009-06-13 00:33:18 UTC (rev 2229)
@@ -1954,7 +1954,11 @@
* handle breakpoints, not debugging */
u32 addr = 0;
if (argc == 1)
- addr = strtoul(args[0], NULL, 0);
+ {
+ int retval = parse_u32(args[0], &addr);
+ if (ERROR_OK != retval)
+ return retval;
+ }
return target_resume(target, 0, addr, 1, 0);
}
@@ -1971,7 +1975,11 @@
* handle breakpoints, debugging */
u32 addr = 0;
if (argc == 1)
- addr = strtoul(args[0], NULL, 0);
+ {
+ int retval = parse_u32(args[0], &addr);
+ if (ERROR_OK != retval)
+ return retval;
+ }
target_t *target = get_current_target(cmd_ctx);
return target->type->step(target, 0, addr, 1);
|
|
From: <zw...@ma...> - 2009-06-13 02:34:42
|
Author: zwelch
Date: 2009-06-13 02:33:01 +0200 (Sat, 13 Jun 2009)
New Revision: 2227
Modified:
trunk/src/target/target.c
Log:
Cleanup and fi handle_wait_halt_command:
- Use unsigned type for delay variable.
- Use parse_uint to ensure delay argument parses properly.
- Bug fix: Return syntax error if more than one argument is given.
- Bug fix: Return syntax error when argument fails to parse.
Modified: trunk/src/target/target.c
===================================================================
--- trunk/src/target/target.c 2009-06-13 00:32:54 UTC (rev 2226)
+++ trunk/src/target/target.c 2009-06-13 00:33:01 UTC (rev 2227)
@@ -1822,21 +1822,23 @@
static int handle_wait_halt_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
{
- int ms = 5000;
+ if (argc > 1)
+ return ERROR_COMMAND_SYNTAX_ERROR;
- if (argc > 0)
+ unsigned ms = 5000;
+ if (1 == argc)
{
- char *end;
-
- ms = strtoul(args[0], &end, 0) * 1000;
- if (*end)
+ int retval = parse_uint(args[0], &ms);
+ if (ERROR_OK != retval)
{
command_print(cmd_ctx, "usage: %s [seconds]", cmd);
- return ERROR_OK;
+ return ERROR_COMMAND_SYNTAX_ERROR;
}
+ // convert seconds (given) to milliseconds (needed)
+ ms *= 1000;
}
+
target_t *target = get_current_target(cmd_ctx);
-
return target_wait_state(target, TARGET_HALTED, ms);
}
|
|
From: <zw...@ma...> - 2009-06-13 02:34:42
|
Author: zwelch
Date: 2009-06-13 02:33:11 +0200 (Sat, 13 Jun 2009)
New Revision: 2228
Modified:
trunk/src/target/target.c
Log:
Cleanup and improve handle_halt_command:
- Make argument check use parse_uint to ensure value parses properly.
- Move variable declarations to location of first use.
Modified: trunk/src/target/target.c
===================================================================
--- trunk/src/target/target.c 2009-06-13 00:33:01 UTC (rev 2227)
+++ trunk/src/target/target.c 2009-06-13 00:33:11 UTC (rev 2228)
@@ -1889,23 +1889,20 @@
static int handle_halt_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
{
- int retval;
- target_t *target = get_current_target(cmd_ctx);
-
LOG_DEBUG("-");
- if ((retval = target_halt(target)) != ERROR_OK)
- {
+ target_t *target = get_current_target(cmd_ctx);
+ int retval = target_halt(target);
+ if (ERROR_OK != retval)
return retval;
- }
if (argc == 1)
{
- int wait;
- char *end;
-
- wait = strtoul(args[0], &end, 0);
- if (!*end && !wait)
+ unsigned wait;
+ retval = parse_uint(args[0], &wait);
+ if (ERROR_OK != retval)
+ return ERROR_COMMAND_SYNTAX_ERROR;
+ if (!wait)
return ERROR_OK;
}
|
|
From: <zw...@ma...> - 2009-06-13 02:34:39
|
Author: zwelch
Date: 2009-06-13 02:32:54 +0200 (Sat, 13 Jun 2009)
New Revision: 2226
Modified:
trunk/src/target/target.c
Log:
Use parse_uint in handle_reg_command to ensure reg number parses properly.
Modified: trunk/src/target/target.c
===================================================================
--- trunk/src/target/target.c 2009-06-13 00:32:40 UTC (rev 2225)
+++ trunk/src/target/target.c 2009-06-13 00:32:54 UTC (rev 2226)
@@ -1704,16 +1704,19 @@
/* access a single register by its ordinal number */
if ((args[0][0] >= '0') && (args[0][0] <= '9'))
{
- int num = strtoul(args[0], NULL, 0);
+ unsigned num;
+ int retval = parse_uint(args[0], &num);
+ if (ERROR_OK != retval)
+ return ERROR_COMMAND_SYNTAX_ERROR;
+
reg_cache_t *cache = target->reg_cache;
-
count = 0;
while(cache)
{
int i;
for (i = 0; i < cache->num_regs; i++)
{
- if (count++ == num)
+ if (count++ == (int)num)
{
reg = &cache->reg_list[i];
break;
|
|
From: <zw...@ma...> - 2009-06-13 02:34:38
|
Author: zwelch
Date: 2009-06-13 02:32:40 +0200 (Sat, 13 Jun 2009)
New Revision: 2225
Modified:
trunk/src/target/target.c
Log:
Use parse_uint in get_target to ensure target id is parsed properly.
Modified: trunk/src/target/target.c
===================================================================
--- trunk/src/target/target.c 2009-06-12 22:06:02 UTC (rev 2224)
+++ trunk/src/target/target.c 2009-06-13 00:32:40 UTC (rev 2225)
@@ -323,8 +323,6 @@
target_t *get_target(const char *id)
{
target_t *target;
- char *endptr;
- int num;
/* try as tcltarget name */
for (target = all_targets; target; target = target->next) {
@@ -335,12 +333,12 @@
}
/* no match, try as number */
- num = strtoul(id, &endptr, 0);
- if (*endptr != 0)
+ unsigned num;
+ if (parse_uint(id, &num) != ERROR_OK)
return NULL;
for (target = all_targets; target; target = target->next) {
- if (target->target_number == num)
+ if (target->target_number == (int)num)
return target;
}
|
|
From: <zw...@ma...> - 2009-06-13 00:06:07
|
Author: zwelch
Date: 2009-06-13 00:06:02 +0200 (Sat, 13 Jun 2009)
New Revision: 2224
Modified:
trunk/src/helper/command.c
trunk/src/helper/command.h
trunk/src/jtag/tcl.c
Log:
David Brownell <da...@pa...>:
Currently the "debug_level 3" command tracing ignores commands
that could return values to TCL scripts (by plugging in to a
slightly lower level of the interpreter stack).
Fix that by abstracting the tracing command and starting to
make some of those previously-untraced commands use this new
mechanism.
Modified: trunk/src/helper/command.c
===================================================================
--- trunk/src/helper/command.c 2009-06-12 21:53:17 UTC (rev 2223)
+++ trunk/src/helper/command.c 2009-06-12 22:06:02 UTC (rev 2224)
@@ -61,6 +61,23 @@
extern command_context_t *global_cmd_ctx;
+void script_debug(Jim_Interp *interp, const char *name, int argc, Jim_Obj *const *argv)
+{
+ int i;
+
+ LOG_DEBUG("command - %s", name);
+ for (i = 0; i < argc; i++) {
+ int len;
+ const char *w = Jim_GetString(argv[i], &len);
+
+ /* end of line comment? */
+ if (*w == '#')
+ break;
+
+ LOG_DEBUG("%s - argv[%d]=%s", name, i, w);
+ }
+}
+
static int script_command(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
/* the private data is stashed in the interp structure */
@@ -85,7 +102,7 @@
target_call_timer_callbacks_now();
LOG_USER_N("%s", ""); /* Keep GDB connection alive*/
- LOG_DEBUG("script_command - %s", c->name);
+ script_debug(interp, c->name, argc, argv);
words = malloc(sizeof(char *) * argc);
for (i = 0; i < argc; i++)
@@ -102,7 +119,6 @@
{
return JIM_ERR;
}
- LOG_DEBUG("script_command - %s, argv[%u]=%s", c->name, i, words[i]);
}
nwords = i;
Modified: trunk/src/helper/command.h
===================================================================
--- trunk/src/helper/command.h 2009-06-12 21:53:17 UTC (rev 2223)
+++ trunk/src/helper/command.h 2009-06-12 22:06:02 UTC (rev 2224)
@@ -123,4 +123,6 @@
DEFINE_PARSE_ULONG(u16, uint16_t, UINT16_MAX)
DEFINE_PARSE_ULONG(u8, uint8_t, UINT8_MAX)
+void script_debug(Jim_Interp *interp, const char *cmd, int argc, Jim_Obj *const *argv);
+
#endif /* COMMAND_H */
Modified: trunk/src/jtag/tcl.c
===================================================================
--- trunk/src/jtag/tcl.c 2009-06-12 21:53:17 UTC (rev 2223)
+++ trunk/src/jtag/tcl.c 2009-06-12 22:06:02 UTC (rev 2224)
@@ -1248,6 +1248,8 @@
endstate = TAP_IDLE;
+ script_debug(interp, "drscan", argc, args);
+
/* validate arguments as numbers */
e = JIM_OK;
for (i = 2; i < argc; i+=2)
@@ -1369,6 +1371,8 @@
return JIM_ERR;
}
+ script_debug(interp, "pathmove", argc, args);
+
int i;
for (i=0; i<argc-1; i++)
{
@@ -1403,6 +1407,8 @@
static int Jim_Command_flush_count(Jim_Interp *interp, int argc, Jim_Obj *const *args)
{
+ script_debug(interp, "flush_count", argc, args);
+
Jim_SetResult(interp, Jim_NewIntObj(interp, jtag_get_flush_queue_count()));
return JIM_OK;
|
|
From: <zw...@ma...> - 2009-06-12 23:53:20
|
Author: zwelch
Date: 2009-06-12 23:53:17 +0200 (Fri, 12 Jun 2009)
New Revision: 2223
Modified:
trunk/doc/openocd.texi
Log:
David Brownell <da...@pa...>:
Move the discussion of the "scan_chain" command up to go with
the presentation of that topic in the TAP declaration chapter.
This makes the presentation of the TAP and target lists be
parallel, which will be something of an aid to understanding
that they are different (and how).
Modified: trunk/doc/openocd.texi
===================================================================
--- trunk/doc/openocd.texi 2009-06-12 21:43:53 UTC (rev 2222)
+++ trunk/doc/openocd.texi 2009-06-12 21:53:17 UTC (rev 2223)
@@ -2132,22 +2132,43 @@
@section Scan Chains
-OpenOCD uses a JTAG adapter (interface) to talk to your board,
-which has a daisy chain of TAPs.
-That daisy chain is called a @dfn{scan chain}.
-Simple configurations may have a single TAP in the scan chain,
-perhaps for a microcontroller.
-Complex configurations might have a dozen or more TAPs:
+TAPs are part of a hardware @dfn{scan chain},
+which is daisy chain of TAPs.
+They also need to be added to
+OpenOCD's software mirror of that hardware list,
+giving each member a name and associating other data with it.
+Simple scan chains, with a single TAP, are common in
+systems with a single microcontroller or microprocessor.
+More complex chips may have several TAPs internally.
+Very complex scan chains might have a dozen or more TAPs:
several in one chip, more in the next, and connecting
to other boards with their own chips and TAPs.
+You can display the list with the @command{scan_chain} command.
+(Don't confuse this with the list displayed by the @command{targets}
+command, presented in the next chapter.
+That only displays TAPs for CPUs which are configured as
+debugging targets.)
+Here's what the scan chain might look like for a chip more than one TAP:
+
+@verbatim
+ TapName Enabled IdCode Expected IrLen IrCap IrMask Instr
+-- ------------------ ------- ---------- ---------- ----- ----- ------ -----
+ 0 omap5912.dsp Y 0x03df1d81 0x03df1d81 38 0 0 0x...
+ 1 omap5912.arm Y 0x0692602f 0x0692602f 4 0x1 0 0xc
+ 2 omap5912.unknown Y 0x00000000 0x00000000 8 0 0 0xff
+@end verbatim
+
Unfortunately those TAPs can't always be autoconfigured,
because not all devices provide good support for that.
-(JTAG doesn't require supporting IDCODE instructions.)
+JTAG doesn't require supporting IDCODE instructions, and
+chips with JTAG routers may not link TAPs into the chain
+until they are told to do so.
+
The configuration mechanism currently supported by OpenOCD
requires explicit configuration of all TAP devices using
-@command{jtag newtap} commands.
-One like this would declare a tap and name it @code{chip1.cpu}:
+@command{jtag newtap} commands, as detailed later in this chapter.
+A command like this would declare one tap and name it @code{chip1.cpu}:
@example
jtag newtap chip1 cpu -irlen 7 -ircapture 0x01 -irmask 0x55
@@ -2180,6 +2201,29 @@
@option{str912}, to support more than one chip of each type.
@xref{Config File Guidelines}.
+At this writing there is only a single command to work with
+scan chains, and there is no support for enumerating
+TAPs or examining their attributes.
+
+@deffn Command {scan_chain}
+Displays the TAPs in the scan chain configuration,
+and their status.
+The set of TAPs listed by this command is fixed by
+exiting the OpenOCD configuration stage,
+but systems with a JTAG router can
+enable or disable TAPs dynamically.
+In addition to the enable/disable status, the contents of
+each TAP's instruction register can also change.
+@end deffn
+
+@c FIXME! there should be commands to enumerate TAPs
+@c and get their attributes, like there are for targets.
+@c "jtag cget ..." will handle attributes.
+@c "jtag names" for enumerating TAPs, maybe.
+
+@c Probably want "jtag eventlist", and a "tap-reset" event
+@c (on entry to RESET state).
+
@section TAP Names
When TAP objects are declared with @command{jtag newtap},
@@ -2202,7 +2246,7 @@
should not be counted upon.
Update all of your scripts to use TAP names rather than numbers.
Using TAP numbers in target configuration scripts prevents
-reusing on boards with multiple targets.
+reusing those scripts on boards with multiple targets.
@end quotation
@section TAP Declaration Commands
@@ -4981,17 +5025,6 @@
to execute before they take effect.
@end deffn
-@deffn Command {scan_chain}
-Displays the TAPs in the scan chain configuration,
-and their status.
-The set of TAPs listed by this command is fixed by
-exiting the OpenOCD configuration stage,
-but systems with a JTAG router can
-enable or disable TAPs dynamically.
-In addition to the enable/disable status, the contents of
-each TAP's instruction register can also change.
-@end deffn
-
@c tms_sequence (short|long)
@c ... temporary, debug-only, probably gone before 0.2 ships
|
|
From: <zw...@ma...> - 2009-06-12 23:43:57
|
Author: zwelch
Date: 2009-06-12 23:43:53 +0200 (Fri, 12 Jun 2009)
New Revision: 2222
Modified:
trunk/src/jtag/core.c
trunk/src/jtag/tcl.c
Log:
David Brownell <da...@pa...>:
Partial fix to the "long IR length" problems.
- Current code could handle up to 32 bit IR lengths with
full functionality, if it didn't just reject may of them
out of hand. So only reject clear errors, where the IR
mask (or capture instruction) needs more than IrLen bits.
- Longer IR lengths can only be handled in BYPASS mode
for now. Example: TI's DSPs use 38-bit IR lengths.
So we can't issue their IDCODE instructions...
A more complete fix would be able to issue longer instructions;
or minimally, would fail cleanly for the non-BYPASS case.
Note that this *could* make some currently broken scripts fail,
since the previous code accepted garbage values so long as
they didn't use more than 16 bits.
Modified: trunk/src/jtag/core.c
===================================================================
--- trunk/src/jtag/core.c 2009-06-12 21:31:11 UTC (rev 2221)
+++ trunk/src/jtag/core.c 2009-06-12 21:43:53 UTC (rev 2222)
@@ -1073,6 +1073,7 @@
tap->expected_mask = malloc(tap->ir_length);
tap->cur_instr = malloc(tap->ir_length);
+ /// @todo cope sanely with ir_length bigger than 32 bits
buf_set_u32(tap->expected, 0, tap->ir_length, tap->ir_capture_value);
buf_set_u32(tap->expected_mask, 0, tap->ir_length, tap->ir_capture_mask);
buf_set_ones(tap->cur_instr, tap->ir_length);
Modified: trunk/src/jtag/tcl.c
===================================================================
--- trunk/src/jtag/tcl.c 2009-06-12 21:31:11 UTC (rev 2221)
+++ trunk/src/jtag/tcl.c 2009-06-12 21:43:53 UTC (rev 2222)
@@ -296,7 +296,16 @@
return JIM_OK;
}
+static int is_bad_irval(int ir_length, jim_wide w)
+{
+ jim_wide v = 1;
+ v <<= ir_length;
+ v -= 1;
+ v = ~v;
+ return (w & v) != 0;
+}
+
extern void jtag_tap_init(jtag_tap_t *tap);
extern void jtag_tap_free(jtag_tap_t *tap);
@@ -411,22 +420,28 @@
Jim_SetResult_sprintf( goi->interp, "option: %s bad parameter", n->name );
return e;
}
- if( (w < 0) || (w > 0xffff) ){
- /* wacky value */
- Jim_SetResult_sprintf( goi->interp, "option: %s - wacky value: %d (0x%x)",
- n->name, (int)(w), (int)(w));
- return JIM_ERR;
- }
switch(n->value){
case NTAP_OPT_IRLEN:
+ if (w < (jim_wide) sizeof(pTap->ir_capture_value))
+ LOG_WARNING("huge IR length %d", (int) w);
pTap->ir_length = w;
reqbits &= (~(NTREQ_IRLEN));
break;
case NTAP_OPT_IRMASK:
+ if (is_bad_irval(pTap->ir_length, w)) {
+ LOG_ERROR("IR mask %x too big",
+ (int) w);
+ return ERROR_FAIL;
+ }
pTap->ir_capture_mask = w;
reqbits &= (~(NTREQ_IRMASK));
break;
case NTAP_OPT_IRCAPTURE:
+ if (is_bad_irval(pTap->ir_length, w)) {
+ LOG_ERROR("IR capture %x too big",
+ (int) w);
+ return ERROR_FAIL;
+ }
pTap->ir_capture_value = w;
reqbits &= (~(NTREQ_IRCAPTURE));
break;
|
|
From: <zw...@ma...> - 2009-06-12 23:31:15
|
Author: zwelch
Date: 2009-06-12 23:31:11 +0200 (Fri, 12 Jun 2009)
New Revision: 2221
Modified:
trunk/src/flash/mflash.c
trunk/src/flash/mflash.h
Log:
unsik Kim <don...@gm...>:
Improve error handling in mflash driver.
Modified: trunk/src/flash/mflash.c
===================================================================
--- trunk/src/flash/mflash.c 2009-06-12 04:14:28 UTC (rev 2220)
+++ trunk/src/flash/mflash.c 2009-06-12 21:31:11 UTC (rev 2221)
@@ -141,7 +141,7 @@
} else if (gpio.port[0] == 'j') {
gpio_con = S3C2440_GPJCON;
} else {
- LOG_ERROR("invalid port %d%s", gpio.num, gpio.port);
+ LOG_ERROR("mflash: invalid port %d%s", gpio.num, gpio.port);
return ERROR_INVALID_ARGUMENTS;
}
@@ -173,7 +173,7 @@
} else if (gpio.port[0] == 'j') {
gpio_dat = S3C2440_GPJDAT;
} else {
- LOG_ERROR("invalid port %d%s", gpio.num, gpio.port);
+ LOG_ERROR("mflash: invalid port %d%s", gpio.num, gpio.port);
return ERROR_INVALID_ARGUMENTS;
}
@@ -198,12 +198,16 @@
static int mg_init_gpio (void)
{
+ int ret;
mflash_gpio_drv_t *gpio_drv = mflash_bank->gpio_drv;
- gpio_drv->set_gpio_to_output(mflash_bank->rst_pin);
- gpio_drv->set_gpio_output_val(mflash_bank->rst_pin, 1);
+ ret = gpio_drv->set_gpio_to_output(mflash_bank->rst_pin);
+ if (ret != ERROR_OK)
+ return ret;
- return ERROR_OK;
+ ret = gpio_drv->set_gpio_output_val(mflash_bank->rst_pin, 1);
+
+ return ret;
}
static int mg_dsk_wait(mg_io_type_wait wait, u32 time)
@@ -212,13 +216,16 @@
target_t *target = mflash_bank->target;
u32 mg_task_reg = mflash_bank->base + MG_REG_OFFSET;
duration_t duration;
+ int ret;
long long t=0;
duration_start_measure(&duration);
while (time) {
- target_read_u8(target, mg_task_reg + MG_REG_STATUS, &status);
+ ret = target_read_u8(target, mg_task_reg + MG_REG_STATUS, &status);
+ if (ret != ERROR_OK)
+ return ret;
if (status & mg_io_rbit_status_busy)
{
@@ -244,19 +251,13 @@
/* Now we check the error condition! */
if (status & mg_io_rbit_status_error)
{
- target_read_u8(target, mg_task_reg + MG_REG_ERROR, &error);
+ ret = target_read_u8(target, mg_task_reg + MG_REG_ERROR, &error);
+ if (ret != ERROR_OK)
+ return ret;
- if (error & mg_io_rbit_err_bad_sect_num) {
- LOG_ERROR("sector not found");
- return ERROR_FAIL;
- }
- else if (error & (mg_io_rbit_err_bad_block | mg_io_rbit_err_uncorrectable)) {
- LOG_ERROR("bad block");
- return ERROR_FAIL;
- } else {
- LOG_ERROR("disk operation fail");
- return ERROR_FAIL;
- }
+ LOG_ERROR("mflash: io error 0x%02x", error);
+
+ return ERROR_MG_IO;
}
switch (wait)
@@ -283,8 +284,8 @@
break;
}
- LOG_ERROR("timeout occured");
- return ERROR_FAIL;
+ LOG_ERROR("mflash: timeout occured");
+ return ERROR_MG_TIMEOUT;
}
static int mg_dsk_srst(u8 on)
@@ -312,74 +313,85 @@
target_t *target = mflash_bank->target;
u32 mg_task_reg = mflash_bank->base + MG_REG_OFFSET;
u8 value;
+ int ret;
- if (mg_dsk_wait(mg_io_wait_rdy_noerr, MG_OEM_DISK_WAIT_TIME_NORMAL) != ERROR_OK)
- return ERROR_FAIL;
+ ret = mg_dsk_wait(mg_io_wait_rdy_noerr, MG_OEM_DISK_WAIT_TIME_NORMAL);
+ if (ret != ERROR_OK)
+ return ret;
value = mg_io_rval_dev_drv_master | mg_io_rval_dev_lba_mode |((sect_num >> 24) & 0xf);
- target_write_u8(target, mg_task_reg + MG_REG_DRV_HEAD, value);
- target_write_u8(target, mg_task_reg + MG_REG_SECT_CNT, (u8)cnt);
- target_write_u8(target, mg_task_reg + MG_REG_SECT_NUM, (u8)sect_num);
- target_write_u8(target, mg_task_reg + MG_REG_CYL_LOW, (u8)(sect_num >> 8));
- target_write_u8(target, mg_task_reg + MG_REG_CYL_HIGH, (u8)(sect_num >> 16));
+ ret = target_write_u8(target, mg_task_reg + MG_REG_DRV_HEAD, value);
+ ret |= target_write_u8(target, mg_task_reg + MG_REG_SECT_CNT, (u8)cnt);
+ ret |= target_write_u8(target, mg_task_reg + MG_REG_SECT_NUM, (u8)sect_num);
+ ret |= target_write_u8(target, mg_task_reg + MG_REG_CYL_LOW, (u8)(sect_num >> 8));
+ ret |= target_write_u8(target, mg_task_reg + MG_REG_CYL_HIGH, (u8)(sect_num >> 16));
- target_write_u8(target, mg_task_reg + MG_REG_COMMAND, cmd);
+ if (ret != ERROR_OK)
+ return ret;
- return ERROR_OK;
+ return target_write_u8(target, mg_task_reg + MG_REG_COMMAND, cmd);
}
static int mg_dsk_drv_info(void)
{
target_t *target = mflash_bank->target;
u32 mg_buff = mflash_bank->base + MG_BUFFER_OFFSET;
+ int ret;
- if ( mg_dsk_io_cmd(0, 1, mg_io_cmd_identify) != ERROR_OK)
- return ERROR_FAIL;
+ if ((ret = mg_dsk_io_cmd(0, 1, mg_io_cmd_identify)) != ERROR_OK)
+ return ret;
- if ( mg_dsk_wait(mg_io_wait_drq, MG_OEM_DISK_WAIT_TIME_NORMAL) != ERROR_OK)
- return ERROR_FAIL;
+ if ((ret = mg_dsk_wait(mg_io_wait_drq, MG_OEM_DISK_WAIT_TIME_NORMAL)) != ERROR_OK)
+ return ret;
- LOG_INFO("read drive info.");
+ LOG_INFO("mflash: read drive info");
if (! mflash_bank->drv_info)
mflash_bank->drv_info = malloc(sizeof(mg_drv_info_t));
target_read_memory(target, mg_buff, 2, sizeof(mg_io_type_drv_info) >> 1,
(u8 *)&mflash_bank->drv_info->drv_id);
+ if (ret != ERROR_OK)
+ return ret;
mflash_bank->drv_info->tot_sects = (u32)(mflash_bank->drv_info->drv_id.total_user_addressable_sectors_hi << 16)
+ mflash_bank->drv_info->drv_id.total_user_addressable_sectors_lo;
- target_write_u8(target, mflash_bank->base + MG_REG_OFFSET + MG_REG_COMMAND, mg_io_cmd_confirm_read);
-
- return ERROR_OK;
+ return target_write_u8(target, mflash_bank->base + MG_REG_OFFSET + MG_REG_COMMAND, mg_io_cmd_confirm_read);
}
static int mg_mflash_rst(void)
{
- mg_init_gpio();
+ int ret;
- mg_hdrst(0);
+ if ((ret = mg_init_gpio()) != ERROR_OK)
+ return ret;
- if (mg_dsk_wait(mg_io_wait_bsy, MG_OEM_DISK_WAIT_TIME_LONG) != ERROR_OK)
- return ERROR_FAIL;
+ if ((ret = mg_hdrst(0)) != ERROR_OK)
+ return ret;
- mg_hdrst(1);
+ if ((ret = mg_dsk_wait(mg_io_wait_bsy, MG_OEM_DISK_WAIT_TIME_LONG)) != ERROR_OK)
+ return ret;
- if (mg_dsk_wait(mg_io_wait_not_bsy, MG_OEM_DISK_WAIT_TIME_LONG) != ERROR_OK)
- return ERROR_FAIL;
+ if ((ret = mg_hdrst(1)) != ERROR_OK)
+ return ret;
- mg_dsk_srst(1);
+ if ((ret = mg_dsk_wait(mg_io_wait_not_bsy, MG_OEM_DISK_WAIT_TIME_LONG)) != ERROR_OK)
+ return ret;
- if (mg_dsk_wait(mg_io_wait_bsy, MG_OEM_DISK_WAIT_TIME_LONG) != ERROR_OK)
- return ERROR_FAIL;
+ if ((ret = mg_dsk_srst(1)) != ERROR_OK)
+ return ret;
- mg_dsk_srst(0);
+ if ((ret = mg_dsk_wait(mg_io_wait_bsy, MG_OEM_DISK_WAIT_TIME_LONG)) != ERROR_OK)
+ return ret;
- if (mg_dsk_wait(mg_io_wait_not_bsy, MG_OEM_DISK_WAIT_TIME_LONG) != ERROR_OK)
- return ERROR_FAIL;
+ if ((ret = mg_dsk_srst(0)) != ERROR_OK)
+ return ret;
+ if ((ret = mg_dsk_wait(mg_io_wait_not_bsy, MG_OEM_DISK_WAIT_TIME_LONG)) != ERROR_OK)
+ return ret;
+
LOG_INFO("mflash: reset ok");
return ERROR_OK;
@@ -387,13 +399,12 @@
static int mg_mflash_probe(void)
{
- if (mg_mflash_rst() != ERROR_OK)
- return ERROR_FAIL;
+ int ret;
- if (mg_dsk_drv_info() != ERROR_OK)
- return ERROR_FAIL;
+ if ((ret = mg_mflash_rst()) != ERROR_OK)
+ return ret;
- return ERROR_OK;
+ return mg_dsk_drv_info();
}
static int mg_probe_cmd(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
@@ -418,59 +429,68 @@
u8 *buff_ptr = buff;
duration_t duration;
- if ( mg_dsk_io_cmd(sect_num, sect_cnt, mg_io_cmd_read) != ERROR_OK )
- return ERROR_FAIL;
+ if ((ret = mg_dsk_io_cmd(sect_num, sect_cnt, mg_io_cmd_read)) != ERROR_OK )
+ return ret;
address = mflash_bank->base + MG_BUFFER_OFFSET;
duration_start_measure(&duration);
for (i = 0; i < sect_cnt; i++) {
- mg_dsk_wait(mg_io_wait_drq, MG_OEM_DISK_WAIT_TIME_NORMAL);
+ ret = mg_dsk_wait(mg_io_wait_drq, MG_OEM_DISK_WAIT_TIME_NORMAL);
+ if (ret != ERROR_OK)
+ return ret;
- target_read_memory(target, address, 2, MG_MFLASH_SECTOR_SIZE / 2, buff_ptr);
+ ret = target_read_memory(target, address, 2, MG_MFLASH_SECTOR_SIZE / 2, buff_ptr);
+ if (ret != ERROR_OK)
+ return ret;
+
buff_ptr += MG_MFLASH_SECTOR_SIZE;
- target_write_u8(target, mflash_bank->base + MG_REG_OFFSET + MG_REG_COMMAND, mg_io_cmd_confirm_read);
+ ret = target_write_u8(target, mflash_bank->base + MG_REG_OFFSET + MG_REG_COMMAND, mg_io_cmd_confirm_read);
+ if (ret != ERROR_OK)
+ return ret;
- LOG_DEBUG("%u (0x%8.8x) sector read", sect_num + i, (sect_num + i) * MG_MFLASH_SECTOR_SIZE);
+ LOG_DEBUG("mflash: %u (0x%8.8x) sector read", sect_num + i, (sect_num + i) * MG_MFLASH_SECTOR_SIZE);
duration_stop_measure(&duration, NULL);
if ((duration.duration.tv_sec * 1000 + duration.duration.tv_usec / 1000) > 3000) {
- LOG_INFO("read %u'th sectors", sect_num + i);
+ LOG_INFO("mflash: read %u'th sectors", sect_num + i);
duration_start_measure(&duration);
}
}
- ret = mg_dsk_wait(mg_io_wait_rdy, MG_OEM_DISK_WAIT_TIME_NORMAL);
-
- return ret;
+ return mg_dsk_wait(mg_io_wait_rdy, MG_OEM_DISK_WAIT_TIME_NORMAL);
}
static int mg_mflash_read_sects(void *buff, u32 sect_num, u32 sect_cnt)
{
u32 quotient, residue, i;
u8 *buff_ptr = buff;
+ int ret = ERROR_OK;
quotient = sect_cnt >> 8;
residue = sect_cnt % 256;
for (i = 0; i < quotient; i++) {
- LOG_DEBUG("sect num : %u buff : 0x%0lx", sect_num,
+ LOG_DEBUG("mflash: sect num : %u buff : 0x%0lx", sect_num,
(unsigned long)buff_ptr);
- mg_mflash_do_read_sects(buff_ptr, sect_num, 256);
+ ret = mg_mflash_do_read_sects(buff_ptr, sect_num, 256);
+ if (ret != ERROR_OK)
+ return ret;
+
sect_num += 256;
buff_ptr += 256 * MG_MFLASH_SECTOR_SIZE;
}
if (residue) {
- LOG_DEBUG("sect num : %u buff : %0lx", sect_num,
+ LOG_DEBUG("mflash: sect num : %u buff : %0lx", sect_num,
(unsigned long)buff_ptr);
- mg_mflash_do_read_sects(buff_ptr, sect_num, residue);
+ return mg_mflash_do_read_sects(buff_ptr, sect_num, residue);
}
- return ERROR_OK;
+ return ret;
}
static int mg_mflash_do_write_sects(void *buff, u32 sect_num, u32 sect_cnt,
@@ -482,8 +502,8 @@
u8 *buff_ptr = buff;
duration_t duration;
- if ( mg_dsk_io_cmd(sect_num, sect_cnt, cmd) != ERROR_OK )
- return ERROR_FAIL;
+ if ((ret = mg_dsk_io_cmd(sect_num, sect_cnt, cmd)) != ERROR_OK )
+ return ret;
address = mflash_bank->base + MG_BUFFER_OFFSET;
@@ -492,23 +512,24 @@
for (i = 0; i < sect_cnt; i++) {
ret = mg_dsk_wait(mg_io_wait_drq, MG_OEM_DISK_WAIT_TIME_NORMAL);
if (ret != ERROR_OK)
- LOG_ERROR("mg_io_wait_drq time out");
+ return ret;
ret = target_write_memory(target, address, 2, MG_MFLASH_SECTOR_SIZE / 2, buff_ptr);
if (ret != ERROR_OK)
- LOG_ERROR("mem write error");
+ return ret;
+
buff_ptr += MG_MFLASH_SECTOR_SIZE;
ret = target_write_u8(target, mflash_bank->base + MG_REG_OFFSET + MG_REG_COMMAND, mg_io_cmd_confirm_write);
if (ret != ERROR_OK)
- LOG_ERROR("mg_io_cmd_confirm_write error");
+ return ret;
- LOG_DEBUG("%u (0x%8.8x) sector write", sect_num + i, (sect_num + i) * MG_MFLASH_SECTOR_SIZE);
+ LOG_DEBUG("mflash: %u (0x%8.8x) sector write", sect_num + i, (sect_num + i) * MG_MFLASH_SECTOR_SIZE);
duration_stop_measure(&duration, NULL);
if ((duration.duration.tv_sec * 1000 + duration.duration.tv_usec / 1000) > 3000) {
- LOG_INFO("wrote %u'th sectors", sect_num + i);
+ LOG_INFO("mflash: wrote %u'th sectors", sect_num + i);
duration_start_measure(&duration);
}
}
@@ -525,51 +546,57 @@
{
u32 quotient, residue, i;
u8 *buff_ptr = buff;
+ int ret = ERROR_OK;
quotient = sect_cnt >> 8;
residue = sect_cnt % 256;
for (i = 0; i < quotient; i++) {
- LOG_DEBUG("sect num : %u buff : %0lx", sect_num,
+ LOG_DEBUG("mflash: sect num : %u buff : %0lx", sect_num,
(unsigned long)buff_ptr);
- mg_mflash_do_write_sects(buff_ptr, sect_num, 256, mg_io_cmd_write);
+ ret = mg_mflash_do_write_sects(buff_ptr, sect_num, 256, mg_io_cmd_write);
+ if (ret != ERROR_OK)
+ return ret;
+
sect_num += 256;
buff_ptr += 256 * MG_MFLASH_SECTOR_SIZE;
}
if (residue) {
- LOG_DEBUG("sect num : %u buff : %0lx", sect_num,
+ LOG_DEBUG("mflash: sect num : %u buff : %0lx", sect_num,
(unsigned long)buff_ptr);
- mg_mflash_do_write_sects(buff_ptr, sect_num, residue, mg_io_cmd_write);
+ return mg_mflash_do_write_sects(buff_ptr, sect_num, residue, mg_io_cmd_write);
}
- return ERROR_OK;
+ return ret;
}
static int mg_mflash_read (u32 addr, u8 *buff, u32 len)
{
- u8 *sect_buff, *buff_ptr = buff;
+ u8 *buff_ptr = buff;
+ u8 sect_buff[MG_MFLASH_SECTOR_SIZE];
u32 cur_addr, next_sec_addr, end_addr, cnt, sect_num;
+ int ret = ERROR_OK;
cnt = 0;
cur_addr = addr;
end_addr = addr + len;
- sect_buff = malloc(MG_MFLASH_SECTOR_SIZE);
-
if (cur_addr & MG_MFLASH_SECTOR_SIZE_MASK) {
next_sec_addr = (cur_addr + MG_MFLASH_SECTOR_SIZE) & ~MG_MFLASH_SECTOR_SIZE_MASK;
sect_num = cur_addr >> MG_MFLASH_SECTOR_SIZE_SHIFT;
- mg_mflash_read_sects(sect_buff, sect_num, 1);
+ ret = mg_mflash_read_sects(sect_buff, sect_num, 1);
+ if (ret != ERROR_OK)
+ return ret;
if (end_addr < next_sec_addr) {
memcpy(buff_ptr, sect_buff + (cur_addr & MG_MFLASH_SECTOR_SIZE_MASK), end_addr - cur_addr);
- LOG_DEBUG("copies %u byte from sector offset 0x%8.8x", end_addr - cur_addr, cur_addr);
+ LOG_DEBUG("mflash: copies %u byte from sector offset 0x%8.8x", end_addr - cur_addr, cur_addr);
cur_addr = end_addr;
} else {
memcpy(buff_ptr, sect_buff + (cur_addr & MG_MFLASH_SECTOR_SIZE_MASK), next_sec_addr - cur_addr);
- LOG_DEBUG("copies %u byte from sector offset 0x%8.8x", next_sec_addr - cur_addr, cur_addr);
+ LOG_DEBUG("mflash: copies %u byte from sector offset 0x%8.8x", next_sec_addr - cur_addr, cur_addr);
buff_ptr += (next_sec_addr - cur_addr);
cur_addr = next_sec_addr;
}
@@ -586,7 +613,8 @@
}
if (cnt)
- mg_mflash_read_sects(buff_ptr, sect_num, cnt);
+ if ((ret = mg_mflash_read_sects(buff_ptr, sect_num, cnt)) != ERROR_OK)
+ return ret;
buff_ptr += cnt * MG_MFLASH_SECTOR_SIZE;
cur_addr += cnt * MG_MFLASH_SECTOR_SIZE;
@@ -594,47 +622,52 @@
if (cur_addr < end_addr) {
sect_num = cur_addr >> MG_MFLASH_SECTOR_SIZE_SHIFT;
- mg_mflash_read_sects(sect_buff, sect_num, 1);
+ ret = mg_mflash_read_sects(sect_buff, sect_num, 1);
+ if (ret != ERROR_OK)
+ return ret;
+
memcpy(buff_ptr, sect_buff, end_addr - cur_addr);
- LOG_DEBUG("copies %u byte", end_addr - cur_addr);
+ LOG_DEBUG("mflash: copies %u byte", end_addr - cur_addr);
}
}
- free(sect_buff);
-
- return ERROR_OK;
+ return ret;
}
static int mg_mflash_write(u32 addr, u8 *buff, u32 len)
{
- u8 *sect_buff, *buff_ptr = buff;
+ u8 *buff_ptr = buff;
+ u8 sect_buff[MG_MFLASH_SECTOR_SIZE];
u32 cur_addr, next_sec_addr, end_addr, cnt, sect_num;
+ int ret = ERROR_OK;
cnt = 0;
cur_addr = addr;
end_addr = addr + len;
- sect_buff = malloc(MG_MFLASH_SECTOR_SIZE);
-
if (cur_addr & MG_MFLASH_SECTOR_SIZE_MASK) {
next_sec_addr = (cur_addr + MG_MFLASH_SECTOR_SIZE) & ~MG_MFLASH_SECTOR_SIZE_MASK;
sect_num = cur_addr >> MG_MFLASH_SECTOR_SIZE_SHIFT;
- mg_mflash_read_sects(sect_buff, sect_num, 1);
+ ret = mg_mflash_read_sects(sect_buff, sect_num, 1);
+ if (ret != ERROR_OK)
+ return ret;
if (end_addr < next_sec_addr) {
memcpy(sect_buff + (cur_addr & MG_MFLASH_SECTOR_SIZE_MASK), buff_ptr, end_addr - cur_addr);
- LOG_DEBUG("copies %u byte to sector offset 0x%8.8x", end_addr - cur_addr, cur_addr);
+ LOG_DEBUG("mflash: copies %u byte to sector offset 0x%8.8x", end_addr - cur_addr, cur_addr);
cur_addr = end_addr;
} else {
memcpy(sect_buff + (cur_addr & MG_MFLASH_SECTOR_SIZE_MASK), buff_ptr, next_sec_addr - cur_addr);
- LOG_DEBUG("copies %u byte to sector offset 0x%8.8x", next_sec_addr - cur_addr, cur_addr);
+ LOG_DEBUG("mflash: copies %u byte to sector offset 0x%8.8x", next_sec_addr - cur_addr, cur_addr);
buff_ptr += (next_sec_addr - cur_addr);
cur_addr = next_sec_addr;
}
- mg_mflash_write_sects(sect_buff, sect_num, 1);
+ ret = mg_mflash_write_sects(sect_buff, sect_num, 1);
+ if (ret != ERROR_OK)
+ return ret;
}
if (cur_addr < end_addr) {
@@ -648,7 +681,8 @@
}
if (cnt)
- mg_mflash_write_sects(buff_ptr, sect_num, cnt);
+ if ((ret = mg_mflash_write_sects(buff_ptr, sect_num, cnt)) != ERROR_OK)
+ return ret;
buff_ptr += cnt * MG_MFLASH_SECTOR_SIZE;
cur_addr += cnt * MG_MFLASH_SECTOR_SIZE;
@@ -656,16 +690,17 @@
if (cur_addr < end_addr) {
sect_num = cur_addr >> MG_MFLASH_SECTOR_SIZE_SHIFT;
- mg_mflash_read_sects(sect_buff, sect_num, 1);
+ ret = mg_mflash_read_sects(sect_buff, sect_num, 1);
+ if (ret != ERROR_OK)
+ return ret;
+
memcpy(sect_buff, buff_ptr, end_addr - cur_addr);
- LOG_DEBUG("copies %u byte", end_addr - cur_addr);
- mg_mflash_write_sects(sect_buff, sect_num, 1);
+ LOG_DEBUG("mflash: copies %u byte", end_addr - cur_addr);
+ ret = mg_mflash_write_sects(sect_buff, sect_num, 1);
}
}
- free(sect_buff);
-
- return ERROR_OK;
+ return ret;
}
static int mg_write_cmd(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
@@ -675,6 +710,7 @@
fileio_t fileio;
duration_t duration;
char *duration_text;
+ int ret;
if (argc != 3) {
return ERROR_COMMAND_SYNTAX_ERROR;
@@ -682,9 +718,9 @@
address = strtoul(args[2], NULL, 0);
- if (fileio_open(&fileio, args[1], FILEIO_READ, FILEIO_BINARY) != ERROR_OK) {
- return ERROR_FAIL;
- }
+ ret = fileio_open(&fileio, args[1], FILEIO_READ, FILEIO_BINARY);
+ if (ret != ERROR_OK)
+ return ret;
buffer = malloc(MG_FILEIO_CHUNK);
if (!buffer) {
@@ -698,18 +734,18 @@
duration_start_measure(&duration);
for (i = 0; i < cnt; i++) {
- if (fileio_read(&fileio, MG_FILEIO_CHUNK, buffer, &buf_cnt) !=
+ if ((ret = fileio_read(&fileio, MG_FILEIO_CHUNK, buffer, &buf_cnt)) !=
ERROR_OK)
goto mg_write_cmd_err;
- if (mg_mflash_write(address, buffer, MG_FILEIO_CHUNK) != ERROR_OK)
+ if ((ret = mg_mflash_write(address, buffer, MG_FILEIO_CHUNK)) != ERROR_OK)
goto mg_write_cmd_err;
address += MG_FILEIO_CHUNK;
}
if (res) {
- if (fileio_read(&fileio, res, buffer, &buf_cnt) != ERROR_OK)
+ if ((ret = fileio_read(&fileio, res, buffer, &buf_cnt)) != ERROR_OK)
goto mg_write_cmd_err;
- if (mg_mflash_write(address, buffer, res) != ERROR_OK)
+ if ((ret = mg_mflash_write(address, buffer, res)) != ERROR_OK)
goto mg_write_cmd_err;
}
@@ -731,7 +767,7 @@
free(buffer);
fileio_close(&fileio);
- return ERROR_FAIL;
+ return ret;
}
static int mg_dump_cmd(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
@@ -741,6 +777,7 @@
fileio_t fileio;
duration_t duration;
char *duration_text;
+ int ret;
if (argc != 4) {
return ERROR_COMMAND_SYNTAX_ERROR;
@@ -749,9 +786,9 @@
address = strtoul(args[2], NULL, 0);
size = strtoul(args[3], NULL, 0);
- if (fileio_open(&fileio, args[1], FILEIO_WRITE, FILEIO_BINARY) != ERROR_OK) {
- return ERROR_FAIL;
- }
+ ret = fileio_open(&fileio, args[1], FILEIO_WRITE, FILEIO_BINARY);
+ if (ret != ERROR_OK)
+ return ret;
buffer = malloc(MG_FILEIO_CHUNK);
if (!buffer) {
@@ -765,18 +802,18 @@
duration_start_measure(&duration);
for (i = 0; i < cnt; i++) {
- if (mg_mflash_read(address, buffer, MG_FILEIO_CHUNK) != ERROR_OK)
+ if ((ret = mg_mflash_read(address, buffer, MG_FILEIO_CHUNK)) != ERROR_OK)
goto mg_dump_cmd_err;
- if (fileio_write(&fileio, MG_FILEIO_CHUNK, buffer, &size_written)
+ if ((ret = fileio_write(&fileio, MG_FILEIO_CHUNK, buffer, &size_written))
!= ERROR_OK)
goto mg_dump_cmd_err;
address += MG_FILEIO_CHUNK;
}
if (res) {
- if (mg_mflash_read(address, buffer, res) != ERROR_OK)
+ if ((ret = mg_mflash_read(address, buffer, res)) != ERROR_OK)
goto mg_dump_cmd_err;
- if (fileio_write(&fileio, res, buffer, &size_written) != ERROR_OK)
+ if ((ret = fileio_write(&fileio, res, buffer, &size_written)) != ERROR_OK)
goto mg_dump_cmd_err;
}
@@ -798,24 +835,25 @@
free(buffer);
fileio_close(&fileio);
- return ERROR_FAIL;
+ return ret;
}
static int mg_set_feature(mg_feature_id feature, mg_feature_val config)
{
target_t *target = mflash_bank->target;
u32 mg_task_reg = mflash_bank->base + MG_REG_OFFSET;
+ int ret;
- if (mg_dsk_wait(mg_io_wait_rdy_noerr, MG_OEM_DISK_WAIT_TIME_NORMAL)
+ if ((ret = mg_dsk_wait(mg_io_wait_rdy_noerr, MG_OEM_DISK_WAIT_TIME_NORMAL))
!= ERROR_OK)
- return ERROR_FAIL;
+ return ret;
- target_write_u8(target, mg_task_reg + MG_REG_FEATURE, feature);
- target_write_u8(target, mg_task_reg + MG_REG_SECT_CNT, config);
- target_write_u8(target, mg_task_reg + MG_REG_COMMAND,
+ ret = target_write_u8(target, mg_task_reg + MG_REG_FEATURE, feature);
+ ret |= target_write_u8(target, mg_task_reg + MG_REG_SECT_CNT, config);
+ ret |= target_write_u8(target, mg_task_reg + MG_REG_COMMAND,
mg_io_cmd_set_feature);
- return ERROR_OK;
+ return ret;
}
static int mg_is_valid_pll(double XIN, int N, double CLK_OUT, int NO)
@@ -824,7 +862,7 @@
double v2 = CLK_OUT * NO;
if (v1 <1000000 || v1 > 15000000 || v2 < 100000000 || v2 > 500000000)
- return ERROR_FAIL;
+ return ERROR_MG_INVALID_PLL;
return ERROR_OK;
}
@@ -922,29 +960,34 @@
u16 i, j;
u32 address = mflash_bank->base + MG_BUFFER_OFFSET;
target_t *target = mflash_bank->target;
+ int ret;
for (j = 0; j < 10; j++) {
for (i = 0; i < MG_MFLASH_SECTOR_SIZE >> 1; i++)
buff[i] = i;
- target_write_memory(target, address, 2,
+ ret = target_write_memory(target, address, 2,
MG_MFLASH_SECTOR_SIZE / 2, (u8 *)buff);
+ if (ret != ERROR_OK)
+ return ret;
memset(buff, 0xff, MG_MFLASH_SECTOR_SIZE);
- target_read_memory(target, address, 2,
+ ret = target_read_memory(target, address, 2,
MG_MFLASH_SECTOR_SIZE / 2, (u8 *)buff);
+ if (ret != ERROR_OK)
+ return ret;
for (i = 0; i < MG_MFLASH_SECTOR_SIZE >> 1; i++) {
if (buff[i] != i) {
LOG_ERROR("mflash: verify interface fail");
- return ERROR_FAIL;
+ return ERROR_MG_INTERFACE;
}
}
}
LOG_INFO("mflash: verify interface ok");
- return ERROR_OK;
+ return ret;
}
static const char g_strSEG_SerialNum[20] = {
@@ -1075,32 +1118,34 @@
static int mg_storage_config(void)
{
u8 buff[512];
+ int ret;
- if (mg_set_feature(mg_feature_id_transmode, mg_feature_val_trans_vcmd)
+ if ((ret = mg_set_feature(mg_feature_id_transmode, mg_feature_val_trans_vcmd))
!= ERROR_OK)
- return ERROR_FAIL;
+ return ret;
mg_gen_ataid((mg_io_type_drv_info *)buff);
- if (mg_mflash_do_write_sects(buff, 0, 1, mg_vcmd_update_stgdrvinfo)
+ if ((ret = mg_mflash_do_write_sects(buff, 0, 1, mg_vcmd_update_stgdrvinfo))
!= ERROR_OK)
- return ERROR_FAIL;
+ return ret;
- if (mg_set_feature(mg_feature_id_transmode, mg_feature_val_trans_default)
+ if ((ret = mg_set_feature(mg_feature_id_transmode, mg_feature_val_trans_default))
!= ERROR_OK)
- return ERROR_FAIL;
+ return ret;
LOG_INFO("mflash: storage config ok");
- return ERROR_OK;
+ return ret;
}
static int mg_boot_config(void)
{
u8 buff[512];
+ int ret;
- if (mg_set_feature(mg_feature_id_transmode, mg_feature_val_trans_vcmd)
+ if ((ret = mg_set_feature(mg_feature_id_transmode, mg_feature_val_trans_vcmd))
!= ERROR_OK)
- return ERROR_FAIL;
+ return ret;
memset(buff, 0xff, 512);
@@ -1109,21 +1154,22 @@
buff[2] = 4; /* boot size */
*((u32 *)(buff + 4)) = 0; /* XIP size */
- if (mg_mflash_do_write_sects(buff, 0, 1, mg_vcmd_update_xipinfo)
+ if ((ret = mg_mflash_do_write_sects(buff, 0, 1, mg_vcmd_update_xipinfo))
!= ERROR_OK)
- return ERROR_FAIL;
+ return ret;
- if (mg_set_feature(mg_feature_id_transmode, mg_feature_val_trans_default)
+ if ((ret = mg_set_feature(mg_feature_id_transmode, mg_feature_val_trans_default))
!= ERROR_OK)
- return ERROR_FAIL;
+ return ret;
LOG_INFO("mflash: boot config ok");
- return ERROR_OK;
+ return ret;
}
static int mg_set_pll(mg_pll_t *pll)
{
u8 buff[512];
+ int ret;
memset(buff, 0xff, 512);
/* PLL Lock cycle and Feedback 9bit Divider */
@@ -1132,38 +1178,40 @@
buff[6] = pll->input_div; /* PLL Input 5bit Divider */
buff[7] = pll->output_div; /* PLL Output Divider */
- if (mg_set_feature(mg_feature_id_transmode, mg_feature_val_trans_vcmd)
+ if ((ret = mg_set_feature(mg_feature_id_transmode, mg_feature_val_trans_vcmd))
!= ERROR_OK)
- return ERROR_FAIL;
+ return ret;
- if (mg_mflash_do_write_sects(buff, 0, 1, mg_vcmd_wr_pll)
+ if ((ret = mg_mflash_do_write_sects(buff, 0, 1, mg_vcmd_wr_pll))
!= ERROR_OK)
- return ERROR_FAIL;
+ return ret;
- if (mg_set_feature(mg_feature_id_transmode, mg_feature_val_trans_default)
+ if ((ret = mg_set_feature(mg_feature_id_transmode, mg_feature_val_trans_default))
!= ERROR_OK)
- return ERROR_FAIL;
+ return ret;
LOG_INFO("mflash: set pll ok");
- return ERROR_OK;
+ return ret;
}
static int mg_erase_nand(void)
{
- if (mg_set_feature(mg_feature_id_transmode, mg_feature_val_trans_vcmd)
+ int ret;
+
+ if ((ret = mg_set_feature(mg_feature_id_transmode, mg_feature_val_trans_vcmd))
!= ERROR_OK)
- return ERROR_FAIL;
+ return ret;
- if (mg_mflash_do_write_sects(NULL, 0, 0, mg_vcmd_purge_nand)
+ if ((ret = mg_mflash_do_write_sects(NULL, 0, 0, mg_vcmd_purge_nand))
!= ERROR_OK)
- return ERROR_FAIL;
+ return ret;
- if (mg_set_feature(mg_feature_id_transmode, mg_feature_val_trans_default)
+ if ((ret = mg_set_feature(mg_feature_id_transmode, mg_feature_val_trans_default))
!= ERROR_OK)
- return ERROR_FAIL;
+ return ret;
LOG_INFO("mflash: erase nand ok");
- return ERROR_OK;
+ return ret;
}
int mg_config_cmd(struct command_context_s *cmd_ctx, char *cmd,
@@ -1171,39 +1219,38 @@
{
double fin, fout;
mg_pll_t pll;
+ int ret;
- if (mg_verify_interface() != ERROR_OK)
- return ERROR_FAIL;
+ if ((ret = mg_verify_interface()) != ERROR_OK)
+ return ret;
- if (mg_mflash_rst() != ERROR_OK)
- return ERROR_FAIL;
+ if ((ret = mg_mflash_rst()) != ERROR_OK)
+ return ret;
switch (argc) {
case 2:
- if (!strcmp(args[1], "boot")) {
- if (mg_boot_config() != ERROR_OK)
- return ERROR_FAIL;
-
- return ERROR_OK;
- } else if (!strcmp(args[1], "storage")) {
- if (mg_storage_config() != ERROR_OK)
- return ERROR_FAIL;
-
- return ERROR_OK;
- } else
+ if (!strcmp(args[1], "boot"))
+ return mg_boot_config();
+ else if (!strcmp(args[1], "storage"))
+ return mg_storage_config();
+ else
return ERROR_COMMAND_NOTFOUND;
break;
case 3:
if (!strcmp(args[1], "pll")) {
fin = strtoul(args[2], NULL, 0);
- if (fin > MG_PLL_CLK_OUT)
- return ERROR_FAIL;
+ if (fin > MG_PLL_CLK_OUT) {
+ LOG_ERROR("mflash: input freq. is too large");
+ return ERROR_MG_INVALID_OSC;
+ }
fout = mg_calc_pll(fin, &pll);
- if (!fout)
- return ERROR_FAIL;
+ if (!fout) {
+ LOG_ERROR("mflash: cannot generate valid pll");
+ return ERROR_MG_INVALID_PLL;
+ }
LOG_INFO("mflash: Fout=%u Hz, feedback=%u,"
"indiv=%u, outdiv=%u, lock=%u",
@@ -1211,21 +1258,16 @@
pll.input_div, pll.output_div,
pll.lock_cyc);
- if (mg_erase_nand() != ERROR_OK)
- return ERROR_FAIL;
+ if ((ret = mg_erase_nand()) != ERROR_OK)
+ return ret;
- if (mg_set_pll(&pll) != ERROR_OK)
- return ERROR_FAIL;
-
- return ERROR_OK;
+ return mg_set_pll(&pll);
} else
return ERROR_COMMAND_NOTFOUND;
break;
default:
return ERROR_COMMAND_SYNTAX_ERROR;
}
-
- return ERROR_OK;
}
int mflash_init_drivers(struct command_context_s *cmd_ctx)
@@ -1276,7 +1318,7 @@
if (! mflash_bank->gpio_drv) {
LOG_ERROR("%s is unsupported soc", args[0]);
- return ERROR_INVALID_ARGUMENTS;
+ return ERROR_MG_UNSUPPORTED_SOC;
}
return ERROR_OK;
Modified: trunk/src/flash/mflash.h
===================================================================
--- trunk/src/flash/mflash.h 2009-06-12 04:14:28 UTC (rev 2220)
+++ trunk/src/flash/mflash.h 2009-06-12 21:31:11 UTC (rev 2221)
@@ -178,6 +178,13 @@
#define MG_FILEIO_CHUNK 1048576
+#define ERROR_MG_IO (-1600)
+#define ERROR_MG_TIMEOUT (-1601)
+#define ERROR_MG_INVALID_PLL (-1603)
+#define ERROR_MG_INTERFACE (-1604)
+#define ERROR_MG_INVALID_OSC (-1605)
+#define ERROR_MG_UNSUPPORTED_SOC (-1606)
+
typedef enum _mg_io_type_wait{
mg_io_wait_bsy = 1,
|
|
From: <zw...@ma...> - 2009-06-12 06:14:32
|
Author: zwelch
Date: 2009-06-12 06:14:28 +0200 (Fri, 12 Jun 2009)
New Revision: 2220
Modified:
trunk/src/target/mips_m4k.c
Log:
Further cleanup to MIPS target read/write memory function:
- Move the mips32_..._read_mem calls to top-level of read_mem function.
- Change: Only perform mips_m4k_read_mem conversion when retval == ERROR_OK.
- Prevents pointless conversions of bogus read values after failures.
- Eliminate retval variable from mips_m4k_write_mem; return directly.
- Move declaration of retval variable to point of first use.
- Remove the now redundant switch statements testing size:
- argument sanitizing already covers these cases.
Modified: trunk/src/target/mips_m4k.c
===================================================================
--- trunk/src/target/mips_m4k.c 2009-06-12 04:14:18 UTC (rev 2219)
+++ trunk/src/target/mips_m4k.c 2009-06-12 04:14:28 UTC (rev 2220)
@@ -732,7 +732,6 @@
{
mips32_common_t *mips32 = target->arch_info;
mips_ejtag_t *ejtag_info = &mips32->ejtag_info;
- int retval;
LOG_DEBUG("address: 0x%8.8x, size: 0x%8.8x, count: 0x%8.8x", address, size, count);
@@ -749,22 +748,14 @@
if (((size == 4) && (address & 0x3u)) || ((size == 2) && (address & 0x1u)))
return ERROR_TARGET_UNALIGNED_ACCESS;
- switch (size)
- {
- case 4:
- case 2:
- case 1:
- /* if noDMA off, use DMAACC mode for memory read */
- if(ejtag_info->impcode & EJTAG_IMP_NODMA)
- retval = mips32_pracc_read_mem(ejtag_info, address, size, count, (void *)buffer);
- else
- retval = mips32_dmaacc_read_mem(ejtag_info, address, size, count, (void *)buffer);
- break;
- default:
- LOG_ERROR("BUG: we shouldn't get here");
- exit(-1);
- break;
- }
+ /* if noDMA off, use DMAACC mode for memory read */
+ int retval;
+ if(ejtag_info->impcode & EJTAG_IMP_NODMA)
+ retval = mips32_pracc_read_mem(ejtag_info, address, size, count, (void *)buffer);
+ else
+ retval = mips32_dmaacc_read_mem(ejtag_info, address, size, count, (void *)buffer);
+ if (ERROR_OK != retval)
+ return retval;
/* TAP data register is loaded LSB first (little endian) */
if (target->endianness == TARGET_BIG_ENDIAN)
@@ -787,15 +778,14 @@
}
}
}
-
- return retval;
+
+ return ERROR_OK;
}
int mips_m4k_write_memory(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer)
{
mips32_common_t *mips32 = target->arch_info;
mips_ejtag_t *ejtag_info = &mips32->ejtag_info;
- int retval;
LOG_DEBUG("address: 0x%8.8x, size: 0x%8.8x, count: 0x%8.8x", address, size, count);
@@ -812,19 +802,6 @@
if (((size == 4) && (address & 0x3u)) || ((size == 2) && (address & 0x1u)))
return ERROR_TARGET_UNALIGNED_ACCESS;
- switch (size)
- {
- case 4:
- case 2:
- case 1:
- /* if noDMA off, use DMAACC mode for memory write */
- break;
- default:
- LOG_ERROR("BUG: we shouldn't get here");
- exit(-1);
- break;
- }
-
/* TAP data register is loaded LSB first (little endian) */
if (target->endianness == TARGET_BIG_ENDIAN)
{
@@ -847,13 +824,11 @@
}
}
+ /* if noDMA off, use DMAACC mode for memory write */
if(ejtag_info->impcode & EJTAG_IMP_NODMA)
- retval = mips32_pracc_write_mem(ejtag_info, address, size, count, (void *)buffer);
+ return mips32_pracc_write_mem(ejtag_info, address, size, count, (void *)buffer);
else
- retval = mips32_dmaacc_write_mem(ejtag_info, address, size, count, (void *)buffer);
-
-
- return retval;
+ return mips32_dmaacc_write_mem(ejtag_info, address, size, count, (void *)buffer);
}
int mips_m4k_register_commands(struct command_context_s *cmd_ctx)
|
|
From: <zw...@ma...> - 2009-06-12 06:14:26
|
Author: zwelch
Date: 2009-06-12 06:14:18 +0200 (Fri, 12 Jun 2009)
New Revision: 2219
Modified:
trunk/src/target/mips_ejtag.c
trunk/src/target/mips_m4k.c
Log:
David Claffey <dnc...@gm...>:
This patch helps fix MIPS big endian (elf32-tradbigmips) targets.
If "-endian big" is not set in target create, the endianess defaults to
little. mw and md commands will still work, but binary file loads will
have the incorrect word order loaded into memory.
The EJTAG processor access data register (PrAcc) is little endian
regardless of the CPU endianness; it is always loaded LSB first. This
is confirmed by the fact that mips_ejtag_drscan_32() uses buf_set_u32()
to load the scan field; buf_set_u32() is a little-endian formatter. For
big endian targets, data buffers have to be modified so the LSB of each
u32 or u16 is at the lower (first) memory location. If the drscan
out_value word order is set using buf_set_u32() then it makes sense to
also fixup the in_value with buf_get_u32(); a symmetry argument. This
has no affect on little endian hosts.
Modified: trunk/src/target/mips_ejtag.c
===================================================================
--- trunk/src/target/mips_ejtag.c 2009-06-12 01:41:07 UTC (rev 2218)
+++ trunk/src/target/mips_ejtag.c 2009-06-12 04:14:18 UTC (rev 2219)
@@ -118,7 +118,7 @@
if (tap==NULL)
return ERROR_FAIL;
scan_field_t field;
- u8 t[4];
+ u8 t[4], r[4];
int retval;
field.tap = tap;
@@ -126,7 +126,7 @@
field.out_value = t;
buf_set_u32(field.out_value, 0, field.num_bits, *data);
- field.in_value = (u8*)data;
+ field.in_value = r;
@@ -139,6 +139,8 @@
return retval;
}
+ *data = buf_get_u32(field.in_value, 0, 32);
+
keep_alive();
return ERROR_OK;
Modified: trunk/src/target/mips_m4k.c
===================================================================
--- trunk/src/target/mips_m4k.c 2009-06-12 01:41:07 UTC (rev 2218)
+++ trunk/src/target/mips_m4k.c 2009-06-12 04:14:18 UTC (rev 2219)
@@ -732,6 +732,7 @@
{
mips32_common_t *mips32 = target->arch_info;
mips_ejtag_t *ejtag_info = &mips32->ejtag_info;
+ int retval;
LOG_DEBUG("address: 0x%8.8x, size: 0x%8.8x, count: 0x%8.8x", address, size, count);
@@ -755,22 +756,46 @@
case 1:
/* if noDMA off, use DMAACC mode for memory read */
if(ejtag_info->impcode & EJTAG_IMP_NODMA)
- return mips32_pracc_read_mem(ejtag_info, address, size, count, (void *)buffer);
+ retval = mips32_pracc_read_mem(ejtag_info, address, size, count, (void *)buffer);
else
- return mips32_dmaacc_read_mem(ejtag_info, address, size, count, (void *)buffer);
+ retval = mips32_dmaacc_read_mem(ejtag_info, address, size, count, (void *)buffer);
+ break;
default:
LOG_ERROR("BUG: we shouldn't get here");
exit(-1);
break;
}
- return ERROR_OK;
+ /* TAP data register is loaded LSB first (little endian) */
+ if (target->endianness == TARGET_BIG_ENDIAN)
+ {
+ u32 i, t32;
+ u16 t16;
+
+ for(i = 0; i < (count*size); i += size)
+ {
+ switch(size)
+ {
+ case 4:
+ t32 = le_to_h_u32(&buffer[i]);
+ h_u32_to_be(&buffer[i], t32);
+ break;
+ case 2:
+ t16 = le_to_h_u16(&buffer[i]);
+ h_u16_to_be(&buffer[i], t16);
+ break;
+ }
+ }
+ }
+
+ return retval;
}
int mips_m4k_write_memory(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer)
{
mips32_common_t *mips32 = target->arch_info;
mips_ejtag_t *ejtag_info = &mips32->ejtag_info;
+ int retval;
LOG_DEBUG("address: 0x%8.8x, size: 0x%8.8x, count: 0x%8.8x", address, size, count);
@@ -793,10 +818,6 @@
case 2:
case 1:
/* if noDMA off, use DMAACC mode for memory write */
- if(ejtag_info->impcode & EJTAG_IMP_NODMA)
- mips32_pracc_write_mem(ejtag_info, address, size, count, (void *)buffer);
- else
- mips32_dmaacc_write_mem(ejtag_info, address, size, count, (void *)buffer);
break;
default:
LOG_ERROR("BUG: we shouldn't get here");
@@ -804,7 +825,35 @@
break;
}
- return ERROR_OK;
+ /* TAP data register is loaded LSB first (little endian) */
+ if (target->endianness == TARGET_BIG_ENDIAN)
+ {
+ u32 i, t32;
+ u16 t16;
+
+ for(i = 0; i < (count*size); i += size)
+ {
+ switch(size)
+ {
+ case 4:
+ t32 = be_to_h_u32(&buffer[i]);
+ h_u32_to_le(&buffer[i], t32);
+ break;
+ case 2:
+ t16 = be_to_h_u16(&buffer[i]);
+ h_u16_to_le(&buffer[i], t16);
+ break;
+ }
+ }
+ }
+
+ if(ejtag_info->impcode & EJTAG_IMP_NODMA)
+ retval = mips32_pracc_write_mem(ejtag_info, address, size, count, (void *)buffer);
+ else
+ retval = mips32_dmaacc_write_mem(ejtag_info, address, size, count, (void *)buffer);
+
+
+ return retval;
}
int mips_m4k_register_commands(struct command_context_s *cmd_ctx)
|
|
From: <zw...@ma...> - 2009-06-12 03:41:11
|
Author: zwelch Date: 2009-06-12 03:41:07 +0200 (Fri, 12 Jun 2009) New Revision: 2218 Modified: trunk/src/jtag/tcl.c Log: Fix unitialized use of cur_speed in handle_jtag_khz_command: - Use the default KHz speed setting, in case interface is not initialized. Modified: trunk/src/jtag/tcl.c =================================================================== --- trunk/src/jtag/tcl.c 2009-06-12 01:41:00 UTC (rev 2217) +++ trunk/src/jtag/tcl.c 2009-06-12 01:41:07 UTC (rev 2218) @@ -1038,7 +1038,7 @@ return retval; } - int cur_speed; + int cur_speed = jtag_get_speed_khz(); retval = jtag_get_speed_readable(&cur_speed); if (ERROR_OK != retval) return retval; |