Zach Welch <zw@superlucidity.net> fix ft2232 usb io format warning
[openocd.git] / src / jtag / ft2232.c
index 9a3c986fecf6f70cb2944785dfd4bebbfb16fb82..62b15d656d8a916c1ab584aae9c44b025c6352ba 100644 (file)
 #include <ftdi.h>
 #endif
 
-/* enable this to debug io latency
- */
-#if 0
-#define _DEBUG_USB_IO_
-#endif
-
-/* enable this to debug communication
- */
-#if 0
-#define _DEBUG_USB_COMMS_
-#endif
+static int ft2232_execute_queue(void);
 
-int ft2232_execute_queue(void);
+static int ft2232_speed(int speed);
+static int ft2232_speed_div(int speed, int* khz);
+static int ft2232_khz(int khz, int* jtag_speed);
+static int ft2232_register_commands(struct command_context_s* cmd_ctx);
+static int ft2232_init(void);
+static int ft2232_quit(void);
 
-int ft2232_speed(int speed);
-int ft2232_speed_div(int speed, int* khz);
-int ft2232_khz(int khz, int* jtag_speed);
-int ft2232_register_commands(struct command_context_s* cmd_ctx);
-int ft2232_init(void);
-int ft2232_quit(void);
-
-int ft2232_handle_device_desc_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc);
-int ft2232_handle_serial_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc);
-int ft2232_handle_layout_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc);
-int ft2232_handle_vid_pid_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc);
-int ft2232_handle_latency_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc);
+static int ft2232_handle_device_desc_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc);
+static int ft2232_handle_serial_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc);
+static int ft2232_handle_layout_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);
+static int ft2232_handle_latency_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc);
 
 
 /**
@@ -97,10 +85,11 @@ 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 = NULL;
-char*         ft2232_serial  = NULL;
-char*         ft2232_layout  = NULL;
-unsigned char ft2232_latency = 2;
+static char *        ft2232_device_desc_A = NULL;
+static char*         ft2232_device_desc = NULL;
+static char*         ft2232_serial  = NULL;
+static char*         ft2232_layout  = NULL;
+static unsigned char ft2232_latency = 2;
 
 #define MAX_USB_IDS 8
 /* vid = pid = 0 marks the end of the list */
@@ -116,28 +105,31 @@ typedef struct ft2232_layout_s
 } ft2232_layout_t;
 
 /* init procedures for supported layouts */
-int  usbjtag_init(void);
-int  jtagkey_init(void);
-int  olimex_jtag_init(void);
-int  flyswatter_init(void);
-int  turtle_init(void);
-int  comstick_init(void);
-int  stm32stick_init(void);
-int  axm0432_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);
 
 /* reset procedures for supported layouts */
-void usbjtag_reset(int trst, int srst);
-void jtagkey_reset(int trst, int srst);
-void olimex_jtag_reset(int trst, int srst);
-void flyswatter_reset(int trst, int srst);
-void turtle_reset(int trst, int srst);
-void comstick_reset(int trst, int srst);
-void stm32stick_reset(int trst, int srst);
-void axm0432_jtag_reset(int trst, int srst);
+static void usbjtag_reset(int trst, int srst);
+static void jtagkey_reset(int trst, int srst);
+static void olimex_jtag_reset(int trst, int srst);
+static void flyswatter_reset(int trst, int srst);
+static void turtle_reset(int trst, int srst);
+static void comstick_reset(int trst, int srst);
+static void stm32stick_reset(int trst, int srst);
+static void axm0432_jtag_reset(int trst, int srst);
+static void sheevaplug_reset(int trst, int srst);
 
 /* blink procedures for layouts that support a blinking led */
