#if (BUILD_FT2232_FTD2XX==1 && BUILD_FT2232_LIBFTDI==1)
#error "BUILD_FT2232_FTD2XX && BUILD_FT2232_LIBFTDI are mutually exclusive"
#if (BUILD_FT2232_FTD2XX==1 && BUILD_FT2232_LIBFTDI==1)
#error "BUILD_FT2232_FTD2XX && BUILD_FT2232_LIBFTDI are mutually exclusive"
- * Function ft2232_stableclocks
- * will send out \a num_cycles on the TCK line while the TAP(s)
- * are in a stable state. Calling code must ensure that current state is
- * stable, that verification is not done in here.
- * @param num_cycles is the count of clocks cycles to send.
- * @return int - ERROR_OK or ERROR_JTAG_QUEUE_FAILED
+ * Send out \a num_cycles on the TCK line while the TAP(s) are in a
+ * stable state. Calling code must ensure that current state is stable,
+ * that verification is not done in here.
+ *
+ * @param num_cycles The number of clocks cycles to send.
+ * @param cmd The command to send.
+ *
+ * @returns ERROR_OK on success, or ERROR_JTAG_QUEUE_FAILED on failure.
static char* ft2232_device_desc = NULL;
static char* ft2232_serial = NULL;
static char* ft2232_layout = NULL;
static char* ft2232_device_desc = NULL;
static char* ft2232_serial = NULL;
static char* ft2232_layout = NULL;
-static u16 ft2232_vid[MAX_USB_IDS + 1] = { 0x0403, 0 };
-static u16 ft2232_pid[MAX_USB_IDS + 1] = { 0x6010, 0 };
+static uint16_t ft2232_vid[MAX_USB_IDS + 1] = { 0x0403, 0 };
+static uint16_t ft2232_pid[MAX_USB_IDS + 1] = { 0x6010, 0 };
-static int usbjtag_init(void);
-static int jtagkey_init(void);
-static int olimex_jtag_init(void);
-static int flyswatter_init(void);
-static int turtle_init(void);
-static int comstick_init(void);
-static int stm32stick_init(void);
-static int axm0432_jtag_init(void);
-static int sheevaplug_init(void);
-static int icebear_jtag_init(void);
-static int cortino_jtag_init(void);
+static int usbjtag_init(void);
+static int jtagkey_init(void);
+static int olimex_jtag_init(void);
+static int flyswatter_init(void);
+static int turtle_init(void);
+static int comstick_init(void);
+static int stm32stick_init(void);
+static int axm0432_jtag_init(void);
+static int sheevaplug_init(void);
+static int icebear_jtag_init(void);
+static int cortino_jtag_init(void);
/* reset procedures for supported layouts */
static void usbjtag_reset(int trst, int srst);
/* reset procedures for supported layouts */
static void usbjtag_reset(int trst, int srst);
{
{ "usbjtag", usbjtag_init, usbjtag_reset, NULL },
{ "jtagkey", jtagkey_init, jtagkey_reset, NULL },
{
{ "usbjtag", usbjtag_init, usbjtag_reset, NULL },
{ "jtagkey", jtagkey_init, jtagkey_reset, NULL },
{ NULL, NULL, NULL, NULL },
};
{ NULL, NULL, NULL, NULL },
};
-static u8 nTRST, nTRSTnOE, nSRST, nSRSTnOE;
+static uint8_t nTRST, nTRSTnOE, nSRST, nSRSTnOE;
-static ft2232_layout_t* layout;
-static u8 low_output = 0x0;
-static u8 low_direction = 0x0;
-static u8 high_output = 0x0;
-static u8 high_direction = 0x0;
+static const ft2232_layout_t *layout;
+static uint8_t low_output = 0x0;
+static uint8_t low_direction = 0x0;
+static uint8_t high_output = 0x0;
+static uint8_t high_direction = 0x0;
static int ft2232_buffer_size = 0;
static int ft2232_read_pointer = 0;
static int ft2232_expect_read = 0;
static int ft2232_buffer_size = 0;
static int ft2232_read_pointer = 0;
static int ft2232_expect_read = 0;
* writes a byte into the byte buffer, "ft2232_buffer", which must be sent later.
* @param val is the byte to send.
*/
* writes a byte into the byte buffer, "ft2232_buffer", which must be sent later.
* @param val is the byte to send.
*/
* significant bit of tms_bits and progressing to more significant bits.
* Rigorous state transition logging is done here via tap_set_state().
*
* significant bit of tms_bits and progressing to more significant bits.
* Rigorous state transition logging is done here via tap_set_state().
*
- * @param pmsse_cmd is one of the MPSSE TMS oriented commands such as 0x4b or 0x6b. See
- * the MPSSE spec referenced above for their functionality. The MPSSE command
- * "Clock Data to TMS/CS Pin (no Read)" is often used for this, 0x4b.
+ * @param mpsse_cmd One of the MPSSE TMS oriented commands such as
+ * 0x4b or 0x6b. See the MPSSE spec referenced above for their
+ * functionality. The MPSSE command "Clock Data to TMS/CS Pin (no Read)"
+ * is often used for this, 0x4b.
+ *
+ * @param tms_bits Holds the sequence of bits to send.
+ * @param tms_count Tells how many bits in the sequence.
+ * @param tdi_bit A single bit to pass on to TDI before the first TCK
+ * cycle and held static for the duration of TMS clocking.
- * @param tms_bits holds the sequence of bits to send.
- * @param tms_count tells how many bits in the sequence.
- * @param tdi_bit is a single bit which is passed on to TDI before the first TCK cycle
- * and is held static for the duration of TMS clocking. See the MPSSE spec referenced above.
+ * See the MPSSE spec referenced above.
-static void clock_tms( u8 mpsse_cmd, int tms_bits, int tms_count, bool tdi_bit )
+static void clock_tms(uint8_t mpsse_cmd, int tms_bits, int tms_count, bool tdi_bit)
-// LOG_DEBUG("mpsse cmd=%02x, tms_bits=0x%08x, bit_count=%d", mpsse_cmd, tms_bits, tms_count );
+// LOG_DEBUG("mpsse cmd=%02x, tms_bits=0x%08x, bit_count=%d", mpsse_cmd, tms_bits, tms_count);
int tms_bits = tap_get_tms_path(start_state, goal_state);
int tms_count = tap_get_tms_path_len(start_state, goal_state);
int tms_bits = tap_get_tms_path(start_state, goal_state);
int tms_count = tap_get_tms_path_len(start_state, goal_state);
- clock_tms( 0x4b, tms_bits, tms_count, 0 );
+ clock_tms(0x4b, tms_bits, tms_count, 0);
- .name = "ft2232",
- .execute_queue = ft2232_execute_queue,
- .speed = ft2232_speed,
- .speed_div = ft2232_speed_div,
- .khz = ft2232_khz,
- .register_commands = ft2232_register_commands,
- .init = ft2232_init,
- .quit = ft2232_quit,
+ .name = "ft2232",
+ .execute_queue = ft2232_execute_queue,
+ .speed = ft2232_speed,
+ .speed_div = ft2232_speed_div,
+ .khz = ft2232_khz,
+ .register_commands = ft2232_register_commands,
+ .init = ft2232_init,
+ .quit = ft2232_quit,
- DWORD dw_bytes_written;
- if ( ( status = FT_Write(ftdih, buf, size, &dw_bytes_written) ) != FT_OK )
+ DWORD dw_bytes_written;
+ if ((status = FT_Write(ftdih, buf, size, &dw_bytes_written)) != FT_OK)
{
*bytes_written = dw_bytes_written;
LOG_ERROR("FT_Write returned: %lu", status);
{
*bytes_written = dw_bytes_written;
LOG_ERROR("FT_Write returned: %lu", status);
- if ( ( status = FT_Read(ftdih, buf + *bytes_read, size -
- *bytes_read, &dw_bytes_read) ) != FT_OK )
+ if ((status = FT_Read(ftdih, buf + *bytes_read, size -
+ *bytes_read, &dw_bytes_read)) != FT_OK)
- LOG_ERROR("couldn't read the requested number of bytes from FT2232 device (%i < %i)", *bytes_read, size);
+ LOG_ERROR("couldn't read the requested number of bytes from FT2232 device (%i < %i)",
+ (unsigned int)(*bytes_read),
+ (unsigned int)size);
int retval = ft2232_write(&buf, 1, &bytes_written);
if (ERROR_OK != retval || bytes_written != 1)
{
int retval = ft2232_write(&buf, 1, &bytes_written);
if (ERROR_OK != retval || bytes_written != 1)
{
buf[1] = speed & 0xff; /* valueL (0=6MHz, 1=3MHz, 2=2.0MHz, ...*/
buf[2] = (speed >> 8) & 0xff; /* valueH */
LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
buf[1] = speed & 0xff; /* valueL (0=6MHz, 1=3MHz, 2=2.0MHz, ...*/
buf[2] = (speed >> 8) & 0xff; /* valueH */
LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
if (bits_left > 1)
{
buffer[cur_byte] = buffer_read() >> 1;
}
/* This shift depends on the length of the clock data to tms instruction, insterted at end of the scan, now fixed to a two step transition in ft2232_add_scan */
if (bits_left > 1)
{
buffer[cur_byte] = buffer_read() >> 1;
}
/* This shift depends on the length of the clock data to tms instruction, insterted at end of the scan, now fixed to a two step transition in ft2232_add_scan */
#ifdef _DEBUG_USB_IO_
struct timeval start, inter, inter2, end;
#ifdef _DEBUG_USB_IO_
struct timeval start, inter, inter2, end;
* ending with the last state at path[num_states-1]
* @param num_states is the count of state steps to move through
*/
* ending with the last state at path[num_states-1]
* @param num_states is the count of state steps to move through
*/
- else if (tap_state_transition(walker, true) == desired_next_state )
- tms_bits |= (1<<state_ndx);
+ else if (tap_state_transition(walker, true) == desired_next_state)
+ tms_bits |= (1 << state_ndx);
- LOG_ERROR( "BUG: %s -> %s isn't a valid TAP transition",
- tap_state_name(walker), tap_state_name(desired_next_state) );
+ LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition",
+ tap_state_name(walker), tap_state_name(desired_next_state));
- clock_tms( 0x4b, tms_bits, num_states, 0 );
+ clock_tms(0x4b, tms_bits, num_states, 0);
-void ft2232_add_scan(bool ir_scan, enum scan_type type, u8* buffer, int scan_size)
+static void ft2232_add_scan(bool ir_scan, enum scan_type type, uint8_t* buffer, int scan_size)
/* LOG_DEBUG("added TDI bytes (io %i)", num_bytes); */
}
else if (type == SCAN_OUT)
{
/* Clock Data Bytes Out on -ve Clock Edge LSB First (no Read) */
/* LOG_DEBUG("added TDI bytes (io %i)", num_bytes); */
}
else if (type == SCAN_OUT)
{
/* Clock Data Bytes Out on -ve Clock Edge LSB First (no Read) */
/* LOG_DEBUG("added TDI bytes (o)"); */
}
else if (type == SCAN_IN)
{
/* Clock Data Bytes In on +ve Clock Edge LSB First (no Write) */
/* LOG_DEBUG("added TDI bytes (o)"); */
}
else if (type == SCAN_IN)
{
/* Clock Data Bytes In on +ve Clock Edge LSB First (no Write) */
/* LOG_DEBUG("added TDI bytes (i %i)", num_bytes); */
}
thisrun_bytes = (num_bytes > 65537) ? 65536 : (num_bytes - 1);
num_bytes -= thisrun_bytes;
/* LOG_DEBUG("added TDI bytes (i %i)", num_bytes); */
}
thisrun_bytes = (num_bytes > 65537) ? 65536 : (num_bytes - 1);
num_bytes -= thisrun_bytes;
/* LOG_DEBUG("added TDI bits (io) %i", bits_left - 1); */
}
else if (type == SCAN_OUT)
{
/* Clock Data Bits Out on -ve Clock Edge LSB First (no Read) */
/* LOG_DEBUG("added TDI bits (io) %i", bits_left - 1); */
}
else if (type == SCAN_OUT)
{
/* Clock Data Bits Out on -ve Clock Edge LSB First (no Read) */
/* LOG_DEBUG("added TDI bits (o)"); */
}
else if (type == SCAN_IN)
{
/* Clock Data Bits In on +ve Clock Edge LSB First (no Write) */
/* LOG_DEBUG("added TDI bits (o)"); */
}
else if (type == SCAN_IN)
{
/* Clock Data Bits In on +ve Clock Edge LSB First (no Write) */
- if ( ( ir_scan && (tap_get_end_state() == TAP_IRSHIFT) )
- || ( !ir_scan && (tap_get_end_state() == TAP_DRSHIFT) ) )
+ if (( ir_scan && (tap_get_end_state() == TAP_IRSHIFT))
+ || (!ir_scan && (tap_get_end_state() == TAP_DRSHIFT)))
/* LOG_DEBUG("added TDI bits (io) %i", bits_left - 1); */
}
else if (type == SCAN_OUT)
{
/* Clock Data Bits Out on -ve Clock Edge LSB First (no Read) */
/* LOG_DEBUG("added TDI bits (io) %i", bits_left - 1); */
}
else if (type == SCAN_OUT)
{
/* Clock Data Bits Out on -ve Clock Edge LSB First (no Read) */
/* LOG_DEBUG("added TDI bits (o)"); */
}
else if (type == SCAN_IN)
{
/* Clock Data Bits In on +ve Clock Edge LSB First (no Write) */
/* LOG_DEBUG("added TDI bits (o)"); */
}
else if (type == SCAN_IN)
{
/* Clock Data Bits In on +ve Clock Edge LSB First (no Write) */
- tms_bits = tap_get_tms_path( tap_get_state(), tap_get_end_state() );
- tms_count = tap_get_tms_path_len( tap_get_state(), tap_get_end_state() );
+ tms_bits = tap_get_tms_path(tap_get_state(), tap_get_end_state());
+ tms_count = tap_get_tms_path_len(tap_get_state(), tap_get_end_state());
- clock_tms( mpsse_cmd, tms_bits, tms_count, last_bit );
+ clock_tms(mpsse_cmd, tms_bits, tms_count, last_bit);
-static int ft2232_large_scan(scan_command_t* cmd, enum scan_type type, u8* buffer, int scan_size)
+static int ft2232_large_scan(scan_command_t* cmd, enum scan_type type, uint8_t* buffer, int scan_size)
- u8* receive_buffer = malloc( CEIL(scan_size, 8) );
- u8* receive_pointer = receive_buffer;
- u32 bytes_written;
- u32 bytes_read;
+ uint8_t* receive_buffer = malloc(CEIL(scan_size, 8));
+ uint8_t* receive_pointer = receive_buffer;
+ uint32_t bytes_written;
+ uint32_t bytes_read;
- LOG_DEBUG("ft2232_buffer_size: %i, bytes_written: %i", ft2232_buffer_size, bytes_written);
+ LOG_DEBUG("ft2232_buffer_size: %i, bytes_written: %i",
+ ft2232_buffer_size, (int)bytes_written);
/* LOG_DEBUG("added TDI bytes (io %i)", num_bytes); */
}
else if (type == SCAN_OUT)
{
/* Clock Data Bytes Out on -ve Clock Edge LSB First (no Read) */
/* LOG_DEBUG("added TDI bytes (io %i)", num_bytes); */
}
else if (type == SCAN_OUT)
{
/* Clock Data Bytes Out on -ve Clock Edge LSB First (no Read) */
/* LOG_DEBUG("added TDI bytes (o)"); */
}
else if (type == SCAN_IN)
{
/* Clock Data Bytes In on +ve Clock Edge LSB First (no Write) */
/* LOG_DEBUG("added TDI bytes (o)"); */
}
else if (type == SCAN_IN)
{
/* Clock Data Bytes In on +ve Clock Edge LSB First (no Write) */
/* LOG_DEBUG("added TDI bytes (i %i)", num_bytes); */
}
thisrun_bytes = (num_bytes > 65537) ? 65536 : (num_bytes - 1);
thisrun_read = thisrun_bytes;
num_bytes -= thisrun_bytes;
/* LOG_DEBUG("added TDI bytes (i %i)", num_bytes); */
}
thisrun_bytes = (num_bytes > 65537) ? 65536 : (num_bytes - 1);
thisrun_read = thisrun_bytes;
num_bytes -= thisrun_bytes;
- LOG_DEBUG("ft2232_buffer_size: %i, bytes_written: %i", ft2232_buffer_size, bytes_written);
+ LOG_DEBUG("ft2232_buffer_size: %i, bytes_written: %i",
+ ft2232_buffer_size,
+ (int)bytes_written);
- LOG_DEBUG("thisrun_read: %i, bytes_read: %i", thisrun_read, bytes_read);
+ LOG_DEBUG("thisrun_read: %i, bytes_read: %i",
+ thisrun_read,
+ (int)bytes_read);
/* LOG_DEBUG("added TDI bits (io) %i", bits_left - 1); */
}
else if (type == SCAN_OUT)
{
/* Clock Data Bits Out on -ve Clock Edge LSB First (no Read) */
/* LOG_DEBUG("added TDI bits (io) %i", bits_left - 1); */
}
else if (type == SCAN_OUT)
{
/* Clock Data Bits Out on -ve Clock Edge LSB First (no Read) */
/* LOG_DEBUG("added TDI bits (o)"); */
}
else if (type == SCAN_IN)
{
/* Clock Data Bits In on +ve Clock Edge LSB First (no Write) */
/* LOG_DEBUG("added TDI bits (o)"); */
}
else if (type == SCAN_IN)
{
/* Clock Data Bits In on +ve Clock Edge LSB First (no Write) */
/* LOG_DEBUG("added TDI bits (io) %i", bits_left - 1); */
}
else if (type == SCAN_OUT)
{
/* Clock Data Bits Out on -ve Clock Edge LSB First (no Read) */
/* LOG_DEBUG("added TDI bits (io) %i", bits_left - 1); */
}
else if (type == SCAN_OUT)
{
/* Clock Data Bits Out on -ve Clock Edge LSB First (no Read) */
/* LOG_DEBUG("added TDI bits (o)"); */
}
else if (type == SCAN_IN)
{
/* Clock Data Bits In on +ve Clock Edge LSB First (no Write) */
/* LOG_DEBUG("added TDI bits (o)"); */
}
else if (type == SCAN_IN)
{
/* Clock Data Bits In on +ve Clock Edge LSB First (no Write) */
- int tms_bits = tap_get_tms_path( tap_get_state(), tap_get_end_state() );
- int tms_count = tap_get_tms_path_len( tap_get_state(), tap_get_end_state() );
- u8 mpsse_cmd;
+ int tms_bits = tap_get_tms_path(tap_get_state(), tap_get_end_state());
+ int tms_count = tap_get_tms_path_len(tap_get_state(), tap_get_end_state());
+ uint8_t mpsse_cmd;
- clock_tms( mpsse_cmd, tms_bits, tms_count, last_bit );
+ clock_tms(mpsse_cmd, tms_bits, tms_count, last_bit);
- LOG_DEBUG("ft2232_buffer_size: %i, bytes_written: %i", ft2232_buffer_size, bytes_written);
+ LOG_DEBUG("ft2232_buffer_size: %i, bytes_written: %i",
+ ft2232_buffer_size,
+ (int)bytes_written);
- LOG_DEBUG("thisrun_read: %i, bytes_read: %i", thisrun_read, bytes_read);
+ LOG_DEBUG("thisrun_read: %i, bytes_read: %i",
+ thisrun_read,
+ (int)bytes_read);
predicted_size += CEIL(num_bytes, 65536) * 3;
/* remaining bits - 1 (up to 7) */
predicted_size += CEIL(num_bytes, 65536) * 3;
/* remaining bits - 1 (up to 7) */
predicted_size += num_bytes + CEIL(num_bytes, 65536) * 3;
/* remaining bits -1 (up to 7) */
predicted_size += num_bytes + CEIL(num_bytes, 65536) * 3;
/* remaining bits -1 (up to 7) */
LOG_DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst, srst, high_output,
high_direction);
}
LOG_DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst, srst, high_output,
high_direction);
}
LOG_DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst, srst, high_output,
high_direction);
}
LOG_DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst, srst, high_output,
high_direction);
}
LOG_DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst, srst, high_output,
high_direction);
}
LOG_DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst, srst, high_output,
high_direction);
}
LOG_DEBUG("trst: %i, srst: %i, low_output: 0x%2.2x, low_direction: 0x%2.2x", trst, srst, low_output, low_direction);
}
LOG_DEBUG("trst: %i, srst: %i, low_output: 0x%2.2x, low_direction: 0x%2.2x", trst, srst, low_output, low_direction);
}
LOG_DEBUG("srst: %i, low_output: 0x%2.2x, low_direction: 0x%2.2x", srst, low_output, low_direction);
}
LOG_DEBUG("srst: %i, low_output: 0x%2.2x, low_direction: 0x%2.2x", srst, low_output, low_direction);
}
LOG_DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst, srst, high_output,
high_direction);
}
LOG_DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst, srst, high_output,
high_direction);
}
LOG_DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst, srst, high_output,
high_direction);
}
LOG_DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst, srst, high_output,
high_direction);
}
LOG_DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst, srst, high_output, high_direction);
}
LOG_DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst, srst, high_output, high_direction);
}
if (tap_get_state() != TAP_IDLE)
predicted_size += 3;
predicted_size += 3 * CEIL(cmd->cmd.runtest->num_cycles, 7);
if (tap_get_state() != TAP_IDLE)
predicted_size += 3;
predicted_size += 3 * CEIL(cmd->cmd.runtest->num_cycles, 7);
/* there are no state transitions in this code, so omit state tracking */
/* command "Clock Data to TMS/CS Pin (no Read)" */
/* there are no state transitions in this code, so omit state tracking */
/* command "Clock Data to TMS/CS Pin (no Read)" */
- LOG_DEBUG( "runtest: %i, end in %s", cmd->cmd.runtest->num_cycles, tap_state_name( tap_get_end_state() ) );
+ LOG_DEBUG("runtest: %i, end in %s", cmd->cmd.runtest->num_cycles, tap_state_name(tap_get_end_state()));
int retval = ERROR_OK;
tap_state_t* path = cmd->cmd.pathmove->path;
int num_states = cmd->cmd.pathmove->num_states;
DEBUG_JTAG_IO("pathmove: %i states, current: %s end: %s", num_states,
int retval = ERROR_OK;
tap_state_t* path = cmd->cmd.pathmove->path;
int num_states = cmd->cmd.pathmove->num_states;
DEBUG_JTAG_IO("pathmove: %i states, current: %s end: %s", num_states,
- tap_state_name( tap_get_state() ),
- tap_state_name( path[num_states-1] )
+ tap_state_name(tap_get_state()),
+ tap_state_name(path[num_states-1])
scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer);
predicted_size = ft2232_predict_scan_out(scan_size, type);
scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer);
predicted_size = ft2232_predict_scan_out(scan_size, type);
{
LOG_DEBUG("oversized ft2232 scan (predicted_size > FT2232_BUFFER_SIZE)");
/* unsent commands before this */
{
LOG_DEBUG("oversized ft2232 scan (predicted_size > FT2232_BUFFER_SIZE)");
/* unsent commands before this */
- LOG_DEBUG( "%s scan, %i bits, end in %s", (cmd->cmd.scan->ir_scan) ? "IR" : "DR", scan_size,
- tap_state_name( tap_get_end_state() ) );
+ LOG_DEBUG("%s scan, %i bits, end in %s", (cmd->cmd.scan->ir_scan) ? "IR" : "DR", scan_size,
+ tap_state_name(tap_get_end_state()));
if (ft2232_stableclocks(cmd->cmd.stableclocks->num_cycles, cmd) != ERROR_OK)
retval = ERROR_JTAG_QUEUE_FAILED;
#ifdef _DEBUG_JTAG_IO_
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() ) );
+ LOG_DEBUG("clocks %i while in %s", cmd->cmd.stableclocks->num_cycles, tap_state_name(tap_get_state()));
- case JTAG_RESET: retval = ft2232_execute_reset(cmd); break;
- case JTAG_RUNTEST: retval = ft2232_execute_runtest(cmd); break;
- case JTAG_STATEMOVE: retval = ft2232_execute_statemove(cmd); break;
- case JTAG_PATHMOVE: retval = ft2232_execute_pathmove(cmd); break;
- case JTAG_SCAN: retval = ft2232_execute_scan(cmd); break;
- case JTAG_SLEEP: retval = ft2232_execute_sleep(cmd); break;
- case JTAG_STABLECLOCKS: retval = ft2232_execute_stableclocks(cmd); break;
+ case JTAG_RESET: retval = ft2232_execute_reset(cmd); break;
+ case JTAG_RUNTEST: retval = ft2232_execute_runtest(cmd); break;
+ case JTAG_STATEMOVE: retval = ft2232_execute_statemove(cmd); break;
+ case JTAG_PATHMOVE: retval = ft2232_execute_pathmove(cmd); break;
+ case JTAG_SCAN: retval = ft2232_execute_scan(cmd); break;
+ case JTAG_SLEEP: retval = ft2232_execute_sleep(cmd); break;
+ case JTAG_STABLECLOCKS: retval = ft2232_execute_stableclocks(cmd); break;
-static int ft2232_init_ftd2xx(u16 vid, u16 pid, int more, int* try_more)
+static int ft2232_init_ftd2xx(uint16_t vid, uint16_t pid, int more, int* try_more)
LOG_DEBUG("'ft2232' interface using FTD2XX with '%s' layout (%4.4x:%4.4x)", ft2232_layout, vid, pid);
#if IS_WIN32 == 0
/* Add non-standard Vid/Pid to the linux driver */
LOG_DEBUG("'ft2232' interface using FTD2XX with '%s' layout (%4.4x:%4.4x)", ft2232_layout, vid, pid);
#if IS_WIN32 == 0
/* Add non-standard Vid/Pid to the linux driver */
// under Win32, the FTD2XX driver appends an "A" to the end
// of the description, if we tried by the desc, then
// try by the alternate "A" description.
// under Win32, the FTD2XX driver appends an "A" to the end
// of the description, if we tried by the desc, then
// try by the alternate "A" description.
// Try the alternate method.
openex_string = ft2232_device_desc_A;
status = FT_OpenEx(openex_string, openex_flags, &ftdih);
// Try the alternate method.
openex_string = ft2232_device_desc_A;
status = FT_OpenEx(openex_string, openex_flags, &ftdih);
// yea, the "alternate" method worked!
} else {
// drat, give the user a meaningfull message.
// telling the use we tried *BOTH* methods.
LOG_WARNING("Unable to open FTDI Device tried: '%s' and '%s'\n",
ft2232_device_desc,
// yea, the "alternate" method worked!
} else {
// drat, give the user a meaningfull message.
// telling the use we tried *BOTH* methods.
LOG_WARNING("Unable to open FTDI Device tried: '%s' and '%s'\n",
ft2232_device_desc,
{
LOG_ERROR("unable to set latency timer: %lu", status);
return ERROR_JTAG_INIT_FAILED;
}
{
LOG_ERROR("unable to set latency timer: %lu", status);
return ERROR_JTAG_INIT_FAILED;
}
{
LOG_ERROR("unable to get latency timer: %lu", status);
return ERROR_JTAG_INIT_FAILED;
{
LOG_ERROR("unable to get latency timer: %lu", status);
return ERROR_JTAG_INIT_FAILED;
{
LOG_ERROR("unable to set timeouts: %lu", status);
return ERROR_JTAG_INIT_FAILED;
}
{
LOG_ERROR("unable to set timeouts: %lu", status);
return ERROR_JTAG_INIT_FAILED;
}
{
LOG_ERROR("unable to enable bit i/o mode: %lu", status);
return ERROR_JTAG_INIT_FAILED;
}
{
LOG_ERROR("unable to enable bit i/o mode: %lu", status);
return ERROR_JTAG_INIT_FAILED;
}
- if ( ( status = FT_GetDeviceInfo(ftdih, &ftdi_device, &deviceID, SerialNumber, Description, NULL) ) != FT_OK )
+ if ((status = FT_GetDeviceInfo(ftdih, &ftdi_device, &deviceID, SerialNumber, Description, NULL)) != FT_OK)
{
LOG_ERROR("unable to get FT_GetDeviceInfo: %lu", status);
return ERROR_JTAG_INIT_FAILED;
{
LOG_ERROR("unable to get FT_GetDeviceInfo: %lu", status);
return ERROR_JTAG_INIT_FAILED;
{
LOG_ERROR("error purging ftd2xx device: %lu", status);
return ERROR_JTAG_INIT_FAILED;
{
LOG_ERROR("error purging ftd2xx device: %lu", status);
return ERROR_JTAG_INIT_FAILED;
-static int ft2232_init_libftdi(u16 vid, u16 pid, int more, int* try_more)
+static int ft2232_init_libftdi(uint16_t vid, uint16_t pid, int more, int* try_more)
LOG_DEBUG("'ft2232' interface using libftdi with '%s' layout (%4.4x:%4.4x)",
ft2232_layout, vid, pid);
LOG_DEBUG("'ft2232' interface using libftdi with '%s' layout (%4.4x:%4.4x)",
ft2232_layout, vid, pid);
LOG_DEBUG("ft2232 interface using 7 step jtag state transitions");
}
else
{
LOG_DEBUG("ft2232 interface using shortest path jtag state transitions");
LOG_DEBUG("ft2232 interface using 7 step jtag state transitions");
}
else
{
LOG_DEBUG("ft2232 interface using shortest path jtag state transitions");
{
ft2232_layout = "usbjtag";
LOG_WARNING("No ft2232 layout specified, using default 'usbjtag'");
{
ft2232_layout = "usbjtag";
LOG_WARNING("No ft2232 layout specified, using default 'usbjtag'");
buf[2] = low_direction; /* dir (output=1), TCK/TDI/TMS=out, TDO=in */
LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
buf[2] = low_direction; /* dir (output=1), TCK/TDI/TMS=out, TDO=in */
LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
buf[2] = low_direction; /* dir (output=1), TCK/TDI/TMS=out, TDO=in, nOE=out */
LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
buf[2] = low_direction; /* dir (output=1), TCK/TDI/TMS=out, TDO=in, nOE=out */
LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
if (jtag_reset_config & RESET_TRST_OPEN_DRAIN)
{
LOG_ERROR("can't set nTRSTOE to push-pull on the Dicarlo jtag");
if (jtag_reset_config & RESET_TRST_OPEN_DRAIN)
{
LOG_ERROR("can't set nTRSTOE to push-pull on the Dicarlo jtag");
buf[2] = high_direction; /* all outputs (xRST and xRSTnOE) */
LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
buf[2] = high_direction; /* all outputs (xRST and xRSTnOE) */
LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
buf[2] = low_direction; /* dir (output=1), TCK/TDI/TMS=out, TDO=in, nOE=out */
LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
buf[2] = low_direction; /* dir (output=1), TCK/TDI/TMS=out, TDO=in, nOE=out */
LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
- else if ( (strcmp(layout->name, "jtagkey_prototype_v1") == 0)
- || (strcmp(layout->name, "oocdlink") == 0) )
+ else if ((strcmp(layout->name, "jtagkey_prototype_v1") == 0)
+ || (strcmp(layout->name, "oocdlink") == 0))
buf[2] = high_direction; /* all outputs (xRST and xRSTnOE) */
LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
buf[2] = high_direction; /* all outputs (xRST and xRSTnOE) */
LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
buf[2] = low_direction; /* dir (output=1), TCK/TDI/TMS=out, TDO=in, nOE=out */
LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
buf[2] = low_direction; /* dir (output=1), TCK/TDI/TMS=out, TDO=in, nOE=out */
LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
buf[2] = high_direction; /* all outputs (xRST and xRSTnOE) */
LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
buf[2] = high_direction; /* all outputs (xRST and xRSTnOE) */
LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
buf[2] = low_direction; /* dir (output=1), TCK/TDI/TMS=out, TDO=in, nOE[12]=out, n[ST]srst=out */
LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
buf[2] = low_direction; /* dir (output=1), TCK/TDI/TMS=out, TDO=in, nOE[12]=out, n[ST]srst=out */
LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
buf[2] = high_direction; /* all outputs (xRST and xRSTnOE) */
LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
buf[2] = high_direction; /* all outputs (xRST and xRSTnOE) */
LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
buf[2] = low_direction; /* dir (output=1), TCK/TDI/TMS=out, TDO=in, nOE=out */
LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
buf[2] = low_direction; /* dir (output=1), TCK/TDI/TMS=out, TDO=in, nOE=out */
LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
buf[2] = high_direction;
LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
buf[2] = high_direction;
LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
buf[2] = low_direction; /* dir (output=1), TCK/TDI/TMS=out, TDO=in, nOE=out */
LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
buf[2] = low_direction; /* dir (output=1), TCK/TDI/TMS=out, TDO=in, nOE=out */
LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
buf[2] = high_direction;
LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
buf[2] = high_direction;
LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
buf[2] = low_direction; /* dir (output=1), TCK/TDI/TMS=out, TDO=in, nOE=out */
LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
buf[2] = low_direction; /* dir (output=1), TCK/TDI/TMS=out, TDO=in, nOE=out */
LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
buf[2] = high_direction;
LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
buf[2] = high_direction;
LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
buf[2] = low_direction; /* dir (output=1), TCK/TDI/TMS=out, TDO=in, nOE=out */
LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
buf[2] = low_direction; /* dir (output=1), TCK/TDI/TMS=out, TDO=in, nOE=out */
LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
buf[2] = high_direction;
LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
buf[2] = high_direction;
LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
// under Win32, the FTD2XX driver appends an "A" to the end
// of the description, this examines the given desc
// and creates the 'missing' _A or non_A variable.
// under Win32, the FTD2XX driver appends an "A" to the end
// of the description, this examines the given desc
// and creates the 'missing' _A or non_A variable.
// it was, so make this the "A" version.
ft2232_device_desc_A = ft2232_device_desc;
// and *CREATE* the non-A version.
// it was, so make this the "A" version.
ft2232_device_desc_A = ft2232_device_desc;
// and *CREATE* the non-A version.
- sprintf( buf, "%s A", ft2232_device_desc );
- ft2232_device_desc_A = strdup( buf );
+ sprintf(buf, "%s A", ft2232_device_desc);
+ ft2232_device_desc_A = strdup(buf);
static int ft2232_handle_vid_pid_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc)
{
static int ft2232_handle_vid_pid_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc)
{
if (argc > MAX_USB_IDS * 2)
{
LOG_WARNING("ignoring extra IDs in ft2232_vid_pid "
"(maximum is %d pairs)", MAX_USB_IDS);
argc = MAX_USB_IDS * 2;
}
if (argc > MAX_USB_IDS * 2)
{
LOG_WARNING("ignoring extra IDs in ft2232_vid_pid "
"(maximum is %d pairs)", MAX_USB_IDS);
argc = MAX_USB_IDS * 2;
}
- ft2232_vid[i >> 1] = strtol(args[i], NULL, 0);
- ft2232_pid[i >> 1] = strtol(args[i + 1], NULL, 0);
+ retval = parse_u16(args[i], &ft2232_vid[i >> 1]);
+ if (ERROR_OK != retval)
+ break;
+ retval = parse_u16(args[i + 1], &ft2232_pid[i >> 1]);
+ if (ERROR_OK != retval)
+ break;
/* there are no state transitions in this code, so omit state tracking */
/* command "Clock Data to TMS/CS Pin (no Read)" */
/* there are no state transitions in this code, so omit state tracking */
/* command "Clock Data to TMS/CS Pin (no Read)" */
/* ---------------------------------------------------------------------
* Support for IceBear JTAG adapter from Section5:
/* ---------------------------------------------------------------------
* Support for IceBear JTAG adapter from Section5:
low_direction = 0x0b; /* output: TCK TDI TMS; input: TDO */
low_output = 0x08; /* high: TMS; low: TCK TDI */
nTRST = 0x10;
nSRST = 0x20;
low_direction = 0x0b; /* output: TCK TDI TMS; input: TDO */
low_output = 0x08; /* high: TMS; low: TCK TDI */
nTRST = 0x10;
nSRST = 0x20;
if ((jtag_reset_config & RESET_TRST_OPEN_DRAIN) != 0) {
low_direction &= ~nTRST; /* nTRST high impedance */
}
if ((jtag_reset_config & RESET_TRST_OPEN_DRAIN) != 0) {
low_direction &= ~nTRST; /* nTRST high impedance */
}
buf[2] = low_direction;
LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
buf[2] = low_direction;
LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
buf[2] = high_direction; /* all outputs (xRST and xRSTnOE) */
LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
buf[2] = high_direction; /* all outputs (xRST and xRSTnOE) */
LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
LOG_DEBUG("trst: %i, srst: %i, low_output: 0x%2.2x, low_direction: 0x%2.2x", trst, srst, low_output, low_direction);
}
LOG_DEBUG("trst: %i, srst: %i, low_output: 0x%2.2x, low_direction: 0x%2.2x", trst, srst, low_output, low_direction);
}