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(int_least32_t hz
);
76 static int vsllink_swd_switch_seq(enum swd_special_seq seq
);
78 /* VSLLink lowlevel functions */
80 struct libusb_context
*libusb_ctx
;
81 struct libusb_device_handle
*usb_device_handle
;
84 static int vsllink_usb_open(struct vsllink
*vsllink
);
85 static void vsllink_usb_close(struct vsllink
*vsllink
);
87 #if defined _DEBUG_JTAG_IO_
88 static void vsllink_debug_buffer(uint8_t *buffer
, int length
);
91 static int tap_length
;
92 static int tap_buffer_size
;
93 static uint8_t *tms_buffer
;
94 static uint8_t *tdi_buffer
;
95 static uint8_t *tdo_buffer
;
99 static struct vsllink
*vsllink_handle
;
101 static int vsllink_execute_queue(void)
103 struct jtag_command
*cmd
= jtag_command_queue
;
108 DEBUG_JTAG_IO("-------------------------------------"
110 "-------------------------------------");
112 while (cmd
!= NULL
) {
115 DEBUG_JTAG_IO("runtest %i cycles, end in %s",
116 cmd
->cmd
.runtest
->num_cycles
,
117 tap_state_name(cmd
->cmd
.runtest
->end_state
));
119 vsllink_end_state(cmd
->cmd
.runtest
->end_state
);
120 vsllink_runtest(cmd
->cmd
.runtest
->num_cycles
);
124 DEBUG_JTAG_IO("statemove end in %s",
125 tap_state_name(cmd
->cmd
.statemove
->end_state
));
127 vsllink_end_state(cmd
->cmd
.statemove
->end_state
);
128 vsllink_state_move();
132 DEBUG_JTAG_IO("pathmove: %i states, end in %s",
133 cmd
->cmd
.pathmove
->num_states
,
134 tap_state_name(cmd
->cmd
.pathmove
->path
[cmd
->cmd
.pathmove
->num_states
- 1]));
136 vsllink_path_move(cmd
->cmd
.pathmove
->num_states
, cmd
->cmd
.pathmove
->path
);
140 DEBUG_JTAG_IO("JTAG Scan...");
142 vsllink_end_state(cmd
->cmd
.scan
->end_state
);
144 scan_size
= jtag_build_buffer(
145 cmd
->cmd
.scan
, &buffer
);
147 if (cmd
->cmd
.scan
->ir_scan
)
149 "JTAG Scan write IR(%d bits), "
152 tap_state_name(cmd
->cmd
.scan
->end_state
));
156 "JTAG Scan write DR(%d bits), "
159 tap_state_name(cmd
->cmd
.scan
->end_state
));
161 #ifdef _DEBUG_JTAG_IO_
162 vsllink_debug_buffer(buffer
,
163 DIV_ROUND_UP(scan_size
, 8));
166 type
= jtag_scan_type(cmd
->cmd
.scan
);
168 vsllink_scan(cmd
->cmd
.scan
->ir_scan
,
169 type
, buffer
, scan_size
,
174 DEBUG_JTAG_IO("reset trst: %i srst %i",
175 cmd
->cmd
.reset
->trst
,
176 cmd
->cmd
.reset
->srst
);
178 vsllink_tap_execute();
180 if (cmd
->cmd
.reset
->trst
== 1)
181 tap_set_state(TAP_RESET
);
183 vsllink_reset(cmd
->cmd
.reset
->trst
,
184 cmd
->cmd
.reset
->srst
);
188 DEBUG_JTAG_IO("sleep %i", cmd
->cmd
.sleep
->us
);
189 vsllink_tap_execute();
190 jtag_sleep(cmd
->cmd
.sleep
->us
);
193 case JTAG_STABLECLOCKS
:
194 DEBUG_JTAG_IO("add %d clocks",
195 cmd
->cmd
.stableclocks
->num_cycles
);
197 switch (tap_get_state()) {
199 /* tms must be '1' to stay
209 /* else, tms should be '0' */
212 /* above stable states are OK */
214 LOG_ERROR("jtag_add_clocks() "
215 "in non-stable state \"%s\"",
216 tap_state_name(tap_get_state())
220 vsllink_stableclocks(cmd
->cmd
.stableclocks
->num_cycles
, scan_size
);
224 DEBUG_JTAG_IO("add %d jtag tms",
225 cmd
->cmd
.tms
->num_bits
);
227 vsllink_tms(cmd
->cmd
.tms
->num_bits
, cmd
->cmd
.tms
->bits
);
231 LOG_ERROR("BUG: unknown JTAG command type "
232 "encountered: %d", cmd
->type
);
238 return vsllink_tap_execute();
241 static int vsllink_speed(int speed
)
244 vsllink_swd_frequency(speed
* 1000);
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(jtag_get_speed_khz() * 1000);
351 vsllink_swd_switch_seq(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(int_least32_t hz
)
733 const int_least32_t delay2hz
[] = {
734 1850000, 235000, 130000, 102000, 85000, 72000
738 uint16_t delay
= UINT16_MAX
;
740 for (uint16_t i
= 0; i
< ARRAY_SIZE(delay2hz
); i
++) {
741 if (hz
>= delay2hz
[i
]) {
748 if (delay
== UINT16_MAX
)
749 delay
= (500000 / hz
) - 1;
751 /* Calculate retry count after a WAIT response. This will give
752 * a retry timeout at about ~250 ms. 54 is the number of bits
753 * found in a transaction. */
754 uint16_t retry_count
= 250 * hz
/ 1000 / 54;
756 LOG_DEBUG("SWD delay: %d, retry count: %d", delay
, retry_count
);
758 versaloon_interface
.adaptors
.swd
.config(0, 2, retry_count
, delay
);
764 static int vsllink_swd_switch_seq(enum swd_special_seq seq
)
768 LOG_DEBUG("SWD line reset");
769 versaloon_interface
.adaptors
.swd
.seqout(0, swd_seq_line_reset
,
770 swd_seq_line_reset_len
);
773 LOG_DEBUG("JTAG-to-SWD");
774 versaloon_interface
.adaptors
.swd
.seqout(0, swd_seq_jtag_to_swd
,
775 swd_seq_jtag_to_swd_len
);
778 LOG_DEBUG("SWD-to-JTAG");
779 versaloon_interface
.adaptors
.swd
.seqout(0, swd_seq_swd_to_jtag
,
780 swd_seq_swd_to_jtag_len
);
783 LOG_ERROR("Sequence %d not supported", seq
);
790 static void vsllink_swd_read_reg(uint8_t cmd
, uint32_t *value
, uint32_t ap_delay_clk
)
792 versaloon_interface
.adaptors
.swd
.transact(0, cmd
, value
, NULL
);
795 static void vsllink_swd_write_reg(uint8_t cmd
, uint32_t value
, uint32_t ap_delay_clk
)
797 versaloon_interface
.adaptors
.swd
.transact(0, cmd
, &value
, NULL
);
800 static int vsllink_swd_run_queue(void)
802 return versaloon_interface
.adaptors
.peripheral_commit();
805 /****************************************************************************
806 * VSLLink USB low-level functions */
808 static int vsllink_check_usb_strings(
809 struct libusb_device_handle
*usb_device_handle
,
810 struct libusb_device_descriptor
*usb_desc
)
812 char desc_string
[256];
815 if (NULL
!= versaloon_interface
.usb_setting
.serialstring
) {
816 retval
= libusb_get_string_descriptor_ascii(usb_device_handle
,
817 usb_desc
->iSerialNumber
, (unsigned char *)desc_string
,
818 sizeof(desc_string
));
822 if (strncmp(desc_string
, versaloon_interface
.usb_setting
.serialstring
,
823 sizeof(desc_string
)))
827 retval
= libusb_get_string_descriptor_ascii(usb_device_handle
,
828 usb_desc
->iProduct
, (unsigned char *)desc_string
,
829 sizeof(desc_string
));
833 if (strstr(desc_string
, "Versaloon") == NULL
)
839 static int vsllink_usb_open(struct vsllink
*vsllink
)
841 ssize_t num_devices
, i
;
842 libusb_device
**usb_devices
;
843 struct libusb_device_descriptor usb_desc
;
844 struct libusb_device_handle
*usb_device_handle
;
847 num_devices
= libusb_get_device_list(vsllink
->libusb_ctx
, &usb_devices
);
849 if (num_devices
<= 0)
852 for (i
= 0; i
< num_devices
; i
++) {
853 libusb_device
*device
= usb_devices
[i
];
855 retval
= libusb_get_device_descriptor(device
, &usb_desc
);
859 if (usb_desc
.idVendor
!= versaloon_interface
.usb_setting
.vid
||
860 usb_desc
.idProduct
!= versaloon_interface
.usb_setting
.pid
)
863 retval
= libusb_open(device
, &usb_device_handle
);
867 retval
= vsllink_check_usb_strings(usb_device_handle
, &usb_desc
);
868 if (ERROR_OK
== retval
)
871 libusb_close(usb_device_handle
);
874 libusb_free_device_list(usb_devices
, 1);
876 if (i
== num_devices
)
879 retval
= libusb_claim_interface(usb_device_handle
,
880 versaloon_interface
.usb_setting
.interface
);
882 LOG_ERROR("unable to claim interface");
883 libusb_close(usb_device_handle
);
887 vsllink
->usb_device_handle
= usb_device_handle
;
891 static void vsllink_usb_close(struct vsllink
*vsllink
)
893 libusb_release_interface(vsllink
->usb_device_handle
,
894 versaloon_interface
.usb_setting
.interface
);
895 libusb_close(vsllink
->usb_device_handle
);
898 #define BYTES_PER_LINE 16
900 #if defined _DEBUG_JTAG_IO_
901 static void vsllink_debug_buffer(uint8_t *buffer
, int length
)
908 for (i
= 0; i
< length
; i
+= BYTES_PER_LINE
) {
909 snprintf(line
, 5, "%04x", i
);
910 for (j
= i
; j
< i
+ BYTES_PER_LINE
&& j
< length
; j
++) {
911 snprintf(s
, 4, " %02x", buffer
[j
]);
914 LOG_DEBUG("%s", line
);
917 #endif /* _DEBUG_JTAG_IO_ */
919 static const struct command_registration vsllink_command_handlers
[] = {
921 .name
= "vsllink_usb_vid",
922 .handler
= &vsllink_handle_usb_vid_command
,
923 .mode
= COMMAND_CONFIG
,
926 .name
= "vsllink_usb_pid",
927 .handler
= &vsllink_handle_usb_pid_command
,
928 .mode
= COMMAND_CONFIG
,
931 .name
= "vsllink_usb_serial",
932 .handler
= &vsllink_handle_usb_serial_command
,
933 .mode
= COMMAND_CONFIG
,
936 .name
= "vsllink_usb_bulkin",
937 .handler
= &vsllink_handle_usb_bulkin_command
,
938 .mode
= COMMAND_CONFIG
,
941 .name
= "vsllink_usb_bulkout",
942 .handler
= &vsllink_handle_usb_bulkout_command
,
943 .mode
= COMMAND_CONFIG
,
946 .name
= "vsllink_usb_interface",
947 .handler
= &vsllink_handle_usb_interface_command
,
948 .mode
= COMMAND_CONFIG
,
950 COMMAND_REGISTRATION_DONE
953 static const char * const vsllink_transports
[] = {"jtag", "swd", NULL
};
955 static const struct swd_driver vsllink_swd_driver
= {
956 .init
= vsllink_swd_init
,
957 .frequency
= vsllink_swd_frequency
,
958 .switch_seq
= vsllink_swd_switch_seq
,
959 .read_reg
= vsllink_swd_read_reg
,
960 .write_reg
= vsllink_swd_write_reg
,
961 .run
= vsllink_swd_run_queue
,
964 struct jtag_interface vsllink_interface
= {
966 .supported
= DEBUG_CAP_TMS_SEQ
,
967 .commands
= vsllink_command_handlers
,
968 .transports
= vsllink_transports
,
969 .swd
= &vsllink_swd_driver
,
971 .init
= vsllink_init
,
972 .quit
= vsllink_quit
,
974 .speed
= vsllink_speed
,
975 .speed_div
= vsllink_speed_div
,
976 .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)