-void olimex_jtag_blink(void);
-void turtle_jtag_blink(void);
+static void olimex_jtag_blink(void);
+static void flyswatter_jtag_blink(void);
+static void turtle_jtag_blink(void);
 
 ft2232_layout_t            ft2232_layouts[] =
 {
@@ -148,12 +140,13 @@ ft2232_layout_t            ft2232_layouts[] =
        { "signalyzer",           usbjtag_init,              usbjtag_reset,      NULL                    },
        { "evb_lm3s811",          usbjtag_init,              usbjtag_reset,      NULL                    },
        { "olimex-jtag",          olimex_jtag_init,          olimex_jtag_reset,  olimex_jtag_blink       },
-       { "flyswatter",           flyswatter_init,           flyswatter_reset,   NULL                    },
+       { "flyswatter",           flyswatter_init,           flyswatter_reset,   flyswatter_jtag_blink   },
        { "turtelizer2",          turtle_init,               turtle_reset,       turtle_jtag_blink       },
        { "comstick",             comstick_init,             comstick_reset,     NULL                    },
        { "stm32stick",           stm32stick_init,           stm32stick_reset,   NULL                    },
        { "axm0432_jtag",         axm0432_jtag_init,         axm0432_jtag_reset, NULL                    },
-       { NULL,                   NULL,                      NULL },
+       {"sheevaplug",            sheevaplug_init,           sheevaplug_reset,   NULL                    },
+       { NULL,                   NULL,                      NULL,               NULL                    },
 };
 
 static u8                  nTRST, nTRSTnOE, nSRST, nSRSTnOE;
@@ -195,7 +188,7 @@ jtag_interface_t ft2232_interface =
        .quit = ft2232_quit,
 };
 
-int ft2232_write(u8* buf, int size, u32* bytes_written)
+static int ft2232_write(u8* buf, int size, u32* bytes_written)
 {
 #if BUILD_FT2232_FTD2XX == 1
        FT_STATUS status;
@@ -228,7 +221,7 @@ int ft2232_write(u8* buf, int size, u32* bytes_written)
 }
 
 
-int ft2232_read(u8* buf, int size, u32* bytes_read)
+static int ft2232_read(u8* buf, u32 size, u32* bytes_read)
 {
 #if BUILD_FT2232_FTD2XX == 1
        DWORD     dw_bytes_read;
@@ -276,7 +269,7 @@ int ft2232_read(u8* buf, int size, u32* bytes_read)
 }
 
 
-int ft2232_speed(int speed)
+static int ft2232_speed(int speed)
 {
        u8  buf[3];
        int retval;
@@ -297,7 +290,7 @@ int ft2232_speed(int speed)
 }
 
 
