jtag: linuxgpiod: drop extra parenthesis
[openocd.git] / src / jtag / drivers / ftdi.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2
3 /**************************************************************************
4 * Copyright (C) 2012 by Andreas Fritiofson *
5 * andreas.fritiofson@gmail.com *
6 ***************************************************************************/
7
8 /**
9 * @file
10 * JTAG adapters based on the FT2232 full and high speed USB parts are
11 * popular low cost JTAG debug solutions. Many FT2232 based JTAG adapters
12 * are discrete, but development boards may integrate them as alternatives
13 * to more capable (and expensive) third party JTAG pods.
14 *
15 * JTAG uses only one of the two communications channels ("MPSSE engines")
16 * on these devices. Adapters based on FT4232 parts have four ports/channels
17 * (A/B/C/D), instead of just two (A/B).
18 *
19 * Especially on development boards integrating one of these chips (as
20 * opposed to discrete pods/dongles), the additional channels can be used
21 * for a variety of purposes, but OpenOCD only uses one channel at a time.
22 *
23 * - As a USB-to-serial adapter for the target's console UART ...
24 * which may be able to support ROM boot loaders that load initial
25 * firmware images to flash (or SRAM).
26 *
27 * - On systems which support ARM's SWD in addition to JTAG, or instead
28 * of it, that second port can be used for reading SWV/SWO trace data.
29 *
30 * - Additional JTAG links, e.g. to a CPLD or * FPGA.
31 *
32 * FT2232 based JTAG adapters are "dumb" not "smart", because most JTAG
33 * request/response interactions involve round trips over the USB link.
34 * A "smart" JTAG adapter has intelligence close to the scan chain, so it
35 * can for example poll quickly for a status change (usually taking on the
36 * order of microseconds not milliseconds) before beginning a queued
37 * transaction which require the previous one to have completed.
38 *
39 * There are dozens of adapters of this type, differing in details which
40 * this driver needs to understand. Those "layout" details are required
41 * as part of FT2232 driver configuration.
42 *
43 * This code uses information contained in the MPSSE specification which was
44 * found here:
45 * https://www.ftdichip.com/Support/Documents/AppNotes/AN2232C-01_MPSSE_Cmnd.pdf
46 * Hereafter this is called the "MPSSE Spec".
47 *
48 * The datasheet for the ftdichip.com's FT2232H part is here:
49 * https://www.ftdichip.com/Support/Documents/DataSheets/ICs/DS_FT2232H.pdf
50 *
51 * Also note the issue with code 0x4b (clock data to TMS) noted in
52 * http://developer.intra2net.com/mailarchive/html/libftdi/2009/msg00292.html
53 * which can affect longer JTAG state paths.
54 */
55
56 #ifdef HAVE_CONFIG_H
57 #include "config.h"
58 #endif
59
60 /* project specific includes */
61 #include <jtag/adapter.h>
62 #include <jtag/interface.h>
63 #include <jtag/swd.h>
64 #include <transport/transport.h>
65 #include <helper/time_support.h>
66 #include <helper/log.h>
67 #include <helper/nvp.h>
68
69 #if IS_CYGWIN == 1
70 #include <windows.h>
71 #endif
72
73 #include <assert.h>
74
75 /* FTDI access library includes */
76 #include "mpsse.h"
77
78 #define JTAG_MODE (LSB_FIRST | POS_EDGE_IN | NEG_EDGE_OUT)
79 #define JTAG_MODE_ALT (LSB_FIRST | NEG_EDGE_IN | NEG_EDGE_OUT)
80 #define SWD_MODE (LSB_FIRST | POS_EDGE_IN | NEG_EDGE_OUT)
81
82 static char *ftdi_device_desc;
83 static uint8_t ftdi_channel;
84 static uint8_t ftdi_jtag_mode = JTAG_MODE;
85
86 static bool swd_mode;
87
88 #define MAX_USB_IDS 8
89 /* vid = pid = 0 marks the end of the list */
90 static uint16_t ftdi_vid[MAX_USB_IDS + 1] = { 0 };
91 static uint16_t ftdi_pid[MAX_USB_IDS + 1] = { 0 };
92
93 static struct mpsse_ctx *mpsse_ctx;
94
95 struct signal {
96 const char *name;
97 uint16_t data_mask;
98 uint16_t input_mask;
99 uint16_t oe_mask;
100 bool invert_data;
101 bool invert_input;
102 bool invert_oe;
103 struct signal *next;
104 };
105
106 static struct signal *signals;
107
108 /* FIXME: Where to store per-instance data? We need an SWD context. */
109 static struct swd_cmd_queue_entry {
110 uint8_t cmd;
111 uint32_t *dst;
112 uint8_t trn_ack_data_parity_trn[DIV_ROUND_UP(4 + 3 + 32 + 1 + 4, 8)];
113 } *swd_cmd_queue;
114 static size_t swd_cmd_queue_length;
115 static size_t swd_cmd_queue_alloced;
116 static int queued_retval;
117 static int freq;
118
119 static uint16_t output;
120 static uint16_t direction;
121 static uint16_t jtag_output_init;
122 static uint16_t jtag_direction_init;
123
124 static int ftdi_swd_switch_seq(enum swd_special_seq seq);
125
126 static struct signal *find_signal_by_name(const char *name)
127 {
128 for (struct signal *sig = signals; sig; sig = sig->next) {
129 if (strcmp(name, sig->name) == 0)
130 return sig;
131 }
132 return NULL;
133 }
134
135 static struct signal *create_signal(const char *name)
136 {
137 struct signal **psig = &signals;
138 while (*psig)
139 psig = &(*psig)->next;
140
141 *psig = calloc(1, sizeof(**psig));
142 if (!*psig)
143 return NULL;
144
145 (*psig)->name = strdup(name);
146 if (!(*psig)->name) {
147 free(*psig);
148 *psig = NULL;
149 }
150 return *psig;
151 }
152
153 static int ftdi_set_signal(const struct signal *s, char value)
154 {
155 bool data;
156 bool oe;
157
158 if (s->data_mask == 0 && s->oe_mask == 0) {
159 LOG_ERROR("interface doesn't provide signal '%s'", s->name);
160 return ERROR_FAIL;
161 }
162 switch (value) {
163 case '0':
164 data = s->invert_data;
165 oe = !s->invert_oe;
166 break;
167 case '1':
168 if (s->data_mask == 0) {
169 LOG_ERROR("interface can't drive '%s' high", s->name);
170 return ERROR_FAIL;
171 }
172 data = !s->invert_data;
173 oe = !s->invert_oe;
174 break;
175 case 'z':
176 case 'Z':
177 if (s->oe_mask == 0) {
178 LOG_ERROR("interface can't tri-state '%s'", s->name);
179 return ERROR_FAIL;
180 }
181 data = s->invert_data;
182 oe = s->invert_oe;
183 break;
184 default:
185 LOG_ERROR("invalid signal level specifier \'%c\'(0x%02x)", value, value);
186 return ERROR_FAIL;
187 }
188
189 uint16_t old_output = output;
190 uint16_t old_direction = direction;
191
192 output = data ? output | s->data_mask : output & ~s->data_mask;
193 if (s->oe_mask == s->data_mask)
194 direction = oe ? direction | s->oe_mask : direction & ~s->oe_mask;
195 else
196 output = oe ? output | s->oe_mask : output & ~s->oe_mask;
197
198 if ((output & 0xff) != (old_output & 0xff) || (direction & 0xff) != (old_direction & 0xff))
199 mpsse_set_data_bits_low_byte(mpsse_ctx, output & 0xff, direction & 0xff);
200 if ((output >> 8 != old_output >> 8) || (direction >> 8 != old_direction >> 8))
201 mpsse_set_data_bits_high_byte(mpsse_ctx, output >> 8, direction >> 8);
202
203 return ERROR_OK;
204 }
205
206 static int ftdi_get_signal(const struct signal *s, uint16_t *value_out)
207 {
208 uint8_t data_low = 0;
209 uint8_t data_high = 0;
210
211 if (s->input_mask == 0) {
212 LOG_ERROR("interface doesn't provide signal '%s'", s->name);
213 return ERROR_FAIL;
214 }
215
216 if (s->input_mask & 0xff)
217 mpsse_read_data_bits_low_byte(mpsse_ctx, &data_low);
218 if (s->input_mask >> 8)
219 mpsse_read_data_bits_high_byte(mpsse_ctx, &data_high);
220
221 mpsse_flush(mpsse_ctx);
222
223 *value_out = (((uint16_t)data_high) << 8) | data_low;
224
225 if (s->invert_input)
226 *value_out = ~(*value_out);
227
228 *value_out &= s->input_mask;
229
230 return ERROR_OK;
231 }
232
233 /**
234 * Function move_to_state
235 * moves the TAP controller from the current state to a
236 * \a goal_state through a path given by tap_get_tms_path(). State transition
237 * logging is performed by delegation to clock_tms().
238 *
239 * @param goal_state is the destination state for the move.
240 */
241 static void move_to_state(tap_state_t goal_state)
242 {
243 tap_state_t start_state = tap_get_state();
244
245 /* goal_state is 1/2 of a tuple/pair of states which allow convenient
246 lookup of the required TMS pattern to move to this state from the
247 start state.
248 */
249
250 /* do the 2 lookups */
251 uint8_t tms_bits = tap_get_tms_path(start_state, goal_state);
252 int tms_count = tap_get_tms_path_len(start_state, goal_state);
253 assert(tms_count <= 8);
254
255 LOG_DEBUG_IO("start=%s goal=%s", tap_state_name(start_state), tap_state_name(goal_state));
256
257 /* Track state transitions step by step */
258 for (int i = 0; i < tms_count; i++)
259 tap_set_state(tap_state_transition(tap_get_state(), (tms_bits >> i) & 1));
260
261 mpsse_clock_tms_cs_out(mpsse_ctx,
262 &tms_bits,
263 0,
264 tms_count,
265 false,
266 ftdi_jtag_mode);
267 }
268
269 static int ftdi_speed(int speed)
270 {
271 int retval;
272 retval = mpsse_set_frequency(mpsse_ctx, speed);
273
274 if (retval < 0) {
275 LOG_ERROR("couldn't set FTDI TCK speed");
276 return retval;
277 }
278
279 if (!swd_mode && speed >= 10000000 && ftdi_jtag_mode != JTAG_MODE_ALT)
280 LOG_INFO("ftdi: if you experience problems at higher adapter clocks, try "
281 "the command \"ftdi tdo_sample_edge falling\"");
282 return ERROR_OK;
283 }
284
285 static int ftdi_speed_div(int speed, int *khz)
286 {
287 *khz = speed / 1000;
288 return ERROR_OK;
289 }
290
291 static int ftdi_khz(int khz, int *jtag_speed)
292 {
293 if (khz == 0 && !mpsse_is_high_speed(mpsse_ctx)) {
294 LOG_DEBUG("RCLK not supported");
295 return ERROR_FAIL;
296 }
297
298 *jtag_speed = khz * 1000;
299 return ERROR_OK;
300 }
301
302 static void ftdi_end_state(tap_state_t state)
303 {
304 if (tap_is_state_stable(state))
305 tap_set_end_state(state);
306 else {
307 LOG_ERROR("BUG: %s is not a stable end state", tap_state_name(state));
308 exit(-1);
309 }
310 }
311
312 static void ftdi_execute_runtest(struct jtag_command *cmd)
313 {
314 int i;
315 uint8_t zero = 0;
316
317 LOG_DEBUG_IO("runtest %i cycles, end in %s",
318 cmd->cmd.runtest->num_cycles,
319 tap_state_name(cmd->cmd.runtest->end_state));
320
321 if (tap_get_state() != TAP_IDLE)
322 move_to_state(TAP_IDLE);
323
324 /* TODO: Reuse ftdi_execute_stableclocks */
325 i = cmd->cmd.runtest->num_cycles;
326 while (i > 0) {
327 /* there are no state transitions in this code, so omit state tracking */
328 unsigned this_len = i > 7 ? 7 : i;
329 mpsse_clock_tms_cs_out(mpsse_ctx, &zero, 0, this_len, false, ftdi_jtag_mode);
330 i -= this_len;
331 }
332
333 ftdi_end_state(cmd->cmd.runtest->end_state);
334
335 if (tap_get_state() != tap_get_end_state())
336 move_to_state(tap_get_end_state());
337
338 LOG_DEBUG_IO("runtest: %i, end in %s",
339 cmd->cmd.runtest->num_cycles,
340 tap_state_name(tap_get_end_state()));
341 }
342
343 static void ftdi_execute_statemove(struct jtag_command *cmd)
344 {
345 LOG_DEBUG_IO("statemove end in %s",
346 tap_state_name(cmd->cmd.statemove->end_state));
347
348 ftdi_end_state(cmd->cmd.statemove->end_state);
349
350 /* shortest-path move to desired end state */
351 if (tap_get_state() != tap_get_end_state() || tap_get_end_state() == TAP_RESET)
352 move_to_state(tap_get_end_state());
353 }
354
355 /**
356 * Clock a bunch of TMS (or SWDIO) transitions, to change the JTAG
357 * (or SWD) state machine. REVISIT: Not the best method, perhaps.
358 */
359 static void ftdi_execute_tms(struct jtag_command *cmd)
360 {
361 LOG_DEBUG_IO("TMS: %d bits", cmd->cmd.tms->num_bits);
362
363 /* TODO: Missing tap state tracking, also missing from ft2232.c! */
364 mpsse_clock_tms_cs_out(mpsse_ctx,
365 cmd->cmd.tms->bits,
366 0,
367 cmd->cmd.tms->num_bits,
368 false,
369 ftdi_jtag_mode);
370 }
371
372 static void ftdi_execute_pathmove(struct jtag_command *cmd)
373 {
374 tap_state_t *path = cmd->cmd.pathmove->path;
375 int num_states = cmd->cmd.pathmove->num_states;
376
377 LOG_DEBUG_IO("pathmove: %i states, current: %s end: %s", num_states,
378 tap_state_name(tap_get_state()),
379 tap_state_name(path[num_states-1]));
380
381 int state_count = 0;
382 unsigned bit_count = 0;
383 uint8_t tms_byte = 0;
384
385 LOG_DEBUG_IO("-");
386
387 /* this loop verifies that the path is legal and logs each state in the path */
388 while (num_states--) {
389
390 /* either TMS=0 or TMS=1 must work ... */
391 if (tap_state_transition(tap_get_state(), false)
392 == path[state_count])
393 buf_set_u32(&tms_byte, bit_count++, 1, 0x0);
394 else if (tap_state_transition(tap_get_state(), true)
395 == path[state_count]) {
396 buf_set_u32(&tms_byte, bit_count++, 1, 0x1);
397
398 /* ... or else the caller goofed BADLY */
399 } else {
400 LOG_ERROR("BUG: %s -> %s isn't a valid "
401 "TAP state transition",
402 tap_state_name(tap_get_state()),
403 tap_state_name(path[state_count]));
404 exit(-1);
405 }
406
407 tap_set_state(path[state_count]);
408 state_count++;
409
410 if (bit_count == 7 || num_states == 0) {
411 mpsse_clock_tms_cs_out(mpsse_ctx,
412 &tms_byte,
413 0,
414 bit_count,
415 false,
416 ftdi_jtag_mode);
417 bit_count = 0;
418 }
419 }
420 tap_set_end_state(tap_get_state());
421 }
422
423 static void ftdi_execute_scan(struct jtag_command *cmd)
424 {
425 LOG_DEBUG_IO("%s type:%d", cmd->cmd.scan->ir_scan ? "IRSCAN" : "DRSCAN",
426 jtag_scan_type(cmd->cmd.scan));
427
428 /* Make sure there are no trailing fields with num_bits == 0, or the logic below will fail. */
429 while (cmd->cmd.scan->num_fields > 0
430 && cmd->cmd.scan->fields[cmd->cmd.scan->num_fields - 1].num_bits == 0) {
431 cmd->cmd.scan->num_fields--;
432 LOG_DEBUG_IO("discarding trailing empty field");
433 }
434
435 if (cmd->cmd.scan->num_fields == 0) {
436 LOG_DEBUG_IO("empty scan, doing nothing");
437 return;
438 }
439
440 if (cmd->cmd.scan->ir_scan) {
441 if (tap_get_state() != TAP_IRSHIFT)
442 move_to_state(TAP_IRSHIFT);
443 } else {
444 if (tap_get_state() != TAP_DRSHIFT)
445 move_to_state(TAP_DRSHIFT);
446 }
447
448 ftdi_end_state(cmd->cmd.scan->end_state);
449
450 struct scan_field *field = cmd->cmd.scan->fields;
451 unsigned scan_size = 0;
452
453 for (int i = 0; i < cmd->cmd.scan->num_fields; i++, field++) {
454 scan_size += field->num_bits;
455 LOG_DEBUG_IO("%s%s field %d/%d %d bits",
456 field->in_value ? "in" : "",
457 field->out_value ? "out" : "",
458 i,
459 cmd->cmd.scan->num_fields,
460 field->num_bits);
461
462 if (i == cmd->cmd.scan->num_fields - 1 && tap_get_state() != tap_get_end_state()) {
463 /* Last field, and we're leaving IRSHIFT/DRSHIFT. Clock last bit during tap
464 * movement. This last field can't have length zero, it was checked above. */
465 mpsse_clock_data(mpsse_ctx,
466 field->out_value,
467 0,
468 field->in_value,
469 0,
470 field->num_bits - 1,
471 ftdi_jtag_mode);
472 uint8_t last_bit = 0;
473 if (field->out_value)
474 bit_copy(&last_bit, 0, field->out_value, field->num_bits - 1, 1);
475
476 /* If endstate is TAP_IDLE, clock out 1-1-0 (->EXIT1 ->UPDATE ->IDLE)
477 * Otherwise, clock out 1-0 (->EXIT1 ->PAUSE)
478 */
479 uint8_t tms_bits = 0x03;
480 mpsse_clock_tms_cs(mpsse_ctx,
481 &tms_bits,
482 0,
483 field->in_value,
484 field->num_bits - 1,
485 1,
486 last_bit,
487 ftdi_jtag_mode);
488 tap_set_state(tap_state_transition(tap_get_state(), 1));
489 if (tap_get_end_state() == TAP_IDLE) {
490 mpsse_clock_tms_cs_out(mpsse_ctx,
491 &tms_bits,
492 1,
493 2,
494 last_bit,
495 ftdi_jtag_mode);
496 tap_set_state(tap_state_transition(tap_get_state(), 1));
497 tap_set_state(tap_state_transition(tap_get_state(), 0));
498 } else {
499 mpsse_clock_tms_cs_out(mpsse_ctx,
500 &tms_bits,
501 2,
502 1,
503 last_bit,
504 ftdi_jtag_mode);
505 tap_set_state(tap_state_transition(tap_get_state(), 0));
506 }
507 } else
508 mpsse_clock_data(mpsse_ctx,
509 field->out_value,
510 0,
511 field->in_value,
512 0,
513 field->num_bits,
514 ftdi_jtag_mode);
515 }
516
517 if (tap_get_state() != tap_get_end_state())
518 move_to_state(tap_get_end_state());
519
520 LOG_DEBUG_IO("%s scan, %i bits, end in %s",
521 (cmd->cmd.scan->ir_scan) ? "IR" : "DR", scan_size,
522 tap_state_name(tap_get_end_state()));
523 }
524
525 static int ftdi_reset(int trst, int srst)
526 {
527 struct signal *sig_ntrst = find_signal_by_name("nTRST");
528 struct signal *sig_nsrst = find_signal_by_name("nSRST");
529
530 LOG_DEBUG_IO("reset trst: %i srst %i", trst, srst);
531
532 if (!swd_mode) {
533 if (trst == 1) {
534 if (sig_ntrst)
535 ftdi_set_signal(sig_ntrst, '0');
536 else
537 LOG_ERROR("Can't assert TRST: nTRST signal is not defined");
538 } else if (sig_ntrst && jtag_get_reset_config() & RESET_HAS_TRST &&
539 trst == 0) {
540 if (jtag_get_reset_config() & RESET_TRST_OPEN_DRAIN)
541 ftdi_set_signal(sig_ntrst, 'z');
542 else
543 ftdi_set_signal(sig_ntrst, '1');
544 }
545 }
546
547 if (srst == 1) {
548 if (sig_nsrst)
549 ftdi_set_signal(sig_nsrst, '0');
550 else
551 LOG_ERROR("Can't assert SRST: nSRST signal is not defined");
552 } else if (sig_nsrst && jtag_get_reset_config() & RESET_HAS_SRST &&
553 srst == 0) {
554 if (jtag_get_reset_config() & RESET_SRST_PUSH_PULL)
555 ftdi_set_signal(sig_nsrst, '1');
556 else
557 ftdi_set_signal(sig_nsrst, 'z');
558 }
559
560 return mpsse_flush(mpsse_ctx);
561 }
562
563 static void ftdi_execute_sleep(struct jtag_command *cmd)
564 {
565 LOG_DEBUG_IO("sleep %" PRIu32, cmd->cmd.sleep->us);
566
567 mpsse_flush(mpsse_ctx);
568 jtag_sleep(cmd->cmd.sleep->us);
569 LOG_DEBUG_IO("sleep %" PRIu32 " usec while in %s",
570 cmd->cmd.sleep->us,
571 tap_state_name(tap_get_state()));
572 }
573
574 static void ftdi_execute_stableclocks(struct jtag_command *cmd)
575 {
576 /* this is only allowed while in a stable state. A check for a stable
577 * state was done in jtag_add_clocks()
578 */
579 int num_cycles = cmd->cmd.stableclocks->num_cycles;
580
581 /* 7 bits of either ones or zeros. */
582 uint8_t tms = tap_get_state() == TAP_RESET ? 0x7f : 0x00;
583
584 /* TODO: Use mpsse_clock_data with in=out=0 for this, if TMS can be set to
585 * the correct level and remain there during the scan */
586 while (num_cycles > 0) {
587 /* there are no state transitions in this code, so omit state tracking */
588 unsigned this_len = num_cycles > 7 ? 7 : num_cycles;
589 mpsse_clock_tms_cs_out(mpsse_ctx, &tms, 0, this_len, false, ftdi_jtag_mode);
590 num_cycles -= this_len;
591 }
592
593 LOG_DEBUG_IO("clocks %i while in %s",
594 cmd->cmd.stableclocks->num_cycles,
595 tap_state_name(tap_get_state()));
596 }
597
598 static void ftdi_execute_command(struct jtag_command *cmd)
599 {
600 switch (cmd->type) {
601 case JTAG_RUNTEST:
602 ftdi_execute_runtest(cmd);
603 break;
604 case JTAG_TLR_RESET:
605 ftdi_execute_statemove(cmd);
606 break;
607 case JTAG_PATHMOVE:
608 ftdi_execute_pathmove(cmd);
609 break;
610 case JTAG_SCAN:
611 ftdi_execute_scan(cmd);
612 break;
613 case JTAG_SLEEP:
614 ftdi_execute_sleep(cmd);
615 break;
616 case JTAG_STABLECLOCKS:
617 ftdi_execute_stableclocks(cmd);
618 break;
619 case JTAG_TMS:
620 ftdi_execute_tms(cmd);
621 break;
622 default:
623 LOG_ERROR("BUG: unknown JTAG command type encountered: %d", cmd->type);
624 break;
625 }
626 }
627
628 static int ftdi_execute_queue(struct jtag_command *cmd_queue)
629 {
630 /* blink, if the current layout has that feature */
631 struct signal *led = find_signal_by_name("LED");
632 if (led)
633 ftdi_set_signal(led, '1');
634
635 for (struct jtag_command *cmd = cmd_queue; cmd; cmd = cmd->next) {
636 /* fill the write buffer with the desired command */
637 ftdi_execute_command(cmd);
638 }
639
640 if (led)
641 ftdi_set_signal(led, '0');
642
643 int retval = mpsse_flush(mpsse_ctx);
644 if (retval != ERROR_OK)
645 LOG_ERROR("error while flushing MPSSE queue: %d", retval);
646
647 return retval;
648 }
649
650 static int ftdi_initialize(void)
651 {
652 if (tap_get_tms_path_len(TAP_IRPAUSE, TAP_IRPAUSE) == 7)
653 LOG_DEBUG("ftdi interface using 7 step jtag state transitions");
654 else
655 LOG_DEBUG("ftdi interface using shortest path jtag state transitions");
656
657 if (!ftdi_vid[0] && !ftdi_pid[0]) {
658 LOG_ERROR("Please specify ftdi vid_pid");
659 return ERROR_JTAG_INIT_FAILED;
660 }
661
662 mpsse_ctx = mpsse_open(ftdi_vid, ftdi_pid, ftdi_device_desc,
663 adapter_get_required_serial(), adapter_usb_get_location(), ftdi_channel);
664 if (!mpsse_ctx)
665 return ERROR_JTAG_INIT_FAILED;
666
667 output = jtag_output_init;
668 direction = jtag_direction_init;
669
670 if (swd_mode) {
671 struct signal *sig = find_signal_by_name("SWD_EN");
672 if (!sig) {
673 LOG_ERROR("SWD mode is active but SWD_EN signal is not defined");
674 return ERROR_JTAG_INIT_FAILED;
675 }
676 /* A dummy SWD_EN would have zero mask */
677 if (sig->data_mask)
678 ftdi_set_signal(sig, '1');
679 }
680
681 mpsse_set_data_bits_low_byte(mpsse_ctx, output & 0xff, direction & 0xff);
682 mpsse_set_data_bits_high_byte(mpsse_ctx, output >> 8, direction >> 8);
683
684 mpsse_loopback_config(mpsse_ctx, false);
685
686 freq = mpsse_set_frequency(mpsse_ctx, adapter_get_speed_khz() * 1000);
687
688 return mpsse_flush(mpsse_ctx);
689 }
690
691 static int ftdi_quit(void)
692 {
693 mpsse_close(mpsse_ctx);
694
695 struct signal *sig = signals;
696 while (sig) {
697 struct signal *next = sig->next;
698 free((void *)sig->name);
699 free(sig);
700 sig = next;
701 }
702
703 free(ftdi_device_desc);
704
705 free(swd_cmd_queue);
706
707 return ERROR_OK;
708 }
709
710 COMMAND_HANDLER(ftdi_handle_device_desc_command)
711 {
712 if (CMD_ARGC == 1) {
713 free(ftdi_device_desc);
714 ftdi_device_desc = strdup(CMD_ARGV[0]);
715 } else {
716 LOG_ERROR("expected exactly one argument to ftdi device_desc <description>");
717 }
718
719 return ERROR_OK;
720 }
721
722 COMMAND_HANDLER(ftdi_handle_channel_command)
723 {
724 if (CMD_ARGC == 1)
725 COMMAND_PARSE_NUMBER(u8, CMD_ARGV[0], ftdi_channel);
726 else
727 return ERROR_COMMAND_SYNTAX_ERROR;
728
729 return ERROR_OK;
730 }
731
732 COMMAND_HANDLER(ftdi_handle_layout_init_command)
733 {
734 if (CMD_ARGC != 2)
735 return ERROR_COMMAND_SYNTAX_ERROR;
736
737 COMMAND_PARSE_NUMBER(u16, CMD_ARGV[0], jtag_output_init);
738 COMMAND_PARSE_NUMBER(u16, CMD_ARGV[1], jtag_direction_init);
739
740 return ERROR_OK;
741 }
742
743 COMMAND_HANDLER(ftdi_handle_layout_signal_command)
744 {
745 if (CMD_ARGC < 1)
746 return ERROR_COMMAND_SYNTAX_ERROR;
747
748 bool invert_data = false;
749 uint16_t data_mask = 0;
750 bool invert_input = false;
751 uint16_t input_mask = 0;
752 bool invert_oe = false;
753 uint16_t oe_mask = 0;
754 for (unsigned i = 1; i < CMD_ARGC; i += 2) {
755 if (strcmp("-data", CMD_ARGV[i]) == 0) {
756 invert_data = false;
757 COMMAND_PARSE_NUMBER(u16, CMD_ARGV[i + 1], data_mask);
758 } else if (strcmp("-ndata", CMD_ARGV[i]) == 0) {
759 invert_data = true;
760 COMMAND_PARSE_NUMBER(u16, CMD_ARGV[i + 1], data_mask);
761 } else if (strcmp("-input", CMD_ARGV[i]) == 0) {
762 invert_input = false;
763 COMMAND_PARSE_NUMBER(u16, CMD_ARGV[i + 1], input_mask);
764 } else if (strcmp("-ninput", CMD_ARGV[i]) == 0) {
765 invert_input = true;
766 COMMAND_PARSE_NUMBER(u16, CMD_ARGV[i + 1], input_mask);
767 } else if (strcmp("-oe", CMD_ARGV[i]) == 0) {
768 invert_oe = false;
769 COMMAND_PARSE_NUMBER(u16, CMD_ARGV[i + 1], oe_mask);
770 } else if (strcmp("-noe", CMD_ARGV[i]) == 0) {
771 invert_oe = true;
772 COMMAND_PARSE_NUMBER(u16, CMD_ARGV[i + 1], oe_mask);
773 } else if (!strcmp("-alias", CMD_ARGV[i]) ||
774 !strcmp("-nalias", CMD_ARGV[i])) {
775 if (!strcmp("-nalias", CMD_ARGV[i])) {
776 invert_data = true;
777 invert_input = true;
778 }
779 struct signal *sig = find_signal_by_name(CMD_ARGV[i + 1]);
780 if (!sig) {
781 LOG_ERROR("signal %s is not defined", CMD_ARGV[i + 1]);
782 return ERROR_FAIL;
783 }
784 data_mask = sig->data_mask;
785 input_mask = sig->input_mask;
786 oe_mask = sig->oe_mask;
787 invert_input ^= sig->invert_input;
788 invert_oe = sig->invert_oe;
789 invert_data ^= sig->invert_data;
790 } else {
791 LOG_ERROR("unknown option '%s'", CMD_ARGV[i]);
792 return ERROR_COMMAND_SYNTAX_ERROR;
793 }
794 }
795
796 struct signal *sig;
797 sig = find_signal_by_name(CMD_ARGV[0]);
798 if (!sig)
799 sig = create_signal(CMD_ARGV[0]);
800 if (!sig) {
801 LOG_ERROR("failed to create signal %s", CMD_ARGV[0]);
802 return ERROR_FAIL;
803 }
804
805 sig->invert_data = invert_data;
806 sig->data_mask = data_mask;
807 sig->invert_input = invert_input;
808 sig->input_mask = input_mask;
809 sig->invert_oe = invert_oe;
810 sig->oe_mask = oe_mask;
811
812 return ERROR_OK;
813 }
814
815 COMMAND_HANDLER(ftdi_handle_set_signal_command)
816 {
817 if (CMD_ARGC < 2)
818 return ERROR_COMMAND_SYNTAX_ERROR;
819
820 struct signal *sig;
821 sig = find_signal_by_name(CMD_ARGV[0]);
822 if (!sig) {
823 LOG_ERROR("interface configuration doesn't define signal '%s'", CMD_ARGV[0]);
824 return ERROR_FAIL;
825 }
826
827 switch (*CMD_ARGV[1]) {
828 case '0':
829 case '1':
830 case 'z':
831 case 'Z':
832 /* single character level specifier only */
833 if (CMD_ARGV[1][1] == '\0') {
834 ftdi_set_signal(sig, *CMD_ARGV[1]);
835 break;
836 }
837 /* fallthrough */
838 default:
839 LOG_ERROR("unknown signal level '%s', use 0, 1 or z", CMD_ARGV[1]);
840 return ERROR_COMMAND_ARGUMENT_INVALID;
841 }
842
843 return mpsse_flush(mpsse_ctx);
844 }
845
846 COMMAND_HANDLER(ftdi_handle_get_signal_command)
847 {
848 if (CMD_ARGC < 1)
849 return ERROR_COMMAND_SYNTAX_ERROR;
850
851 struct signal *sig;
852 uint16_t sig_data = 0;
853 sig = find_signal_by_name(CMD_ARGV[0]);
854 if (!sig) {
855 LOG_ERROR("interface configuration doesn't define signal '%s'", CMD_ARGV[0]);
856 return ERROR_FAIL;
857 }
858
859 int ret = ftdi_get_signal(sig, &sig_data);
860 if (ret != ERROR_OK)
861 return ret;
862
863 LOG_USER("Signal %s = %#06x", sig->name, sig_data);
864
865 return ERROR_OK;
866 }
867
868 COMMAND_HANDLER(ftdi_handle_vid_pid_command)
869 {
870 if (CMD_ARGC > MAX_USB_IDS * 2) {
871 LOG_WARNING("ignoring extra IDs in ftdi vid_pid "
872 "(maximum is %d pairs)", MAX_USB_IDS);
873 CMD_ARGC = MAX_USB_IDS * 2;
874 }
875 if (CMD_ARGC < 2 || (CMD_ARGC & 1)) {
876 LOG_WARNING("incomplete ftdi vid_pid configuration directive");
877 if (CMD_ARGC < 2)
878 return ERROR_COMMAND_SYNTAX_ERROR;
879 /* remove the incomplete trailing id */
880 CMD_ARGC -= 1;
881 }
882
883 unsigned i;
884 for (i = 0; i < CMD_ARGC; i += 2) {
885 COMMAND_PARSE_NUMBER(u16, CMD_ARGV[i], ftdi_vid[i >> 1]);
886 COMMAND_PARSE_NUMBER(u16, CMD_ARGV[i + 1], ftdi_pid[i >> 1]);
887 }
888
889 /*
890 * Explicitly terminate, in case there are multiples instances of
891 * ftdi vid_pid.
892 */
893 ftdi_vid[i >> 1] = ftdi_pid[i >> 1] = 0;
894
895 return ERROR_OK;
896 }
897
898 COMMAND_HANDLER(ftdi_handle_tdo_sample_edge_command)
899 {
900 const struct nvp *n;
901 static const struct nvp nvp_ftdi_jtag_modes[] = {
902 { .name = "rising", .value = JTAG_MODE },
903 { .name = "falling", .value = JTAG_MODE_ALT },
904 { .name = NULL, .value = -1 },
905 };
906
907 if (CMD_ARGC > 0) {
908 n = nvp_name2value(nvp_ftdi_jtag_modes, CMD_ARGV[0]);
909 if (!n->name)
910 return ERROR_COMMAND_SYNTAX_ERROR;
911 ftdi_jtag_mode = n->value;
912
913 }
914
915 n = nvp_value2name(nvp_ftdi_jtag_modes, ftdi_jtag_mode);
916 command_print(CMD, "ftdi samples TDO on %s edge of TCK", n->name);
917
918 return ERROR_OK;
919 }
920
921 static const struct command_registration ftdi_subcommand_handlers[] = {
922 {
923 .name = "device_desc",
924 .handler = &ftdi_handle_device_desc_command,
925 .mode = COMMAND_CONFIG,
926 .help = "set the USB device description of the FTDI device",
927 .usage = "description_string",
928 },
929 {
930 .name = "channel",
931 .handler = &ftdi_handle_channel_command,
932 .mode = COMMAND_CONFIG,
933 .help = "set the channel of the FTDI device that is used as JTAG",
934 .usage = "(0-3)",
935 },
936 {
937 .name = "layout_init",
938 .handler = &ftdi_handle_layout_init_command,
939 .mode = COMMAND_CONFIG,
940 .help = "initialize the FTDI GPIO signals used "
941 "to control output-enables and reset signals",
942 .usage = "data direction",
943 },
944 {
945 .name = "layout_signal",
946 .handler = &ftdi_handle_layout_signal_command,
947 .mode = COMMAND_ANY,
948 .help = "define a signal controlled by one or more FTDI GPIO as data "
949 "and/or output enable",
950 .usage = "name [-data mask|-ndata mask] [-oe mask|-noe mask] [-alias|-nalias name]",
951 },
952 {
953 .name = "set_signal",
954 .handler = &ftdi_handle_set_signal_command,
955 .mode = COMMAND_EXEC,
956 .help = "control a layout-specific signal",
957 .usage = "name (1|0|z)",
958 },
959 {
960 .name = "get_signal",
961 .handler = &ftdi_handle_get_signal_command,
962 .mode = COMMAND_EXEC,
963 .help = "read the value of a layout-specific signal",
964 .usage = "name",
965 },
966 {
967 .name = "vid_pid",
968 .handler = &ftdi_handle_vid_pid_command,
969 .mode = COMMAND_CONFIG,
970 .help = "the vendor ID and product ID of the FTDI device",
971 .usage = "(vid pid)*",
972 },
973 {
974 .name = "tdo_sample_edge",
975 .handler = &ftdi_handle_tdo_sample_edge_command,
976 .mode = COMMAND_ANY,
977 .help = "set which TCK clock edge is used for sampling TDO "
978 "- default is rising-edge (Setting to falling-edge may "
979 "allow signalling speed increase)",
980 .usage = "(rising|falling)",
981 },
982 COMMAND_REGISTRATION_DONE
983 };
984
985 static const struct command_registration ftdi_command_handlers[] = {
986 {
987 .name = "ftdi",
988 .mode = COMMAND_ANY,
989 .help = "perform ftdi management",
990 .chain = ftdi_subcommand_handlers,
991 .usage = "",
992 },
993 COMMAND_REGISTRATION_DONE
994 };
995
996 static int create_default_signal(const char *name, uint16_t data_mask)
997 {
998 struct signal *sig = create_signal(name);
999 if (!sig) {
1000 LOG_ERROR("failed to create signal %s", name);
1001 return ERROR_FAIL;
1002 }
1003 sig->invert_data = false;
1004 sig->data_mask = data_mask;
1005 sig->invert_oe = false;
1006 sig->oe_mask = 0;
1007
1008 return ERROR_OK;
1009 }
1010
1011 static int create_signals(void)
1012 {
1013 if (create_default_signal("TCK", 0x01) != ERROR_OK)
1014 return ERROR_FAIL;
1015 if (create_default_signal("TDI", 0x02) != ERROR_OK)
1016 return ERROR_FAIL;
1017 if (create_default_signal("TDO", 0x04) != ERROR_OK)
1018 return ERROR_FAIL;
1019 if (create_default_signal("TMS", 0x08) != ERROR_OK)
1020 return ERROR_FAIL;
1021 return ERROR_OK;
1022 }
1023
1024 static int ftdi_swd_init(void)
1025 {
1026 LOG_INFO("FTDI SWD mode enabled");
1027 swd_mode = true;
1028
1029 if (create_signals() != ERROR_OK)
1030 return ERROR_FAIL;
1031
1032 swd_cmd_queue_alloced = 10;
1033 swd_cmd_queue = malloc(swd_cmd_queue_alloced * sizeof(*swd_cmd_queue));
1034
1035 return swd_cmd_queue ? ERROR_OK : ERROR_FAIL;
1036 }
1037
1038 static void ftdi_swd_swdio_en(bool enable)
1039 {
1040 struct signal *oe = find_signal_by_name("SWDIO_OE");
1041 if (oe) {
1042 if (oe->data_mask)
1043 ftdi_set_signal(oe, enable ? '1' : '0');
1044 else {
1045 /* Sets TDI/DO pin to input during rx when both pins are connected
1046 to SWDIO */
1047 if (enable)
1048 direction |= jtag_direction_init & 0x0002U;
1049 else
1050 direction &= ~0x0002U;
1051 mpsse_set_data_bits_low_byte(mpsse_ctx, output & 0xff, direction & 0xff);
1052 }
1053 }
1054 }
1055
1056 /**
1057 * Flush the MPSSE queue and process the SWD transaction queue
1058 * @return
1059 */
1060 static int ftdi_swd_run_queue(void)
1061 {
1062 LOG_DEBUG_IO("Executing %zu queued transactions", swd_cmd_queue_length);
1063 int retval;
1064 struct signal *led = find_signal_by_name("LED");
1065
1066 if (queued_retval != ERROR_OK) {
1067 LOG_DEBUG_IO("Skipping due to previous errors: %d", queued_retval);
1068 goto skip;
1069 }
1070
1071 /* A transaction must be followed by another transaction or at least 8 idle cycles to
1072 * ensure that data is clocked through the AP. */
1073 mpsse_clock_data_out(mpsse_ctx, NULL, 0, 8, SWD_MODE);
1074
1075 /* Terminate the "blink", if the current layout has that feature */
1076 if (led)
1077 ftdi_set_signal(led, '0');
1078
1079 queued_retval = mpsse_flush(mpsse_ctx);
1080 if (queued_retval != ERROR_OK) {
1081 LOG_ERROR("MPSSE failed");
1082 goto skip;
1083 }
1084
1085 for (size_t i = 0; i < swd_cmd_queue_length; i++) {
1086 int ack = buf_get_u32(swd_cmd_queue[i].trn_ack_data_parity_trn, 1, 3);
1087
1088 /* Devices do not reply to DP_TARGETSEL write cmd, ignore received ack */
1089 bool check_ack = swd_cmd_returns_ack(swd_cmd_queue[i].cmd);
1090
1091 LOG_CUSTOM_LEVEL((check_ack && ack != SWD_ACK_OK) ? LOG_LVL_DEBUG : LOG_LVL_DEBUG_IO,
1092 "%s%s %s %s reg %X = %08" PRIx32,
1093 check_ack ? "" : "ack ignored ",
1094 ack == SWD_ACK_OK ? "OK" : ack == SWD_ACK_WAIT ? "WAIT" : ack == SWD_ACK_FAULT ? "FAULT" : "JUNK",
1095 swd_cmd_queue[i].cmd & SWD_CMD_APNDP ? "AP" : "DP",
1096 swd_cmd_queue[i].cmd & SWD_CMD_RNW ? "read" : "write",
1097 (swd_cmd_queue[i].cmd & SWD_CMD_A32) >> 1,
1098 buf_get_u32(swd_cmd_queue[i].trn_ack_data_parity_trn,
1099 1 + 3 + (swd_cmd_queue[i].cmd & SWD_CMD_RNW ? 0 : 1), 32));
1100
1101 if (ack != SWD_ACK_OK && check_ack) {
1102 queued_retval = swd_ack_to_error_code(ack);
1103 goto skip;
1104
1105 } else if (swd_cmd_queue[i].cmd & SWD_CMD_RNW) {
1106 uint32_t data = buf_get_u32(swd_cmd_queue[i].trn_ack_data_parity_trn, 1 + 3, 32);
1107 int parity = buf_get_u32(swd_cmd_queue[i].trn_ack_data_parity_trn, 1 + 3 + 32, 1);
1108
1109 if (parity != parity_u32(data)) {
1110 LOG_ERROR("SWD Read data parity mismatch");
1111 queued_retval = ERROR_FAIL;
1112 goto skip;
1113 }
1114
1115 if (swd_cmd_queue[i].dst)
1116 *swd_cmd_queue[i].dst = data;
1117 }
1118 }
1119
1120 skip:
1121 swd_cmd_queue_length = 0;
1122 retval = queued_retval;
1123 queued_retval = ERROR_OK;
1124
1125 /* Queue a new "blink" */
1126 if (led && retval == ERROR_OK)
1127 ftdi_set_signal(led, '1');
1128
1129 return retval;
1130 }
1131
1132 static void ftdi_swd_queue_cmd(uint8_t cmd, uint32_t *dst, uint32_t data, uint32_t ap_delay_clk)
1133 {
1134 if (swd_cmd_queue_length >= swd_cmd_queue_alloced) {
1135 /* Not enough room in the queue. Run the queue and increase its size for next time.
1136 * Note that it's not possible to avoid running the queue here, because mpsse contains
1137 * pointers into the queue which may be invalid after the realloc. */
1138 queued_retval = ftdi_swd_run_queue();
1139 struct swd_cmd_queue_entry *q = realloc(swd_cmd_queue, swd_cmd_queue_alloced * 2 * sizeof(*swd_cmd_queue));
1140 if (q) {
1141 swd_cmd_queue = q;
1142 swd_cmd_queue_alloced *= 2;
1143 LOG_DEBUG("Increased SWD command queue to %zu elements", swd_cmd_queue_alloced);
1144 }
1145 }
1146
1147 if (queued_retval != ERROR_OK)
1148 return;
1149
1150 size_t i = swd_cmd_queue_length++;
1151 swd_cmd_queue[i].cmd = cmd | SWD_CMD_START | SWD_CMD_PARK;
1152
1153 mpsse_clock_data_out(mpsse_ctx, &swd_cmd_queue[i].cmd, 0, 8, SWD_MODE);
1154
1155 if (swd_cmd_queue[i].cmd & SWD_CMD_RNW) {
1156 /* Queue a read transaction */
1157 swd_cmd_queue[i].dst = dst;
1158
1159 ftdi_swd_swdio_en(false);
1160 mpsse_clock_data_in(mpsse_ctx, swd_cmd_queue[i].trn_ack_data_parity_trn,
1161 0, 1 + 3 + 32 + 1 + 1, SWD_MODE);
1162 ftdi_swd_swdio_en(true);
1163 } else {
1164 /* Queue a write transaction */
1165 ftdi_swd_swdio_en(false);
1166
1167 mpsse_clock_data_in(mpsse_ctx, swd_cmd_queue[i].trn_ack_data_parity_trn,
1168 0, 1 + 3 + 1, SWD_MODE);
1169
1170 ftdi_swd_swdio_en(true);
1171
1172 buf_set_u32(swd_cmd_queue[i].trn_ack_data_parity_trn, 1 + 3 + 1, 32, data);
1173 buf_set_u32(swd_cmd_queue[i].trn_ack_data_parity_trn, 1 + 3 + 1 + 32, 1, parity_u32(data));
1174
1175 mpsse_clock_data_out(mpsse_ctx, swd_cmd_queue[i].trn_ack_data_parity_trn,
1176 1 + 3 + 1, 32 + 1, SWD_MODE);
1177 }
1178
1179 /* Insert idle cycles after AP accesses to avoid WAIT */
1180 if (cmd & SWD_CMD_APNDP)
1181 mpsse_clock_data_out(mpsse_ctx, NULL, 0, ap_delay_clk, SWD_MODE);
1182
1183 }
1184
1185 static void ftdi_swd_read_reg(uint8_t cmd, uint32_t *value, uint32_t ap_delay_clk)
1186 {
1187 assert(cmd & SWD_CMD_RNW);
1188 ftdi_swd_queue_cmd(cmd, value, 0, ap_delay_clk);
1189 }
1190
1191 static void ftdi_swd_write_reg(uint8_t cmd, uint32_t value, uint32_t ap_delay_clk)
1192 {
1193 assert(!(cmd & SWD_CMD_RNW));
1194 ftdi_swd_queue_cmd(cmd, NULL, value, ap_delay_clk);
1195 }
1196
1197 static int ftdi_swd_switch_seq(enum swd_special_seq seq)
1198 {
1199 switch (seq) {
1200 case LINE_RESET:
1201 LOG_DEBUG("SWD line reset");
1202 ftdi_swd_swdio_en(true);
1203 mpsse_clock_data_out(mpsse_ctx, swd_seq_line_reset, 0, swd_seq_line_reset_len, SWD_MODE);
1204 break;
1205 case JTAG_TO_SWD:
1206 LOG_DEBUG("JTAG-to-SWD");
1207 ftdi_swd_swdio_en(true);
1208 mpsse_clock_data_out(mpsse_ctx, swd_seq_jtag_to_swd, 0, swd_seq_jtag_to_swd_len, SWD_MODE);
1209 break;
1210 case JTAG_TO_DORMANT:
1211 LOG_DEBUG("JTAG-to-DORMANT");
1212 ftdi_swd_swdio_en(true);
1213 mpsse_clock_data_out(mpsse_ctx, swd_seq_jtag_to_dormant, 0, swd_seq_jtag_to_dormant_len, SWD_MODE);
1214 break;
1215 case SWD_TO_JTAG:
1216 LOG_DEBUG("SWD-to-JTAG");
1217 ftdi_swd_swdio_en(true);
1218 mpsse_clock_data_out(mpsse_ctx, swd_seq_swd_to_jtag, 0, swd_seq_swd_to_jtag_len, SWD_MODE);
1219 break;
1220 case SWD_TO_DORMANT:
1221 LOG_DEBUG("SWD-to-DORMANT");
1222 ftdi_swd_swdio_en(true);
1223 mpsse_clock_data_out(mpsse_ctx, swd_seq_swd_to_dormant, 0, swd_seq_swd_to_dormant_len, SWD_MODE);
1224 break;
1225 case DORMANT_TO_SWD:
1226 LOG_DEBUG("DORMANT-to-SWD");
1227 ftdi_swd_swdio_en(true);
1228 mpsse_clock_data_out(mpsse_ctx, swd_seq_dormant_to_swd, 0, swd_seq_dormant_to_swd_len, SWD_MODE);
1229 break;
1230 case DORMANT_TO_JTAG:
1231 LOG_DEBUG("DORMANT-to-JTAG");
1232 ftdi_swd_swdio_en(true);
1233 mpsse_clock_data_out(mpsse_ctx, swd_seq_dormant_to_jtag, 0, swd_seq_dormant_to_jtag_len, SWD_MODE);
1234 break;
1235 default:
1236 LOG_ERROR("Sequence %d not supported", seq);
1237 return ERROR_FAIL;
1238 }
1239
1240 return ERROR_OK;
1241 }
1242
1243 static const struct swd_driver ftdi_swd = {
1244 .init = ftdi_swd_init,
1245 .switch_seq = ftdi_swd_switch_seq,
1246 .read_reg = ftdi_swd_read_reg,
1247 .write_reg = ftdi_swd_write_reg,
1248 .run = ftdi_swd_run_queue,
1249 };
1250
1251 static const char * const ftdi_transports[] = { "jtag", "swd", NULL };
1252
1253 static struct jtag_interface ftdi_interface = {
1254 .supported = DEBUG_CAP_TMS_SEQ,
1255 .execute_queue = ftdi_execute_queue,
1256 };
1257
1258 struct adapter_driver ftdi_adapter_driver = {
1259 .name = "ftdi",
1260 .transports = ftdi_transports,
1261 .commands = ftdi_command_handlers,
1262
1263 .init = ftdi_initialize,
1264 .quit = ftdi_quit,
1265 .reset = ftdi_reset,
1266 .speed = ftdi_speed,
1267 .khz = ftdi_khz,
1268 .speed_div = ftdi_speed_div,
1269
1270 .jtag_ops = &ftdi_interface,
1271 .swd_ops = &ftdi_swd,
1272 };

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)