static int ft2232_stableclocks(int num_cycles, jtag_command_t* cmd);
+char * ft2232_device_desc_A = NULL;
char* ft2232_device_desc = NULL;
char* ft2232_serial = NULL;
char* ft2232_layout = NULL;
switch (cmd->type)
{
case JTAG_END_STATE:
- if (cmd->cmd.end_state->end_state != -1)
+ if (cmd->cmd.end_state->end_state != TAP_INVALID)
ft2232_end_state(cmd->cmd.end_state->end_state);
break;
if (tap_get_state() != TAP_IDLE)
predicted_size += 3;
predicted_size += 3 * CEIL(cmd->cmd.runtest->num_cycles, 7);
- if ( (cmd->cmd.runtest->end_state != -1) && (cmd->cmd.runtest->end_state != TAP_IDLE) )
+ if ( (cmd->cmd.runtest->end_state != TAP_INVALID) && (cmd->cmd.runtest->end_state != TAP_IDLE) )
predicted_size += 3;
- if ( (cmd->cmd.runtest->end_state == -1) && (tap_get_end_state() != TAP_IDLE) )
+ if ( (cmd->cmd.runtest->end_state == TAP_INVALID) && (tap_get_end_state() != TAP_IDLE) )
predicted_size += 3;
if (ft2232_buffer_size + predicted_size + 1 > FT2232_BUFFER_SIZE)
{
/* LOG_DEBUG("added TMS scan (no read)"); */
}
- if (cmd->cmd.runtest->end_state != -1)
+ if (cmd->cmd.runtest->end_state != TAP_INVALID)
ft2232_end_state(cmd->cmd.runtest->end_state);
if ( tap_get_state() != tap_get_end_state() )
require_send = 0;
first_unsent = cmd;
}
- if (cmd->cmd.statemove->end_state != -1)
+ if (cmd->cmd.statemove->end_state != TAP_INVALID)
ft2232_end_state(cmd->cmd.statemove->end_state);
/* command "Clock Data to TMS/CS Pin (no Read)" */
retval = ERROR_JTAG_QUEUE_FAILED;
/* current command */
- if (cmd->cmd.scan->end_state != -1)
+ if (cmd->cmd.scan->end_state != TAP_INVALID)
ft2232_end_state(cmd->cmd.scan->end_state);
ft2232_large_scan(cmd->cmd.scan, type, buffer, scan_size);
require_send = 0;
}
ft2232_expect_read += ft2232_predict_scan_in(scan_size, type);
/* LOG_DEBUG("new read size: %i", ft2232_expect_read); */
- if (cmd->cmd.scan->end_state != -1)
+ if (cmd->cmd.scan->end_state != TAP_INVALID)
ft2232_end_state(cmd->cmd.scan->end_state);
ft2232_add_scan(cmd->cmd.scan->ir_scan, type, buffer, scan_size);
require_send = 1;
return ERROR_JTAG_INIT_FAILED;
}
- if ( ( status = FT_OpenEx(openex_string, openex_flags, &ftdih) ) != FT_OK )
+ status = FT_OpenEx(openex_string, openex_flags, &ftdih);
+ if( status != FT_OK ){
+ // 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.
+ if( openex_string == ft2232_device_desc ){
+ // Try the alternate method.
+ openex_string = ft2232_device_desc_A;
+ status = FT_OpenEx(openex_string, openex_flags, &ftdih);
+ if( status == FT_OK ){
+ // 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,
+ ft2232_device_desc_A );
+ }
+ }
+ }
+
+ if ( status != FT_OK )
{
DWORD num_devices;
int ft2232_handle_device_desc_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc)
{
+ char *cp;
+ char buf[200];
if (argc == 1)
{
ft2232_device_desc = strdup(args[0]);
+ cp = strchr( ft2232_device_desc, 0 );
+ // 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.
+ if( (cp[-1] == 'A') && (cp[-2]==' ') ){
+ // it was, so make this the "A" version.
+ ft2232_device_desc_A = ft2232_device_desc;
+ // and *CREATE* the non-A version.
+ strcpy( buf, ft2232_device_desc );
+ cp = strchr( buf, 0 );
+ cp[-2] = 0;
+ ft2232_device_desc = strdup( buf );
+ } else {
+ // <space>A not defined
+ // so create it
+ sprintf( buf, "%s A", ft2232_device_desc );
+ ft2232_device_desc_A = strdup( buf );
+ }
}
else
{