-int ft2232_speed_div(int speed, int* khz)
+static int ft2232_speed_div(int speed, int* khz)
 {
        /* Take a look in the FT2232 manual,
         * AN2232C-01 Command Processor for
@@ -309,7 +302,7 @@ int ft2232_speed_div(int speed, int* khz)
 }
 
 
-int ft2232_khz(int khz, int* jtag_speed)
+static int ft2232_khz(int khz, int* jtag_speed)
 {
        if (khz==0)
        {
@@ -350,7 +343,7 @@ int ft2232_khz(int khz, int* jtag_speed)
 }
 
 
-int ft2232_register_commands(struct command_context_s* cmd_ctx)
+static int ft2232_register_commands(struct command_context_s* cmd_ctx)
 {
        register_command(cmd_ctx, NULL, "ft2232_device_desc", ft2232_handle_device_desc_command,
                        COMMAND_CONFIG, "the USB device description of the FTDI FT2232 device");
@@ -378,7 +371,7 @@ void ft2232_end_state(tap_state_t state)
 }
 
 
-void ft2232_read_scan(enum scan_type type, u8* buffer, int scan_size)
+static void ft2232_read_scan(enum scan_type type, u8* buffer, int scan_size)
 {
        int num_bytes = (scan_size + 7) / 8;
        int bits_left = scan_size;
@@ -402,7 +395,7 @@ void ft2232_read_scan(enum scan_type type, u8* buffer, int scan_size)
 }
 
 
-void ft2232_debug_dump_buffer(void)
+static void ft2232_debug_dump_buffer(void)
 {
        int   i;
        char  line[256];
@@ -423,7 +416,7 @@ void ft2232_debug_dump_buffer(void)
 }
 
 
-int ft2232_send_and_recv(jtag_command_t* first, jtag_command_t* last)
+static int ft2232_send_and_recv(jtag_command_t* first, jtag_command_t* last)
 {
        jtag_command_t* cmd;
        u8*             buffer;
@@ -479,9 +472,10 @@ int ft2232_send_and_recv(jtag_command_t* first, jtag_command_t* last)
                timeval_subtract(&d_inter2, &inter2, &start);
                timeval_subtract(&d_end, &end, &start);
 
-               LOG_INFO("inter: %i.%06i, inter2: %i.%06i end: %i.%06i", d_inter.tv_sec, d_inter.tv_usec, d_inter2.tv_sec,
-                               d_inter2.tv_usec, d_end.tv_sec,
-                               d_end.tv_usec);
+               LOG_INFO("inter: %u.%06u, inter2: %u.%06u end: %u.%06u",
+                       (unsigned)d_inter.tv_sec, (unsigned)d_inter.tv_usec,
+                       (unsigned)d_inter2.tv_sec, (unsigned)d_inter2.tv_usec,
+                       (unsigned)d_end.tv_sec, (unsigned)d_end.tv_usec);
 #endif
 
                ft2232_buffer_size = bytes_read;
@@ -541,7 +535,7 @@ int ft2232_send_and_recv(jtag_command_t* first, jtag_command_t* last)
 }
 
 
-void ft2232_add_pathmove(pathmove_command_t* cmd)
+static void ft2232_add_pathmove(pathmove_command_t* cmd)
 {
        int num_states = cmd->num_states;
        int state_count = 0;
@@ -562,9 +556,9 @@ void ft2232_add_pathmove(pathmove_command_t* cmd)
 
                while (num_states_batch--)
                {
-                       if (tap_state_transition(tap_get_state(), FALSE) == cmd->path[state_count])
+                       if (tap_state_transition(tap_get_state(), false) == cmd->path[state_count])
                                buf_set_u32(&tms_byte, bit_count++, 1, 0x0);
-                       else if (tap_state_transition(tap_get_state(), TRUE) == cmd->path[state_count])
+                       else if (tap_state_transition(tap_get_state(), true) == cmd->path[state_count])
                                buf_set_u32(&tms_byte, bit_count++, 1, 0x1);
                        else
                        {
@@ -737,7 +731,7 @@ void ft2232_add_scan(int ir_scan, enum scan_type type, u8* buffer, int scan_size
 }
 
 
-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, u8* buffer, int scan_size)
 {
        int num_bytes = (scan_size + 7) / 8;
        int bits_left = scan_size;
@@ -947,7 +941,7 @@ int ft2232_large_scan(scan_command_t* cmd, enum scan_type type, u8* buffer, int
 }
 
 
-int ft2232_predict_scan_out(int scan_size, enum scan_type type)
+static int ft2232_predict_scan_out(int scan_size, enum scan_type type)
 {
        int predicted_size = 3;
        int num_bytes = (scan_size - 1) / 8;
@@ -974,7 +968,7 @@ int ft2232_predict_scan_out(int scan_size, enum scan_type type)
 }
 
 
-int ft2232_predict_scan_in(int scan_size, enum scan_type type)
+static int ft2232_predict_scan_in(int scan_size, enum scan_type type)
 {
        int predicted_size = 0;
 
@@ -996,7 +990,7 @@ int ft2232_predict_scan_in(int scan_size, enum scan_type type)
 }
 
 
-void usbjtag_reset(int trst, int srst)
+static void usbjtag_reset(int trst, int srst)
 {
        if (trst == 1)
        {
@@ -1035,7 +1029,7 @@ void usbjtag_reset(int trst, int srst)
 }
 
 
-void jtagkey_reset(int trst, int srst)
+static void jtagkey_reset(int trst, int srst)
 {
        if (trst == 1)
        {
@@ -1076,7 +1070,7 @@ void jtagkey_reset(int trst, int srst)
 }
 
 
-void olimex_jtag_reset(int trst, int srst)
+static void olimex_jtag_reset(int trst, int srst)
 {
        if (trst == 1)
        {
@@ -1111,7 +1105,7 @@ void olimex_jtag_reset(int trst, int srst)
 }
 
 
-void axm0432_jtag_reset(int trst, int srst)
+static void axm0432_jtag_reset(int trst, int srst)
 {
        if (trst == 1)
        {
@@ -1141,7 +1135,7 @@ void axm0432_jtag_reset(int trst, int srst)
 }
 
 
-void flyswatter_reset(int trst, int srst)
+static void flyswatter_reset(int trst, int srst)
 {
        if (trst == 1)
        {
@@ -1169,7 +1163,7 @@ void flyswatter_reset(int trst, int srst)
 }
 
 
-void turtle_reset(int trst, int srst)
+static void turtle_reset(int trst, int srst)
 {
        trst = trst;
 
@@ -1190,7 +1184,7 @@ void turtle_reset(int trst, int srst)
 }
 
 
-void comstick_reset(int trst, int srst)
+static void comstick_reset(int trst, int srst)
 {
        if (trst == 1)
        {
@@ -1219,7 +1213,7 @@ void comstick_reset(int trst, int srst)
 }
 
 
-void stm32stick_reset(int trst, int srst)
+static void stm32stick_reset(int trst, int srst)
 {
        if (trst == 1)
        {
@@ -1253,7 +1247,27 @@ void stm32stick_reset(int trst, int srst)
 }
 
 
-int ft2232_execute_queue()
+
+static void sheevaplug_reset(int trst, int srst)
+{
+       if (trst == 1)
+               high_output &= ~nTRST;
+       else if (trst == 0)
+               high_output |= nTRST;
+
+       if (srst == 1)
+               high_output &= ~nSRSTnOE;
+       else if (srst == 0)
+               high_output |= nSRSTnOE;
+
+       /* command "set data bits high byte" */
+       BUFFER_ADD = 0x82;
+       BUFFER_ADD = high_output;
+       BUFFER_ADD = high_direction;
+       LOG_DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst, srst, high_output, high_direction);
+}
+
+static int ft2232_execute_queue()
 {
        jtag_command_t* cmd = jtag_command_queue;   /* currently processed command */
        u8*             buffer;
@@ -1283,7 +1297,7 @@ int ft2232_execute_queue()
                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;
 
@@ -1316,9 +1330,9 @@ int ft2232_execute_queue()
                        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)
                        {
@@ -1354,7 +1368,7 @@ int ft2232_execute_queue()
                                /* 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() )
@@ -1384,7 +1398,7 @@ int ft2232_execute_queue()
                                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)" */
@@ -1433,7 +1447,7 @@ int ft2232_execute_queue()
                                                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;
@@ -1454,7 +1468,7 @@ int ft2232_execute_queue()
                        }
                        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;
