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, see <http://www.gnu.org/licenses/>. *
16 ***************************************************************************/
18 /* Versaloon is a programming tool for multiple MCUs.
19 * It's distributed under GPLv3.
20 * You can find it at http://www.Versaloon.com/.
27 #include <jtag/interface.h>
28 #include <jtag/commands.h>
32 #include "versaloon/versaloon_include.h"
33 #include "versaloon/versaloon.h"
35 static int vsllink_tms_offset
;
37 struct pending_scan_result
{
40 int length
; /* Number of bits to read */
41 struct scan_command
*command
; /* Corresponding scan command */
44 bool last
; /* indicate the last scan pending */
47 #define MAX_PENDING_SCAN_RESULTS 256
49 static int pending_scan_results_length
;
50 static struct pending_scan_result
51 pending_scan_results_buffer
[MAX_PENDING_SCAN_RESULTS
];
53 /* Queue command functions */
54 static void vsllink_end_state(tap_state_t state
);
55 static void vsllink_state_move(void);
56 static void vsllink_path_move(int num_states
, tap_state_t
*path
);
57 static void vsllink_tms(int num_bits
, const uint8_t *bits
);
58 static void vsllink_runtest(int num_cycles
);
59 static void vsllink_stableclocks(int num_cycles
, int tms
);
60 static void vsllink_scan(bool ir_scan
, enum scan_type type
,
61 uint8_t *buffer
, int scan_size
, struct scan_command
*command
);
62 static void vsllink_reset(int trst
, int srst
);
64 /* VSLLink tap buffer functions */
65 static void vsllink_tap_append_step(int tms
, int tdi
);
66 static void vsllink_tap_init(void);
67 static int vsllink_tap_execute(void);
68 static void vsllink_tap_ensure_pending(int scans
);
69 static void vsllink_tap_append_scan(int length
, uint8_t *buffer
,
70 struct scan_command
*command
);
72 /* VSLLink SWD functions */
73 static int_least32_t vsllink_swd_frequency(int_least32_t hz
);
74 static int vsllink_swd_switch_seq(enum swd_special_seq seq
);
76 /* VSLLink lowlevel functions */
78 struct libusb_context
*libusb_ctx
;
79 struct libusb_device_handle
*usb_device_handle
;
82 static int vsllink_usb_open(struct vsllink
*vsllink
);
83 static void vsllink_usb_close(struct vsllink
*vsllink
);
85 static void vsllink_debug_buffer(uint8_t *buffer
, int length
);
87 static int tap_length
;
88 static int tap_buffer_size
;
89 static uint8_t *tms_buffer
;
90 static uint8_t *tdi_buffer
;
91 static uint8_t *tdo_buffer
;
95 static struct vsllink
*vsllink_handle
;
97 static int vsllink_execute_queue(void)
99 struct jtag_command
*cmd
= jtag_command_queue
;
104 LOG_DEBUG_IO("-------------------------------------"
106 "-------------------------------------");
108 while (cmd
!= NULL
) {
111 LOG_DEBUG_IO("runtest %i cycles, end in %s",
112 cmd
->cmd
.runtest
->num_cycles
,
113 tap_state_name(cmd
->cmd
.runtest
->end_state
));
115 vsllink_end_state(cmd
->cmd
.runtest
->end_state
);
116 vsllink_runtest(cmd
->cmd
.runtest
->num_cycles
);
120 LOG_DEBUG_IO("statemove end in %s",
121 tap_state_name(cmd
->cmd
.statemove
->end_state
));
123 vsllink_end_state(cmd
->cmd
.statemove
->end_state
);
124 vsllink_state_move();
128 LOG_DEBUG_IO("pathmove: %i states, end in %s",
129 cmd
->cmd
.pathmove
->num_states
,
130 tap_state_name(cmd
->cmd
.pathmove
->path
[cmd
->cmd
.pathmove
->num_states
- 1]));
132 vsllink_path_move(cmd
->cmd
.pathmove
->num_states
, cmd
->cmd
.pathmove
->path
);
136 LOG_DEBUG_IO("JTAG Scan...");
138 vsllink_end_state(cmd
->cmd
.scan
->end_state
);
140 scan_size
= jtag_build_buffer(
141 cmd
->cmd
.scan
, &buffer
);
143 if (cmd
->cmd
.scan
->ir_scan
)
145 "JTAG Scan write IR(%d bits), "
148 tap_state_name(cmd
->cmd
.scan
->end_state
));
152 "JTAG Scan write DR(%d bits), "
155 tap_state_name(cmd
->cmd
.scan
->end_state
));
157 if (LOG_LEVEL_IS(LOG_LVL_DEBUG_IO
))
158 vsllink_debug_buffer(buffer
, DIV_ROUND_UP(scan_size
, 8));
160 type
= jtag_scan_type(cmd
->cmd
.scan
);
162 vsllink_scan(cmd
->cmd
.scan
->ir_scan
,
163 type
, buffer
, scan_size
,
168 LOG_DEBUG_IO("reset trst: %i srst %i",
169 cmd
->cmd
.reset
->trst
,
170 cmd
->cmd
.reset
->srst
);
172 vsllink_tap_execute();
174 if (cmd
->cmd
.reset
->trst
== 1)
175 tap_set_state(TAP_RESET
);
177 vsllink_reset(cmd
->cmd
.reset
->trst
,
178 cmd
->cmd
.reset
->srst
);
182 LOG_DEBUG_IO("sleep %i", cmd
->cmd
.sleep
->us
);
183 vsllink_tap_execute();
184 jtag_sleep(cmd
->cmd
.sleep
->us
);
187 case JTAG_STABLECLOCKS
:
188 LOG_DEBUG_IO("add %d clocks",
189 cmd
->cmd
.stableclocks
->num_cycles
);
191 switch (tap_get_state()) {
193 /* tms must be '1' to stay
203 /* else, tms should be '0' */
206 /* above stable states are OK */
208 LOG_ERROR("jtag_add_clocks() "
209 "in non-stable state \"%s\"",
210 tap_state_name(tap_get_state())
214 vsllink_stableclocks(cmd
->cmd
.stableclocks
->num_cycles
, scan_size
);
218 LOG_DEBUG_IO("add %d jtag tms",
219 cmd
->cmd
.tms
->num_bits
);
221 vsllink_tms(cmd
->cmd
.tms
->num_bits
, cmd
->cmd
.tms
->bits
);
225 LOG_ERROR("BUG: unknown JTAG command type "
226 "encountered: %d", cmd
->type
);
232 return vsllink_tap_execute();
235 static int vsllink_speed(int speed
)
238 vsllink_swd_frequency(speed
* 1000);
242 versaloon_interface
.adaptors
.jtag_raw
.config(0, (uint16_t)speed
);
243 return versaloon_interface
.adaptors
.peripheral_commit();
246 static int vsllink_khz(int khz
, int *jtag_speed
)
253 static int vsllink_speed_div(int jtag_speed
, int *khz
)
260 static void vsllink_free_buffer(void)
262 if (tdi_buffer
!= NULL
) {
266 if (tdo_buffer
!= NULL
) {
270 if (tms_buffer
!= NULL
) {
276 static int vsllink_quit(void)
278 versaloon_interface
.adaptors
.gpio
.config(0, GPIO_SRST
| GPIO_TRST
,
279 0, 0, GPIO_SRST
| GPIO_TRST
);
280 versaloon_interface
.adaptors
.gpio
.fini(0);
283 versaloon_interface
.adaptors
.swd
.fini(0);
285 versaloon_interface
.adaptors
.jtag_raw
.fini(0);
287 versaloon_interface
.adaptors
.peripheral_commit();
288 versaloon_interface
.fini();
290 vsllink_free_buffer();
291 vsllink_usb_close(vsllink_handle
);
293 free(vsllink_handle
);
298 static int vsllink_interface_init(void)
300 vsllink_handle
= malloc(sizeof(struct vsllink
));
301 if (NULL
== vsllink_handle
) {
302 LOG_ERROR("unable to allocate memory");
306 libusb_init(&vsllink_handle
->libusb_ctx
);
308 if (ERROR_OK
!= vsllink_usb_open(vsllink_handle
)) {
309 LOG_ERROR("Can't find USB JTAG Interface!" \
310 "Please check connection and permissions.");
311 return ERROR_JTAG_INIT_FAILED
;
313 LOG_DEBUG("vsllink found on %04X:%04X",
314 versaloon_interface
.usb_setting
.vid
,
315 versaloon_interface
.usb_setting
.pid
);
316 versaloon_usb_device_handle
= vsllink_handle
->usb_device_handle
;
318 if (ERROR_OK
!= versaloon_interface
.init())
320 if (versaloon_interface
.usb_setting
.buf_size
< 32) {
321 versaloon_interface
.fini();
328 static int vsllink_init(void)
330 int retval
= vsllink_interface_init();
331 if (ERROR_OK
!= retval
)
334 versaloon_interface
.adaptors
.gpio
.init(0);
335 versaloon_interface
.adaptors
.gpio
.config(0, GPIO_SRST
, 0, GPIO_SRST
,
337 versaloon_interface
.adaptors
.delay
.delayms(100);
338 versaloon_interface
.adaptors
.peripheral_commit();
341 versaloon_interface
.adaptors
.gpio
.config(0, GPIO_TRST
, 0,
342 GPIO_TRST
, GPIO_TRST
);
343 versaloon_interface
.adaptors
.swd
.init(0);
344 vsllink_swd_frequency(jtag_get_speed_khz() * 1000);
345 vsllink_swd_switch_seq(JTAG_TO_SWD
);
348 /* malloc buffer size for tap */
349 tap_buffer_size
= versaloon_interface
.usb_setting
.buf_size
/ 2 - 32;
350 vsllink_free_buffer();
351 tdi_buffer
= malloc(tap_buffer_size
);
352 tdo_buffer
= malloc(tap_buffer_size
);
353 tms_buffer
= malloc(tap_buffer_size
);
354 if ((NULL
== tdi_buffer
) || (NULL
== tdo_buffer
) || (NULL
== tms_buffer
)) {
359 versaloon_interface
.adaptors
.jtag_raw
.init(0);
360 versaloon_interface
.adaptors
.jtag_raw
.config(0, jtag_get_speed_khz());
361 versaloon_interface
.adaptors
.gpio
.config(0, GPIO_SRST
| GPIO_TRST
,
362 GPIO_TRST
, GPIO_SRST
, GPIO_SRST
);
365 if (ERROR_OK
!= versaloon_interface
.adaptors
.peripheral_commit())
373 /**************************************************************************
374 * Queue command implementations */
376 static void vsllink_end_state(tap_state_t state
)
378 if (tap_is_state_stable(state
))
379 tap_set_end_state(state
);
381 LOG_ERROR("BUG: %i is not a valid end state", state
);
386 /* Goes to the end state. */
387 static void vsllink_state_move(void)
390 uint8_t tms_scan
= tap_get_tms_path(tap_get_state(),
391 tap_get_end_state());
392 uint8_t tms_scan_bits
= tap_get_tms_path_len(tap_get_state(),
393 tap_get_end_state());
395 for (i
= 0; i
< tms_scan_bits
; i
++)
396 vsllink_tap_append_step((tms_scan
>> i
) & 1, 0);
398 tap_set_state(tap_get_end_state());
401 static void vsllink_path_move(int num_states
, tap_state_t
*path
)
403 for (int i
= 0; i
< num_states
; i
++) {
404 if (path
[i
] == tap_state_transition(tap_get_state(), false))
405 vsllink_tap_append_step(0, 0);
406 else if (path
[i
] == tap_state_transition(tap_get_state(), true))
407 vsllink_tap_append_step(1, 0);
409 LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition",
410 tap_state_name(tap_get_state()),
411 tap_state_name(path
[i
]));
415 tap_set_state(path
[i
]);
418 tap_set_end_state(tap_get_state());
421 static void vsllink_tms(int num_bits
, const uint8_t *bits
)
423 for (int i
= 0; i
< num_bits
; i
++)
424 vsllink_tap_append_step((bits
[i
/ 8] >> (i
% 8)) & 1, 0);
427 static void vsllink_stableclocks(int num_cycles
, int tms
)
429 while (num_cycles
> 0) {
430 vsllink_tap_append_step(tms
, 0);
435 static void vsllink_runtest(int num_cycles
)
437 tap_state_t saved_end_state
= tap_get_end_state();
439 if (tap_get_state() != TAP_IDLE
) {
440 /* enter IDLE state */
441 vsllink_end_state(TAP_IDLE
);
442 vsllink_state_move();
445 vsllink_stableclocks(num_cycles
, 0);
449 vsllink_end_state(saved_end_state
);
450 if (tap_get_end_state() != tap_get_end_state())
451 vsllink_state_move();
454 static void vsllink_scan(bool ir_scan
, enum scan_type type
, uint8_t *buffer
,
455 int scan_size
, struct scan_command
*command
)
457 tap_state_t saved_end_state
;
459 saved_end_state
= tap_get_end_state();
461 /* Move to appropriate scan state */
462 vsllink_end_state(ir_scan
? TAP_IRSHIFT
: TAP_DRSHIFT
);
464 if (tap_get_state() != tap_get_end_state())
465 vsllink_state_move();
466 vsllink_end_state(saved_end_state
);
469 vsllink_tap_append_scan(scan_size
, buffer
, command
);
471 /* Goto Pause and record position to insert tms:0 */
472 vsllink_tap_append_step(0, 0);
473 vsllink_tms_offset
= tap_length
;
475 tap_set_state(ir_scan
? TAP_IRPAUSE
: TAP_DRPAUSE
);
477 if (tap_get_state() != tap_get_end_state())
478 vsllink_state_move();
481 static void vsllink_reset(int trst
, int srst
)
483 LOG_DEBUG("trst: %i, srst: %i", trst
, srst
);
486 versaloon_interface
.adaptors
.gpio
.config(0, GPIO_SRST
, 0, GPIO_SRST
, GPIO_SRST
);
488 versaloon_interface
.adaptors
.gpio
.config(0, GPIO_SRST
, GPIO_SRST
, 0, 0);
492 versaloon_interface
.adaptors
.gpio
.out(0, GPIO_TRST
, GPIO_TRST
);
494 versaloon_interface
.adaptors
.gpio
.out(0, GPIO_TRST
, 0);
497 versaloon_interface
.adaptors
.peripheral_commit();
500 COMMAND_HANDLER(vsllink_handle_usb_vid_command
)
503 return ERROR_COMMAND_SYNTAX_ERROR
;
505 COMMAND_PARSE_NUMBER(u16
, CMD_ARGV
[0],
506 versaloon_interface
.usb_setting
.vid
);
510 COMMAND_HANDLER(vsllink_handle_usb_pid_command
)
513 return ERROR_COMMAND_SYNTAX_ERROR
;
514 COMMAND_PARSE_NUMBER(u16
, CMD_ARGV
[0],
515 versaloon_interface
.usb_setting
.pid
);
519 COMMAND_HANDLER(vsllink_handle_usb_serial_command
)
522 return ERROR_COMMAND_SYNTAX_ERROR
;
524 free(versaloon_interface
.usb_setting
.serialstring
);
527 versaloon_interface
.usb_setting
.serialstring
= strdup(CMD_ARGV
[0]);
529 versaloon_interface
.usb_setting
.serialstring
= NULL
;
534 COMMAND_HANDLER(vsllink_handle_usb_bulkin_command
)
537 return ERROR_COMMAND_SYNTAX_ERROR
;
539 COMMAND_PARSE_NUMBER(u8
, CMD_ARGV
[0],
540 versaloon_interface
.usb_setting
.ep_in
);
542 versaloon_interface
.usb_setting
.ep_in
|= 0x80;
547 COMMAND_HANDLER(vsllink_handle_usb_bulkout_command
)
550 return ERROR_COMMAND_SYNTAX_ERROR
;
552 COMMAND_PARSE_NUMBER(u8
, CMD_ARGV
[0],
553 versaloon_interface
.usb_setting
.ep_out
);
555 versaloon_interface
.usb_setting
.ep_out
&= ~0x80;
560 COMMAND_HANDLER(vsllink_handle_usb_interface_command
)
563 return ERROR_COMMAND_SYNTAX_ERROR
;
565 COMMAND_PARSE_NUMBER(u8
, CMD_ARGV
[0],
566 versaloon_interface
.usb_setting
.interface
);
570 /**************************************************************************
571 * VSLLink tap functions */
573 static void vsllink_tap_init(void)
576 pending_scan_results_length
= 0;
577 vsllink_tms_offset
= 0;
580 static void vsllink_tap_ensure_pending(int scans
)
582 int available_scans
=
583 MAX_PENDING_SCAN_RESULTS
- pending_scan_results_length
;
585 if (scans
> available_scans
)
586 vsllink_tap_execute();
589 static void vsllink_tap_append_step(int tms
, int tdi
)
591 int index_var
= tap_length
/ 8;
593 int bit_index
= tap_length
% 8;
594 uint8_t bit
= 1 << bit_index
;
597 tms_buffer
[index_var
] |= bit
;
599 tms_buffer
[index_var
] &= ~bit
;
602 tdi_buffer
[index_var
] |= bit
;
604 tdi_buffer
[index_var
] &= ~bit
;
608 if (tap_buffer_size
* 8 <= tap_length
)
609 vsllink_tap_execute();
612 static void vsllink_tap_append_scan(int length
, uint8_t *buffer
,
613 struct scan_command
*command
)
615 struct pending_scan_result
*pending_scan_result
;
616 int len_tmp
, len_all
, i
;
619 while (len_all
< length
) {
620 vsllink_tap_ensure_pending(1);
621 pending_scan_result
=
622 &pending_scan_results_buffer
[
623 pending_scan_results_length
];
625 if ((length
- len_all
) > (tap_buffer_size
* 8 - tap_length
)) {
626 /* Use all memory available
627 vsllink_tap_append_step will commit automatically */
628 len_tmp
= tap_buffer_size
* 8 - tap_length
;
629 pending_scan_result
->last
= false;
631 len_tmp
= length
- len_all
;
632 pending_scan_result
->last
= true;
634 pending_scan_result
->src_offset
= tap_length
;
635 pending_scan_result
->dest_offset
= len_all
;
636 pending_scan_result
->length
= len_tmp
;
637 pending_scan_result
->command
= command
;
638 pending_scan_result
->buffer
= buffer
;
639 pending_scan_results_length
++;
641 for (i
= 0; i
< len_tmp
; i
++) {
642 vsllink_tap_append_step(((len_all
+ i
) < length
-1
644 (buffer
[(len_all
+ i
)/8]
645 >> ((len_all
+ i
)%8)) & 1);
652 static int vsllink_jtag_execute(void)
660 versaloon_interface
.adaptors
.jtag_raw
.execute(0, tdi_buffer
, tms_buffer
,
661 tdo_buffer
, tap_length
);
663 result
= versaloon_interface
.adaptors
.peripheral_commit();
665 if (result
== ERROR_OK
) {
666 for (i
= 0; i
< pending_scan_results_length
; i
++) {
667 struct pending_scan_result
*pending_scan_result
=
668 &pending_scan_results_buffer
[i
];
669 uint8_t *buffer
= pending_scan_result
->buffer
;
670 int length
= pending_scan_result
->length
;
671 int src_first
= pending_scan_result
->src_offset
;
672 int dest_first
= pending_scan_result
->dest_offset
;
673 bool last
= pending_scan_result
->last
;
675 struct scan_command
*command
;
677 command
= pending_scan_result
->command
;
678 buf_set_buf(tdo_buffer
, src_first
, buffer
, dest_first
, length
);
681 "JTAG scan read(%d bits, from src %d bits to dest %d bits):",
682 length
, src_first
, dest_first
);
683 if (LOG_LEVEL_IS(LOG_LVL_DEBUG_IO
))
684 vsllink_debug_buffer(buffer
+ dest_first
/ 8, DIV_ROUND_UP(length
, 7));
687 if (jtag_read_buffer(buffer
, command
)
690 return ERROR_JTAG_QUEUE_FAILED
;
693 if (pending_scan_result
->buffer
!= NULL
)
694 free(pending_scan_result
->buffer
);
698 LOG_ERROR("vsllink_jtag_execute failure");
699 return ERROR_JTAG_QUEUE_FAILED
;
707 static int vsllink_tap_execute(void)
712 return vsllink_jtag_execute();
715 static int vsllink_swd_init(void)
717 LOG_INFO("VSLLink SWD mode enabled");
723 static int_least32_t vsllink_swd_frequency(int_least32_t hz
)
725 const int_least32_t delay2hz
[] = {
726 1850000, 235000, 130000, 102000, 85000, 72000
730 uint16_t delay
= UINT16_MAX
;
732 for (uint16_t i
= 0; i
< ARRAY_SIZE(delay2hz
); i
++) {
733 if (hz
>= delay2hz
[i
]) {
740 if (delay
== UINT16_MAX
)
741 delay
= (500000 / hz
) - 1;
743 /* Calculate retry count after a WAIT response. This will give
744 * a retry timeout at about ~250 ms. 54 is the number of bits
745 * found in a transaction. */
746 uint16_t retry_count
= 250 * hz
/ 1000 / 54;
748 LOG_DEBUG("SWD delay: %d, retry count: %d", delay
, retry_count
);
750 versaloon_interface
.adaptors
.swd
.config(0, 2, retry_count
, delay
);
756 static int vsllink_swd_switch_seq(enum swd_special_seq seq
)
760 LOG_DEBUG("SWD line reset");
761 versaloon_interface
.adaptors
.swd
.seqout(0, swd_seq_line_reset
,
762 swd_seq_line_reset_len
);
765 LOG_DEBUG("JTAG-to-SWD");
766 versaloon_interface
.adaptors
.swd
.seqout(0, swd_seq_jtag_to_swd
,
767 swd_seq_jtag_to_swd_len
);
770 LOG_DEBUG("SWD-to-JTAG");
771 versaloon_interface
.adaptors
.swd
.seqout(0, swd_seq_swd_to_jtag
,
772 swd_seq_swd_to_jtag_len
);
775 LOG_ERROR("Sequence %d not supported", seq
);
782 static void vsllink_swd_read_reg(uint8_t cmd
, uint32_t *value
, uint32_t ap_delay_clk
)
784 versaloon_interface
.adaptors
.swd
.transact(0, cmd
, value
, NULL
);
787 static void vsllink_swd_write_reg(uint8_t cmd
, uint32_t value
, uint32_t ap_delay_clk
)
789 versaloon_interface
.adaptors
.swd
.transact(0, cmd
, &value
, NULL
);
792 static int vsllink_swd_run_queue(void)
794 return versaloon_interface
.adaptors
.peripheral_commit();
797 /****************************************************************************
798 * VSLLink USB low-level functions */
800 static int vsllink_check_usb_strings(
801 struct libusb_device_handle
*usb_device_handle
,
802 struct libusb_device_descriptor
*usb_desc
)
804 char desc_string
[256];
807 if (NULL
!= versaloon_interface
.usb_setting
.serialstring
) {
808 retval
= libusb_get_string_descriptor_ascii(usb_device_handle
,
809 usb_desc
->iSerialNumber
, (unsigned char *)desc_string
,
810 sizeof(desc_string
));
814 if (strncmp(desc_string
, versaloon_interface
.usb_setting
.serialstring
,
815 sizeof(desc_string
)))
819 retval
= libusb_get_string_descriptor_ascii(usb_device_handle
,
820 usb_desc
->iProduct
, (unsigned char *)desc_string
,
821 sizeof(desc_string
));
825 if (strstr(desc_string
, "Versaloon") == NULL
)
831 static int vsllink_usb_open(struct vsllink
*vsllink
)
833 ssize_t num_devices
, i
;
834 libusb_device
**usb_devices
;
835 struct libusb_device_descriptor usb_desc
;
836 struct libusb_device_handle
*usb_device_handle
;
839 num_devices
= libusb_get_device_list(vsllink
->libusb_ctx
, &usb_devices
);
841 if (num_devices
<= 0)
844 for (i
= 0; i
< num_devices
; i
++) {
845 libusb_device
*device
= usb_devices
[i
];
847 retval
= libusb_get_device_descriptor(device
, &usb_desc
);
851 if (usb_desc
.idVendor
!= versaloon_interface
.usb_setting
.vid
||
852 usb_desc
.idProduct
!= versaloon_interface
.usb_setting
.pid
)
855 retval
= libusb_open(device
, &usb_device_handle
);
859 retval
= vsllink_check_usb_strings(usb_device_handle
, &usb_desc
);
860 if (ERROR_OK
== retval
)
863 libusb_close(usb_device_handle
);
866 libusb_free_device_list(usb_devices
, 1);
868 if (i
== num_devices
)
871 retval
= libusb_claim_interface(usb_device_handle
,
872 versaloon_interface
.usb_setting
.interface
);
874 LOG_ERROR("unable to claim interface");
875 libusb_close(usb_device_handle
);
879 vsllink
->usb_device_handle
= usb_device_handle
;
883 static void vsllink_usb_close(struct vsllink
*vsllink
)
885 libusb_release_interface(vsllink
->usb_device_handle
,
886 versaloon_interface
.usb_setting
.interface
);
887 libusb_close(vsllink
->usb_device_handle
);
890 #define BYTES_PER_LINE 16
892 static void vsllink_debug_buffer(uint8_t *buffer
, int length
)
899 for (i
= 0; i
< length
; i
+= BYTES_PER_LINE
) {
900 snprintf(line
, 5, "%04x", i
& 0xffff);
901 for (j
= i
; j
< i
+ BYTES_PER_LINE
&& j
< length
; j
++) {
902 snprintf(s
, 4, " %02x", buffer
[j
]);
905 LOG_DEBUG_IO("%s", line
);
909 static const struct command_registration vsllink_command_handlers
[] = {
911 .name
= "vsllink_usb_vid",
912 .handler
= &vsllink_handle_usb_vid_command
,
913 .mode
= COMMAND_CONFIG
,
914 .help
= "Set USB VID",
918 .name
= "vsllink_usb_pid",
919 .handler
= &vsllink_handle_usb_pid_command
,
920 .mode
= COMMAND_CONFIG
,
921 .help
= "Set USB PID",
925 .name
= "vsllink_usb_serial",
926 .handler
= &vsllink_handle_usb_serial_command
,
927 .mode
= COMMAND_CONFIG
,
928 .help
= "Set or disable check for USB serial",
929 .usage
= "[<serial>]",
932 .name
= "vsllink_usb_bulkin",
933 .handler
= &vsllink_handle_usb_bulkin_command
,
934 .mode
= COMMAND_CONFIG
,
935 .help
= "Set USB input endpoint",
939 .name
= "vsllink_usb_bulkout",
940 .handler
= &vsllink_handle_usb_bulkout_command
,
941 .mode
= COMMAND_CONFIG
,
942 .help
= "Set USB output endpoint",
946 .name
= "vsllink_usb_interface",
947 .handler
= &vsllink_handle_usb_interface_command
,
948 .mode
= COMMAND_CONFIG
,
949 .help
= "Set USB output interface",
950 .usage
= "<interface>",
952 COMMAND_REGISTRATION_DONE
955 static const char * const vsllink_transports
[] = {"jtag", "swd", NULL
};
957 static const struct swd_driver vsllink_swd_driver
= {
958 .init
= vsllink_swd_init
,
959 .switch_seq
= vsllink_swd_switch_seq
,
960 .read_reg
= vsllink_swd_read_reg
,
961 .write_reg
= vsllink_swd_write_reg
,
962 .run
= vsllink_swd_run_queue
,
965 struct jtag_interface vsllink_interface
= {
967 .supported
= DEBUG_CAP_TMS_SEQ
,
968 .commands
= vsllink_command_handlers
,
969 .transports
= vsllink_transports
,
970 .swd
= &vsllink_swd_driver
,
972 .init
= vsllink_init
,
973 .quit
= vsllink_quit
,
975 .speed
= vsllink_speed
,
976 .speed_div
= vsllink_speed_div
,
977 .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)