1 /***************************************************************************
2 * Copyright (C) 2004 by Dominic Rath *
3 * Dominic.Rath@gmx.de *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
26 /* project specific includes */
30 #include "configuration.h"
41 /* enable this to debug io latency
44 #define _DEBUG_USB_IO_
47 /* enable this to debug communication
50 #define _DEBUG_USB_COMMS_
53 /* enable this to work around ftd2xx deadlock
56 #define _FTD2XX_QUEUE_DELAY_
59 int ftd2xx_execute_queue(void);
61 int ftd2xx_speed(int speed
);
62 int ftd2xx_register_commands(struct command_context_s
*cmd_ctx
);
63 int ftd2xx_init(void);
64 int ftd2xx_quit(void);
66 int ftd2xx_handle_device_desc_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
);
67 int ftd2xx_handle_layout_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
);
68 int ftd2xx_handle_vid_pid_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
);
70 char *ftd2xx_device_desc
= NULL
;
71 char *ftd2xx_layout
= NULL
;
72 u16 ftd2xx_vid
= 0x0403;
73 u16 ftd2xx_pid
= 0x6010;
75 typedef struct ftd2xx_layout_s
79 void(*reset
)(int trst
, int srst
);
82 int usbjtag_init(void);
83 int jtagkey_init(void);
84 void usbjtag_reset(int trst
, int srst
);
85 void jtagkey_reset(int trst
, int srst
);
87 ftd2xx_layout_t ftd2xx_layouts
[] =
89 {"usbjtag", usbjtag_init
, usbjtag_reset
},
90 {"jtagkey", jtagkey_init
, jtagkey_reset
},
91 {"jtagkey_prototype_v1", jtagkey_init
, jtagkey_reset
},
95 static u8 nTRST
, nTRSTnOE
, nSRST
, nSRSTnOE
;
97 static ftd2xx_layout_t
*layout
;
98 static u8 low_output
= 0x0;
99 static u8 low_direction
= 0x0;
100 static u8 high_output
= 0x0;
101 static u8 high_direction
= 0x0;
102 static FT_HANDLE ftdih
= NULL
;
104 static u8
*ftd2xx_buffer
= NULL
;
105 static int ftd2xx_buffer_size
= 0;
106 static int ftd2xx_read_pointer
= 0;
107 static int ftd2xx_expect_read
= 0;
108 #define FTD2XX_BUFFER_SIZE 131072
109 #define BUFFER_ADD ftd2xx_buffer[ftd2xx_buffer_size++]
110 #define BUFFER_READ ftd2xx_buffer[ftd2xx_read_pointer++]
112 jtag_interface_t ftd2xx_interface
=
117 .execute_queue
= ftd2xx_execute_queue
,
119 .support_statemove
= 1,
121 .speed
= ftd2xx_speed
,
122 .register_commands
= ftd2xx_register_commands
,
127 int ftd2xx_speed(int speed
)
133 buf
[0] = 0x86; /* command "set divisor" */
134 buf
[1] = speed
& 0xff; /* valueL (0=6MHz, 1=3MHz, 2=1.5MHz, ...*/
135 buf
[2] = (speed
>> 8) & 0xff; /* valueH */
137 DEBUG("%2.2x %2.2x %2.2x", buf
[0], buf
[1], buf
[2]);
138 if (((status
= FT_Write(ftdih
, buf
, 3, &bytes_written
)) != FT_OK
) || (bytes_written
!= 3))
140 ERROR("couldn't write to ftdi device: %i", status
);
147 int ftd2xx_register_commands(struct command_context_s
*cmd_ctx
)
149 register_command(cmd_ctx
, NULL
, "ftd2xx_device_desc", ftd2xx_handle_device_desc_command
,
150 COMMAND_CONFIG
, NULL
);
151 register_command(cmd_ctx
, NULL
, "ftd2xx_layout", ftd2xx_handle_layout_command
,
152 COMMAND_CONFIG
, NULL
);
153 register_command(cmd_ctx
, NULL
, "ftd2xx_vid_pid", ftd2xx_handle_vid_pid_command
,
154 COMMAND_CONFIG
, NULL
);
158 void ftd2xx_end_state(state
)
160 if (tap_move_map
[state
] != -1)
164 ERROR("BUG: %i is not a valid end state", state
);
169 void ftd2xx_read_scan(enum scan_type type
, u8
* buffer
, int scan_size
)
171 int num_bytes
= ((scan_size
+ 7) / 8);
172 int bits_left
= scan_size
;
175 while(num_bytes
-- > 1)
177 buffer
[cur_byte
] = BUFFER_READ
;
182 buffer
[cur_byte
] = 0x0;
186 buffer
[cur_byte
] = BUFFER_READ
>> 1;
189 buffer
[cur_byte
] = (buffer
[cur_byte
] | ((BUFFER_READ
& 0x02) << 6)) >> (8 - bits_left
);
193 void ftd2xx_debug_dump_buffer(void)
199 for (i
= 0; i
< ftd2xx_buffer_size
; i
++)
201 line_p
+= snprintf(line_p
, 256 - (line_p
- line
), "%2.2x ", ftd2xx_buffer
[i
]);
213 int ftd2xx_send_and_recv(jtag_command_t
*first
, jtag_command_t
*last
)
223 #ifdef _DEBUG_USB_IO_
224 struct timeval start
, inter
, inter2
, end
;
227 #ifdef _DEBUG_USB_COMMS_
228 DEBUG("write buffer (size %i):", ftd2xx_buffer_size
);
229 ftd2xx_debug_dump_buffer();
232 #ifdef _DEBUG_USB_IO_
233 gettimeofday(&start
, NULL
);
236 if ((status
= FT_Write(ftdih
, ftd2xx_buffer
, ftd2xx_buffer_size
, &bytes_written
)) != FT_OK
)
238 ERROR("couldn't write to ftdi device: %i", status
);
242 #ifdef _DEBUG_USB_IO_
243 gettimeofday(&inter
, NULL
);
246 if (ftd2xx_expect_read
)
249 ftd2xx_buffer_size
= 0;
251 #ifdef _FTD2XX_QUEUE_DELAY_
253 while (inrxqueue
< ftd2xx_expect_read
)
255 FT_GetQueueStatus(ftdih
, &inrxqueue
);
256 if (inrxqueue
>= ftd2xx_expect_read
)
262 #ifdef _DEBUG_USB_IO_
263 gettimeofday(&inter2
, NULL
);
266 if ((status
= FT_Read(ftdih
, ftd2xx_buffer
, ftd2xx_expect_read
, &bytes_read
)) != FT_OK
)
268 ERROR("couldn't read from ftdi device: %i", status
);
272 #ifdef _DEBUG_USB_IO_
273 gettimeofday(&end
, NULL
);
275 INFO("inter: %i.%i, inter2: %i.%i end: %i.%i", inter
.tv_sec
- start
.tv_sec
, inter
.tv_usec
- start
.tv_usec
,
276 inter2
.tv_sec
- start
.tv_sec
, inter2
.tv_usec
- start
.tv_usec
,
277 end
.tv_sec
- start
.tv_sec
, end
.tv_usec
- start
.tv_usec
);
281 ftd2xx_buffer_size
= bytes_read
;
283 if (ftd2xx_expect_read
!= ftd2xx_buffer_size
)
285 ERROR("ftd2xx_expect_read (%i) != ftd2xx_buffer_size (%i) (%i retries)", ftd2xx_expect_read
, ftd2xx_buffer_size
, 100 - timeout
);
286 ftd2xx_debug_dump_buffer();
291 #ifdef _DEBUG_USB_COMMS_
292 DEBUG("read buffer (%i retries): %i bytes", 100 - timeout
, ftd2xx_buffer_size
);
293 ftd2xx_debug_dump_buffer();
297 ftd2xx_expect_read
= 0;
298 ftd2xx_read_pointer
= 0;
306 type
= jtag_scan_type(cmd
->cmd
.scan
);
307 if (type
!= SCAN_OUT
)
309 scan_size
= jtag_scan_size(cmd
->cmd
.scan
);
310 buffer
= calloc(CEIL(scan_size
, 8), 1);
311 ftd2xx_read_scan(type
, buffer
, scan_size
);
312 jtag_read_buffer(buffer
, cmd
->cmd
.scan
);
322 ftd2xx_buffer_size
= 0;
327 void ftd2xx_add_scan(int ir_scan
, enum scan_type type
, u8
*buffer
, int scan_size
)
329 int num_bytes
= (scan_size
+ 7) / 8;
330 int bits_left
= scan_size
;
334 /* command "Clock Data to TMS/CS Pin (no Read)" */
341 BUFFER_ADD
= TAP_MOVE(cur_state
, TAP_SI
);
346 BUFFER_ADD
= TAP_MOVE(cur_state
, TAP_SD
);
349 //DEBUG("added TMS scan (no read)");
351 /* add command for complete bytes */
356 /* Clock Data Bytes In and Out LSB First */
358 //DEBUG("added TDI bytes (io %i)", num_bytes);
360 else if (type
== SCAN_OUT
)
362 /* Clock Data Bytes Out on -ve Clock Edge LSB First (no Read) */
364 //DEBUG("added TDI bytes (o)");
366 else if (type
== SCAN_IN
)
368 /* Clock Data Bytes In on +ve Clock Edge LSB First (no Write) */
370 //DEBUG("added TDI bytes (i %i)", num_bytes);
372 BUFFER_ADD
= (num_bytes
-2) & 0xff;
373 BUFFER_ADD
= (num_bytes
>> 8) & 0xff;
377 /* add complete bytes */
378 while(num_bytes
-- > 1)
380 BUFFER_ADD
= buffer
[cur_byte
];
387 bits_left
-= 8 * (num_bytes
- 1);
390 /* the most signifcant bit is scanned during TAP movement */
392 last_bit
= (buffer
[cur_byte
] >> (bits_left
- 1)) & 0x1;
396 /* process remaining bits but the last one */
401 /* Clock Data Bits In and Out LSB First */
403 //DEBUG("added TDI bits (io) %i", bits_left - 1);
405 else if (type
== SCAN_OUT
)
407 /* Clock Data Bits Out on -ve Clock Edge LSB First (no Read) */
409 //DEBUG("added TDI bits (o)");
411 else if (type
== SCAN_IN
)
413 /* Clock Data Bits In on +ve Clock Edge LSB First (no Write) */
415 //DEBUG("added TDI bits (i %i)", bits_left - 1);
417 BUFFER_ADD
= bits_left
- 2;
419 BUFFER_ADD
= buffer
[cur_byte
];
422 /* move from Shift-IR/DR to end state */
423 if (type
!= SCAN_OUT
)
425 /* Clock Data to TMS/CS Pin with Read */
427 //DEBUG("added TMS scan (read)");
431 /* Clock Data to TMS/CS Pin (no Read) */
433 //DEBUG("added TMS scan (no read)");
436 BUFFER_ADD
= TAP_MOVE(cur_state
, end_state
) | (last_bit
<< 7);
437 cur_state
= end_state
;
441 int ftd2xx_predict_scan_out(int scan_size
, enum scan_type type
)
443 int predicted_size
= 6;
444 if (type
== SCAN_IN
) /* only from device to host */
446 predicted_size
+= (CEIL(scan_size
, 8) > 1) ? 3 : 0;
447 predicted_size
+= ((scan_size
- 1) % 8) ? 2 : 0;
449 else /* host to device, or bidirectional */
451 predicted_size
+= (CEIL(scan_size
, 8) > 1) ? (CEIL(scan_size
, 8) + 3 - 1) : 0;
452 predicted_size
+= ((scan_size
- 1) % 8) ? 3 : 0;
455 return predicted_size
;
458 int ftd2xx_predict_scan_in(int scan_size
, enum scan_type type
)
460 int predicted_size
= 0;
462 if (type
!= SCAN_OUT
)
465 predicted_size
+= (CEIL(scan_size
, 8) > 1) ? (CEIL(scan_size
, 8) - 1) : 0;
466 /* remaining bits - 1 */
467 predicted_size
+= ((scan_size
- 1) % 8) ? 1 : 0;
468 /* last bit (from TMS scan) */
472 //DEBUG("scan_size: %i, predicted_size: %i", scan_size, predicted_size);
474 return predicted_size
;
477 void usbjtag_reset(int trst
, int srst
)
482 if (jtag_reset_config
& RESET_TRST_OPEN_DRAIN
)
483 low_direction
|= nTRSTnOE
; /* switch to output pin (output is low) */
485 low_output
&= ~nTRST
; /* switch output low */
489 if (jtag_reset_config
& RESET_TRST_OPEN_DRAIN
)
490 low_direction
&= ~nTRSTnOE
; /* switch to input pin (high-Z + internal and external pullup) */
492 low_output
|= nTRST
; /* switch output high */
497 if (jtag_reset_config
& RESET_SRST_PUSH_PULL
)
498 low_output
&= ~nSRST
; /* switch output low */
500 low_direction
|= nSRSTnOE
; /* switch to output pin (output is low) */
504 if (jtag_reset_config
& RESET_SRST_PUSH_PULL
)
505 low_output
|= nSRST
; /* switch output high */
507 low_direction
&= ~nSRSTnOE
; /* switch to input pin (high-Z) */
510 /* command "set data bits low byte" */
512 BUFFER_ADD
= low_output
;
513 BUFFER_ADD
= low_direction
;
517 void jtagkey_reset(int trst
, int srst
)
522 if (jtag_reset_config
& RESET_TRST_OPEN_DRAIN
)
523 high_output
&= ~nTRSTnOE
;
525 high_output
&= ~nTRST
;
529 if (jtag_reset_config
& RESET_TRST_OPEN_DRAIN
)
530 high_output
|= nTRSTnOE
;
532 high_output
|= nTRST
;
537 if (jtag_reset_config
& RESET_SRST_PUSH_PULL
)
538 high_output
&= ~nSRST
;
540 high_output
&= ~nSRSTnOE
;
544 if (jtag_reset_config
& RESET_SRST_PUSH_PULL
)
545 high_output
|= nSRST
;
547 high_output
|= nSRSTnOE
;
550 /* command "set data bits high byte" */
552 BUFFER_ADD
= high_output
;
553 BUFFER_ADD
= high_direction
;
554 DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst
, srst
, high_output
, high_direction
);
557 int ftd2xx_execute_queue()
559 jtag_command_t
*cmd
= jtag_command_queue
; /* currently processed command */
560 jtag_command_t
*first_unsent
= cmd
; /* next command that has to be sent */
562 int scan_size
; /* size of IR or DR scan */
565 int predicted_size
= 0;
566 int require_send
= 0;
568 ftd2xx_buffer_size
= 0;
569 ftd2xx_expect_read
= 0;
576 if (cmd
->cmd
.end_state
->end_state
!= -1)
577 ftd2xx_end_state(cmd
->cmd
.end_state
->end_state
);
580 /* only send the maximum buffer size that FT2232C can handle */
582 if (ftd2xx_buffer_size
+ predicted_size
+ 1 > FTD2XX_BUFFER_SIZE
)
584 ftd2xx_send_and_recv(first_unsent
, cmd
);
589 layout
->reset(cmd
->cmd
.reset
->trst
, cmd
->cmd
.reset
->srst
);
594 /* only send the maximum buffer size that FT2232C can handle */
596 if (cur_state
!= TAP_RTI
)
598 predicted_size
+= 3 * CEIL(cmd
->cmd
.runtest
->num_cycles
, 7);
599 if ((cmd
->cmd
.runtest
->end_state
!= -1) && (cmd
->cmd
.runtest
->end_state
!= TAP_RTI
))
601 if ((cmd
->cmd
.runtest
->end_state
== -1) && (end_state
!= TAP_RTI
))
603 if (ftd2xx_buffer_size
+ predicted_size
+ 1 > FTD2XX_BUFFER_SIZE
)
605 ftd2xx_send_and_recv(first_unsent
, cmd
);
609 if (cur_state
!= TAP_RTI
)
611 /* command "Clock Data to TMS/CS Pin (no Read)" */
616 BUFFER_ADD
= TAP_MOVE(cur_state
, TAP_RTI
);
620 i
= cmd
->cmd
.runtest
->num_cycles
;
623 /* command "Clock Data to TMS/CS Pin (no Read)" */
626 BUFFER_ADD
= (i
> 7) ? 6 : (i
- 1);
630 i
-= (i
> 7) ? 7 : i
;
631 //DEBUG("added TMS scan (no read)");
633 if (cmd
->cmd
.runtest
->end_state
!= -1)
634 ftd2xx_end_state(cmd
->cmd
.runtest
->end_state
);
635 if (cur_state
!= end_state
)
637 /* command "Clock Data to TMS/CS Pin (no Read)" */
642 BUFFER_ADD
= TAP_MOVE(cur_state
, end_state
);
643 cur_state
= end_state
;
644 //DEBUG("added TMS scan (no read)");
649 /* only send the maximum buffer size that FT2232C can handle */
651 if (ftd2xx_buffer_size
+ predicted_size
+ 1 > FTD2XX_BUFFER_SIZE
)
653 ftd2xx_send_and_recv(first_unsent
, cmd
);
657 if (cmd
->cmd
.statemove
->end_state
!= -1)
658 ftd2xx_end_state(cmd
->cmd
.statemove
->end_state
);
659 /* command "Clock Data to TMS/CS Pin (no Read)" */
664 BUFFER_ADD
= TAP_MOVE(cur_state
, end_state
);
665 //DEBUG("added TMS scan (no read)");
666 cur_state
= end_state
;
670 scan_size
= jtag_build_buffer(cmd
->cmd
.scan
, &buffer
);
671 type
= jtag_scan_type(cmd
->cmd
.scan
);
672 predicted_size
= ftd2xx_predict_scan_out(scan_size
, type
);
673 if (ftd2xx_buffer_size
+ predicted_size
+ 1 > FTD2XX_BUFFER_SIZE
)
675 DEBUG("ftd2xx buffer size reached, sending queued commands (first_unsent: %x, cmd: %x)", first_unsent
, cmd
);
676 ftd2xx_send_and_recv(first_unsent
, cmd
);
680 ftd2xx_expect_read
+= ftd2xx_predict_scan_in(scan_size
, type
);
681 //DEBUG("new read size: %i", ftd2xx_expect_read);
682 if (cmd
->cmd
.scan
->end_state
!= -1)
683 ftd2xx_end_state(cmd
->cmd
.scan
->end_state
);
684 ftd2xx_add_scan(cmd
->cmd
.scan
->ir_scan
, type
, buffer
, scan_size
);
690 ftd2xx_send_and_recv(first_unsent
, cmd
);
691 first_unsent
= cmd
->next
;
692 jtag_sleep(cmd
->cmd
.sleep
->us
);
695 ERROR("BUG: unknown JTAG command type encountered");
701 if (require_send
> 0)
702 ftd2xx_send_and_recv(first_unsent
, cmd
);
707 int ftd2xx_init(void)
713 ftd2xx_layout_t
*cur_layout
= ftd2xx_layouts
;
715 if ((ftd2xx_layout
== NULL
) || (ftd2xx_layout
[0] == 0))
717 ftd2xx_layout
= "usbjtag";
718 WARNING("No ftd2xx layout specified, using default 'usbjtag'");
721 while (cur_layout
->name
)
723 if (strcmp(cur_layout
->name
, ftd2xx_layout
) == 0)
733 ERROR("No matching layout found for %s", ftd2xx_layout
);
734 return ERROR_JTAG_INIT_FAILED
;
737 if (ftd2xx_device_desc
== NULL
)
739 WARNING("no ftd2xx device description specified, using default 'Dual RS232'");
740 ftd2xx_device_desc
= "Dual RS232";
744 /* Add JTAGkey Vid/Pid to the linux driver */
745 if ((status
= FT_SetVIDPID(ftd2xx_vid
, ftd2xx_pid
)) != FT_OK
)
747 WARNING("couldn't add %4.4x:%4.4x", ftd2xx_vid
, ftd2xx_pid
);
751 if ((status
= FT_OpenEx(ftd2xx_device_desc
, FT_OPEN_BY_DESCRIPTION
, &ftdih
)) != FT_OK
)
753 ERROR("unable to open ftdi device: %i", status
);
754 status
= FT_ListDevices(&num_devices
, NULL
, FT_LIST_NUMBER_ONLY
);
757 char **desc_array
= malloc(sizeof(char*) * (num_devices
+ 1));
760 for (i
= 0; i
< num_devices
; i
++)
761 desc_array
[i
] = malloc(64);
762 desc_array
[num_devices
] = NULL
;
764 status
= FT_ListDevices(desc_array
, &num_devices
, FT_LIST_ALL
| FT_OPEN_BY_DESCRIPTION
);
768 ERROR("ListDevices: %d\n", num_devices
);
769 for (i
= 0; i
< num_devices
; i
++)
770 ERROR("%i: %s", i
, desc_array
[i
]);
773 for (i
= 0; i
< num_devices
; i
++)
779 printf("ListDevices: NONE\n");
781 return ERROR_JTAG_INIT_FAILED
;
784 if ((status
= FT_SetLatencyTimer(ftdih
, 2)) != FT_OK
)
786 ERROR("unable to set latency timer: %i", status
);
787 return ERROR_JTAG_INIT_FAILED
;
790 if ((status
= FT_GetLatencyTimer(ftdih
, &latency_timer
)) != FT_OK
)
792 ERROR("unable to get latency timer: %i", status
);
793 return ERROR_JTAG_INIT_FAILED
;
797 DEBUG("current latency timer: %i", latency_timer
);
800 if ((status
= FT_SetBitMode(ftdih
, 0x0b, 2)) != FT_OK
)
802 ERROR("unable to enable bit i/o mode: %i", status
);
803 return ERROR_JTAG_INIT_FAILED
;
806 ftd2xx_buffer_size
= 0;
807 ftd2xx_buffer
= malloc(FTD2XX_BUFFER_SIZE
);
809 if (layout
->init() != ERROR_OK
)
810 return ERROR_JTAG_INIT_FAILED
;
812 ftd2xx_speed(jtag_speed
);
814 if ((status
= FT_Purge(ftdih
, FT_PURGE_RX
| FT_PURGE_TX
)) != FT_OK
)
816 ERROR("error purging ftd2xx device: %i", status
);
817 return ERROR_JTAG_INIT_FAILED
;
823 int usbjtag_init(void)
830 low_direction
= 0x0b;
837 if (jtag_reset_config
& RESET_TRST_OPEN_DRAIN
)
839 low_direction
&= ~nTRSTnOE
; /* nTRST input */
840 low_output
&= ~nTRST
; /* nTRST = 0 */
844 low_direction
|= nTRSTnOE
; /* nTRST output */
845 low_output
|= nTRST
; /* nTRST = 1 */
848 if (jtag_reset_config
& RESET_SRST_PUSH_PULL
)
850 low_direction
|= nSRSTnOE
; /* nSRST output */
851 low_output
|= nSRST
; /* nSRST = 1 */
855 low_direction
&= ~nSRSTnOE
; /* nSRST input */
856 low_output
&= ~nSRST
; /* nSRST = 0 */
859 /* initialize low byte for jtag */
860 buf
[0] = 0x80; /* command "set data bits low byte" */
861 buf
[1] = low_output
; /* value (TMS=1,TCK=0, TDI=0, xRST high) */
862 buf
[2] = low_direction
; /* dir (output=1), TCK/TDI/TMS=out, TDO=in */
863 DEBUG("%2.2x %2.2x %2.2x", buf
[0], buf
[1], buf
[2]);
865 if (((FT_Write(ftdih
, buf
, 3, &bytes_written
)) != FT_OK
) || (bytes_written
!= 3))
867 ERROR("couldn't write to ftdi device: %i", status
);
868 return ERROR_JTAG_INIT_FAILED
;
874 int jtagkey_init(void)
881 low_direction
= 0x1b;
883 /* initialize low byte for jtag */
884 buf
[0] = 0x80; /* command "set data bits low byte" */
885 buf
[1] = low_output
; /* value (TMS=1,TCK=0, TDI=0, nOE=0) */
886 buf
[2] = low_direction
; /* dir (output=1), TCK/TDI/TMS=out, TDO=in, nOE=out */
887 DEBUG("%2.2x %2.2x %2.2x", buf
[0], buf
[1], buf
[2]);
889 if (((FT_Write(ftdih
, buf
, 3, &bytes_written
)) != FT_OK
) || (bytes_written
!= 3))
891 ERROR("couldn't write to ftdi device: %i", status
);
892 return ERROR_JTAG_INIT_FAILED
;
895 if (strcmp(layout
->name
, "jtagkey") == 0)
902 else if (strcmp(layout
->name
, "jtagkey_prototype_v1") == 0)
911 ERROR("BUG: jtagkey_init called for non jtagkey layout");
916 high_direction
= 0x0f;
918 if (jtag_reset_config
& RESET_TRST_OPEN_DRAIN
)
920 high_output
|= nTRSTnOE
;
921 high_output
&= ~nTRST
;
925 high_output
&= ~nTRSTnOE
;
926 high_output
|= nTRST
;
929 if (jtag_reset_config
& RESET_SRST_PUSH_PULL
)
931 high_output
&= ~nSRSTnOE
;
932 high_output
|= nSRST
;
936 high_output
|= nSRSTnOE
;
937 high_output
&= ~nSRST
;
940 /* initialize high port */
941 buf
[0] = 0x82; /* command "set data bits low byte" */
942 buf
[1] = high_output
; /* value */
943 buf
[2] = high_direction
; /* all outputs (xRST and xRSTnOE) */
944 DEBUG("%2.2x %2.2x %2.2x", buf
[0], buf
[1], buf
[2]);
946 if (((FT_Write(ftdih
, buf
, 3, &bytes_written
)) != FT_OK
) || (bytes_written
!= 3))
948 ERROR("couldn't write to ftdi device: %i", status
);
949 return ERROR_JTAG_INIT_FAILED
;
955 int ftd2xx_quit(void)
959 status
= FT_Close(ftdih
);
966 int ftd2xx_handle_device_desc_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
)
970 ftd2xx_device_desc
= strdup(args
[0]);
974 ERROR("expected exactly one argument to ftd2xx_device_desc <description>");
980 int ftd2xx_handle_layout_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
)
985 ftd2xx_layout
= malloc(strlen(args
[0]) + 1);
986 strcpy(ftd2xx_layout
, args
[0]);
991 int ftd2xx_handle_vid_pid_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
)
995 ftd2xx_vid
= strtol(args
[0], NULL
, 0);
996 ftd2xx_pid
= strtol(args
[1], NULL
, 0);
1000 WARNING("incomplete ftd2xx_vid_pid configuration directive");
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)