* Copyright (C) 2005 by Dominic Rath *
* Dominic.Rath@gmx.de *
* *
+ * Copyright (C) 2007,2008 Øyvind Harboe *
+ * oyvind.harboe@zylin.com *
+ * *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
return t + offset;
}
-void cmd_queue_free()
+void cmd_queue_free(void)
{
cmd_queue_page_t *page = cmd_queue_pages;
cmd_queue_pages = NULL;
}
-static void jtag_prelude1()
+static void jtag_prelude1(void)
{
if (jtag_trst == 1)
{
for (i=0; i<num_states; i++)
{
+ if (path[i] == TAP_TLR)
+ {
+ LOG_ERROR("BUG: TAP_TLR is not a valid state for pathmove sequences");
+ exit(-1);
+ }
if ((tap_transitions[cur_state].low != path[i])&&
(tap_transitions[cur_state].high != path[i]))
{
jtag_prelude1();
- cmd_queue_cur_state = path[num_states - 1];
retval=interface_jtag_add_pathmove(num_states, path);
+ cmd_queue_cur_state = path[num_states - 1];
if (retval!=ERROR_OK)
jtag_error=retval;
}
/* Try to examine chain layout according to IEEE 1149.1 §12
*/
-int jtag_examine_chain()
+int jtag_examine_chain(void)
{
jtag_device_t *device = jtag_devices;
scan_field_t field;
/* LSB must not be 0, this indicates a device in bypass */
device_count++;
+ LOG_WARNING("Device was in bypass after TRST/TMS reset");
+
bit_count += 1;
}
else
if (idcode == 0x000000FF)
{
- /* End of chain (invalid manufacturer ID) */
+ int unexpected=0;
+ /* End of chain (invalid manufacturer ID)
+ *
+ * The JTAG examine is the very first thing that happens
+ *
+ * A single JTAG device requires only 64 bits to be read back correctly.
+ *
+ * The code below adds a check that the rest of the data scanned (640 bits)
+ * are all as expected. This helps diagnose/catch problems with the JTAG chain
+ *
+ * earlier and gives more helpful/explicit error messages.
+ */
+ for (bit_count += 32; bit_count < (JTAG_MAX_CHAIN_SIZE * 32) - 31;bit_count += 32)
+ {
+ idcode = buf_get_u32(idcode_buffer, bit_count, 32);
+ if (unexpected||(idcode != 0x000000FF))
+ {
+ LOG_WARNING("Unexpected idcode after end of chain! %d 0x%08x", bit_count, idcode);
+ unexpected = 1;
+ }
+ }
+
break;
}
return ERROR_OK;
}
-int jtag_validate_chain()
+int jtag_validate_chain(void)
{
jtag_device_t *device = jtag_devices;
int total_ir_length = 0;
if (validate_tries > 5)
{
- LOG_ERROR("Could not validate JTAG chain, exit");
+ LOG_ERROR("Could not validate JTAG chain");
return ERROR_JTAG_INVALID_INTERFACE;
}
usleep(10000);
static int default_speed_div(int speed, int *khz)
{
+ LOG_ERROR("Translation from jtag_speed to khz not implemented");
return ERROR_FAIL;
}
{
} else
{
- retval=ERROR_COMMAND_SYNTAX_ERROR;
+ return ERROR_COMMAND_SYNTAX_ERROR;
}
command_print(cmd_ctx, "jtag_speed: %d", jtag_speed);
{
} else
{
- retval=ERROR_COMMAND_SYNTAX_ERROR;
+ return ERROR_COMMAND_SYNTAX_ERROR;
}
+
+ if (jtag!=NULL)
+ {
+ int what_speed;
+ if ((retval=jtag->speed_div(jtag_speed, &speed_khz))!=ERROR_OK)
+ return retval;
+ }
+
command_print(cmd_ctx, "jtag_khz: %d", speed_khz);
return retval;