1 /***************************************************************************
2 * Copyright (C) 2009-2010 by Simon Qian <SimonQian@SimonQian.com> *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
18 ***************************************************************************/
20 /* Versaloon is a programming tool for multiple MCUs.
21 * It's distributed under GPLv3.
22 * You can find it at http://www.Versaloon.com/.
29 #include <jtag/interface.h>
30 #include <jtag/commands.h>
34 #include "versaloon/versaloon_include.h"
35 #include "versaloon/versaloon.h"
37 static int vsllink_tms_offset
;
39 struct pending_scan_result
{
42 int length
; /* Number of bits to read */
43 struct scan_command
*command
; /* Corresponding scan command */
46 bool last
; /* indicate the last scan pending */
49 #define MAX_PENDING_SCAN_RESULTS 256
51 static int pending_scan_results_length
;
52 static struct pending_scan_result
53 pending_scan_results_buffer
[MAX_PENDING_SCAN_RESULTS
];
55 /* Queue command functions */
56 static void vsllink_end_state(tap_state_t state
);
57 static void vsllink_state_move(void);
58 static void vsllink_path_move(int num_states
, tap_state_t
*path
);
59 static void vsllink_tms(int num_bits
, const uint8_t *bits
);
60 static void vsllink_runtest(int num_cycles
);
61 static void vsllink_stableclocks(int num_cycles
, int tms
);
62 static void vsllink_scan(bool ir_scan
, enum scan_type type
,
63 uint8_t *buffer
, int scan_size
, struct scan_command
*command
);
64 static void vsllink_reset(int trst
, int srst
);
66 /* VSLLink tap buffer functions */
67 static void vsllink_tap_append_step(int tms
, int tdi
);
68 static void vsllink_tap_init(void);
69 static int vsllink_tap_execute(void);
70 static void vsllink_tap_ensure_pending(int scans
);
71 static void vsllink_tap_append_scan(int length
, uint8_t *buffer
,
72 struct scan_command
*command
);
74 /* VSLLink SWD functions */
75 static int_least32_t vsllink_swd_frequency(struct adiv5_dap
*dap
,
77 static int vsllink_swd_switch_seq(struct adiv5_dap
*dap
,
78 enum swd_special_seq seq
);
80 /* VSLLink lowlevel functions */
82 struct libusb_context
*libusb_ctx
;
83 struct libusb_device_handle
*usb_device_handle
;
86 static int vsllink_usb_open(struct vsllink
*vsllink
);
87 static void vsllink_usb_close(struct vsllink
*vsllink
);
89 #if defined _DEBUG_JTAG_IO_
90 static void vsllink_debug_buffer(uint8_t *buffer
, int length
);
93 static int tap_length
;
94 static int tap_buffer_size
;
95 static uint8_t *tms_buffer
;
96 static uint8_t *tdi_buffer
;
97 static uint8_t *tdo_buffer
;
101 static struct vsllink
*vsllink_handle
;
103 static int vsllink_execute_queue(void)
105 struct jtag_command
*cmd
= jtag_command_queue
;
110 DEBUG_JTAG_IO("-------------------------------------"
112 "-------------------------------------");
114 while (cmd
!= NULL
) {
117 DEBUG_JTAG_IO("runtest %i cycles, end in %s",
118 cmd
->cmd
.runtest
->num_cycles
,
119 tap_state_name(cmd
->cmd
.runtest
->end_state
));
121 vsllink_end_state(cmd
->cmd
.runtest
->end_state
);
122 vsllink_runtest(cmd
->cmd
.runtest
->num_cycles
);
126 DEBUG_JTAG_IO("statemove end in %s",
127 tap_state_name(cmd
->cmd
.statemove
->end_state
));
129 vsllink_end_state(cmd
->cmd
.statemove
->end_state
);
130 vsllink_state_move();
134 DEBUG_JTAG_IO("pathmove: %i states, end in %s",
135 cmd
->cmd
.pathmove
->num_states
,
136 tap_state_name(cmd
->cmd
.pathmove
->path
[cmd
->cmd
.pathmove
->num_states
- 1]));
138 vsllink_path_move(cmd
->cmd
.pathmove
->num_states
, cmd
->cmd
.pathmove
->path
);
142 DEBUG_JTAG_IO("JTAG Scan...");
144 vsllink_end_state(cmd
->cmd
.scan
->end_state
);
146 scan_size
= jtag_build_buffer(
147 cmd
->cmd
.scan
, &buffer
);
149 if (cmd
->cmd
.scan
->ir_scan
)
151 "JTAG Scan write IR(%d bits), "
154 tap_state_name(cmd
->cmd
.scan
->end_state
));
158 "JTAG Scan write DR(%d bits), "
161 tap_state_name(cmd
->cmd
.scan
->end_state
));
163 #ifdef _DEBUG_JTAG_IO_
164 vsllink_debug_buffer(buffer
,
165 DIV_ROUND_UP(scan_size
, 8));
168 type
= jtag_scan_type(cmd
->cmd
.scan
);
170 vsllink_scan(cmd
->cmd
.scan
->ir_scan
,
171 type
, buffer
, scan_size
,
176 DEBUG_JTAG_IO("reset trst: %i srst %i",
177 cmd
->cmd
.reset
->trst
,
178 cmd
->cmd
.reset
->srst
);
180 vsllink_tap_execute();
182 if (cmd
->cmd
.reset
->trst
== 1)
183 tap_set_state(TAP_RESET
);
185 vsllink_reset(cmd
->cmd
.reset
->trst
,
186 cmd
->cmd
.reset
->srst
);
190 DEBUG_JTAG_IO("sleep %i", cmd
->cmd
.sleep
->us
);
191 vsllink_tap_execute();
192 jtag_sleep(cmd
->cmd
.sleep
->us
);
195 case JTAG_STABLECLOCKS
:
196 DEBUG_JTAG_IO("add %d clocks",
197 cmd
->cmd
.stableclocks
->num_cycles
);
199 switch (tap_get_state()) {
201 /* tms must be '1' to stay
211 /* else, tms should be '0' */
214 /* above stable states are OK */
216 LOG_ERROR("jtag_add_clocks() "
217 "in non-stable state \"%s\"",
218 tap_state_name(tap_get_state())
222 vsllink_stableclocks(cmd
->cmd
.stableclocks
->num_cycles
, scan_size
);
226 DEBUG_JTAG_IO("add %d jtag tms",
227 cmd
->cmd
.tms
->num_bits
);
229 vsllink_tms(cmd
->cmd
.tms
->num_bits
, cmd
->cmd
.tms
->bits
);
233 LOG_ERROR("BUG: unknown JTAG command type "
234 "encountered: %d", cmd
->type
);
240 return vsllink_tap_execute();
243 static int vsllink_speed(int speed
)
248 versaloon_interface
.adaptors
.jtag_raw
.config(0, (uint16_t)speed
);
249 return versaloon_interface
.adaptors
.peripheral_commit();
252 static int vsllink_khz(int khz
, int *jtag_speed
)
259 static int vsllink_speed_div(int jtag_speed
, int *khz
)
266 static void vsllink_free_buffer(void)
268 if (tdi_buffer
!= NULL
) {
272 if (tdo_buffer
!= NULL
) {
276 if (tms_buffer
!= NULL
) {
282 static int vsllink_quit(void)
284 versaloon_interface
.adaptors
.gpio
.config(0, GPIO_SRST
| GPIO_TRST
,
285 0, 0, GPIO_SRST
| GPIO_TRST
);
286 versaloon_interface
.adaptors
.gpio
.fini(0);
289 versaloon_interface
.adaptors
.swd
.fini(0);
291 versaloon_interface
.adaptors
.jtag_raw
.fini(0);
293 versaloon_interface
.adaptors
.peripheral_commit();
294 versaloon_interface
.fini();
296 vsllink_free_buffer();
297 vsllink_usb_close(vsllink_handle
);
299 free(vsllink_handle
);
304 static int vsllink_interface_init(void)
306 vsllink_handle
= malloc(sizeof(struct vsllink
));
307 if (NULL
== vsllink_handle
) {
308 LOG_ERROR("unable to allocate memory");
312 libusb_init(&vsllink_handle
->libusb_ctx
);
314 if (ERROR_OK
!= vsllink_usb_open(vsllink_handle
)) {
315 LOG_ERROR("Can't find USB JTAG Interface!" \
316 "Please check connection and permissions.");
317 return ERROR_JTAG_INIT_FAILED
;
319 LOG_DEBUG("vsllink found on %04X:%04X",
320 versaloon_interface
.usb_setting
.vid
,
321 versaloon_interface
.usb_setting
.pid
);
322 versaloon_usb_device_handle
= vsllink_handle
->usb_device_handle
;
324 if (ERROR_OK
!= versaloon_interface
.init())
326 if (versaloon_interface
.usb_setting
.buf_size
< 32) {
327 versaloon_interface
.fini();
334 static int vsllink_init(void)
336 int retval
= vsllink_interface_init();
337 if (ERROR_OK
!= retval
)
340 versaloon_interface
.adaptors
.gpio
.init(0);
341 versaloon_interface
.adaptors
.gpio
.config(0, GPIO_SRST
, 0, GPIO_SRST
,
343 versaloon_interface
.adaptors
.delay
.delayms(100);
344 versaloon_interface
.adaptors
.peripheral_commit();
347 versaloon_interface
.adaptors
.gpio
.config(0, GPIO_TRST
, 0,
348 GPIO_TRST
, GPIO_TRST
);
349 versaloon_interface
.adaptors
.swd
.init(0);
350 vsllink_swd_frequency(NULL
, jtag_get_speed_khz() * 1000);
351 vsllink_swd_switch_seq(NULL
, JTAG_TO_SWD
);
354 /* malloc buffer size for tap */
355 tap_buffer_size
= versaloon_interface
.usb_setting
.buf_size
/ 2 - 32;
356 vsllink_free_buffer();
357 tdi_buffer
= malloc(tap_buffer_size
);
358 tdo_buffer
= malloc(tap_buffer_size
);
359 tms_buffer
= malloc(tap_buffer_size
);
360 if ((NULL
== tdi_buffer
) || (NULL
== tdo_buffer
) || (NULL
== tms_buffer
)) {
365 versaloon_interface
.adaptors
.jtag_raw
.init(0);
366 versaloon_interface
.adaptors
.jtag_raw
.config(0, jtag_get_speed_khz());
367 versaloon_interface
.adaptors
.gpio
.config(0, GPIO_SRST
| GPIO_TRST
,
368 GPIO_TRST
, GPIO_SRST
, GPIO_SRST
);
371 if (ERROR_OK
!= versaloon_interface
.adaptors
.peripheral_commit())
379 /**************************************************************************
380 * Queue command implementations */
382 static void vsllink_end_state(tap_state_t state
)
384 if (tap_is_state_stable(state
))
385 tap_set_end_state(state
);
387 LOG_ERROR("BUG: %i is not a valid end state", state
);
392 /* Goes to the end state. */
393 static void vsllink_state_move(void)
396 uint8_t tms_scan
= tap_get_tms_path(tap_get_state(),
397 tap_get_end_state());
398 uint8_t tms_scan_bits
= tap_get_tms_path_len(tap_get_state(),
399 tap_get_end_state());
401 for (i
= 0; i
< tms_scan_bits
; i
++)
402 vsllink_tap_append_step((tms_scan
>> i
) & 1, 0);
404 tap_set_state(tap_get_end_state());
407 static void vsllink_path_move(int num_states
, tap_state_t
*path
)
409 for (int i
= 0; i
< num_states
; i
++) {
410 if (path
[i
] == tap_state_transition(tap_get_state(), false))
411 vsllink_tap_append_step(0, 0);
412 else if (path
[i
] == tap_state_transition(tap_get_state(), true))
413 vsllink_tap_append_step(1, 0);
415 LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition",
416 tap_state_name(tap_get_state()),
417 tap_state_name(path
[i
]));
421 tap_set_state(path
[i
]);
424 tap_set_end_state(tap_get_state());
427 static void vsllink_tms(int num_bits
, const uint8_t *bits
)
429 for (int i
= 0; i
< num_bits
; i
++)
430 vsllink_tap_append_step((bits
[i
/ 8] >> (i
% 8)) & 1, 0);
433 static void vsllink_stableclocks(int num_cycles
, int tms
)
435 while (num_cycles
> 0) {
436 vsllink_tap_append_step(tms
, 0);
441 static void vsllink_runtest(int num_cycles
)
443 tap_state_t saved_end_state
= tap_get_end_state();
445 if (tap_get_state() != TAP_IDLE
) {
446 /* enter IDLE state */
447 vsllink_end_state(TAP_IDLE
);
448 vsllink_state_move();
451 vsllink_stableclocks(num_cycles
, 0);
455 vsllink_end_state(saved_end_state
);
456 if (tap_get_end_state() != tap_get_end_state())
457 vsllink_state_move();
460 static void vsllink_scan(bool ir_scan
, enum scan_type type
, uint8_t *buffer
,
461 int scan_size
, struct scan_command
*command
)
463 tap_state_t saved_end_state
;
465 saved_end_state
= tap_get_end_state();
467 /* Move to appropriate scan state */
468 vsllink_end_state(ir_scan
? TAP_IRSHIFT
: TAP_DRSHIFT
);
470 if (tap_get_state() != tap_get_end_state())
471 vsllink_state_move();
472 vsllink_end_state(saved_end_state
);
475 vsllink_tap_append_scan(scan_size
, buffer
, command
);
477 /* Goto Pause and record position to insert tms:0 */
478 vsllink_tap_append_step(0, 0);
479 vsllink_tms_offset
= tap_length
;
481 tap_set_state(ir_scan
? TAP_IRPAUSE
: TAP_DRPAUSE
);
483 if (tap_get_state() != tap_get_end_state())
484 vsllink_state_move();
487 static void vsllink_reset(int trst
, int srst
)
489 LOG_DEBUG("trst: %i, srst: %i", trst
, srst
);
492 versaloon_interface
.adaptors
.gpio
.config(0, GPIO_SRST
, 0, GPIO_SRST
, GPIO_SRST
);
494 versaloon_interface
.adaptors
.gpio
.config(0, GPIO_SRST
, GPIO_SRST
, 0, 0);
498 versaloon_interface
.adaptors
.gpio
.out(0, GPIO_TRST
, GPIO_TRST
);
500 versaloon_interface
.adaptors
.gpio
.out(0, GPIO_TRST
, 0);
503 versaloon_interface
.adaptors
.peripheral_commit();
506 COMMAND_HANDLER(vsllink_handle_usb_vid_command
)
509 return ERROR_COMMAND_SYNTAX_ERROR
;
511 COMMAND_PARSE_NUMBER(u16
, CMD_ARGV
[0],
512 versaloon_interface
.usb_setting
.vid
);
516 COMMAND_HANDLER(vsllink_handle_usb_pid_command
)
519 return ERROR_COMMAND_SYNTAX_ERROR
;
520 COMMAND_PARSE_NUMBER(u16
, CMD_ARGV
[0],
521 versaloon_interface
.usb_setting
.pid
);
525 COMMAND_HANDLER(vsllink_handle_usb_serial_command
)
528 return ERROR_COMMAND_SYNTAX_ERROR
;
530 free(versaloon_interface
.usb_setting
.serialstring
);
533 versaloon_interface
.usb_setting
.serialstring
= strdup(CMD_ARGV
[0]);
535 versaloon_interface
.usb_setting
.serialstring
= NULL
;
540 COMMAND_HANDLER(vsllink_handle_usb_bulkin_command
)
543 return ERROR_COMMAND_SYNTAX_ERROR
;
545 COMMAND_PARSE_NUMBER(u8
, CMD_ARGV
[0],
546 versaloon_interface
.usb_setting
.ep_in
);
548 versaloon_interface
.usb_setting
.ep_in
|= 0x80;
553 COMMAND_HANDLER(vsllink_handle_usb_bulkout_command
)
556 return ERROR_COMMAND_SYNTAX_ERROR
;
558 COMMAND_PARSE_NUMBER(u8
, CMD_ARGV
[0],
559 versaloon_interface
.usb_setting
.ep_out
);
561 versaloon_interface
.usb_setting
.ep_out
&= ~0x80;
566 COMMAND_HANDLER(vsllink_handle_usb_interface_command
)
569 return ERROR_COMMAND_SYNTAX_ERROR
;
571 COMMAND_PARSE_NUMBER(u8
, CMD_ARGV
[0],
572 versaloon_interface
.usb_setting
.interface
);
576 /**************************************************************************
577 * VSLLink tap functions */
579 static void vsllink_tap_init(void)
582 pending_scan_results_length
= 0;
583 vsllink_tms_offset
= 0;
586 static void vsllink_tap_ensure_pending(int scans
)
588 int available_scans
=
589 MAX_PENDING_SCAN_RESULTS
- pending_scan_results_length
;
591 if (scans
> available_scans
)
592 vsllink_tap_execute();
595 static void vsllink_tap_append_step(int tms
, int tdi
)
597 int index_var
= tap_length
/ 8;
599 int bit_index
= tap_length
% 8;
600 uint8_t bit
= 1 << bit_index
;
603 tms_buffer
[index_var
] |= bit
;
605 tms_buffer
[index_var
] &= ~bit
;
608 tdi_buffer
[index_var
] |= bit
;
610 tdi_buffer
[index_var
] &= ~bit
;
614 if (tap_buffer_size
* 8 <= tap_length
)
615 vsllink_tap_execute();
618 static void vsllink_tap_append_scan(int length
, uint8_t *buffer
,
619 struct scan_command
*command
)
621 struct pending_scan_result
*pending_scan_result
;
622 int len_tmp
, len_all
, i
;
625 while (len_all
< length
) {
626 vsllink_tap_ensure_pending(1);
627 pending_scan_result
=
628 &pending_scan_results_buffer
[
629 pending_scan_results_length
];
631 if ((length
- len_all
) > (tap_buffer_size
* 8 - tap_length
)) {
632 /* Use all memory available
633 vsllink_tap_append_step will commit automatically */
634 len_tmp
= tap_buffer_size
* 8 - tap_length
;
635 pending_scan_result
->last
= false;
637 len_tmp
= length
- len_all
;
638 pending_scan_result
->last
= true;
640 pending_scan_result
->src_offset
= tap_length
;
641 pending_scan_result
->dest_offset
= len_all
;
642 pending_scan_result
->length
= len_tmp
;
643 pending_scan_result
->command
= command
;
644 pending_scan_result
->buffer
= buffer
;
645 pending_scan_results_length
++;
647 for (i
= 0; i
< len_tmp
; i
++) {
648 vsllink_tap_append_step(((len_all
+ i
) < length
-1
650 (buffer
[(len_all
+ i
)/8]
651 >> ((len_all
+ i
)%8)) & 1);
658 static int vsllink_jtag_execute(void)
666 versaloon_interface
.adaptors
.jtag_raw
.execute(0, tdi_buffer
, tms_buffer
,
667 tdo_buffer
, tap_length
);
669 result
= versaloon_interface
.adaptors
.peripheral_commit();
671 if (result
== ERROR_OK
) {
672 for (i
= 0; i
< pending_scan_results_length
; i
++) {
673 struct pending_scan_result
*pending_scan_result
=
674 &pending_scan_results_buffer
[i
];
675 uint8_t *buffer
= pending_scan_result
->buffer
;
676 int length
= pending_scan_result
->length
;
677 int src_first
= pending_scan_result
->src_offset
;
678 int dest_first
= pending_scan_result
->dest_offset
;
679 bool last
= pending_scan_result
->last
;
681 struct scan_command
*command
;
683 command
= pending_scan_result
->command
;
684 buf_set_buf(tdo_buffer
, src_first
, buffer
, dest_first
, length
);
686 #ifdef _DEBUG_JTAG_IO_
688 "JTAG scan read(%d bits, from src %d bits to dest %d bits):",
689 length
, src_first
, dest_first
);
690 vsllink_debug_buffer(buffer
+ dest_first
/ 8,
691 DIV_ROUND_UP(length
, 7));
695 if (jtag_read_buffer(buffer
, command
)
698 return ERROR_JTAG_QUEUE_FAILED
;
701 if (pending_scan_result
->buffer
!= NULL
)
702 free(pending_scan_result
->buffer
);
706 LOG_ERROR("vsllink_jtag_execute failure");
707 return ERROR_JTAG_QUEUE_FAILED
;
715 static int vsllink_tap_execute(void)
720 return vsllink_jtag_execute();
723 static int vsllink_swd_init(void)
725 LOG_INFO("VSLLink SWD mode enabled");
731 static int_least32_t vsllink_swd_frequency(struct adiv5_dap
*dap
,
734 const int_least32_t delay2hz
[] = {
735 1850000, 235000, 130000, 102000, 85000, 72000
739 uint16_t delay
= UINT16_MAX
;
741 for (uint16_t i
= 0; i
< ARRAY_SIZE(delay2hz
); i
++) {
742 if (hz
>= delay2hz
[i
]) {
749 if (delay
== UINT16_MAX
)
750 delay
= (500000 / hz
) - 1;
752 /* Calculate retry count after a WAIT response. This will give
753 * a retry timeout at about ~250 ms. 54 is the number of bits
754 * found in a transaction. */
755 uint16_t retry_count
= 250 * hz
/ 1000 / 54;
757 LOG_DEBUG("SWD delay: %d, retry count: %d", delay
, retry_count
);
759 versaloon_interface
.adaptors
.swd
.config(0, 2, retry_count
, delay
);
765 static int vsllink_swd_switch_seq(struct adiv5_dap
*dap
,
766 enum swd_special_seq seq
)
770 LOG_DEBUG("SWD line reset");
771 versaloon_interface
.adaptors
.swd
.seqout(0, swd_seq_line_reset
,
772 swd_seq_line_reset_len
);
775 LOG_DEBUG("JTAG-to-SWD");
776 versaloon_interface
.adaptors
.swd
.seqout(0, swd_seq_jtag_to_swd
,
777 swd_seq_jtag_to_swd_len
);
780 LOG_DEBUG("SWD-to-JTAG");
781 versaloon_interface
.adaptors
.swd
.seqout(0, swd_seq_swd_to_jtag
,
782 swd_seq_swd_to_jtag_len
);
785 LOG_ERROR("Sequence %d not supported", seq
);
792 static void vsllink_swd_read_reg(struct adiv5_dap
*dap
, uint8_t cmd
,
795 versaloon_interface
.adaptors
.swd
.transact(0, cmd
, value
, NULL
);
798 static void vsllink_swd_write_reg(struct adiv5_dap
*dap
, uint8_t cmd
,
801 versaloon_interface
.adaptors
.swd
.transact(0, cmd
, &value
, NULL
);
804 static int vsllink_swd_run_queue(struct adiv5_dap
*dap
)
806 return versaloon_interface
.adaptors
.peripheral_commit();
809 /****************************************************************************
810 * VSLLink USB low-level functions */
812 static int vsllink_check_usb_strings(
813 struct libusb_device_handle
*usb_device_handle
,
814 struct libusb_device_descriptor
*usb_desc
)
816 char desc_string
[256];
819 if (NULL
!= versaloon_interface
.usb_setting
.serialstring
) {
820 retval
= libusb_get_string_descriptor_ascii(usb_device_handle
,
821 usb_desc
->iSerialNumber
, (unsigned char *)desc_string
,
822 sizeof(desc_string
));
826 if (strncmp(desc_string
, versaloon_interface
.usb_setting
.serialstring
,
827 sizeof(desc_string
)))
831 retval
= libusb_get_string_descriptor_ascii(usb_device_handle
,
832 usb_desc
->iProduct
, (unsigned char *)desc_string
,
833 sizeof(desc_string
));
837 if (strstr(desc_string
, "Versaloon") == NULL
)
843 static int vsllink_usb_open(struct vsllink
*vsllink
)
845 ssize_t num_devices
, i
;
846 libusb_device
**usb_devices
;
847 struct libusb_device_descriptor usb_desc
;
848 struct libusb_device_handle
*usb_device_handle
;
851 num_devices
= libusb_get_device_list(vsllink
->libusb_ctx
, &usb_devices
);
853 if (num_devices
<= 0)
856 for (i
= 0; i
< num_devices
; i
++) {
857 libusb_device
*device
= usb_devices
[i
];
859 retval
= libusb_get_device_descriptor(device
, &usb_desc
);
863 if (usb_desc
.idVendor
!= versaloon_interface
.usb_setting
.vid
||
864 usb_desc
.idProduct
!= versaloon_interface
.usb_setting
.pid
)
867 retval
= libusb_open(device
, &usb_device_handle
);
871 retval
= vsllink_check_usb_strings(usb_device_handle
, &usb_desc
);
872 if (ERROR_OK
== retval
)
875 libusb_close(usb_device_handle
);
878 libusb_free_device_list(usb_devices
, 1);
880 if (i
== num_devices
)
883 retval
= libusb_claim_interface(usb_device_handle
,
884 versaloon_interface
.usb_setting
.interface
);
886 LOG_ERROR("unable to claim interface");
887 libusb_close(usb_device_handle
);
891 vsllink
->usb_device_handle
= usb_device_handle
;
895 static void vsllink_usb_close(struct vsllink
*vsllink
)
897 libusb_release_interface(vsllink
->usb_device_handle
,
898 versaloon_interface
.usb_setting
.interface
);
899 libusb_close(vsllink
->usb_device_handle
);
902 #define BYTES_PER_LINE 16
904 #if defined _DEBUG_JTAG_IO_
905 static void vsllink_debug_buffer(uint8_t *buffer
, int length
)
912 for (i
= 0; i
< length
; i
+= BYTES_PER_LINE
) {
913 snprintf(line
, 5, "%04x", i
);
914 for (j
= i
; j
< i
+ BYTES_PER_LINE
&& j
< length
; j
++) {
915 snprintf(s
, 4, " %02x", buffer
[j
]);
918 LOG_DEBUG("%s", line
);
921 #endif /* _DEBUG_JTAG_IO_ */
923 static const struct command_registration vsllink_command_handlers
[] = {
925 .name
= "vsllink_usb_vid",
926 .handler
= &vsllink_handle_usb_vid_command
,
927 .mode
= COMMAND_CONFIG
,
930 .name
= "vsllink_usb_pid",
931 .handler
= &vsllink_handle_usb_pid_command
,
932 .mode
= COMMAND_CONFIG
,
935 .name
= "vsllink_usb_serial",
936 .handler
= &vsllink_handle_usb_serial_command
,
937 .mode
= COMMAND_CONFIG
,
940 .name
= "vsllink_usb_bulkin",
941 .handler
= &vsllink_handle_usb_bulkin_command
,
942 .mode
= COMMAND_CONFIG
,
945 .name
= "vsllink_usb_bulkout",
946 .handler
= &vsllink_handle_usb_bulkout_command
,
947 .mode
= COMMAND_CONFIG
,
950 .name
= "vsllink_usb_interface",
951 .handler
= &vsllink_handle_usb_interface_command
,
952 .mode
= COMMAND_CONFIG
,
954 COMMAND_REGISTRATION_DONE
957 static const char * const vsllink_transports
[] = {"jtag", "swd", NULL
};
959 static const struct swd_driver vsllink_swd_driver
= {
960 .init
= vsllink_swd_init
,
961 .frequency
= vsllink_swd_frequency
,
962 .switch_seq
= vsllink_swd_switch_seq
,
963 .read_reg
= vsllink_swd_read_reg
,
964 .write_reg
= vsllink_swd_write_reg
,
965 .run
= vsllink_swd_run_queue
,
968 struct jtag_interface vsllink_interface
= {
970 .supported
= DEBUG_CAP_TMS_SEQ
,
971 .commands
= vsllink_command_handlers
,
972 .transports
= vsllink_transports
,
973 .swd
= &vsllink_swd_driver
,
975 .init
= vsllink_init
,
976 .quit
= vsllink_quit
,
978 .speed
= vsllink_speed
,
979 .speed_div
= vsllink_speed_div
,
980 .execute_queue
= vsllink_execute_queue
,
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)