Accept/create both A and Non-A ft2232 based descriptions
authorduane <duane@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Sat, 7 Mar 2009 15:51:26 +0000 (15:51 +0000)
committerduane <duane@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Sat, 7 Mar 2009 15:51:26 +0000 (15:51 +0000)
git-svn-id: svn://svn.berlios.de/openocd/trunk@1401 b42882b7-edfa-0310-969c-e2dbd0fdcd60

src/jtag/ft2232.c

index 52e9df17f4d05e8bca970076bc18a9d5c365c4fb..ae72e35da906900946f7b4082650f68593d65139 100644 (file)
@@ -97,6 +97,7 @@ int ft2232_handle_latency_command(struct command_context_s* cmd_ctx, char* cmd,
 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;
@@ -1570,7 +1571,28 @@ static int ft2232_init_ftd2xx(u16 vid, u16 pid, int more, int* try_more)
                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;
 
@@ -2414,9 +2436,29 @@ int ft2232_quit(void)
 
 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
        {

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)