summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/jtag/commands.c38
-rw-r--r--src/jtag/core.c48
-rw-r--r--src/jtag/ft2232.c45
-rw-r--r--src/jtag/jtag.h6
-rw-r--r--src/openocd.c4
-rw-r--r--src/target/arm11.c1
6 files changed, 80 insertions, 62 deletions
diff --git a/src/jtag/commands.c b/src/jtag/commands.c
index 0cee02af..70e30ab5 100644
--- a/src/jtag/commands.c
+++ b/src/jtag/commands.c
@@ -184,36 +184,37 @@ int jtag_build_buffer(const scan_command_t *cmd, uint8_t **buffer)
bit_count = 0;
-#ifdef _DEBUG_JTAG_IO_
- LOG_DEBUG("%s num_fields: %i", cmd->ir_scan ? "IRSCAN" : "DRSCAN", cmd->num_fields);
-#endif
+ DEBUG_JTAG_IO("%s num_fields: %i",
+ cmd->ir_scan ? "IRSCAN" : "DRSCAN",
+ cmd->num_fields);
for (i = 0; i < cmd->num_fields; i++)
{
if (cmd->fields[i].out_value)
{
#ifdef _DEBUG_JTAG_IO_
- char* char_buf = buf_to_str(cmd->fields[i].out_value, (cmd->fields[i].num_bits > DEBUG_JTAG_IOZ) ? DEBUG_JTAG_IOZ : cmd->fields[i].num_bits, 16);
-#endif
- buf_set_buf(cmd->fields[i].out_value, 0, *buffer, bit_count, cmd->fields[i].num_bits);
-#ifdef _DEBUG_JTAG_IO_
- LOG_DEBUG("fields[%i].out_value[%i]: 0x%s", i, cmd->fields[i].num_bits, char_buf);
+ char *char_buf = buf_to_str(cmd->fields[i].out_value,
+ (cmd->fields[i].num_bits > DEBUG_JTAG_IOZ)
+ ? DEBUG_JTAG_IOZ
+ : cmd->fields[i].num_bits, 16);
+
+ LOG_DEBUG("fields[%i].out_value[%i]: 0x%s", i,
+ cmd->fields[i].num_bits, char_buf);
free(char_buf);
#endif
+ buf_set_buf(cmd->fields[i].out_value, 0, *buffer,
+ bit_count, cmd->fields[i].num_bits);
}
else
{
-#ifdef _DEBUG_JTAG_IO_
- LOG_DEBUG("fields[%i].out_value[%i]: NULL", i, cmd->fields[i].num_bits);
-#endif
+ DEBUG_JTAG_IO("fields[%i].out_value[%i]: NULL",
+ i, cmd->fields[i].num_bits);
}
bit_count += cmd->fields[i].num_bits;
}
-#ifdef _DEBUG_JTAG_IO_
- //LOG_DEBUG("bit_count totalling: %i", bit_count);
-#endif
+ //DEBUG_JTAG_IO("bit_count totalling: %i", bit_count);
return bit_count;
}
@@ -238,8 +239,13 @@ int jtag_read_buffer(uint8_t *buffer, const scan_command_t *cmd)
uint8_t *captured = buf_set_buf(buffer, bit_count, malloc(CEIL(num_bits, 8)), 0, num_bits);
#ifdef _DEBUG_JTAG_IO_
- char *char_buf = buf_to_str(captured, (num_bits > DEBUG_JTAG_IOZ) ? DEBUG_JTAG_IOZ : num_bits, 16);
- LOG_DEBUG("fields[%i].in_value[%i]: 0x%s", i, num_bits, char_buf);
+ char *char_buf = buf_to_str(captured,
+ (num_bits > DEBUG_JTAG_IOZ)
+ ? DEBUG_JTAG_IOZ
+ : num_bits, 16);
+
+ LOG_DEBUG("fields[%i].in_value[%i]: 0x%s",
+ i, num_bits, char_buf);
free(char_buf);
#endif
diff --git a/src/jtag/core.c b/src/jtag/core.c
index 0b752ea4..f7d55b79 100644
--- a/src/jtag/core.c
+++ b/src/jtag/core.c
@@ -68,10 +68,12 @@ static const char *jtag_event_strings[] =
/*
* JTAG adapters must initialize with TRST and SRST de-asserted
- * (they're negative logic, so that means *high*)
+ * (they're negative logic, so that means *high*). But some
+ * hardware doesn't necessarily work that way ... so set things
+ * up so that jtag_init() always forces that state.
*/
-static int jtag_trst = 0;
-static int jtag_srst = 0;
+static int jtag_trst = -1;
+static int jtag_srst = -1;
/**
* List all TAPs that have been created.
@@ -1108,22 +1110,24 @@ static int jtag_validate_ircapture(void)
break;
}
- if (tap->hasidcode)
- {
- /* Validate the two LSBs, which must be 01 per JTAG spec.
- * REVISIT we might be able to verify some MSBs too, using
- * ircapture/irmask attributes.
- */
- val = buf_get_u32(ir_test, chain_pos, tap->ir_length);
- if ((val & 0x3) != 1) {
- LOG_ERROR("%s: IR capture error; saw 0x%0*x not 0x..1",
- jtag_tap_name(tap),
- (tap->ir_length + 7) / tap->ir_length,
- val);
-
- retval = ERROR_JTAG_INIT_FAILED;
- goto done;
- }
+ /* Validate the two LSBs, which must be 01 per JTAG spec.
+ *
+ * Or ... more bits could be provided by TAP declaration.
+ * Plus, some taps (notably in i.MX series chips) violate
+ * this part of the JTAG spec, so their capture mask/value
+ * attributes might disable this test.
+ */
+ val = buf_get_u32(ir_test, chain_pos, tap->ir_length);
+ if ((val & tap->ir_capture_mask) != tap->ir_capture_value) {
+ LOG_ERROR("%s: IR capture error; saw 0x%0*x not 0x%0*x",
+ jtag_tap_name(tap),
+ (tap->ir_length + 7) / tap->ir_length,
+ val,
+ (tap->ir_length + 7) / tap->ir_length,
+ tap->ir_capture_value);
+
+ retval = ERROR_JTAG_INIT_FAILED;
+ goto done;
}
LOG_DEBUG("%s: IR capture 0x%0*x", jtag_tap_name(tap),
(tap->ir_length + 7) / tap->ir_length, val);
@@ -1335,9 +1339,15 @@ int jtag_init_reset(struct command_context_s *cmd_ctx)
int jtag_init(struct command_context_s *cmd_ctx)
{
int retval;
+
if ((retval = jtag_interface_init(cmd_ctx)) != ERROR_OK)
return retval;
+ /* guard against oddball hardware: force resets to be inactive */
+ jtag_add_reset(0, 0);
+ if ((retval = jtag_execute_queue()) != ERROR_OK)
+ return retval;
+
if (Jim_Eval_Named(interp, "jtag_init", __FILE__, __LINE__) != JIM_OK)
return ERROR_FAIL;
diff --git a/src/jtag/ft2232.c b/src/jtag/ft2232.c
index 87f02d60..839976fa 100644
--- a/src/jtag/ft2232.c
+++ b/src/jtag/ft2232.c
@@ -263,9 +263,8 @@ static void clock_tms(uint8_t mpsse_cmd, int tms_bits, int tms_count, bool tdi_b
assert(tms_count > 0);
-#if 0
- LOG_DEBUG("mpsse cmd=%02x, tms_bits = 0x%08x, bit_count=%d", mpsse_cmd, tms_bits, tms_count);
-#endif
+ DEBUG_JTAG_IO("mpsse cmd=%02x, tms_bits = 0x%08x, bit_count=%d",
+ mpsse_cmd, tms_bits, tms_count);
for (tms_byte = tms_ndx = i = 0; i < tms_count; ++i, tms_bits>>=1)
{
@@ -773,6 +772,8 @@ static void ft2232_add_pathmove(tap_state_t* path, int num_states)
assert((unsigned) num_states <= 32u); /* tms_bits only holds 32 bits */
+ DEBUG_JTAG_IO("-");
+
/* this loop verifies that the path is legal and logs each state in the path */
while (num_states)
{
@@ -952,7 +953,6 @@ static void ft2232_add_scan(bool ir_scan, enum scan_type type, uint8_t* buffer,
tms_count = 2;
/* Clock Data to TMS/CS Pin with Read */
mpsse_cmd = 0x6b;
- /* LOG_DEBUG("added TMS scan (read)"); */
}
else
{
@@ -960,9 +960,9 @@ static void ft2232_add_scan(bool ir_scan, enum scan_type type, uint8_t* buffer,
tms_count = tap_get_tms_path_len(tap_get_state(), tap_get_end_state());
/* Clock Data to TMS/CS Pin (no Read) */
mpsse_cmd = 0x4b;
- /* LOG_DEBUG("added TMS scan (no read)"); */
}
+ DEBUG_JTAG_IO("finish %s", (type == SCAN_OUT) ? "without read" : "via PAUSE");
clock_tms(mpsse_cmd, tms_bits, tms_count, last_bit);
}
@@ -1154,6 +1154,7 @@ static int ft2232_large_scan(scan_command_t* cmd, enum scan_type type, uint8_t*
/* LOG_DEBUG("added TMS scan (no read)"); */
}
+ DEBUG_JTAG_IO("finish, %s", (type == SCAN_OUT) ? "no read" : "read");
clock_tms(mpsse_cmd, tms_bits, tms_count, last_bit);
}
@@ -1565,10 +1566,9 @@ static int ft2232_execute_runtest(jtag_command_t *cmd)
}
require_send = 1;
-#ifdef _DEBUG_JTAG_IO_
- LOG_DEBUG("runtest: %i, end in %s", cmd->cmd.runtest->num_cycles, tap_state_name(tap_get_end_state()));
-#endif
-
+ DEBUG_JTAG_IO("runtest: %i, end in %s",
+ cmd->cmd.runtest->num_cycles,
+ tap_state_name(tap_get_end_state()));
return retval;
}
@@ -1577,7 +1577,8 @@ static int ft2232_execute_statemove(jtag_command_t *cmd)
int predicted_size = 0;
int retval = ERROR_OK;
- DEBUG_JTAG_IO("statemove end in %i", cmd->cmd.statemove->end_state);
+ DEBUG_JTAG_IO("statemove end in %s",
+ tap_state_name(cmd->cmd.statemove->end_state));
/* only send the maximum buffer size that FT2232C can handle */
predicted_size = 3;
@@ -1685,10 +1686,9 @@ static int ft2232_execute_scan(jtag_command_t *cmd)
require_send = 1;
if (buffer)
free(buffer);
-#ifdef _DEBUG_JTAG_IO_
- LOG_DEBUG("%s scan, %i bits, end in %s", (cmd->cmd.scan->ir_scan) ? "IR" : "DR", scan_size,
+ DEBUG_JTAG_IO("%s scan, %i bits, end in %s",
+ (cmd->cmd.scan->ir_scan) ? "IR" : "DR", scan_size,
tap_state_name(tap_get_end_state()));
-#endif
return retval;
}
@@ -1720,9 +1720,8 @@ static int ft2232_execute_reset(jtag_command_t *cmd)
layout->reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst);
require_send = 1;
-#ifdef _DEBUG_JTAG_IO_
- LOG_DEBUG("trst: %i, srst: %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst);
-#endif
+ DEBUG_JTAG_IO("trst: %i, srst: %i",
+ cmd->cmd.reset->trst, cmd->cmd.reset->srst);
return retval;
}
@@ -1737,10 +1736,9 @@ static int ft2232_execute_sleep(jtag_command_t *cmd)
retval = ERROR_JTAG_QUEUE_FAILED;
first_unsent = cmd->next;
jtag_sleep(cmd->cmd.sleep->us);
-#ifdef _DEBUG_JTAG_IO_
- LOG_DEBUG("sleep %i usec while in %s", cmd->cmd.sleep->us, tap_state_name(tap_get_state()));
-#endif
-
+ DEBUG_JTAG_IO("sleep %i usec while in %s",
+ cmd->cmd.sleep->us,
+ tap_state_name(tap_get_state()));
return retval;
}
@@ -1754,10 +1752,9 @@ static int ft2232_execute_stableclocks(jtag_command_t *cmd)
*/
if (ft2232_stableclocks(cmd->cmd.stableclocks->num_cycles, cmd) != ERROR_OK)
retval = ERROR_JTAG_QUEUE_FAILED;
-#ifdef _DEBUG_JTAG_IO_
- LOG_DEBUG("clocks %i while in %s", cmd->cmd.stableclocks->num_cycles, tap_state_name(tap_get_state()));
-#endif
-
+ DEBUG_JTAG_IO("clocks %i while in %s",
+ cmd->cmd.stableclocks->num_cycles,
+ tap_state_name(tap_get_state()));
return retval;
}
diff --git a/src/jtag/jtag.h b/src/jtag/jtag.h
index 60774589..35635cd8 100644
--- a/src/jtag/jtag.h
+++ b/src/jtag/jtag.h
@@ -28,9 +28,11 @@
#ifdef _DEBUG_JTAG_IO_
-#define DEBUG_JTAG_IO(expr ...) LOG_DEBUG(expr)
+#define DEBUG_JTAG_IO(expr ...) \
+ do { if (1) LOG_DEBUG(expr); } while (0)
#else
-#define DEBUG_JTAG_IO(expr ...)
+#define DEBUG_JTAG_IO(expr ...) \
+ do { if (0) LOG_DEBUG(expr); } while (0)
#endif
#ifndef DEBUG_JTAG_IOZ
diff --git a/src/openocd.c b/src/openocd.c
index 86b8aaf2..7384065a 100644
--- a/src/openocd.c
+++ b/src/openocd.c
@@ -255,7 +255,9 @@ int openocd_main(int argc, char *argv[])
print_version();
- LOG_OUTPUT("For bug reports, read http://svn.berlios.de/svnroot/repos/openocd/trunk/BUGS\n");
+ LOG_OUTPUT("For bug reports, read\n\t"
+ "http://openocd.berlios.de/doc/doxygen/bugs.html"
+ "\n");
command_context_mode(cmd_ctx, COMMAND_CONFIG);
diff --git a/src/target/arm11.c b/src/target/arm11.c
index 9f85bd78..b840eb08 100644
--- a/src/target/arm11.c
+++ b/src/target/arm11.c
@@ -29,6 +29,7 @@
#include "arm11.h"
#include "armv4_5.h"
#include "arm_simulator.h"
+#include "time_support.h"
#include "target_type.h"