@@ -1546,7 +1560,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;
 
@@ -1561,7 +1596,7 @@ static int ft2232_init_ftd2xx(u16 vid, u16 pid, int more, int* try_more)
                if (status == FT_OK)
                {
                        char** desc_array = malloc( sizeof(char*) * (num_devices + 1) );
-                       int    i;
+                       u32 i;
 
                        for (i = 0; i < num_devices; i++)
                                desc_array[i] = malloc(64);
@@ -1709,7 +1744,7 @@ static int ft2232_purge_libftdi(void)
 
 #endif /* BUILD_FT2232_LIBFTDI == 1 */
 
-int ft2232_init(void)
+static int ft2232_init(void)
 {
        u8  buf[1];
        int retval;
@@ -1791,7 +1826,7 @@ int ft2232_init(void)
 }
 
 
-int usbjtag_init(void)
+static int usbjtag_init(void)
 {
        u8  buf[3];
        u32 bytes_written;
@@ -1866,7 +1901,7 @@ int usbjtag_init(void)
 }
 
 
-int axm0432_jtag_init(void)
+static int axm0432_jtag_init(void)
 {
        u8  buf[3];
        u32 bytes_written;
@@ -1936,7 +1971,7 @@ int axm0432_jtag_init(void)
 }
 
 
-int jtagkey_init(void)
+static int jtagkey_init(void)
 {
        u8  buf[3];
        u32 bytes_written;
@@ -2018,7 +2053,7 @@ int jtagkey_init(void)
 }
 
 
-int olimex_jtag_init(void)
+static int olimex_jtag_init(void)
 {
        u8  buf[3];
        u32 bytes_written;
@@ -2085,7 +2120,7 @@ int olimex_jtag_init(void)
 }
 
 
-int flyswatter_init(void)
+static int flyswatter_init(void)
 {
        u8  buf[3];
        u32 bytes_written;
@@ -2113,7 +2148,7 @@ int flyswatter_init(void)
        high_output    = 0x00;
        high_direction = 0x0c;
 
-       /* turn red LED1 on, LED2 off */
+       /* turn red LED3 on, LED2 off */
        high_output |= 0x08;
 
        /* initialize high port */
@@ -2132,7 +2167,7 @@ int flyswatter_init(void)
 }
 
 
-int turtle_init(void)
+static int turtle_init(void)
 {
        u8  buf[3];
        u32 bytes_written;
@@ -2173,7 +2208,7 @@ int turtle_init(void)
 }
 
 
-int comstick_init(void)
+static int comstick_init(void)
 {
        u8  buf[3];
        u32 bytes_written;
@@ -2217,7 +2252,7 @@ int comstick_init(void)
 }
 
 
-int stm32stick_init(void)
+static int stm32stick_init(void)
 {
        u8  buf[3];
        u32 bytes_written;
@@ -2261,7 +2296,58 @@ int stm32stick_init(void)
 }
 
 
-void olimex_jtag_blink(void)
+static int sheevaplug_init(void)
+{
+       u8 buf[3];
+       u32 bytes_written;
+
+       low_output = 0x08;
+       low_direction = 0x1b;
+
+       /* initialize low byte for jtag */
+       buf[0] = 0x80; /* command "set data bits low byte" */
+       buf[1] = low_output; /* value (TMS=1,TCK=0, TDI=0, nOE=0) */
+       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]);
+
+       if (((ft2232_write(buf, 3, &bytes_written)) != ERROR_OK) || (bytes_written != 3))
+       {
+               LOG_ERROR("couldn't initialize FT2232 with 'sheevaplug' layout"); 
+               return ERROR_JTAG_INIT_FAILED;
+       }
+
+       nTRSTnOE = 0x1;
+       nTRST = 0x02;
+       nSRSTnOE = 0x4;
+       nSRST = 0x08;
+
+       high_output = 0x0;
+       high_direction = 0x0f;
+
+       /* nTRST is always push-pull */
+       high_output &= ~nTRSTnOE;
+       high_output |= nTRST;
+
+       /* nSRST is always open-drain */
+       high_output |= nSRSTnOE;
+       high_output &= ~nSRST;
+
+       /* initialize high port */
+       buf[0] = 0x82; /* command "set data bits high byte" */
+       buf[1] = high_output; /* value */
+       buf[2] = high_direction;   /* all outputs - xRST */
+       LOG_DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
+
+       if (((ft2232_write(buf, 3, &bytes_written)) != ERROR_OK) || (bytes_written != 3))
+       {
+               LOG_ERROR("couldn't initialize FT2232 with 'sheevaplug' layout"); 
+               return ERROR_JTAG_INIT_FAILED;
+       }
+
+       return ERROR_OK;
+}
+
+static void olimex_jtag_blink(void)
 {
        /* Olimex ARM-USB-OCD has a LED connected to ACBUS3
         * ACBUS3 is bit 3 of the GPIOH port
@@ -2283,7 +2369,20 @@ void olimex_jtag_blink(void)
 }
 
 
-void turtle_jtag_blink(void)
+static void flyswatter_jtag_blink(void)
+{
+       /*
+        * Flyswatter has two LEDs connected to ACBUS2 and ACBUS3
+        */
+       high_output ^= 0x0c;
+
+       BUFFER_ADD = 0x82;
+       BUFFER_ADD = high_output;
+       BUFFER_ADD = high_direction;
+}
+
+
+static void turtle_jtag_blink(void)
 {
        /*
         * Turtelizer2 has two LEDs connected to ACBUS2 and ACBUS3
@@ -2303,7 +2402,7 @@ void turtle_jtag_blink(void)
 }
 
 
-int ft2232_quit(void)
+static int ft2232_quit(void)
 {
 #if BUILD_FT2232_FTD2XX == 1
        FT_STATUS status;
@@ -2324,11 +2423,31 @@ int ft2232_quit(void)
 }
 
 
-int ft2232_handle_device_desc_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc)
+static 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
        {
@@ -2339,7 +2458,7 @@ int ft2232_handle_device_desc_command(struct command_context_s* cmd_ctx, char* c
 }
 
 
-int ft2232_handle_serial_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc)
+static int ft2232_handle_serial_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc)
 {
        if (argc == 1)
        {
@@ -2354,7 +2473,7 @@ int ft2232_handle_serial_command(struct command_context_s* cmd_ctx, char* cmd, c
 }
 
 
-int ft2232_handle_layout_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc)
+static int ft2232_handle_layout_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc)
 {
        if (argc == 0)
                return ERROR_OK;
@@ -2366,7 +2485,7 @@ int ft2232_handle_layout_command(struct command_context_s* cmd_ctx, char* cmd, c
 }
 
 
-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)
 {
        int i;
 
@@ -2399,7 +2518,7 @@ int ft2232_handle_vid_pid_command(struct command_context_s* cmd_ctx, char* cmd,
 }
 
 
-int ft2232_handle_latency_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc)
+static int ft2232_handle_latency_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc)
 {
        if (argc == 1)
        {

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)