1 /***************************************************************************
2 * Copyright (C) 2009 by Øyvind Harboe *
3 * Øyvind Harboe <oyvind.harboe@zylin.com> *
5 * Copyright (C) 2009 by SoftPLC Corporation. http://softplc.com *
6 * Dick Hollenbeck <dick@softplc.com> *
8 * Copyright (C) 2004, 2006 by Dominic Rath *
9 * Dominic.Rath@gmx.de *
11 * Copyright (C) 2008 by Spencer Oliver *
12 * spen@spen-soft.co.uk *
14 * This program is free software; you can redistribute it and/or modify *
15 * it under the terms of the GNU General Public License as published by *
16 * the Free Software Foundation; either version 2 of the License, or *
17 * (at your option) any later version. *
19 * This program is distributed in the hope that it will be useful, *
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
22 * GNU General Public License for more details. *
24 * You should have received a copy of the GNU General Public License *
25 * along with this program; if not, write to the *
26 * Free Software Foundation, Inc., *
27 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
28 ***************************************************************************/
30 /* This code uses information contained in the MPSSE specification which was
32 * http://www.ftdichip.com/Documents/AppNotes/AN2232C-01_MPSSE_Cmnd.pdf
33 * Hereafter this is called the "MPSSE Spec".
35 * The datasheet for the ftdichip.com's FT2232D part is here:
36 * http://www.ftdichip.com/Documents/DataSheets/DS_FT2232D.pdf
43 /* project specific includes */
44 #include "interface.h"
46 #include "time_support.h"
54 #if (BUILD_FT2232_FTD2XX == 1 && BUILD_FT2232_LIBFTDI == 1)
55 #error "BUILD_FT2232_FTD2XX && BUILD_FT2232_LIBFTDI are mutually exclusive"
56 #elif (BUILD_FT2232_FTD2XX != 1 && BUILD_FT2232_LIBFTDI != 1)
57 #error "BUILD_FT2232_FTD2XX || BUILD_FT2232_LIBFTDI must be chosen"
60 /* FT2232 access library includes */
61 #if BUILD_FT2232_FTD2XX == 1
63 #elif BUILD_FT2232_LIBFTDI == 1
67 /* max TCK for the high speed devices 30000 kHz */
68 #define FTDI_2232H_4232H_MAX_TCK 30000
69 /* max TCK for the full speed devices 6000 kHz */
70 #define FTDI_2232C_MAX_TCK 6000
71 /* this speed value tells that RTCK is requested */
74 #ifndef BUILD_FT2232_HIGHSPEED
75 #if BUILD_FT2232_FTD2XX == 1
76 enum { FT_DEVICE_2232H
= 6, FT_DEVICE_4232H
};
77 #elif BUILD_FT2232_LIBFTDI == 1
78 enum { TYPE_2232H
= 4, TYPE_4232H
= 5 };
82 static int ft2232_execute_queue(void);
83 static int ft2232_speed(int speed
);
84 static int ft2232_speed_div(int speed
, int* khz
);
85 static int ft2232_khz(int khz
, int* jtag_speed
);
86 static int ft2232_register_commands(struct command_context_s
* cmd_ctx
);
87 static int ft2232_init(void);
88 static int ft2232_quit(void);
90 static int ft2232_handle_device_desc_command(struct command_context_s
* cmd_ctx
, char* cmd
, char** args
, int argc
);
91 static int ft2232_handle_serial_command(struct command_context_s
* cmd_ctx
, char* cmd
, char** args
, int argc
);
92 static int ft2232_handle_layout_command(struct command_context_s
* cmd_ctx
, char* cmd
, char** args
, int argc
);
93 static int ft2232_handle_vid_pid_command(struct command_context_s
* cmd_ctx
, char* cmd
, char** args
, int argc
);
94 static int ft2232_handle_latency_command(struct command_context_s
* cmd_ctx
, char* cmd
, char** args
, int argc
);
97 * Send out \a num_cycles on the TCK line while the TAP(s) are in a
98 * stable state. Calling code must ensure that current state is stable,
99 * that verification is not done in here.
101 * @param num_cycles The number of clocks cycles to send.
102 * @param cmd The command to send.
104 * @returns ERROR_OK on success, or ERROR_JTAG_QUEUE_FAILED on failure.
106 static int ft2232_stableclocks(int num_cycles
, jtag_command_t
* cmd
);
108 static char * ft2232_device_desc_A
= NULL
;
109 static char* ft2232_device_desc
= NULL
;
110 static char* ft2232_serial
= NULL
;
111 static char* ft2232_layout
= NULL
;
112 static uint8_t ft2232_latency
= 2;
113 static unsigned ft2232_max_tck
= FTDI_2232C_MAX_TCK
;
115 #define MAX_USB_IDS 8
116 /* vid = pid = 0 marks the end of the list */
117 static uint16_t ft2232_vid
[MAX_USB_IDS
+ 1] = { 0x0403, 0 };
118 static uint16_t ft2232_pid
[MAX_USB_IDS
+ 1] = { 0x6010, 0 };
120 typedef struct ft2232_layout_s
124 void (*reset
)(int trst
, int srst
);
128 /* init procedures for supported layouts */
129 static int usbjtag_init(void);
130 static int jtagkey_init(void);
131 static int olimex_jtag_init(void);
132 static int flyswatter_init(void);
133 static int turtle_init(void);
134 static int comstick_init(void);
135 static int stm32stick_init(void);
136 static int axm0432_jtag_init(void);
137 static int sheevaplug_init(void);
138 static int icebear_jtag_init(void);
139 static int cortino_jtag_init(void);
141 /* reset procedures for supported layouts */
142 static void usbjtag_reset(int trst
, int srst
);
143 static void jtagkey_reset(int trst
, int srst
);
144 static void olimex_jtag_reset(int trst
, int srst
);
145 static void flyswatter_reset(int trst
, int srst
);
146 static void turtle_reset(int trst
, int srst
);
147 static void comstick_reset(int trst
, int srst
);
148 static void stm32stick_reset(int trst
, int srst
);
149 static void axm0432_jtag_reset(int trst
, int srst
);
150 static void sheevaplug_reset(int trst
, int srst
);
151 static void icebear_jtag_reset(int trst
, int srst
);
153 /* blink procedures for layouts that support a blinking led */
154 static void olimex_jtag_blink(void);
155 static void flyswatter_jtag_blink(void);
156 static void turtle_jtag_blink(void);
158 static const ft2232_layout_t ft2232_layouts
[] =
160 { "usbjtag", usbjtag_init
, usbjtag_reset
, NULL
},
161 { "jtagkey", jtagkey_init
, jtagkey_reset
, NULL
},
162 { "jtagkey_prototype_v1", jtagkey_init
, jtagkey_reset
, NULL
},
163 { "oocdlink", jtagkey_init
, jtagkey_reset
, NULL
},
164 { "signalyzer", usbjtag_init
, usbjtag_reset
, NULL
},
165 { "evb_lm3s811", usbjtag_init
, usbjtag_reset
, NULL
},
166 { "luminary_icdi", usbjtag_init
, usbjtag_reset
, NULL
},
167 { "olimex-jtag", olimex_jtag_init
, olimex_jtag_reset
, olimex_jtag_blink
},
168 { "flyswatter", flyswatter_init
, flyswatter_reset
, flyswatter_jtag_blink
},
169 { "turtelizer2", turtle_init
, turtle_reset
, turtle_jtag_blink
},
170 { "comstick", comstick_init
, comstick_reset
, NULL
},
171 { "stm32stick", stm32stick_init
, stm32stick_reset
, NULL
},
172 { "axm0432_jtag", axm0432_jtag_init
, axm0432_jtag_reset
, NULL
},
173 { "sheevaplug", sheevaplug_init
, sheevaplug_reset
, NULL
},
174 { "icebear", icebear_jtag_init
, icebear_jtag_reset
, NULL
},
175 { "cortino", cortino_jtag_init
, comstick_reset
, NULL
},
176 { NULL
, NULL
, NULL
, NULL
},
179 static uint8_t nTRST
, nTRSTnOE
, nSRST
, nSRSTnOE
;
181 static const ft2232_layout_t
*layout
;
182 static uint8_t low_output
= 0x0;
183 static uint8_t low_direction
= 0x0;
184 static uint8_t high_output
= 0x0;
185 static uint8_t high_direction
= 0x0;
187 #if BUILD_FT2232_FTD2XX == 1
188 static FT_HANDLE ftdih
= NULL
;
189 static FT_DEVICE ftdi_device
= 0;
190 #elif BUILD_FT2232_LIBFTDI == 1
191 static struct ftdi_context ftdic
;
192 static enum ftdi_chip_type ftdi_device
;
195 static jtag_command_t
* first_unsent
; /* next command that has to be sent */
196 static int require_send
;
198 /* http://urjtag.wiki.sourceforge.net/Cable + FT2232 says:
200 "There is a significant difference between libftdi and libftd2xx. The latter
201 one allows to schedule up to 64*64 bytes of result data while libftdi fails
202 with more than 4*64. As a consequence, the FT2232 driver is forced to
203 perform around 16x more USB transactions for long command streams with TDO
204 capture when running with libftdi."
207 #define FT2232_BUFFER_SIZE 131072
208 a comment would have been nice.
211 #define FT2232_BUFFER_SIZE 131072
213 static uint8_t* ft2232_buffer
= NULL
;
214 static int ft2232_buffer_size
= 0;
215 static int ft2232_read_pointer
= 0;
216 static int ft2232_expect_read
= 0;
219 * Function buffer_write
220 * writes a byte into the byte buffer, "ft2232_buffer", which must be sent later.
221 * @param val is the byte to send.
223 static inline void buffer_write(uint8_t val
)
225 assert(ft2232_buffer
);
226 assert((unsigned) ft2232_buffer_size
< (unsigned) FT2232_BUFFER_SIZE
);
227 ft2232_buffer
[ft2232_buffer_size
++] = val
;
231 * Function buffer_read
232 * returns a byte from the byte buffer.
234 static inline uint8_t buffer_read(void)
236 assert(ft2232_buffer
);
237 assert(ft2232_read_pointer
< ft2232_buffer_size
);
238 return ft2232_buffer
[ft2232_read_pointer
++];
242 * Clocks out \a bit_count bits on the TMS line, starting with the least
243 * significant bit of tms_bits and progressing to more significant bits.
244 * Rigorous state transition logging is done here via tap_set_state().
246 * @param mpsse_cmd One of the MPSSE TMS oriented commands such as
247 * 0x4b or 0x6b. See the MPSSE spec referenced above for their
248 * functionality. The MPSSE command "Clock Data to TMS/CS Pin (no Read)"
249 * is often used for this, 0x4b.
251 * @param tms_bits Holds the sequence of bits to send.
252 * @param tms_count Tells how many bits in the sequence.
253 * @param tdi_bit A single bit to pass on to TDI before the first TCK
254 * cycle and held static for the duration of TMS clocking.
256 * See the MPSSE spec referenced above.
258 static void clock_tms(uint8_t mpsse_cmd
, int tms_bits
, int tms_count
, bool tdi_bit
)
262 int tms_ndx
; /* bit index into tms_byte */
264 assert(tms_count
> 0);
267 LOG_DEBUG("mpsse cmd=%02x, tms_bits = 0x%08x, bit_count=%d", mpsse_cmd
, tms_bits
, tms_count
);
270 for (tms_byte
= tms_ndx
= i
= 0; i
< tms_count
; ++i
, tms_bits
>>=1)
272 bool bit
= tms_bits
& 1;
275 tms_byte
|= (1 << tms_ndx
);
277 /* always do state transitions in public view */
278 tap_set_state(tap_state_transition(tap_get_state(), bit
));
280 /* we wrote a bit to tms_byte just above, increment bit index. if bit was zero
285 if (tms_ndx
== 7 || i
== tms_count
-1)
287 buffer_write(mpsse_cmd
);
288 buffer_write(tms_ndx
- 1);
290 /* Bit 7 of the byte is passed on to TDI/DO before the first TCK/SK of
291 TMS/CS and is held static for the duration of TMS/CS clocking.
293 buffer_write(tms_byte
| (tdi_bit
<< 7));
299 * Function get_tms_buffer_requirements
300 * returns what clock_tms() will consume if called with
303 static inline int get_tms_buffer_requirements(int bit_count
)
305 return ((bit_count
+ 6)/7) * 3;
309 * Function move_to_state
310 * moves the TAP controller from the current state to a
311 * \a goal_state through a path given by tap_get_tms_path(). State transition
312 * logging is performed by delegation to clock_tms().
314 * @param goal_state is the destination state for the move.
316 static void move_to_state(tap_state_t goal_state
)
318 tap_state_t start_state
= tap_get_state();
320 /* goal_state is 1/2 of a tuple/pair of states which allow convenient
321 lookup of the required TMS pattern to move to this state from the
325 /* do the 2 lookups */
326 int tms_bits
= tap_get_tms_path(start_state
, goal_state
);
327 int tms_count
= tap_get_tms_path_len(start_state
, goal_state
);
329 DEBUG_JTAG_IO("start=%s goal=%s", tap_state_name(start_state
), tap_state_name(goal_state
));
331 clock_tms(0x4b, tms_bits
, tms_count
, 0);
334 jtag_interface_t ft2232_interface
=
337 .execute_queue
= ft2232_execute_queue
,
338 .speed
= ft2232_speed
,
339 .speed_div
= ft2232_speed_div
,
341 .register_commands
= ft2232_register_commands
,
346 static int ft2232_write(uint8_t* buf
, int size
, uint32_t* bytes_written
)
348 #if BUILD_FT2232_FTD2XX == 1
350 DWORD dw_bytes_written
;
351 if ((status
= FT_Write(ftdih
, buf
, size
, &dw_bytes_written
)) != FT_OK
)
353 *bytes_written
= dw_bytes_written
;
354 LOG_ERROR("FT_Write returned: %lu", status
);
355 return ERROR_JTAG_DEVICE_ERROR
;
359 *bytes_written
= dw_bytes_written
;
362 #elif BUILD_FT2232_LIBFTDI == 1
364 if ((retval
= ftdi_write_data(&ftdic
, buf
, size
)) < 0)
367 LOG_ERROR("ftdi_write_data: %s", ftdi_get_error_string(&ftdic
));
368 return ERROR_JTAG_DEVICE_ERROR
;
372 *bytes_written
= retval
;
378 static int ft2232_read(uint8_t* buf
, uint32_t size
, uint32_t* bytes_read
)
380 #if BUILD_FT2232_FTD2XX == 1
386 while ((*bytes_read
< size
) && timeout
--)
388 if ((status
= FT_Read(ftdih
, buf
+ *bytes_read
, size
-
389 *bytes_read
, &dw_bytes_read
)) != FT_OK
)
392 LOG_ERROR("FT_Read returned: %lu", status
);
393 return ERROR_JTAG_DEVICE_ERROR
;
395 *bytes_read
+= dw_bytes_read
;
398 #elif BUILD_FT2232_LIBFTDI == 1
403 while ((*bytes_read
< size
) && timeout
--)
405 if ((retval
= ftdi_read_data(&ftdic
, buf
+ *bytes_read
, size
- *bytes_read
)) < 0)
408 LOG_ERROR("ftdi_read_data: %s", ftdi_get_error_string(&ftdic
));
409 return ERROR_JTAG_DEVICE_ERROR
;
411 *bytes_read
+= retval
;
416 if (*bytes_read
< size
)
418 LOG_ERROR("couldn't read the requested number of bytes from FT2232 device (%i < %i)",
419 (unsigned int)(*bytes_read
),
421 return ERROR_JTAG_DEVICE_ERROR
;
427 static bool ft2232_device_is_highspeed(void)
429 #if BUILD_FT2232_FTD2XX == 1
430 return (ftdi_device
== FT_DEVICE_2232H
) || (ftdi_device
== FT_DEVICE_4232H
);
431 #elif BUILD_FT2232_LIBFTDI == 1
432 return (ftdi_device
== TYPE_2232H
|| ftdi_device
== TYPE_4232H
);
437 * Commands that only apply to the FT2232H and FT4232H devices.
438 * See chapter 6 in http://www.ftdichip.com/Documents/AppNotes/
439 * AN_108_Command_Processor_for_MPSSE_and_MCU_Host_Bus_Emulation_Modes.pdf
442 static int ft2232h_ft4232h_adaptive_clocking(bool enable
)
444 uint8_t buf
= enable
? 0x96 : 0x97;
445 LOG_DEBUG("%2.2x", buf
);
447 uint32_t bytes_written
;
448 int retval
= ft2232_write(&buf
, 1, &bytes_written
);
449 if ((ERROR_OK
!= retval
) || (bytes_written
!= 1))
451 LOG_ERROR("couldn't write command to %s adaptive clocking"
452 , enable
? "enable" : "disable");
460 * Enable/disable the clk divide by 5 of the 60MHz master clock.
461 * This result in a JTAG clock speed range of 91.553Hz-6MHz
462 * respective 457.763Hz-30MHz.
464 static int ft2232h_ft4232h_clk_divide_by_5(bool enable
)
466 uint32_t bytes_written
;
467 uint8_t buf
= enable
? 0x8b : 0x8a;
468 int retval
= ft2232_write(&buf
, 1, &bytes_written
);
469 if ((ERROR_OK
!= retval
) || (bytes_written
!= 1))
471 LOG_ERROR("couldn't write command to %s clk divide by 5"
472 , enable
? "enable" : "disable");
473 return ERROR_JTAG_INIT_FAILED
;
475 ft2232_max_tck
= enable
? FTDI_2232C_MAX_TCK
: FTDI_2232H_4232H_MAX_TCK
;
476 LOG_INFO("max TCK change to: %u kHz", ft2232_max_tck
);
481 static int ft2232_speed(int speed
)
485 uint32_t bytes_written
;
488 bool enable_adaptive_clocking
= (RTCK_SPEED
== speed
);
489 if (ft2232_device_is_highspeed())
490 retval
= ft2232h_ft4232h_adaptive_clocking(enable_adaptive_clocking
);
491 else if (enable_adaptive_clocking
)
493 LOG_ERROR("ft2232 device %lu does not support RTCK"
494 , (long unsigned int)ftdi_device
);
498 if ((enable_adaptive_clocking
) || (ERROR_OK
!= retval
))
501 buf
[0] = 0x86; /* command "set divisor" */
502 buf
[1] = speed
& 0xff; /* valueL (0 = 6MHz, 1 = 3MHz, 2 = 2.0MHz, ...*/
503 buf
[2] = (speed
>> 8) & 0xff; /* valueH */
505 LOG_DEBUG("%2.2x %2.2x %2.2x", buf
[0], buf
[1], buf
[2]);
506 if (((retval
= ft2232_write(buf
, 3, &bytes_written
)) != ERROR_OK
) || (bytes_written
!= 3))
508 LOG_ERROR("couldn't set FT2232 TCK speed");
515 static int ft2232_speed_div(int speed
, int* khz
)
517 /* Take a look in the FT2232 manual,
518 * AN2232C-01 Command Processor for
519 * MPSSE and MCU Host Bus. Chapter 3.8 */
521 *khz
= (RTCK_SPEED
== speed
) ? 0 : ft2232_max_tck
/ (1 + speed
);
526 static int ft2232_khz(int khz
, int* jtag_speed
)
530 if (ft2232_device_is_highspeed())
532 *jtag_speed
= RTCK_SPEED
;
537 LOG_DEBUG("RCLK not supported");
542 /* Take a look in the FT2232 manual,
543 * AN2232C-01 Command Processor for
544 * MPSSE and MCU Host Bus. Chapter 3.8
546 * We will calc here with a multiplier
547 * of 10 for better rounding later. */
549 /* Calc speed, (ft2232_max_tck / khz) - 1 */
550 /* Use 65000 for better rounding */
551 *jtag_speed
= ((ft2232_max_tck
*10) / khz
) - 10;
553 /* Add 0.9 for rounding */
556 /* Calc real speed */
557 *jtag_speed
= *jtag_speed
/ 10;
559 /* Check if speed is greater than 0 */
565 /* Check max value */
566 if (*jtag_speed
> 0xFFFF)
568 *jtag_speed
= 0xFFFF;
574 static int ft2232_register_commands(struct command_context_s
* cmd_ctx
)
576 register_command(cmd_ctx
, NULL
, "ft2232_device_desc", ft2232_handle_device_desc_command
,
577 COMMAND_CONFIG
, "the USB device description of the FTDI FT2232 device");
578 register_command(cmd_ctx
, NULL
, "ft2232_serial", ft2232_handle_serial_command
,
579 COMMAND_CONFIG
, "the serial number of the FTDI FT2232 device");
580 register_command(cmd_ctx
, NULL
, "ft2232_layout", ft2232_handle_layout_command
,
581 COMMAND_CONFIG
, "the layout of the FT2232 GPIO signals used to control output-enables and reset signals");
582 register_command(cmd_ctx
, NULL
, "ft2232_vid_pid", ft2232_handle_vid_pid_command
,
583 COMMAND_CONFIG
, "the vendor ID and product ID of the FTDI FT2232 device");
584 register_command(cmd_ctx
, NULL
, "ft2232_latency", ft2232_handle_latency_command
,
585 COMMAND_CONFIG
, "set the FT2232 latency timer to a new value");
589 static void ft2232_end_state(tap_state_t state
)
591 if (tap_is_state_stable(state
))
592 tap_set_end_state(state
);
595 LOG_ERROR("BUG: %s is not a stable end state", tap_state_name(state
));
600 static void ft2232_read_scan(enum scan_type type
, uint8_t* buffer
, int scan_size
)
602 int num_bytes
= (scan_size
+ 7) / 8;
603 int bits_left
= scan_size
;
606 while (num_bytes
-- > 1)
608 buffer
[cur_byte
++] = buffer_read();
612 buffer
[cur_byte
] = 0x0;
614 /* There is one more partial byte left from the clock data in/out instructions */
617 buffer
[cur_byte
] = buffer_read() >> 1;
619 /* 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 */
620 buffer
[cur_byte
] = (buffer
[cur_byte
] | (((buffer_read()) << 1) & 0x80)) >> (8 - bits_left
);
623 static void ft2232_debug_dump_buffer(void)
629 for (i
= 0; i
< ft2232_buffer_size
; i
++)
631 line_p
+= snprintf(line_p
, 256 - (line_p
- line
), "%2.2x ", ft2232_buffer
[i
]);
634 LOG_DEBUG("%s", line
);
640 LOG_DEBUG("%s", line
);
643 static int ft2232_send_and_recv(jtag_command_t
* first
, jtag_command_t
* last
)
650 uint32_t bytes_written
= 0;
651 uint32_t bytes_read
= 0;
653 #ifdef _DEBUG_USB_IO_
654 struct timeval start
, inter
, inter2
, end
;
655 struct timeval d_inter
, d_inter2
, d_end
;
658 #ifdef _DEBUG_USB_COMMS_
659 LOG_DEBUG("write buffer (size %i):", ft2232_buffer_size
);
660 ft2232_debug_dump_buffer();
663 #ifdef _DEBUG_USB_IO_
664 gettimeofday(&start
, NULL
);
667 if ((retval
= ft2232_write(ft2232_buffer
, ft2232_buffer_size
, &bytes_written
)) != ERROR_OK
)
669 LOG_ERROR("couldn't write MPSSE commands to FT2232");
673 #ifdef _DEBUG_USB_IO_
674 gettimeofday(&inter
, NULL
);
677 if (ft2232_expect_read
)
680 ft2232_buffer_size
= 0;
682 #ifdef _DEBUG_USB_IO_
683 gettimeofday(&inter2
, NULL
);
686 if ((retval
= ft2232_read(ft2232_buffer
, ft2232_expect_read
, &bytes_read
)) != ERROR_OK
)
688 LOG_ERROR("couldn't read from FT2232");
692 #ifdef _DEBUG_USB_IO_
693 gettimeofday(&end
, NULL
);
695 timeval_subtract(&d_inter
, &inter
, &start
);
696 timeval_subtract(&d_inter2
, &inter2
, &start
);
697 timeval_subtract(&d_end
, &end
, &start
);
699 LOG_INFO("inter: %u.%06u, inter2: %u.%06u end: %u.%06u",
700 (unsigned)d_inter
.tv_sec
, (unsigned)d_inter
.tv_usec
,
701 (unsigned)d_inter2
.tv_sec
, (unsigned)d_inter2
.tv_usec
,
702 (unsigned)d_end
.tv_sec
, (unsigned)d_end
.tv_usec
);
705 ft2232_buffer_size
= bytes_read
;
707 if (ft2232_expect_read
!= ft2232_buffer_size
)
709 LOG_ERROR("ft2232_expect_read (%i) != ft2232_buffer_size (%i) (%i retries)", ft2232_expect_read
,
712 ft2232_debug_dump_buffer();
717 #ifdef _DEBUG_USB_COMMS_
718 LOG_DEBUG("read buffer (%i retries): %i bytes", 100 - timeout
, ft2232_buffer_size
);
719 ft2232_debug_dump_buffer();
723 ft2232_expect_read
= 0;
724 ft2232_read_pointer
= 0;
726 /* return ERROR_OK, unless a jtag_read_buffer returns a failed check
727 * that wasn't handled by a caller-provided error handler
737 type
= jtag_scan_type(cmd
->cmd
.scan
);
738 if (type
!= SCAN_OUT
)
740 scan_size
= jtag_scan_size(cmd
->cmd
.scan
);
741 buffer
= calloc(CEIL(scan_size
, 8), 1);
742 ft2232_read_scan(type
, buffer
, scan_size
);
743 if (jtag_read_buffer(buffer
, cmd
->cmd
.scan
) != ERROR_OK
)
744 retval
= ERROR_JTAG_QUEUE_FAILED
;
756 ft2232_buffer_size
= 0;
762 * Function ft2232_add_pathmove
763 * moves the TAP controller from the current state to a new state through the
764 * given path, where path is an array of tap_state_t's.
766 * @param path is an array of tap_stat_t which gives the states to traverse through
767 * ending with the last state at path[num_states-1]
768 * @param num_states is the count of state steps to move through
770 static void ft2232_add_pathmove(tap_state_t
* path
, int num_states
)
774 assert((unsigned) num_states
<= 32u); /* tms_bits only holds 32 bits */
776 /* this loop verifies that the path is legal and logs each state in the path */
779 unsigned char tms_byte
= 0; /* zero this on each MPSSE batch */
781 int num_states_batch
= num_states
> 7 ? 7 : num_states
;
783 /* command "Clock Data to TMS/CS Pin (no Read)" */
786 /* number of states remaining */
787 buffer_write(num_states_batch
- 1);
789 while (num_states_batch
--) {
790 /* either TMS=0 or TMS=1 must work ... */
791 if (tap_state_transition(tap_get_state(), false)
792 == path
[state_count
])
793 buf_set_u32(&tms_byte
, bit_count
++, 1, 0x0);
794 else if (tap_state_transition(tap_get_state(), true)
795 == path
[state_count
])
796 buf_set_u32(&tms_byte
, bit_count
++, 1, 0x1);
798 /* ... or else the caller goofed BADLY */
800 LOG_ERROR("BUG: %s -> %s isn't a valid "
801 "TAP state transition",
802 tap_state_name(tap_get_state()),
803 tap_state_name(path
[state_count
]));
807 tap_set_state(path
[state_count
]);
812 buffer_write(tms_byte
);
814 tap_set_end_state(tap_get_state());
817 static void ft2232_add_scan(bool ir_scan
, enum scan_type type
, uint8_t* buffer
, int scan_size
)
819 int num_bytes
= (scan_size
+ 7) / 8;
820 int bits_left
= scan_size
;
826 if (tap_get_state() != TAP_DRSHIFT
)
828 move_to_state(TAP_DRSHIFT
);
833 if (tap_get_state() != TAP_IRSHIFT
)
835 move_to_state(TAP_IRSHIFT
);
839 /* add command for complete bytes */
840 while (num_bytes
> 1)
845 /* Clock Data Bytes In and Out LSB First */
847 /* LOG_DEBUG("added TDI bytes (io %i)", num_bytes); */
849 else if (type
== SCAN_OUT
)
851 /* Clock Data Bytes Out on -ve Clock Edge LSB First (no Read) */
853 /* LOG_DEBUG("added TDI bytes (o)"); */
855 else if (type
== SCAN_IN
)
857 /* Clock Data Bytes In on +ve Clock Edge LSB First (no Write) */
859 /* LOG_DEBUG("added TDI bytes (i %i)", num_bytes); */
862 thisrun_bytes
= (num_bytes
> 65537) ? 65536 : (num_bytes
- 1);
863 num_bytes
-= thisrun_bytes
;
865 buffer_write((uint8_t) (thisrun_bytes
- 1));
866 buffer_write((uint8_t) ((thisrun_bytes
- 1) >> 8));
870 /* add complete bytes */
871 while (thisrun_bytes
-- > 0)
873 buffer_write(buffer
[cur_byte
++]);
877 else /* (type == SCAN_IN) */
879 bits_left
-= 8 * (thisrun_bytes
);
883 /* the most signifcant bit is scanned during TAP movement */
885 last_bit
= (buffer
[cur_byte
] >> (bits_left
- 1)) & 0x1;
889 /* process remaining bits but the last one */
894 /* Clock Data Bits In and Out LSB First */
896 /* LOG_DEBUG("added TDI bits (io) %i", bits_left - 1); */
898 else if (type
== SCAN_OUT
)
900 /* Clock Data Bits Out on -ve Clock Edge LSB First (no Read) */
902 /* LOG_DEBUG("added TDI bits (o)"); */
904 else if (type
== SCAN_IN
)
906 /* Clock Data Bits In on +ve Clock Edge LSB First (no Write) */
908 /* LOG_DEBUG("added TDI bits (i %i)", bits_left - 1); */
911 buffer_write(bits_left
- 2);
913 buffer_write(buffer
[cur_byte
]);
916 if ((ir_scan
&& (tap_get_end_state() == TAP_IRSHIFT
))
917 || (!ir_scan
&& (tap_get_end_state() == TAP_DRSHIFT
)))
921 /* Clock Data Bits In and Out LSB First */
923 /* LOG_DEBUG("added TDI bits (io) %i", bits_left - 1); */
925 else if (type
== SCAN_OUT
)
927 /* Clock Data Bits Out on -ve Clock Edge LSB First (no Read) */
929 /* LOG_DEBUG("added TDI bits (o)"); */
931 else if (type
== SCAN_IN
)
933 /* Clock Data Bits In on +ve Clock Edge LSB First (no Write) */
935 /* LOG_DEBUG("added TDI bits (i %i)", bits_left - 1); */
938 buffer_write(last_bit
);
946 /* move from Shift-IR/DR to end state */
947 if (type
!= SCAN_OUT
)
949 /* We always go to the PAUSE state in two step at the end of an IN or IO scan */
950 /* This must be coordinated with the bit shifts in ft2232_read_scan */
953 /* Clock Data to TMS/CS Pin with Read */
955 /* LOG_DEBUG("added TMS scan (read)"); */
959 tms_bits
= tap_get_tms_path(tap_get_state(), tap_get_end_state());
960 tms_count
= tap_get_tms_path_len(tap_get_state(), tap_get_end_state());
961 /* Clock Data to TMS/CS Pin (no Read) */
963 /* LOG_DEBUG("added TMS scan (no read)"); */
966 clock_tms(mpsse_cmd
, tms_bits
, tms_count
, last_bit
);
969 if (tap_get_state() != tap_get_end_state())
971 move_to_state(tap_get_end_state());
975 static int ft2232_large_scan(scan_command_t
* cmd
, enum scan_type type
, uint8_t* buffer
, int scan_size
)
977 int num_bytes
= (scan_size
+ 7) / 8;
978 int bits_left
= scan_size
;
981 uint8_t* receive_buffer
= malloc(CEIL(scan_size
, 8));
982 uint8_t* receive_pointer
= receive_buffer
;
983 uint32_t bytes_written
;
986 int thisrun_read
= 0;
990 LOG_ERROR("BUG: large IR scans are not supported");
994 if (tap_get_state() != TAP_DRSHIFT
)
996 move_to_state(TAP_DRSHIFT
);
999 if ((retval
= ft2232_write(ft2232_buffer
, ft2232_buffer_size
, &bytes_written
)) != ERROR_OK
)
1001 LOG_ERROR("couldn't write MPSSE commands to FT2232");
1004 LOG_DEBUG("ft2232_buffer_size: %i, bytes_written: %i",
1005 ft2232_buffer_size
, (int)bytes_written
);
1006 ft2232_buffer_size
= 0;
1008 /* add command for complete bytes */
1009 while (num_bytes
> 1)
1013 if (type
== SCAN_IO
)
1015 /* Clock Data Bytes In and Out LSB First */
1017 /* LOG_DEBUG("added TDI bytes (io %i)", num_bytes); */
1019 else if (type
== SCAN_OUT
)
1021 /* Clock Data Bytes Out on -ve Clock Edge LSB First (no Read) */
1023 /* LOG_DEBUG("added TDI bytes (o)"); */
1025 else if (type
== SCAN_IN
)
1027 /* Clock Data Bytes In on +ve Clock Edge LSB First (no Write) */
1029 /* LOG_DEBUG("added TDI bytes (i %i)", num_bytes); */
1032 thisrun_bytes
= (num_bytes
> 65537) ? 65536 : (num_bytes
- 1);
1033 thisrun_read
= thisrun_bytes
;
1034 num_bytes
-= thisrun_bytes
;
1035 buffer_write((uint8_t) (thisrun_bytes
- 1));
1036 buffer_write((uint8_t) ((thisrun_bytes
- 1) >> 8));
1038 if (type
!= SCAN_IN
)
1040 /* add complete bytes */
1041 while (thisrun_bytes
-- > 0)
1043 buffer_write(buffer
[cur_byte
]);
1048 else /* (type == SCAN_IN) */
1050 bits_left
-= 8 * (thisrun_bytes
);
1053 if ((retval
= ft2232_write(ft2232_buffer
, ft2232_buffer_size
, &bytes_written
)) != ERROR_OK
)
1055 LOG_ERROR("couldn't write MPSSE commands to FT2232");
1058 LOG_DEBUG("ft2232_buffer_size: %i, bytes_written: %i",
1060 (int)bytes_written
);
1061 ft2232_buffer_size
= 0;
1063 if (type
!= SCAN_OUT
)
1065 if ((retval
= ft2232_read(receive_pointer
, thisrun_read
, &bytes_read
)) != ERROR_OK
)
1067 LOG_ERROR("couldn't read from FT2232");
1070 LOG_DEBUG("thisrun_read: %i, bytes_read: %i",
1073 receive_pointer
+= bytes_read
;
1079 /* the most signifcant bit is scanned during TAP movement */
1080 if (type
!= SCAN_IN
)
1081 last_bit
= (buffer
[cur_byte
] >> (bits_left
- 1)) & 0x1;
1085 /* process remaining bits but the last one */
1088 if (type
== SCAN_IO
)
1090 /* Clock Data Bits In and Out LSB First */
1092 /* LOG_DEBUG("added TDI bits (io) %i", bits_left - 1); */
1094 else if (type
== SCAN_OUT
)
1096 /* Clock Data Bits Out on -ve Clock Edge LSB First (no Read) */
1098 /* LOG_DEBUG("added TDI bits (o)"); */
1100 else if (type
== SCAN_IN
)
1102 /* Clock Data Bits In on +ve Clock Edge LSB First (no Write) */
1104 /* LOG_DEBUG("added TDI bits (i %i)", bits_left - 1); */
1106 buffer_write(bits_left
- 2);
1107 if (type
!= SCAN_IN
)
1108 buffer_write(buffer
[cur_byte
]);
1110 if (type
!= SCAN_OUT
)
1114 if (tap_get_end_state() == TAP_DRSHIFT
)
1116 if (type
== SCAN_IO
)
1118 /* Clock Data Bits In and Out LSB First */
1120 /* LOG_DEBUG("added TDI bits (io) %i", bits_left - 1); */
1122 else if (type
== SCAN_OUT
)
1124 /* Clock Data Bits Out on -ve Clock Edge LSB First (no Read) */
1126 /* LOG_DEBUG("added TDI bits (o)"); */
1128 else if (type
== SCAN_IN
)
1130 /* Clock Data Bits In on +ve Clock Edge LSB First (no Write) */
1132 /* LOG_DEBUG("added TDI bits (i %i)", bits_left - 1); */
1135 buffer_write(last_bit
);
1139 int tms_bits
= tap_get_tms_path(tap_get_state(), tap_get_end_state());
1140 int tms_count
= tap_get_tms_path_len(tap_get_state(), tap_get_end_state());
1143 /* move from Shift-IR/DR to end state */
1144 if (type
!= SCAN_OUT
)
1146 /* Clock Data to TMS/CS Pin with Read */
1148 /* LOG_DEBUG("added TMS scan (read)"); */
1152 /* Clock Data to TMS/CS Pin (no Read) */
1154 /* LOG_DEBUG("added TMS scan (no read)"); */
1157 clock_tms(mpsse_cmd
, tms_bits
, tms_count
, last_bit
);
1160 if (type
!= SCAN_OUT
)
1163 if ((retval
= ft2232_write(ft2232_buffer
, ft2232_buffer_size
, &bytes_written
)) != ERROR_OK
)
1165 LOG_ERROR("couldn't write MPSSE commands to FT2232");
1168 LOG_DEBUG("ft2232_buffer_size: %i, bytes_written: %i",
1170 (int)bytes_written
);
1171 ft2232_buffer_size
= 0;
1173 if (type
!= SCAN_OUT
)
1175 if ((retval
= ft2232_read(receive_pointer
, thisrun_read
, &bytes_read
)) != ERROR_OK
)
1177 LOG_ERROR("couldn't read from FT2232");
1180 LOG_DEBUG("thisrun_read: %i, bytes_read: %i",
1183 receive_pointer
+= bytes_read
;
1189 static int ft2232_predict_scan_out(int scan_size
, enum scan_type type
)
1191 int predicted_size
= 3;
1192 int num_bytes
= (scan_size
- 1) / 8;
1194 if (tap_get_state() != TAP_DRSHIFT
)
1195 predicted_size
+= get_tms_buffer_requirements(tap_get_tms_path_len(tap_get_state(), TAP_DRSHIFT
));
1197 if (type
== SCAN_IN
) /* only from device to host */
1199 /* complete bytes */
1200 predicted_size
+= CEIL(num_bytes
, 65536) * 3;
1202 /* remaining bits - 1 (up to 7) */
1203 predicted_size
+= ((scan_size
- 1) % 8) ? 2 : 0;
1205 else /* host to device, or bidirectional */
1207 /* complete bytes */
1208 predicted_size
+= num_bytes
+ CEIL(num_bytes
, 65536) * 3;
1210 /* remaining bits -1 (up to 7) */
1211 predicted_size
+= ((scan_size
- 1) % 8) ? 3 : 0;
1214 return predicted_size
;
1217 static int ft2232_predict_scan_in(int scan_size
, enum scan_type type
)
1219 int predicted_size
= 0;
1221 if (type
!= SCAN_OUT
)
1223 /* complete bytes */
1224 predicted_size
+= (CEIL(scan_size
, 8) > 1) ? (CEIL(scan_size
, 8) - 1) : 0;
1226 /* remaining bits - 1 */
1227 predicted_size
+= ((scan_size
- 1) % 8) ? 1 : 0;
1229 /* last bit (from TMS scan) */
1230 predicted_size
+= 1;
1233 /* LOG_DEBUG("scan_size: %i, predicted_size: %i", scan_size, predicted_size); */
1235 return predicted_size
;
1238 static void usbjtag_reset(int trst
, int srst
)
1240 enum reset_types jtag_reset_config
= jtag_get_reset_config();
1243 if (jtag_reset_config
& RESET_TRST_OPEN_DRAIN
)
1244 low_direction
|= nTRSTnOE
; /* switch to output pin (output is low) */
1246 low_output
&= ~nTRST
; /* switch output low */
1250 if (jtag_reset_config
& RESET_TRST_OPEN_DRAIN
)
1251 low_direction
&= ~nTRSTnOE
; /* switch to input pin (high-Z + internal and external pullup) */
1253 low_output
|= nTRST
; /* switch output high */
1258 if (jtag_reset_config
& RESET_SRST_PUSH_PULL
)
1259 low_output
&= ~nSRST
; /* switch output low */
1261 low_direction
|= nSRSTnOE
; /* switch to output pin (output is low) */
1265 if (jtag_reset_config
& RESET_SRST_PUSH_PULL
)
1266 low_output
|= nSRST
; /* switch output high */
1268 low_direction
&= ~nSRSTnOE
; /* switch to input pin (high-Z) */
1271 /* command "set data bits low byte" */
1273 buffer_write(low_output
);
1274 buffer_write(low_direction
);
1277 static void jtagkey_reset(int trst
, int srst
)
1279 enum reset_types jtag_reset_config
= jtag_get_reset_config();
1282 if (jtag_reset_config
& RESET_TRST_OPEN_DRAIN
)
1283 high_output
&= ~nTRSTnOE
;
1285 high_output
&= ~nTRST
;
1289 if (jtag_reset_config
& RESET_TRST_OPEN_DRAIN
)
1290 high_output
|= nTRSTnOE
;
1292 high_output
|= nTRST
;
1297 if (jtag_reset_config
& RESET_SRST_PUSH_PULL
)
1298 high_output
&= ~nSRST
;
1300 high_output
&= ~nSRSTnOE
;
1304 if (jtag_reset_config
& RESET_SRST_PUSH_PULL
)
1305 high_output
|= nSRST
;
1307 high_output
|= nSRSTnOE
;
1310 /* command "set data bits high byte" */
1312 buffer_write(high_output
);
1313 buffer_write(high_direction
);
1314 LOG_DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst
, srst
, high_output
,
1318 static void olimex_jtag_reset(int trst
, int srst
)
1320 enum reset_types jtag_reset_config
= jtag_get_reset_config();
1323 if (jtag_reset_config
& RESET_TRST_OPEN_DRAIN
)
1324 high_output
&= ~nTRSTnOE
;
1326 high_output
&= ~nTRST
;
1330 if (jtag_reset_config
& RESET_TRST_OPEN_DRAIN
)
1331 high_output
|= nTRSTnOE
;
1333 high_output
|= nTRST
;
1338 high_output
|= nSRST
;
1342 high_output
&= ~nSRST
;
1345 /* command "set data bits high byte" */
1347 buffer_write(high_output
);
1348 buffer_write(high_direction
);
1349 LOG_DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst
, srst
, high_output
,
1353 static void axm0432_jtag_reset(int trst
, int srst
)
1357 tap_set_state(TAP_RESET
);
1358 high_output
&= ~nTRST
;
1362 high_output
|= nTRST
;
1367 high_output
&= ~nSRST
;
1371 high_output
|= nSRST
;
1374 /* command "set data bits low byte" */
1376 buffer_write(high_output
);
1377 buffer_write(high_direction
);
1378 LOG_DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst
, srst
, high_output
,
1382 static void flyswatter_reset(int trst
, int srst
)
1386 low_output
&= ~nTRST
;
1390 low_output
|= nTRST
;
1395 low_output
|= nSRST
;
1399 low_output
&= ~nSRST
;
1402 /* command "set data bits low byte" */
1404 buffer_write(low_output
);
1405 buffer_write(low_direction
);
1406 LOG_DEBUG("trst: %i, srst: %i, low_output: 0x%2.2x, low_direction: 0x%2.2x", trst
, srst
, low_output
, low_direction
);
1409 static void turtle_reset(int trst
, int srst
)
1415 low_output
|= nSRST
;
1419 low_output
&= ~nSRST
;
1422 /* command "set data bits low byte" */
1424 buffer_write(low_output
);
1425 buffer_write(low_direction
);
1426 LOG_DEBUG("srst: %i, low_output: 0x%2.2x, low_direction: 0x%2.2x", srst
, low_output
, low_direction
);
1429 static void comstick_reset(int trst
, int srst
)
1433 high_output
&= ~nTRST
;
1437 high_output
|= nTRST
;
1442 high_output
&= ~nSRST
;
1446 high_output
|= nSRST
;
1449 /* command "set data bits high byte" */
1451 buffer_write(high_output
);
1452 buffer_write(high_direction
);
1453 LOG_DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst
, srst
, high_output
,
1457 static void stm32stick_reset(int trst
, int srst
)
1461 high_output
&= ~nTRST
;
1465 high_output
|= nTRST
;
1470 low_output
&= ~nSRST
;
1474 low_output
|= nSRST
;
1477 /* command "set data bits low byte" */
1479 buffer_write(low_output
);
1480 buffer_write(low_direction
);
1482 /* command "set data bits high byte" */
1484 buffer_write(high_output
);
1485 buffer_write(high_direction
);
1486 LOG_DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst
, srst
, high_output
,
1490 static void sheevaplug_reset(int trst
, int srst
)
1493 high_output
&= ~nTRST
;
1495 high_output
|= nTRST
;
1498 high_output
&= ~nSRSTnOE
;
1500 high_output
|= nSRSTnOE
;
1502 /* command "set data bits high byte" */
1504 buffer_write(high_output
);
1505 buffer_write(high_direction
);
1506 LOG_DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst
, srst
, high_output
, high_direction
);
1509 static int ft2232_execute_runtest(jtag_command_t
*cmd
)
1513 int predicted_size
= 0;
1516 DEBUG_JTAG_IO("runtest %i cycles, end in %s",
1517 cmd
->cmd
.runtest
->num_cycles
,
1518 tap_state_name(cmd
->cmd
.runtest
->end_state
));
1520 /* only send the maximum buffer size that FT2232C can handle */
1522 if (tap_get_state() != TAP_IDLE
)
1523 predicted_size
+= 3;
1524 predicted_size
+= 3 * CEIL(cmd
->cmd
.runtest
->num_cycles
, 7);
1525 if (cmd
->cmd
.runtest
->end_state
!= TAP_IDLE
)
1526 predicted_size
+= 3;
1527 if (tap_get_end_state() != TAP_IDLE
)
1528 predicted_size
+= 3;
1529 if (ft2232_buffer_size
+ predicted_size
+ 1 > FT2232_BUFFER_SIZE
)
1531 if (ft2232_send_and_recv(first_unsent
, cmd
) != ERROR_OK
)
1532 retval
= ERROR_JTAG_QUEUE_FAILED
;
1536 if (tap_get_state() != TAP_IDLE
)
1538 move_to_state(TAP_IDLE
);
1541 i
= cmd
->cmd
.runtest
->num_cycles
;
1544 /* there are no state transitions in this code, so omit state tracking */
1546 /* command "Clock Data to TMS/CS Pin (no Read)" */
1550 buffer_write((i
> 7) ? 6 : (i
- 1));
1554 tap_set_state(TAP_IDLE
);
1556 i
-= (i
> 7) ? 7 : i
;
1557 /* LOG_DEBUG("added TMS scan (no read)"); */
1560 ft2232_end_state(cmd
->cmd
.runtest
->end_state
);
1562 if (tap_get_state() != tap_get_end_state())
1564 move_to_state(tap_get_end_state());
1568 #ifdef _DEBUG_JTAG_IO_
1569 LOG_DEBUG("runtest: %i, end in %s", cmd
->cmd
.runtest
->num_cycles
, tap_state_name(tap_get_end_state()));
1575 static int ft2232_execute_statemove(jtag_command_t
*cmd
)
1577 int predicted_size
= 0;
1578 int retval
= ERROR_OK
;
1580 DEBUG_JTAG_IO("statemove end in %i", cmd
->cmd
.statemove
->end_state
);
1582 /* only send the maximum buffer size that FT2232C can handle */
1584 if (ft2232_buffer_size
+ predicted_size
+ 1 > FT2232_BUFFER_SIZE
)
1586 if (ft2232_send_and_recv(first_unsent
, cmd
) != ERROR_OK
)
1587 retval
= ERROR_JTAG_QUEUE_FAILED
;
1591 ft2232_end_state(cmd
->cmd
.statemove
->end_state
);
1593 /* For TAP_RESET, ignore the current recorded state. It's often
1594 * wrong at server startup, and this transation is critical whenever
1597 if (tap_get_end_state() == TAP_RESET
) {
1598 clock_tms(0x4b, 0xff, 5, 0);
1601 /* shortest-path move to desired end state */
1602 } else if (tap_get_state() != tap_get_end_state())
1604 move_to_state(tap_get_end_state());
1611 static int ft2232_execute_pathmove(jtag_command_t
*cmd
)
1613 int predicted_size
= 0;
1614 int retval
= ERROR_OK
;
1616 tap_state_t
* path
= cmd
->cmd
.pathmove
->path
;
1617 int num_states
= cmd
->cmd
.pathmove
->num_states
;
1619 DEBUG_JTAG_IO("pathmove: %i states, current: %s end: %s", num_states
,
1620 tap_state_name(tap_get_state()),
1621 tap_state_name(path
[num_states
-1]));
1623 /* only send the maximum buffer size that FT2232C can handle */
1624 predicted_size
= 3 * CEIL(num_states
, 7);
1625 if (ft2232_buffer_size
+ predicted_size
+ 1 > FT2232_BUFFER_SIZE
)
1627 if (ft2232_send_and_recv(first_unsent
, cmd
) != ERROR_OK
)
1628 retval
= ERROR_JTAG_QUEUE_FAILED
;
1634 ft2232_add_pathmove(path
, num_states
);
1640 static int ft2232_execute_scan(jtag_command_t
*cmd
)
1643 int scan_size
; /* size of IR or DR scan */
1644 int predicted_size
= 0;
1645 int retval
= ERROR_OK
;
1647 enum scan_type type
= jtag_scan_type(cmd
->cmd
.scan
);
1649 DEBUG_JTAG_IO("%s type:%d", cmd
->cmd
.scan
->ir_scan
? "IRSCAN" : "DRSCAN", type
);
1651 scan_size
= jtag_build_buffer(cmd
->cmd
.scan
, &buffer
);
1653 predicted_size
= ft2232_predict_scan_out(scan_size
, type
);
1654 if ((predicted_size
+ 1) > FT2232_BUFFER_SIZE
)
1656 LOG_DEBUG("oversized ft2232 scan (predicted_size > FT2232_BUFFER_SIZE)");
1657 /* unsent commands before this */
1658 if (first_unsent
!= cmd
)
1659 if (ft2232_send_and_recv(first_unsent
, cmd
) != ERROR_OK
)
1660 retval
= ERROR_JTAG_QUEUE_FAILED
;
1662 /* current command */
1663 ft2232_end_state(cmd
->cmd
.scan
->end_state
);
1664 ft2232_large_scan(cmd
->cmd
.scan
, type
, buffer
, scan_size
);
1666 first_unsent
= cmd
->next
;
1671 else if (ft2232_buffer_size
+ predicted_size
+ 1 > FT2232_BUFFER_SIZE
)
1673 LOG_DEBUG("ft2232 buffer size reached, sending queued commands (first_unsent: %p, cmd: %p)",
1676 if (ft2232_send_and_recv(first_unsent
, cmd
) != ERROR_OK
)
1677 retval
= ERROR_JTAG_QUEUE_FAILED
;
1681 ft2232_expect_read
+= ft2232_predict_scan_in(scan_size
, type
);
1682 /* LOG_DEBUG("new read size: %i", ft2232_expect_read); */
1683 ft2232_end_state(cmd
->cmd
.scan
->end_state
);
1684 ft2232_add_scan(cmd
->cmd
.scan
->ir_scan
, type
, buffer
, scan_size
);
1688 #ifdef _DEBUG_JTAG_IO_
1689 LOG_DEBUG("%s scan, %i bits, end in %s", (cmd
->cmd
.scan
->ir_scan
) ? "IR" : "DR", scan_size
,
1690 tap_state_name(tap_get_end_state()));
1696 static int ft2232_execute_reset(jtag_command_t
*cmd
)
1699 int predicted_size
= 0;
1702 DEBUG_JTAG_IO("reset trst: %i srst %i",
1703 cmd
->cmd
.reset
->trst
, cmd
->cmd
.reset
->srst
);
1705 /* only send the maximum buffer size that FT2232C can handle */
1707 if (ft2232_buffer_size
+ predicted_size
+ 1 > FT2232_BUFFER_SIZE
)
1709 if (ft2232_send_and_recv(first_unsent
, cmd
) != ERROR_OK
)
1710 retval
= ERROR_JTAG_QUEUE_FAILED
;
1715 if ((cmd
->cmd
.reset
->trst
== 1) || (cmd
->cmd
.reset
->srst
&& (jtag_get_reset_config() & RESET_SRST_PULLS_TRST
)))
1717 tap_set_state(TAP_RESET
);
1720 layout
->reset(cmd
->cmd
.reset
->trst
, cmd
->cmd
.reset
->srst
);
1723 #ifdef _DEBUG_JTAG_IO_
1724 LOG_DEBUG("trst: %i, srst: %i", cmd
->cmd
.reset
->trst
, cmd
->cmd
.reset
->srst
);
1729 static int ft2232_execute_sleep(jtag_command_t
*cmd
)
1734 DEBUG_JTAG_IO("sleep %i", cmd
->cmd
.sleep
->us
);
1736 if (ft2232_send_and_recv(first_unsent
, cmd
) != ERROR_OK
)
1737 retval
= ERROR_JTAG_QUEUE_FAILED
;
1738 first_unsent
= cmd
->next
;
1739 jtag_sleep(cmd
->cmd
.sleep
->us
);
1740 #ifdef _DEBUG_JTAG_IO_
1741 LOG_DEBUG("sleep %i usec while in %s", cmd
->cmd
.sleep
->us
, tap_state_name(tap_get_state()));
1747 static int ft2232_execute_stableclocks(jtag_command_t
*cmd
)
1752 /* this is only allowed while in a stable state. A check for a stable
1753 * state was done in jtag_add_clocks()
1755 if (ft2232_stableclocks(cmd
->cmd
.stableclocks
->num_cycles
, cmd
) != ERROR_OK
)
1756 retval
= ERROR_JTAG_QUEUE_FAILED
;
1757 #ifdef _DEBUG_JTAG_IO_
1758 LOG_DEBUG("clocks %i while in %s", cmd
->cmd
.stableclocks
->num_cycles
, tap_state_name(tap_get_state()));
1764 static int ft2232_execute_command(jtag_command_t
*cmd
)
1771 case JTAG_RESET
: retval
= ft2232_execute_reset(cmd
); break;
1772 case JTAG_RUNTEST
: retval
= ft2232_execute_runtest(cmd
); break;
1773 case JTAG_STATEMOVE
: retval
= ft2232_execute_statemove(cmd
); break;
1774 case JTAG_PATHMOVE
: retval
= ft2232_execute_pathmove(cmd
); break;
1775 case JTAG_SCAN
: retval
= ft2232_execute_scan(cmd
); break;
1776 case JTAG_SLEEP
: retval
= ft2232_execute_sleep(cmd
); break;
1777 case JTAG_STABLECLOCKS
: retval
= ft2232_execute_stableclocks(cmd
); break;
1779 LOG_ERROR("BUG: unknown JTAG command type encountered");
1785 static int ft2232_execute_queue()
1787 jtag_command_t
* cmd
= jtag_command_queue
; /* currently processed command */
1790 first_unsent
= cmd
; /* next command that has to be sent */
1793 /* return ERROR_OK, unless ft2232_send_and_recv reports a failed check
1794 * that wasn't handled by a caller-provided error handler
1798 ft2232_buffer_size
= 0;
1799 ft2232_expect_read
= 0;
1801 /* blink, if the current layout has that feature */
1807 if (ft2232_execute_command(cmd
) != ERROR_OK
)
1808 retval
= ERROR_JTAG_QUEUE_FAILED
;
1809 /* Start reading input before FT2232 TX buffer fills up */
1811 if (ft2232_expect_read
> 256)
1813 if (ft2232_send_and_recv(first_unsent
, cmd
) != ERROR_OK
)
1814 retval
= ERROR_JTAG_QUEUE_FAILED
;
1819 if (require_send
> 0)
1820 if (ft2232_send_and_recv(first_unsent
, cmd
) != ERROR_OK
)
1821 retval
= ERROR_JTAG_QUEUE_FAILED
;
1826 #if BUILD_FT2232_FTD2XX == 1
1827 static int ft2232_init_ftd2xx(uint16_t vid
, uint16_t pid
, int more
, int* try_more
)
1831 char SerialNumber
[16];
1832 char Description
[64];
1833 DWORD openex_flags
= 0;
1834 char* openex_string
= NULL
;
1835 uint8_t latency_timer
;
1837 LOG_DEBUG("'ft2232' interface using FTD2XX with '%s' layout (%4.4x:%4.4x)", ft2232_layout
, vid
, pid
);
1840 /* Add non-standard Vid/Pid to the linux driver */
1841 if ((status
= FT_SetVIDPID(vid
, pid
)) != FT_OK
)
1843 LOG_WARNING("couldn't add %4.4x:%4.4x", vid
, pid
);
1847 if (ft2232_device_desc
&& ft2232_serial
)
1849 LOG_WARNING("can't open by device description and serial number, giving precedence to serial");
1850 ft2232_device_desc
= NULL
;
1853 if (ft2232_device_desc
)
1855 openex_string
= ft2232_device_desc
;
1856 openex_flags
= FT_OPEN_BY_DESCRIPTION
;
1858 else if (ft2232_serial
)
1860 openex_string
= ft2232_serial
;
1861 openex_flags
= FT_OPEN_BY_SERIAL_NUMBER
;
1865 LOG_ERROR("neither device description nor serial number specified");
1866 LOG_ERROR("please add \"ft2232_device_desc <string>\" or \"ft2232_serial <string>\" to your .cfg file");
1868 return ERROR_JTAG_INIT_FAILED
;
1871 status
= FT_OpenEx(openex_string
, openex_flags
, &ftdih
);
1872 if (status
!= FT_OK
) {
1873 /* under Win32, the FTD2XX driver appends an "A" to the end
1874 * of the description, if we tried by the desc, then
1875 * try by the alternate "A" description. */
1876 if (openex_string
== ft2232_device_desc
) {
1877 /* Try the alternate method. */
1878 openex_string
= ft2232_device_desc_A
;
1879 status
= FT_OpenEx(openex_string
, openex_flags
, &ftdih
);
1880 if (status
== FT_OK
) {
1881 /* yea, the "alternate" method worked! */
1883 /* drat, give the user a meaningfull message.
1884 * telling the use we tried *BOTH* methods. */
1885 LOG_WARNING("Unable to open FTDI Device tried: '%s' and '%s'\n",
1887 ft2232_device_desc_A
);
1892 if (status
!= FT_OK
)
1898 LOG_WARNING("unable to open ftdi device (trying more): %lu", status
);
1900 return ERROR_JTAG_INIT_FAILED
;
1902 LOG_ERROR("unable to open ftdi device: %lu", status
);
1903 status
= FT_ListDevices(&num_devices
, NULL
, FT_LIST_NUMBER_ONLY
);
1904 if (status
== FT_OK
)
1906 char** desc_array
= malloc(sizeof(char*) * (num_devices
+ 1));
1909 for (i
= 0; i
< num_devices
; i
++)
1910 desc_array
[i
] = malloc(64);
1912 desc_array
[num_devices
] = NULL
;
1914 status
= FT_ListDevices(desc_array
, &num_devices
, FT_LIST_ALL
| openex_flags
);
1916 if (status
== FT_OK
)
1918 LOG_ERROR("ListDevices: %lu\n", num_devices
);
1919 for (i
= 0; i
< num_devices
; i
++)
1920 LOG_ERROR("%" PRIu32
": \"%s\"", i
, desc_array
[i
]);
1923 for (i
= 0; i
< num_devices
; i
++)
1924 free(desc_array
[i
]);
1930 LOG_ERROR("ListDevices: NONE\n");
1932 return ERROR_JTAG_INIT_FAILED
;
1935 if ((status
= FT_SetLatencyTimer(ftdih
, ft2232_latency
)) != FT_OK
)
1937 LOG_ERROR("unable to set latency timer: %lu", status
);
1938 return ERROR_JTAG_INIT_FAILED
;
1941 if ((status
= FT_GetLatencyTimer(ftdih
, &latency_timer
)) != FT_OK
)
1943 LOG_ERROR("unable to get latency timer: %lu", status
);
1944 return ERROR_JTAG_INIT_FAILED
;
1948 LOG_DEBUG("current latency timer: %i", latency_timer
);
1951 if ((status
= FT_SetTimeouts(ftdih
, 5000, 5000)) != FT_OK
)
1953 LOG_ERROR("unable to set timeouts: %lu", status
);
1954 return ERROR_JTAG_INIT_FAILED
;
1957 if ((status
= FT_SetBitMode(ftdih
, 0x0b, 2)) != FT_OK
)
1959 LOG_ERROR("unable to enable bit i/o mode: %lu", status
);
1960 return ERROR_JTAG_INIT_FAILED
;
1963 if ((status
= FT_GetDeviceInfo(ftdih
, &ftdi_device
, &deviceID
, SerialNumber
, Description
, NULL
)) != FT_OK
)
1965 LOG_ERROR("unable to get FT_GetDeviceInfo: %lu", status
);
1966 return ERROR_JTAG_INIT_FAILED
;
1970 static const char* type_str
[] =
1971 {"BM", "AM", "100AX", "UNKNOWN", "2232C", "232R", "2232H", "4232H"};
1972 unsigned no_of_known_types
= sizeof(type_str
) / sizeof(type_str
[0]) - 1;
1973 unsigned type_index
= ((unsigned)ftdi_device
<= no_of_known_types
)
1974 ? ftdi_device
: FT_DEVICE_UNKNOWN
;
1975 LOG_INFO("device: %lu \"%s\"", ftdi_device
, type_str
[type_index
]);
1976 LOG_INFO("deviceID: %lu", deviceID
);
1977 LOG_INFO("SerialNumber: %s", SerialNumber
);
1978 LOG_INFO("Description: %s", Description
);
1984 static int ft2232_purge_ftd2xx(void)
1988 if ((status
= FT_Purge(ftdih
, FT_PURGE_RX
| FT_PURGE_TX
)) != FT_OK
)
1990 LOG_ERROR("error purging ftd2xx device: %lu", status
);
1991 return ERROR_JTAG_INIT_FAILED
;
1997 #endif /* BUILD_FT2232_FTD2XX == 1 */
1999 #if BUILD_FT2232_LIBFTDI == 1
2000 static int ft2232_init_libftdi(uint16_t vid
, uint16_t pid
, int more
, int* try_more
)
2002 uint8_t latency_timer
;
2004 LOG_DEBUG("'ft2232' interface using libftdi with '%s' layout (%4.4x:%4.4x)",
2005 ft2232_layout
, vid
, pid
);
2007 if (ftdi_init(&ftdic
) < 0)
2008 return ERROR_JTAG_INIT_FAILED
;
2010 if (ftdi_set_interface(&ftdic
, INTERFACE_A
) < 0)
2012 LOG_ERROR("unable to select FT2232 channel A: %s", ftdic
.error_str
);
2013 return ERROR_JTAG_INIT_FAILED
;
2016 /* context, vendor id, product id */
2017 if (ftdi_usb_open_desc(&ftdic
, vid
, pid
, ft2232_device_desc
,
2021 LOG_WARNING("unable to open ftdi device (trying more): %s",
2024 LOG_ERROR("unable to open ftdi device: %s", ftdic
.error_str
);
2026 return ERROR_JTAG_INIT_FAILED
;
2029 /* There is already a reset in ftdi_usb_open_desc, this should be redundant */
2030 if (ftdi_usb_reset(&ftdic
) < 0)
2032 LOG_ERROR("unable to reset ftdi device");
2033 return ERROR_JTAG_INIT_FAILED
;
2036 if (ftdi_set_latency_timer(&ftdic
, ft2232_latency
) < 0)
2038 LOG_ERROR("unable to set latency timer");
2039 return ERROR_JTAG_INIT_FAILED
;
2042 if (ftdi_get_latency_timer(&ftdic
, &latency_timer
) < 0)
2044 LOG_ERROR("unable to get latency timer");
2045 return ERROR_JTAG_INIT_FAILED
;
2049 LOG_DEBUG("current latency timer: %i", latency_timer
);
2052 ftdi_set_bitmode(&ftdic
, 0x0b, 2); /* ctx, JTAG I/O mask */
2054 ftdi_device
= ftdic
.type
;
2055 static const char* type_str
[] =
2056 {"AM", "BM", "2232C", "R", "2232H", "4232H", "Unknown"};
2057 unsigned no_of_known_types
= sizeof(type_str
) / sizeof(type_str
[0]) - 1;
2058 unsigned type_index
= ((unsigned)ftdi_device
< no_of_known_types
)
2059 ? ftdi_device
: no_of_known_types
;
2060 LOG_DEBUG("FTDI chip type: %i \"%s\"", (int)ftdi_device
, type_str
[type_index
]);
2064 static int ft2232_purge_libftdi(void)
2066 if (ftdi_usb_purge_buffers(&ftdic
) < 0)
2068 LOG_ERROR("ftdi_purge_buffers: %s", ftdic
.error_str
);
2069 return ERROR_JTAG_INIT_FAILED
;
2075 #endif /* BUILD_FT2232_LIBFTDI == 1 */
2077 static int ft2232_init(void)
2081 uint32_t bytes_written
;
2082 const ft2232_layout_t
* cur_layout
= ft2232_layouts
;
2085 if (tap_get_tms_path_len(TAP_IRPAUSE
,TAP_IRPAUSE
) == 7)
2087 LOG_DEBUG("ft2232 interface using 7 step jtag state transitions");
2091 LOG_DEBUG("ft2232 interface using shortest path jtag state transitions");
2094 if ((ft2232_layout
== NULL
) || (ft2232_layout
[0] == 0))
2096 ft2232_layout
= "usbjtag";
2097 LOG_WARNING("No ft2232 layout specified, using default 'usbjtag'");
2100 while (cur_layout
->name
)
2102 if (strcmp(cur_layout
->name
, ft2232_layout
) == 0)
2104 layout
= cur_layout
;
2112 LOG_ERROR("No matching layout found for %s", ft2232_layout
);
2113 return ERROR_JTAG_INIT_FAILED
;
2119 * "more indicates that there are more IDs to try, so we should
2120 * not print an error for an ID mismatch (but for anything
2123 * try_more indicates that the error code returned indicates an
2124 * ID mismatch (and nothing else) and that we should proceeed
2125 * with the next ID pair.
2127 int more
= ft2232_vid
[i
+ 1] || ft2232_pid
[i
+ 1];
2130 #if BUILD_FT2232_FTD2XX == 1
2131 retval
= ft2232_init_ftd2xx(ft2232_vid
[i
], ft2232_pid
[i
],
2133 #elif BUILD_FT2232_LIBFTDI == 1
2134 retval
= ft2232_init_libftdi(ft2232_vid
[i
], ft2232_pid
[i
],
2139 if (!more
|| !try_more
)
2143 ft2232_buffer_size
= 0;
2144 ft2232_buffer
= malloc(FT2232_BUFFER_SIZE
);
2146 if (layout
->init() != ERROR_OK
)
2147 return ERROR_JTAG_INIT_FAILED
;
2149 if (ft2232_device_is_highspeed())
2151 #ifndef BUILD_FT2232_HIGHSPEED
2152 #if BUILD_FT2232_FTD2XX == 1
2153 LOG_WARNING("High Speed device found - You need a newer FTD2XX driver (version 2.04.16 or later)");
2154 #elif BUILD_FT2232_LIBFTDI == 1
2155 LOG_WARNING("High Speed device found - You need a newer libftdi version (0.16 or later)");
2158 /* make sure the legacy mode is disabled */
2159 if (ft2232h_ft4232h_clk_divide_by_5(false) != ERROR_OK
)
2160 return ERROR_JTAG_INIT_FAILED
;
2163 ft2232_speed(jtag_get_speed());
2165 buf
[0] = 0x85; /* Disconnect TDI/DO to TDO/DI for Loopback */
2166 if (((retval
= ft2232_write(buf
, 1, &bytes_written
)) != ERROR_OK
) || (bytes_written
!= 1))
2168 LOG_ERROR("couldn't write to FT2232 to disable loopback");
2169 return ERROR_JTAG_INIT_FAILED
;
2172 #if BUILD_FT2232_FTD2XX == 1
2173 return ft2232_purge_ftd2xx();
2174 #elif BUILD_FT2232_LIBFTDI == 1
2175 return ft2232_purge_libftdi();
2181 static int usbjtag_init(void)
2184 uint32_t bytes_written
;
2187 low_direction
= 0x0b;
2189 if (strcmp(ft2232_layout
, "usbjtag") == 0)
2196 else if (strcmp(ft2232_layout
, "signalyzer") == 0)
2203 else if (strcmp(ft2232_layout
, "evb_lm3s811") == 0)
2210 low_direction
= 0x8b;
2212 else if (strcmp(ft2232_layout
, "luminary_icdi") == 0)
2219 low_direction
= 0xcb;
2223 LOG_ERROR("BUG: usbjtag_init called for unknown layout '%s'", ft2232_layout
);
2224 return ERROR_JTAG_INIT_FAILED
;
2227 enum reset_types jtag_reset_config
= jtag_get_reset_config();
2228 if (jtag_reset_config
& RESET_TRST_OPEN_DRAIN
)
2230 low_direction
&= ~nTRSTnOE
; /* nTRST input */
2231 low_output
&= ~nTRST
; /* nTRST = 0 */
2235 low_direction
|= nTRSTnOE
; /* nTRST output */
2236 low_output
|= nTRST
; /* nTRST = 1 */
2239 if (jtag_reset_config
& RESET_SRST_PUSH_PULL
)
2241 low_direction
|= nSRSTnOE
; /* nSRST output */
2242 low_output
|= nSRST
; /* nSRST = 1 */
2246 low_direction
&= ~nSRSTnOE
; /* nSRST input */
2247 low_output
&= ~nSRST
; /* nSRST = 0 */
2250 /* initialize low byte for jtag */
2251 buf
[0] = 0x80; /* command "set data bits low byte" */
2252 buf
[1] = low_output
; /* value (TMS = 1,TCK = 0, TDI = 0, xRST high) */
2253 buf
[2] = low_direction
; /* dir (output = 1), TCK/TDI/TMS = out, TDO = in */
2254 LOG_DEBUG("%2.2x %2.2x %2.2x", buf
[0], buf
[1], buf
[2]);
2256 if (((ft2232_write(buf
, 3, &bytes_written
)) != ERROR_OK
) || (bytes_written
!= 3))
2258 LOG_ERROR("couldn't initialize FT2232 with 'USBJTAG' layout");
2259 return ERROR_JTAG_INIT_FAILED
;
2265 static int axm0432_jtag_init(void)
2268 uint32_t bytes_written
;
2271 low_direction
= 0x2b;
2273 /* initialize low byte for jtag */
2274 buf
[0] = 0x80; /* command "set data bits low byte" */
2275 buf
[1] = low_output
; /* value (TMS = 1,TCK = 0, TDI = 0, nOE = 0) */
2276 buf
[2] = low_direction
; /* dir (output = 1), TCK/TDI/TMS = out, TDO = in, nOE = out */
2277 LOG_DEBUG("%2.2x %2.2x %2.2x", buf
[0], buf
[1], buf
[2]);
2279 if (((ft2232_write(buf
, 3, &bytes_written
)) != ERROR_OK
) || (bytes_written
!= 3))
2281 LOG_ERROR("couldn't initialize FT2232 with 'JTAGkey' layout");
2282 return ERROR_JTAG_INIT_FAILED
;
2285 if (strcmp(layout
->name
, "axm0432_jtag") == 0)
2288 nTRSTnOE
= 0x0; /* No output enable for TRST*/
2290 nSRSTnOE
= 0x0; /* No output enable for SRST*/
2294 LOG_ERROR("BUG: axm0432_jtag_init called for non axm0432 layout");
2299 high_direction
= 0x0c;
2301 enum reset_types jtag_reset_config
= jtag_get_reset_config();
2302 if (jtag_reset_config
& RESET_TRST_OPEN_DRAIN
)
2304 LOG_ERROR("can't set nTRSTOE to push-pull on the Dicarlo jtag");
2308 high_output
|= nTRST
;
2311 if (jtag_reset_config
& RESET_SRST_PUSH_PULL
)
2313 LOG_ERROR("can't set nSRST to push-pull on the Dicarlo jtag");
2317 high_output
|= nSRST
;
2320 /* initialize high port */
2321 buf
[0] = 0x82; /* command "set data bits high byte" */
2322 buf
[1] = high_output
; /* value */
2323 buf
[2] = high_direction
; /* all outputs (xRST and xRSTnOE) */
2324 LOG_DEBUG("%2.2x %2.2x %2.2x", buf
[0], buf
[1], buf
[2]);
2326 if (((ft2232_write(buf
, 3, &bytes_written
)) != ERROR_OK
) || (bytes_written
!= 3))
2328 LOG_ERROR("couldn't initialize FT2232 with 'Dicarlo' layout");
2329 return ERROR_JTAG_INIT_FAILED
;
2335 static int jtagkey_init(void)
2338 uint32_t bytes_written
;
2341 low_direction
= 0x1b;
2343 /* initialize low byte for jtag */
2344 buf
[0] = 0x80; /* command "set data bits low byte" */
2345 buf
[1] = low_output
; /* value (TMS = 1,TCK = 0, TDI = 0, nOE = 0) */
2346 buf
[2] = low_direction
; /* dir (output = 1), TCK/TDI/TMS = out, TDO = in, nOE = out */
2347 LOG_DEBUG("%2.2x %2.2x %2.2x", buf
[0], buf
[1], buf
[2]);
2349 if (((ft2232_write(buf
, 3, &bytes_written
)) != ERROR_OK
) || (bytes_written
!= 3))
2351 LOG_ERROR("couldn't initialize FT2232 with 'JTAGkey' layout");
2352 return ERROR_JTAG_INIT_FAILED
;
2355 if (strcmp(layout
->name
, "jtagkey") == 0)
2362 else if ((strcmp(layout
->name
, "jtagkey_prototype_v1") == 0)
2363 || (strcmp(layout
->name
, "oocdlink") == 0))
2372 LOG_ERROR("BUG: jtagkey_init called for non jtagkey layout");
2377 high_direction
= 0x0f;
2379 enum reset_types jtag_reset_config
= jtag_get_reset_config();
2380 if (jtag_reset_config
& RESET_TRST_OPEN_DRAIN
)
2382 high_output
|= nTRSTnOE
;
2383 high_output
&= ~nTRST
;
2387 high_output
&= ~nTRSTnOE
;
2388 high_output
|= nTRST
;
2391 if (jtag_reset_config
& RESET_SRST_PUSH_PULL
)
2393 high_output
&= ~nSRSTnOE
;
2394 high_output
|= nSRST
;
2398 high_output
|= nSRSTnOE
;
2399 high_output
&= ~nSRST
;
2402 /* initialize high port */
2403 buf
[0] = 0x82; /* command "set data bits high byte" */
2404 buf
[1] = high_output
; /* value */
2405 buf
[2] = high_direction
; /* all outputs (xRST and xRSTnOE) */
2406 LOG_DEBUG("%2.2x %2.2x %2.2x", buf
[0], buf
[1], buf
[2]);
2408 if (((ft2232_write(buf
, 3, &bytes_written
)) != ERROR_OK
) || (bytes_written
!= 3))
2410 LOG_ERROR("couldn't initialize FT2232 with 'JTAGkey' layout");
2411 return ERROR_JTAG_INIT_FAILED
;
2417 static int olimex_jtag_init(void)
2420 uint32_t bytes_written
;
2423 low_direction
= 0x1b;
2425 /* initialize low byte for jtag */
2426 buf
[0] = 0x80; /* command "set data bits low byte" */
2427 buf
[1] = low_output
; /* value (TMS = 1,TCK = 0, TDI = 0, nOE = 0) */
2428 buf
[2] = low_direction
; /* dir (output = 1), TCK/TDI/TMS = out, TDO = in, nOE = out */
2429 LOG_DEBUG("%2.2x %2.2x %2.2x", buf
[0], buf
[1], buf
[2]);
2431 if (((ft2232_write(buf
, 3, &bytes_written
)) != ERROR_OK
) || (bytes_written
!= 3))
2433 LOG_ERROR("couldn't initialize FT2232 with 'Olimex' layout");
2434 return ERROR_JTAG_INIT_FAILED
;
2440 nSRSTnOE
= 0x00; /* no output enable for nSRST */
2443 high_direction
= 0x0f;
2445 enum reset_types jtag_reset_config
= jtag_get_reset_config();
2446 if (jtag_reset_config
& RESET_TRST_OPEN_DRAIN
)
2448 high_output
|= nTRSTnOE
;
2449 high_output
&= ~nTRST
;
2453 high_output
&= ~nTRSTnOE
;
2454 high_output
|= nTRST
;
2457 if (jtag_reset_config
& RESET_SRST_PUSH_PULL
)
2459 LOG_ERROR("can't set nSRST to push-pull on the Olimex ARM-USB-OCD");
2463 high_output
&= ~nSRST
;
2466 /* turn red LED on */
2467 high_output
|= 0x08;
2469 /* initialize high port */
2470 buf
[0] = 0x82; /* command "set data bits high byte" */
2471 buf
[1] = high_output
; /* value */
2472 buf
[2] = high_direction
; /* all outputs (xRST and xRSTnOE) */
2473 LOG_DEBUG("%2.2x %2.2x %2.2x", buf
[0], buf
[1], buf
[2]);
2475 if ((ft2232_write(buf
, 3, &bytes_written
) != ERROR_OK
) || (bytes_written
!= 3))
2477 LOG_ERROR("couldn't initialize FT2232 with 'Olimex' layout");
2478 return ERROR_JTAG_INIT_FAILED
;
2484 static int flyswatter_init(void)
2487 uint32_t bytes_written
;
2490 low_direction
= 0xfb;
2492 /* initialize low byte for jtag */
2493 buf
[0] = 0x80; /* command "set data bits low byte" */
2494 buf
[1] = low_output
; /* value (TMS = 1,TCK = 0, TDI = 0, nOE = 0) */
2495 buf
[2] = low_direction
; /* dir (output = 1), TCK/TDI/TMS = out, TDO = in, nOE[12]=out, n[ST]srst = out */
2496 LOG_DEBUG("%2.2x %2.2x %2.2x", buf
[0], buf
[1], buf
[2]);
2498 if (((ft2232_write(buf
, 3, &bytes_written
)) != ERROR_OK
) || (bytes_written
!= 3))
2500 LOG_ERROR("couldn't initialize FT2232 with 'flyswatter' layout");
2501 return ERROR_JTAG_INIT_FAILED
;
2505 nTRSTnOE
= 0x0; /* not output enable for nTRST */
2507 nSRSTnOE
= 0x00; /* no output enable for nSRST */
2510 high_direction
= 0x0c;
2512 /* turn red LED3 on, LED2 off */
2513 high_output
|= 0x08;
2515 /* initialize high port */
2516 buf
[0] = 0x82; /* command "set data bits high byte" */
2517 buf
[1] = high_output
; /* value */
2518 buf
[2] = high_direction
; /* all outputs (xRST and xRSTnOE) */
2519 LOG_DEBUG("%2.2x %2.2x %2.2x", buf
[0], buf
[1], buf
[2]);
2521 if (((ft2232_write(buf
, 3, &bytes_written
)) != ERROR_OK
) || (bytes_written
!= 3))
2523 LOG_ERROR("couldn't initialize FT2232 with 'flyswatter' layout");
2524 return ERROR_JTAG_INIT_FAILED
;
2530 static int turtle_init(void)
2533 uint32_t bytes_written
;
2536 low_direction
= 0x5b;
2538 /* initialize low byte for jtag */
2539 buf
[0] = 0x80; /* command "set data bits low byte" */
2540 buf
[1] = low_output
; /* value (TMS = 1,TCK = 0, TDI = 0, nOE = 0) */
2541 buf
[2] = low_direction
; /* dir (output = 1), TCK/TDI/TMS = out, TDO = in, nOE = out */
2542 LOG_DEBUG("%2.2x %2.2x %2.2x", buf
[0], buf
[1], buf
[2]);
2544 if (((ft2232_write(buf
, 3, &bytes_written
)) != ERROR_OK
) || (bytes_written
!= 3))
2546 LOG_ERROR("couldn't initialize FT2232 with 'turtelizer2' layout");
2547 return ERROR_JTAG_INIT_FAILED
;
2553 high_direction
= 0x0C;
2555 /* initialize high port */
2556 buf
[0] = 0x82; /* command "set data bits high byte" */
2557 buf
[1] = high_output
;
2558 buf
[2] = high_direction
;
2559 LOG_DEBUG("%2.2x %2.2x %2.2x", buf
[0], buf
[1], buf
[2]);
2561 if (((ft2232_write(buf
, 3, &bytes_written
)) != ERROR_OK
) || (bytes_written
!= 3))
2563 LOG_ERROR("couldn't initialize FT2232 with 'turtelizer2' layout");
2564 return ERROR_JTAG_INIT_FAILED
;
2570 static int comstick_init(void)
2573 uint32_t bytes_written
;
2576 low_direction
= 0x0b;
2578 /* initialize low byte for jtag */
2579 buf
[0] = 0x80; /* command "set data bits low byte" */
2580 buf
[1] = low_output
; /* value (TMS = 1,TCK = 0, TDI = 0, nOE = 0) */
2581 buf
[2] = low_direction
; /* dir (output = 1), TCK/TDI/TMS = out, TDO = in, nOE = out */
2582 LOG_DEBUG("%2.2x %2.2x %2.2x", buf
[0], buf
[1], buf
[2]);
2584 if (((ft2232_write(buf
, 3, &bytes_written
)) != ERROR_OK
) || (bytes_written
!= 3))
2586 LOG_ERROR("couldn't initialize FT2232 with 'comstick' layout");
2587 return ERROR_JTAG_INIT_FAILED
;
2591 nTRSTnOE
= 0x00; /* no output enable for nTRST */
2593 nSRSTnOE
= 0x00; /* no output enable for nSRST */
2596 high_direction
= 0x03;
2598 /* initialize high port */
2599 buf
[0] = 0x82; /* command "set data bits high byte" */
2600 buf
[1] = high_output
;
2601 buf
[2] = high_direction
;
2602 LOG_DEBUG("%2.2x %2.2x %2.2x", buf
[0], buf
[1], buf
[2]);
2604 if (((ft2232_write(buf
, 3, &bytes_written
)) != ERROR_OK
) || (bytes_written
!= 3))
2606 LOG_ERROR("couldn't initialize FT2232 with 'comstick' layout");
2607 return ERROR_JTAG_INIT_FAILED
;
2613 static int stm32stick_init(void)
2616 uint32_t bytes_written
;
2619 low_direction
= 0x8b;
2621 /* initialize low byte for jtag */
2622 buf
[0] = 0x80; /* command "set data bits low byte" */
2623 buf
[1] = low_output
; /* value (TMS = 1,TCK = 0, TDI = 0, nOE = 0) */
2624 buf
[2] = low_direction
; /* dir (output = 1), TCK/TDI/TMS = out, TDO = in, nOE = out */
2625 LOG_DEBUG("%2.2x %2.2x %2.2x", buf
[0], buf
[1], buf
[2]);
2627 if (((ft2232_write(buf
, 3, &bytes_written
)) != ERROR_OK
) || (bytes_written
!= 3))
2629 LOG_ERROR("couldn't initialize FT2232 with 'stm32stick' layout");
2630 return ERROR_JTAG_INIT_FAILED
;
2634 nTRSTnOE
= 0x00; /* no output enable for nTRST */
2636 nSRSTnOE
= 0x00; /* no output enable for nSRST */
2639 high_direction
= 0x03;
2641 /* initialize high port */
2642 buf
[0] = 0x82; /* command "set data bits high byte" */
2643 buf
[1] = high_output
;
2644 buf
[2] = high_direction
;
2645 LOG_DEBUG("%2.2x %2.2x %2.2x", buf
[0], buf
[1], buf
[2]);
2647 if (((ft2232_write(buf
, 3, &bytes_written
)) != ERROR_OK
) || (bytes_written
!= 3))
2649 LOG_ERROR("couldn't initialize FT2232 with 'stm32stick' layout");
2650 return ERROR_JTAG_INIT_FAILED
;
2656 static int sheevaplug_init(void)
2659 uint32_t bytes_written
;
2662 low_direction
= 0x1b;
2664 /* initialize low byte for jtag */
2665 buf
[0] = 0x80; /* command "set data bits low byte" */
2666 buf
[1] = low_output
; /* value (TMS = 1,TCK = 0, TDI = 0, nOE = 0) */
2667 buf
[2] = low_direction
; /* dir (output = 1), TCK/TDI/TMS = out, TDO = in */
2668 LOG_DEBUG("%2.2x %2.2x %2.2x", buf
[0], buf
[1], buf
[2]);
2670 if (((ft2232_write(buf
, 3, &bytes_written
)) != ERROR_OK
) || (bytes_written
!= 3))
2672 LOG_ERROR("couldn't initialize FT2232 with 'sheevaplug' layout");
2673 return ERROR_JTAG_INIT_FAILED
;
2682 high_direction
= 0x0f;
2684 /* nTRST is always push-pull */
2685 high_output
&= ~nTRSTnOE
;
2686 high_output
|= nTRST
;
2688 /* nSRST is always open-drain */
2689 high_output
|= nSRSTnOE
;
2690 high_output
&= ~nSRST
;
2692 /* initialize high port */
2693 buf
[0] = 0x82; /* command "set data bits high byte" */
2694 buf
[1] = high_output
; /* value */
2695 buf
[2] = high_direction
; /* all outputs - xRST */
2696 LOG_DEBUG("%2.2x %2.2x %2.2x", buf
[0], buf
[1], buf
[2]);
2698 if (((ft2232_write(buf
, 3, &bytes_written
)) != ERROR_OK
) || (bytes_written
!= 3))
2700 LOG_ERROR("couldn't initialize FT2232 with 'sheevaplug' layout");
2701 return ERROR_JTAG_INIT_FAILED
;
2707 static int cortino_jtag_init(void)
2710 uint32_t bytes_written
;
2713 low_direction
= 0x1b;
2715 /* initialize low byte for jtag */
2716 buf
[0] = 0x80; /* command "set data bits low byte" */
2717 buf
[1] = low_output
; /* value (TMS = 1,TCK = 0, TDI = 0, nOE = 0) */
2718 buf
[2] = low_direction
; /* dir (output = 1), TCK/TDI/TMS = out, TDO = in, nOE = out */
2719 LOG_DEBUG("%2.2x %2.2x %2.2x", buf
[0], buf
[1], buf
[2]);
2721 if (((ft2232_write(buf
, 3, &bytes_written
)) != ERROR_OK
) || (bytes_written
!= 3))
2723 LOG_ERROR("couldn't initialize FT2232 with 'cortino' layout");
2724 return ERROR_JTAG_INIT_FAILED
;
2728 nTRSTnOE
= 0x00; /* no output enable for nTRST */
2730 nSRSTnOE
= 0x00; /* no output enable for nSRST */
2733 high_direction
= 0x03;
2735 /* initialize high port */
2736 buf
[0] = 0x82; /* command "set data bits high byte" */
2737 buf
[1] = high_output
;
2738 buf
[2] = high_direction
;
2739 LOG_DEBUG("%2.2x %2.2x %2.2x", buf
[0], buf
[1], buf
[2]);
2741 if (((ft2232_write(buf
, 3, &bytes_written
)) != ERROR_OK
) || (bytes_written
!= 3))
2743 LOG_ERROR("couldn't initialize FT2232 with 'stm32stick' layout");
2744 return ERROR_JTAG_INIT_FAILED
;
2750 static void olimex_jtag_blink(void)
2752 /* Olimex ARM-USB-OCD has a LED connected to ACBUS3
2753 * ACBUS3 is bit 3 of the GPIOH port
2755 if (high_output
& 0x08)
2757 /* set port pin high */
2758 high_output
&= 0x07;
2762 /* set port pin low */
2763 high_output
|= 0x08;
2767 buffer_write(high_output
);
2768 buffer_write(high_direction
);
2771 static void flyswatter_jtag_blink(void)
2774 * Flyswatter has two LEDs connected to ACBUS2 and ACBUS3
2776 high_output
^= 0x0c;
2779 buffer_write(high_output
);
2780 buffer_write(high_direction
);
2783 static void turtle_jtag_blink(void)
2786 * Turtelizer2 has two LEDs connected to ACBUS2 and ACBUS3
2788 if (high_output
& 0x08)
2798 buffer_write(high_output
);
2799 buffer_write(high_direction
);
2802 static int ft2232_quit(void)
2804 #if BUILD_FT2232_FTD2XX == 1
2807 status
= FT_Close(ftdih
);
2808 #elif BUILD_FT2232_LIBFTDI == 1
2809 ftdi_usb_close(&ftdic
);
2811 ftdi_deinit(&ftdic
);
2814 free(ft2232_buffer
);
2815 ft2232_buffer
= NULL
;
2820 static int ft2232_handle_device_desc_command(struct command_context_s
* cmd_ctx
, char* cmd
, char** args
, int argc
)
2826 ft2232_device_desc
= strdup(args
[0]);
2827 cp
= strchr(ft2232_device_desc
, 0);
2828 /* under Win32, the FTD2XX driver appends an "A" to the end
2829 * of the description, this examines the given desc
2830 * and creates the 'missing' _A or non_A variable. */
2831 if ((cp
[-1] == 'A') && (cp
[-2]==' ')) {
2832 /* it was, so make this the "A" version. */
2833 ft2232_device_desc_A
= ft2232_device_desc
;
2834 /* and *CREATE* the non-A version. */
2835 strcpy(buf
, ft2232_device_desc
);
2836 cp
= strchr(buf
, 0);
2838 ft2232_device_desc
= strdup(buf
);
2840 /* <space > A not defined
2842 sprintf(buf
, "%s A", ft2232_device_desc
);
2843 ft2232_device_desc_A
= strdup(buf
);
2848 LOG_ERROR("expected exactly one argument to ft2232_device_desc <description>");
2854 static int ft2232_handle_serial_command(struct command_context_s
* cmd_ctx
, char* cmd
, char** args
, int argc
)
2858 ft2232_serial
= strdup(args
[0]);
2862 LOG_ERROR("expected exactly one argument to ft2232_serial <serial-number>");
2868 static int ft2232_handle_layout_command(struct command_context_s
* cmd_ctx
, char* cmd
, char** args
, int argc
)
2873 ft2232_layout
= malloc(strlen(args
[0]) + 1);
2874 strcpy(ft2232_layout
, args
[0]);
2879 static int ft2232_handle_vid_pid_command(struct command_context_s
* cmd_ctx
, char* cmd
, char** args
, int argc
)
2881 if (argc
> MAX_USB_IDS
* 2)
2883 LOG_WARNING("ignoring extra IDs in ft2232_vid_pid "
2884 "(maximum is %d pairs)", MAX_USB_IDS
);
2885 argc
= MAX_USB_IDS
* 2;
2887 if (argc
< 2 || (argc
& 1))
2889 LOG_WARNING("incomplete ft2232_vid_pid configuration directive");
2891 return ERROR_COMMAND_SYNTAX_ERROR
;
2892 /* remove the incomplete trailing id */
2897 int retval
= ERROR_OK
;
2898 for (i
= 0; i
< argc
; i
+= 2)
2900 retval
= parse_u16(args
[i
], &ft2232_vid
[i
>> 1]);
2901 if (ERROR_OK
!= retval
)
2903 retval
= parse_u16(args
[i
+ 1], &ft2232_pid
[i
>> 1]);
2904 if (ERROR_OK
!= retval
)
2909 * Explicitly terminate, in case there are multiples instances of
2912 ft2232_vid
[i
>> 1] = ft2232_pid
[i
>> 1] = 0;
2917 static int ft2232_handle_latency_command(struct command_context_s
* cmd_ctx
, char* cmd
, char** args
, int argc
)
2921 ft2232_latency
= atoi(args
[0]);
2925 LOG_ERROR("expected exactly one argument to ft2232_latency <ms>");
2931 static int ft2232_stableclocks(int num_cycles
, jtag_command_t
* cmd
)
2935 /* 7 bits of either ones or zeros. */
2936 uint8_t tms
= (tap_get_state() == TAP_RESET
? 0x7F : 0x00);
2938 while (num_cycles
> 0)
2940 /* the command 0x4b, "Clock Data to TMS/CS Pin (no Read)" handles
2941 * at most 7 bits per invocation. Here we invoke it potentially
2944 int bitcount_per_command
= (num_cycles
> 7) ? 7 : num_cycles
;
2946 if (ft2232_buffer_size
+ 3 >= FT2232_BUFFER_SIZE
)
2948 if (ft2232_send_and_recv(first_unsent
, cmd
) != ERROR_OK
)
2949 retval
= ERROR_JTAG_QUEUE_FAILED
;
2954 /* there are no state transitions in this code, so omit state tracking */
2956 /* command "Clock Data to TMS/CS Pin (no Read)" */
2960 buffer_write(bitcount_per_command
- 1);
2962 /* TMS data bits are either all zeros or ones to stay in the current stable state */
2967 num_cycles
-= bitcount_per_command
;
2973 /* ---------------------------------------------------------------------
2974 * Support for IceBear JTAG adapter from Section5:
2975 * http://section5.ch/icebear
2977 * Author: Sten, debian@sansys-electronic.com
2980 /* Icebear pin layout
2982 * ADBUS5 (nEMU) nSRST | 2 1| GND (10k->VCC)
2983 * GND GND | 4 3| n.c.
2984 * ADBUS3 TMS | 6 5| ADBUS6 VCC
2985 * ADBUS0 TCK | 8 7| ADBUS7 (GND)
2986 * ADBUS4 nTRST |10 9| ACBUS0 (GND)
2987 * ADBUS1 TDI |12 11| ACBUS1 (GND)
2988 * ADBUS2 TDO |14 13| GND GND
2990 * ADBUS0 O L TCK ACBUS0 GND
2991 * ADBUS1 O L TDI ACBUS1 GND
2992 * ADBUS2 I TDO ACBUS2 n.c.
2993 * ADBUS3 O H TMS ACBUS3 n.c.
2999 static int icebear_jtag_init(void) {
3001 uint32_t bytes_written
;
3003 low_direction
= 0x0b; /* output: TCK TDI TMS; input: TDO */
3004 low_output
= 0x08; /* high: TMS; low: TCK TDI */
3008 enum reset_types jtag_reset_config
= jtag_get_reset_config();
3009 if ((jtag_reset_config
& RESET_TRST_OPEN_DRAIN
) != 0) {
3010 low_direction
&= ~nTRST
; /* nTRST high impedance */
3013 low_direction
|= nTRST
;
3014 low_output
|= nTRST
;
3017 low_direction
|= nSRST
;
3018 low_output
|= nSRST
;
3020 /* initialize low byte for jtag */
3021 buf
[0] = 0x80; /* command "set data bits low byte" */
3022 buf
[1] = low_output
;
3023 buf
[2] = low_direction
;
3024 LOG_DEBUG("%2.2x %2.2x %2.2x", buf
[0], buf
[1], buf
[2]);
3026 if (((ft2232_write(buf
, 3, &bytes_written
)) != ERROR_OK
) || (bytes_written
!= 3)) {
3027 LOG_ERROR("couldn't initialize FT2232 with 'IceBear' layout (low)");
3028 return ERROR_JTAG_INIT_FAILED
;
3032 high_direction
= 0x00;
3035 /* initialize high port */
3036 buf
[0] = 0x82; /* command "set data bits high byte" */
3037 buf
[1] = high_output
; /* value */
3038 buf
[2] = high_direction
; /* all outputs (xRST and xRSTnOE) */
3039 LOG_DEBUG("%2.2x %2.2x %2.2x", buf
[0], buf
[1], buf
[2]);
3041 if (((ft2232_write(buf
, 3, &bytes_written
)) != ERROR_OK
) || (bytes_written
!= 3)) {
3042 LOG_ERROR("couldn't initialize FT2232 with 'IceBear' layout (high)");
3043 return ERROR_JTAG_INIT_FAILED
;
3049 static void icebear_jtag_reset(int trst
, int srst
) {
3052 low_direction
|= nTRST
;
3053 low_output
&= ~nTRST
;
3055 else if (trst
== 0) {
3056 enum reset_types jtag_reset_config
= jtag_get_reset_config();
3057 if ((jtag_reset_config
& RESET_TRST_OPEN_DRAIN
) != 0)
3058 low_direction
&= ~nTRST
;
3060 low_output
|= nTRST
;
3064 low_output
&= ~nSRST
;
3066 else if (srst
== 0) {
3067 low_output
|= nSRST
;
3070 /* command "set data bits low byte" */
3072 buffer_write(low_output
);
3073 buffer_write(low_direction
);
3075 LOG_DEBUG("trst: %i, srst: %i, low_output: 0x%2.2x, low_direction: 0x%2.2x", trst
, srst
, low_output
, low_direction
);
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)