1 /***************************************************************************
2 * Copyright (C) 2011-2013 by Martin Schmoelzer *
3 * <martin.schmoelzer@student.tuwien.ac.at> *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
17 ***************************************************************************/
24 #include <jtag/interface.h>
25 #include <jtag/commands.h>
26 #include <target/image.h>
28 #include "libusb_helper.h"
29 #include "OpenULINK/include/msgtypes.h"
31 /** USB Vendor ID of ULINK device in unconfigured state (no firmware loaded
32 * yet) or with OpenULINK firmware. */
33 #define ULINK_VID 0xC251
35 /** USB Product ID of ULINK device in unconfigured state (no firmware loaded
36 * yet) or with OpenULINK firmware. */
37 #define ULINK_PID 0x2710
39 /** Address of EZ-USB CPU Control & Status register. This register can be
40 * written by issuing a Control EP0 vendor request. */
41 #define CPUCS_REG 0x7F92
43 /** USB Control EP0 bRequest: "Firmware Load". */
44 #define REQUEST_FIRMWARE_LOAD 0xA0
46 /** Value to write into CPUCS to put EZ-USB into reset. */
47 #define CPU_RESET 0x01
49 /** Value to write into CPUCS to put EZ-USB out of reset. */
50 #define CPU_START 0x00
52 /** Base address of firmware in EZ-USB code space. */
53 #define FIRMWARE_ADDR 0x0000
55 /** USB interface number */
56 #define USB_INTERFACE 0
58 /** libusb timeout in ms */
59 #define USB_TIMEOUT 5000
61 /** Delay (in microseconds) to wait while EZ-USB performs ReNumeration. */
62 #define ULINK_RENUMERATION_DELAY 1500000
64 /** Default location of OpenULINK firmware image. */
65 #define ULINK_FIRMWARE_FILE PKGDATADIR "/OpenULINK/ulink_firmware.hex"
67 /** Maximum size of a single firmware section. Entire EZ-USB code space = 8kB */
68 #define SECTION_BUFFERSIZE 8192
70 /** Tuning of OpenOCD SCAN commands split into multiple OpenULINK commands. */
71 #define SPLIT_SCAN_THRESHOLD 10
73 /** ULINK hardware type */
75 /** Original ULINK adapter, based on Cypress EZ-USB (AN2131):
76 * Full JTAG support, no SWD support. */
79 /** Newer ULINK adapter, based on NXP LPC2148. Currently unsupported. */
82 /** Newer ULINK adapter, based on EZ-USB FX2 + FPGA. Currently unsupported. */
85 /** Newer ULINK adapter, possibly based on ULINK 2. Currently unsupported. */
89 enum ulink_payload_direction
{
90 PAYLOAD_DIRECTION_OUT
,
94 enum ulink_delay_type
{
103 * OpenULINK command (OpenULINK command queue element).
105 * For the OUT direction payload, things are quite easy: Payload is stored
106 * in a rather small array (up to 63 bytes), the payload is always allocated
107 * by the function generating the command and freed by ulink_clear_queue().
109 * For the IN direction payload, things get a little bit more complicated:
110 * The maximum IN payload size for a single command is 64 bytes. Assume that
111 * a single OpenOCD command needs to scan 256 bytes. This results in the
112 * generation of four OpenULINK commands. The function generating these
113 * commands shall allocate an uint8_t[256] array. Each command's #payload_in
114 * pointer shall point to the corresponding offset where IN data shall be
115 * placed, while #payload_in_start shall point to the first element of the 256
117 * - first command: #payload_in_start + 0
118 * - second command: #payload_in_start + 64
119 * - third command: #payload_in_start + 128
120 * - fourth command: #payload_in_start + 192
122 * The last command sets #needs_postprocessing to true.
125 uint8_t id
; /**< ULINK command ID */
127 uint8_t *payload_out
; /**< OUT direction payload data */
128 uint8_t payload_out_size
; /**< OUT direction payload size for this command */
130 uint8_t *payload_in_start
; /**< Pointer to first element of IN payload array */
131 uint8_t *payload_in
; /**< Pointer where IN payload shall be stored */
132 uint8_t payload_in_size
; /**< IN direction payload size for this command */
134 /** Indicates if this command needs post-processing */
135 bool needs_postprocessing
;
137 /** Indicates if ulink_clear_queue() should free payload_in_start */
138 bool free_payload_in_start
;
140 /** Pointer to corresponding OpenOCD command for post-processing */
141 struct jtag_command
*cmd_origin
;
143 struct ulink_cmd
*next
; /**< Pointer to next command (linked list) */
146 /** Describes one driver instance */
148 struct libusb_context
*libusb_ctx
;
149 struct libusb_device_handle
*usb_device_handle
;
150 enum ulink_type type
;
152 unsigned int ep_in
; /**< IN endpoint number */
153 unsigned int ep_out
; /**< OUT endpoint number */
155 int delay_scan_in
; /**< Delay value for SCAN_IN commands */
156 int delay_scan_out
; /**< Delay value for SCAN_OUT commands */
157 int delay_scan_io
; /**< Delay value for SCAN_IO commands */
158 int delay_clock_tck
; /**< Delay value for CLOCK_TMS commands */
159 int delay_clock_tms
; /**< Delay value for CLOCK_TCK commands */
161 int commands_in_queue
; /**< Number of commands in queue */
162 struct ulink_cmd
*queue_start
; /**< Pointer to first command in queue */
163 struct ulink_cmd
*queue_end
; /**< Pointer to last command in queue */
166 /**************************** Function Prototypes *****************************/
168 /* USB helper functions */
169 static int ulink_usb_open(struct ulink
**device
);
170 static int ulink_usb_close(struct ulink
**device
);
172 /* ULINK MCU (Cypress EZ-USB) specific functions */
173 static int ulink_cpu_reset(struct ulink
*device
, unsigned char reset_bit
);
174 static int ulink_load_firmware_and_renumerate(struct ulink
**device
, const char *filename
,
176 static int ulink_load_firmware(struct ulink
*device
, const char *filename
);
177 static int ulink_write_firmware_section(struct ulink
*device
,
178 struct image
*firmware_image
, int section_index
);
180 /* Generic helper functions */
181 static void ulink_print_signal_states(uint8_t input_signals
, uint8_t output_signals
);
183 /* OpenULINK command generation helper functions */
184 static int ulink_allocate_payload(struct ulink_cmd
*ulink_cmd
, int size
,
185 enum ulink_payload_direction direction
);
187 /* OpenULINK command queue helper functions */
188 static int ulink_get_queue_size(struct ulink
*device
,
189 enum ulink_payload_direction direction
);
190 static void ulink_clear_queue(struct ulink
*device
);
191 static int ulink_append_queue(struct ulink
*device
, struct ulink_cmd
*ulink_cmd
);
192 static int ulink_execute_queued_commands(struct ulink
*device
, int timeout
);
194 static void ulink_print_queue(struct ulink
*device
);
196 static int ulink_append_scan_cmd(struct ulink
*device
,
197 enum scan_type scan_type
,
202 uint8_t tms_count_start
,
203 uint8_t tms_sequence_start
,
204 uint8_t tms_count_end
,
205 uint8_t tms_sequence_end
,
206 struct jtag_command
*origin
,
208 static int ulink_append_clock_tms_cmd(struct ulink
*device
, uint8_t count
,
210 static int ulink_append_clock_tck_cmd(struct ulink
*device
, uint16_t count
);
211 static int ulink_append_get_signals_cmd(struct ulink
*device
);
212 static int ulink_append_set_signals_cmd(struct ulink
*device
, uint8_t low
,
214 static int ulink_append_sleep_cmd(struct ulink
*device
, uint32_t us
);
215 static int ulink_append_configure_tck_cmd(struct ulink
*device
,
221 static int __attribute__((unused
)) ulink_append_led_cmd(struct ulink
*device
, uint8_t led_state
);
222 static int ulink_append_test_cmd(struct ulink
*device
);
224 /* OpenULINK TCK frequency helper functions */
225 static int ulink_calculate_delay(enum ulink_delay_type type
, long f
, int *delay
);
227 /* Interface between OpenULINK and OpenOCD */
228 static void ulink_set_end_state(tap_state_t endstate
);
229 static int ulink_queue_statemove(struct ulink
*device
);
231 static int ulink_queue_scan(struct ulink
*device
, struct jtag_command
*cmd
);
232 static int ulink_queue_tlr_reset(struct ulink
*device
, struct jtag_command
*cmd
);
233 static int ulink_queue_runtest(struct ulink
*device
, struct jtag_command
*cmd
);
234 static int ulink_queue_reset(struct ulink
*device
, struct jtag_command
*cmd
);
235 static int ulink_queue_pathmove(struct ulink
*device
, struct jtag_command
*cmd
);
236 static int ulink_queue_sleep(struct ulink
*device
, struct jtag_command
*cmd
);
237 static int ulink_queue_stableclocks(struct ulink
*device
, struct jtag_command
*cmd
);
239 static int ulink_post_process_scan(struct ulink_cmd
*ulink_cmd
);
240 static int ulink_post_process_queue(struct ulink
*device
);
242 /* adapter driver functions */
243 static int ulink_execute_queue(void);
244 static int ulink_khz(int khz
, int *jtag_speed
);
245 static int ulink_speed(int speed
);
246 static int ulink_speed_div(int speed
, int *khz
);
247 static int ulink_init(void);
248 static int ulink_quit(void);
250 /****************************** Global Variables ******************************/
252 static struct ulink
*ulink_handle
;
254 /**************************** USB helper functions ****************************/
257 * Opens the ULINK device
259 * Currently, only the original ULINK is supported
261 * @param device pointer to struct ulink identifying ULINK driver instance.
262 * @return on success: ERROR_OK
263 * @return on failure: ERROR_FAIL
265 static int ulink_usb_open(struct ulink
**device
)
267 ssize_t num_devices
, i
;
269 libusb_device
**usb_devices
;
270 struct libusb_device_descriptor usb_desc
;
271 struct libusb_device_handle
*usb_device_handle
;
273 num_devices
= libusb_get_device_list((*device
)->libusb_ctx
, &usb_devices
);
275 if (num_devices
<= 0)
279 for (i
= 0; i
< num_devices
; i
++) {
280 if (libusb_get_device_descriptor(usb_devices
[i
], &usb_desc
) != 0)
282 else if (usb_desc
.idVendor
== ULINK_VID
&& usb_desc
.idProduct
== ULINK_PID
) {
291 if (libusb_open(usb_devices
[i
], &usb_device_handle
) != 0)
293 libusb_free_device_list(usb_devices
, 1);
295 (*device
)->usb_device_handle
= usb_device_handle
;
296 (*device
)->type
= ULINK_1
;
302 * Releases the ULINK interface and closes the USB device handle.
304 * @param device pointer to struct ulink identifying ULINK driver instance.
305 * @return on success: ERROR_OK
306 * @return on failure: ERROR_FAIL
308 static int ulink_usb_close(struct ulink
**device
)
310 if (libusb_release_interface((*device
)->usb_device_handle
, 0) != 0)
313 libusb_close((*device
)->usb_device_handle
);
315 (*device
)->usb_device_handle
= NULL
;
320 /******************* ULINK CPU (EZ-USB) specific functions ********************/
323 * Writes '0' or '1' to the CPUCS register, putting the EZ-USB CPU into reset
326 * @param device pointer to struct ulink identifying ULINK driver instance.
327 * @param reset_bit 0 to put CPU into reset, 1 to put CPU out of reset.
328 * @return on success: ERROR_OK
329 * @return on failure: ERROR_FAIL
331 static int ulink_cpu_reset(struct ulink
*device
, unsigned char reset_bit
)
335 ret
= libusb_control_transfer(device
->usb_device_handle
,
336 (LIBUSB_ENDPOINT_OUT
| LIBUSB_REQUEST_TYPE_VENDOR
| LIBUSB_RECIPIENT_DEVICE
),
337 REQUEST_FIRMWARE_LOAD
, CPUCS_REG
, 0, &reset_bit
, 1, USB_TIMEOUT
);
339 /* usb_control_msg() returns the number of bytes transferred during the
340 * DATA stage of the control transfer - must be exactly 1 in this case! */
347 * Puts the ULINK's EZ-USB microcontroller into reset state, downloads
348 * the firmware image, resumes the microcontroller and re-enumerates
351 * @param device pointer to struct ulink identifying ULINK driver instance.
352 * The usb_handle member will be modified during re-enumeration.
353 * @param filename path to the Intel HEX file containing the firmware image.
354 * @param delay the delay to wait for the device to re-enumerate.
355 * @return on success: ERROR_OK
356 * @return on failure: ERROR_FAIL
358 static int ulink_load_firmware_and_renumerate(struct ulink
**device
,
359 const char *filename
, uint32_t delay
)
363 /* Basic process: After downloading the firmware, the ULINK will disconnect
364 * itself and re-connect after a short amount of time so we have to close
365 * the handle and re-enumerate USB devices */
367 ret
= ulink_load_firmware(*device
, filename
);
371 ret
= ulink_usb_close(device
);
377 ret
= ulink_usb_open(device
);
385 * Downloads a firmware image to the ULINK's EZ-USB microcontroller
388 * @param device pointer to struct ulink identifying ULINK driver instance.
389 * @param filename an absolute or relative path to the Intel HEX file
390 * containing the firmware image.
391 * @return on success: ERROR_OK
392 * @return on failure: ERROR_FAIL
394 static int ulink_load_firmware(struct ulink
*device
, const char *filename
)
396 struct image ulink_firmware_image
;
399 ret
= ulink_cpu_reset(device
, CPU_RESET
);
400 if (ret
!= ERROR_OK
) {
401 LOG_ERROR("Could not halt ULINK CPU");
405 ulink_firmware_image
.base_address
= 0;
406 ulink_firmware_image
.base_address_set
= false;
408 ret
= image_open(&ulink_firmware_image
, filename
, "ihex");
409 if (ret
!= ERROR_OK
) {
410 LOG_ERROR("Could not load firmware image");
414 /* Download all sections in the image to ULINK */
415 for (unsigned int i
= 0; i
< ulink_firmware_image
.num_sections
; i
++) {
416 ret
= ulink_write_firmware_section(device
, &ulink_firmware_image
, i
);
421 image_close(&ulink_firmware_image
);
423 ret
= ulink_cpu_reset(device
, CPU_START
);
424 if (ret
!= ERROR_OK
) {
425 LOG_ERROR("Could not restart ULINK CPU");
433 * Send one contiguous firmware section to the ULINK's EZ-USB microcontroller
436 * @param device pointer to struct ulink identifying ULINK driver instance.
437 * @param firmware_image pointer to the firmware image that contains the section
438 * which should be sent to the ULINK's EZ-USB microcontroller.
439 * @param section_index index of the section within the firmware image.
440 * @return on success: ERROR_OK
441 * @return on failure: ERROR_FAIL
443 static int ulink_write_firmware_section(struct ulink
*device
,
444 struct image
*firmware_image
, int section_index
)
446 uint16_t addr
, size
, bytes_remaining
, chunk_size
;
447 uint8_t data
[SECTION_BUFFERSIZE
];
448 uint8_t *data_ptr
= data
;
452 size
= (uint16_t)firmware_image
->sections
[section_index
].size
;
453 addr
= (uint16_t)firmware_image
->sections
[section_index
].base_address
;
455 LOG_DEBUG("section %02i at addr 0x%04x (size 0x%04x)", section_index
, addr
,
458 /* Copy section contents to local buffer */
459 ret
= image_read_section(firmware_image
, section_index
, 0, size
, data
,
462 if ((ret
!= ERROR_OK
) || (size_read
!= size
)) {
463 /* Propagating the return code would return '0' (misleadingly indicating
464 * successful execution of the function) if only the size check fails. */
468 bytes_remaining
= size
;
470 /* Send section data in chunks of up to 64 bytes to ULINK */
471 while (bytes_remaining
> 0) {
472 if (bytes_remaining
> 64)
475 chunk_size
= bytes_remaining
;
477 ret
= libusb_control_transfer(device
->usb_device_handle
,
478 (LIBUSB_ENDPOINT_OUT
| LIBUSB_REQUEST_TYPE_VENDOR
| LIBUSB_RECIPIENT_DEVICE
),
479 REQUEST_FIRMWARE_LOAD
, addr
, FIRMWARE_ADDR
, (unsigned char *)data_ptr
,
480 chunk_size
, USB_TIMEOUT
);
482 if (ret
!= (int)chunk_size
) {
483 /* Abort if libusb sent less data than requested */
487 bytes_remaining
-= chunk_size
;
489 data_ptr
+= chunk_size
;
495 /************************** Generic helper functions **************************/
498 * Print state of interesting signals via LOG_INFO().
500 * @param input_signals input signal states as returned by CMD_GET_SIGNALS
501 * @param output_signals output signal states as returned by CMD_GET_SIGNALS
503 static void ulink_print_signal_states(uint8_t input_signals
, uint8_t output_signals
)
505 LOG_INFO("ULINK signal states: TDI: %i, TDO: %i, TMS: %i, TCK: %i, TRST: %i,"
507 (output_signals
& SIGNAL_TDI
? 1 : 0),
508 (input_signals
& SIGNAL_TDO
? 1 : 0),
509 (output_signals
& SIGNAL_TMS
? 1 : 0),
510 (output_signals
& SIGNAL_TCK
? 1 : 0),
511 (output_signals
& SIGNAL_TRST
? 0 : 1), /* Inverted by hardware */
512 (output_signals
& SIGNAL_RESET
? 0 : 1)); /* Inverted by hardware */
515 /**************** OpenULINK command generation helper functions ***************/
518 * Allocate and initialize space in memory for OpenULINK command payload.
520 * @param ulink_cmd pointer to command whose payload should be allocated.
521 * @param size the amount of memory to allocate (bytes).
522 * @param direction which payload to allocate.
523 * @return on success: ERROR_OK
524 * @return on failure: ERROR_FAIL
526 static int ulink_allocate_payload(struct ulink_cmd
*ulink_cmd
, int size
,
527 enum ulink_payload_direction direction
)
531 payload
= calloc(size
, sizeof(uint8_t));
533 if (payload
== NULL
) {
534 LOG_ERROR("Could not allocate OpenULINK command payload: out of memory");
539 case PAYLOAD_DIRECTION_OUT
:
540 if (ulink_cmd
->payload_out
!= NULL
) {
541 LOG_ERROR("BUG: Duplicate payload allocation for OpenULINK command");
545 ulink_cmd
->payload_out
= payload
;
546 ulink_cmd
->payload_out_size
= size
;
549 case PAYLOAD_DIRECTION_IN
:
550 if (ulink_cmd
->payload_in_start
!= NULL
) {
551 LOG_ERROR("BUG: Duplicate payload allocation for OpenULINK command");
555 ulink_cmd
->payload_in_start
= payload
;
556 ulink_cmd
->payload_in
= payload
;
557 ulink_cmd
->payload_in_size
= size
;
559 /* By default, free payload_in_start in ulink_clear_queue(). Commands
560 * that do not want this behavior (e. g. split scans) must turn it off
562 ulink_cmd
->free_payload_in_start
= true;
570 /****************** OpenULINK command queue helper functions ******************/
573 * Get the current number of bytes in the queue, including command IDs.
575 * @param device pointer to struct ulink identifying ULINK driver instance.
576 * @param direction the transfer direction for which to get byte count.
577 * @return the number of bytes currently stored in the queue for the specified
580 static int ulink_get_queue_size(struct ulink
*device
,
581 enum ulink_payload_direction direction
)
583 struct ulink_cmd
*current
= device
->queue_start
;
586 while (current
!= NULL
) {
588 case PAYLOAD_DIRECTION_OUT
:
589 sum
+= current
->payload_out_size
+ 1; /* + 1 byte for Command ID */
591 case PAYLOAD_DIRECTION_IN
:
592 sum
+= current
->payload_in_size
;
596 current
= current
->next
;
603 * Clear the OpenULINK command queue.
605 * @param device pointer to struct ulink identifying ULINK driver instance.
606 * @return on success: ERROR_OK
607 * @return on failure: ERROR_FAIL
609 static void ulink_clear_queue(struct ulink
*device
)
611 struct ulink_cmd
*current
= device
->queue_start
;
612 struct ulink_cmd
*next
= NULL
;
614 while (current
!= NULL
) {
615 /* Save pointer to next element */
616 next
= current
->next
;
618 /* Free payloads: OUT payload can be freed immediately */
619 free(current
->payload_out
);
620 current
->payload_out
= NULL
;
622 /* IN payload MUST be freed ONLY if no other commands use the
623 * payload_in_start buffer */
624 if (current
->free_payload_in_start
== true) {
625 free(current
->payload_in_start
);
626 current
->payload_in_start
= NULL
;
627 current
->payload_in
= NULL
;
630 /* Free queue element */
633 /* Proceed with next element */
637 device
->commands_in_queue
= 0;
638 device
->queue_start
= NULL
;
639 device
->queue_end
= NULL
;
643 * Add a command to the OpenULINK command queue.
645 * @param device pointer to struct ulink identifying ULINK driver instance.
646 * @param ulink_cmd pointer to command that shall be appended to the OpenULINK
648 * @return on success: ERROR_OK
649 * @return on failure: ERROR_FAIL
651 static int ulink_append_queue(struct ulink
*device
, struct ulink_cmd
*ulink_cmd
)
653 int newsize_out
, newsize_in
;
656 newsize_out
= ulink_get_queue_size(device
, PAYLOAD_DIRECTION_OUT
) + 1
657 + ulink_cmd
->payload_out_size
;
659 newsize_in
= ulink_get_queue_size(device
, PAYLOAD_DIRECTION_IN
)
660 + ulink_cmd
->payload_in_size
;
662 /* Check if the current command can be appended to the queue */
663 if ((newsize_out
> 64) || (newsize_in
> 64)) {
664 /* New command does not fit. Execute all commands in queue before starting
665 * new queue with the current command as first entry. */
666 ret
= ulink_execute_queued_commands(device
, USB_TIMEOUT
);
669 ret
= ulink_post_process_queue(device
);
672 ulink_clear_queue(device
);
675 if (device
->queue_start
== NULL
) {
676 /* Queue was empty */
677 device
->commands_in_queue
= 1;
679 device
->queue_start
= ulink_cmd
;
680 device
->queue_end
= ulink_cmd
;
682 /* There are already commands in the queue */
683 device
->commands_in_queue
++;
685 device
->queue_end
->next
= ulink_cmd
;
686 device
->queue_end
= ulink_cmd
;
690 ulink_clear_queue(device
);
696 * Sends all queued OpenULINK commands to the ULINK for execution.
698 * @param device pointer to struct ulink identifying ULINK driver instance.
699 * @return on success: ERROR_OK
700 * @return on failure: ERROR_FAIL
702 static int ulink_execute_queued_commands(struct ulink
*device
, int timeout
)
704 struct ulink_cmd
*current
;
705 int ret
, i
, index_out
, index_in
, count_out
, count_in
, transferred
;
708 if (LOG_LEVEL_IS(LOG_LVL_DEBUG_IO
))
709 ulink_print_queue(device
);
715 for (current
= device
->queue_start
; current
; current
= current
->next
) {
716 /* Add command to packet */
717 buffer
[index_out
] = current
->id
;
721 for (i
= 0; i
< current
->payload_out_size
; i
++)
722 buffer
[index_out
+ i
] = current
->payload_out
[i
];
723 index_out
+= current
->payload_out_size
;
724 count_in
+= current
->payload_in_size
;
725 count_out
+= current
->payload_out_size
;
728 /* Send packet to ULINK */
729 ret
= libusb_bulk_transfer(device
->usb_device_handle
, device
->ep_out
,
730 (unsigned char *)buffer
, count_out
, &transferred
, timeout
);
733 if (transferred
!= count_out
)
736 /* Wait for response if commands contain IN payload data */
738 ret
= libusb_bulk_transfer(device
->usb_device_handle
, device
->ep_in
,
739 (unsigned char *)buffer
, 64, &transferred
, timeout
);
742 if (transferred
!= count_in
)
745 /* Write back IN payload data */
747 for (current
= device
->queue_start
; current
; current
= current
->next
) {
748 for (i
= 0; i
< current
->payload_in_size
; i
++) {
749 current
->payload_in
[i
] = buffer
[index_in
];
759 * Convert an OpenULINK command ID (\a id) to a human-readable string.
761 * @param id the OpenULINK command ID.
762 * @return the corresponding human-readable string.
764 static const char *ulink_cmd_id_string(uint8_t id
)
768 return "CMD_SCAN_IN";
769 case CMD_SLOW_SCAN_IN
:
770 return "CMD_SLOW_SCAN_IN";
772 return "CMD_SCAN_OUT";
773 case CMD_SLOW_SCAN_OUT
:
774 return "CMD_SLOW_SCAN_OUT";
776 return "CMD_SCAN_IO";
777 case CMD_SLOW_SCAN_IO
:
778 return "CMD_SLOW_SCAN_IO";
780 return "CMD_CLOCK_TMS";
781 case CMD_SLOW_CLOCK_TMS
:
782 return "CMD_SLOW_CLOCK_TMS";
784 return "CMD_CLOCK_TCK";
785 case CMD_SLOW_CLOCK_TCK
:
786 return "CMD_SLOW_CLOCK_TCK";
788 return "CMD_SLEEP_US";
790 return "CMD_SLEEP_MS";
791 case CMD_GET_SIGNALS
:
792 return "CMD_GET_SIGNALS";
793 case CMD_SET_SIGNALS
:
794 return "CMD_SET_SIGNALS";
795 case CMD_CONFIGURE_TCK_FREQ
:
796 return "CMD_CONFIGURE_TCK_FREQ";
798 return "CMD_SET_LEDS";
802 return "CMD_UNKNOWN";
807 * Print one OpenULINK command to stdout.
809 * @param ulink_cmd pointer to OpenULINK command.
811 static void ulink_print_command(struct ulink_cmd
*ulink_cmd
)
815 printf(" %-22s | OUT size = %i, bytes = 0x",
816 ulink_cmd_id_string(ulink_cmd
->id
), ulink_cmd
->payload_out_size
);
818 for (i
= 0; i
< ulink_cmd
->payload_out_size
; i
++)
819 printf("%02X ", ulink_cmd
->payload_out
[i
]);
820 printf("\n | IN size = %i\n",
821 ulink_cmd
->payload_in_size
);
825 * Print the OpenULINK command queue to stdout.
827 * @param device pointer to struct ulink identifying ULINK driver instance.
829 static void ulink_print_queue(struct ulink
*device
)
831 struct ulink_cmd
*current
;
833 printf("OpenULINK command queue:\n");
835 for (current
= device
->queue_start
; current
; current
= current
->next
)
836 ulink_print_command(current
);
842 * Creates and appends a JTAG scan command to the OpenULINK command queue.
843 * A JTAG scan consists of three steps:
844 * - Move to the desired SHIFT state, depending on scan type (IR/DR scan).
845 * - Shift TDI data into the JTAG chain, optionally reading the TDO pin.
846 * - Move to the desired end state.
848 * @param device pointer to struct ulink identifying ULINK driver instance.
849 * @param scan_type the type of the scan (IN, OUT, IO (bidirectional)).
850 * @param scan_size_bits number of bits to shift into the JTAG chain.
851 * @param tdi pointer to array containing TDI data.
852 * @param tdo_start pointer to first element of array where TDO data shall be
853 * stored. See #ulink_cmd for details.
854 * @param tdo pointer to array where TDO data shall be stored
855 * @param tms_count_start number of TMS state transitions to perform BEFORE
856 * shifting data into the JTAG chain.
857 * @param tms_sequence_start sequence of TMS state transitions that will be
858 * performed BEFORE shifting data into the JTAG chain.
859 * @param tms_count_end number of TMS state transitions to perform AFTER
860 * shifting data into the JTAG chain.
861 * @param tms_sequence_end sequence of TMS state transitions that will be
862 * performed AFTER shifting data into the JTAG chain.
863 * @param origin pointer to OpenOCD command that generated this scan command.
864 * @param postprocess whether this command needs to be post-processed after
866 * @return on success: ERROR_OK
867 * @return on failure: ERROR_FAIL
869 static int ulink_append_scan_cmd(struct ulink
*device
, enum scan_type scan_type
,
870 int scan_size_bits
, uint8_t *tdi
, uint8_t *tdo_start
, uint8_t *tdo
,
871 uint8_t tms_count_start
, uint8_t tms_sequence_start
, uint8_t tms_count_end
,
872 uint8_t tms_sequence_end
, struct jtag_command
*origin
, bool postprocess
)
874 struct ulink_cmd
*cmd
= calloc(1, sizeof(struct ulink_cmd
));
875 int ret
, i
, scan_size_bytes
;
876 uint8_t bits_last_byte
;
881 /* Check size of command. USB buffer can hold 64 bytes, 1 byte is command ID,
882 * 5 bytes are setup data -> 58 remaining payload bytes for TDI data */
883 if (scan_size_bits
> (58 * 8)) {
884 LOG_ERROR("BUG: Tried to create CMD_SCAN_IO OpenULINK command with too"
890 scan_size_bytes
= DIV_ROUND_UP(scan_size_bits
, 8);
892 bits_last_byte
= scan_size_bits
% 8;
893 if (bits_last_byte
== 0)
896 /* Allocate out_payload depending on scan type */
899 if (device
->delay_scan_in
< 0)
900 cmd
->id
= CMD_SCAN_IN
;
902 cmd
->id
= CMD_SLOW_SCAN_IN
;
903 ret
= ulink_allocate_payload(cmd
, 5, PAYLOAD_DIRECTION_OUT
);
906 if (device
->delay_scan_out
< 0)
907 cmd
->id
= CMD_SCAN_OUT
;
909 cmd
->id
= CMD_SLOW_SCAN_OUT
;
910 ret
= ulink_allocate_payload(cmd
, scan_size_bytes
+ 5, PAYLOAD_DIRECTION_OUT
);
913 if (device
->delay_scan_io
< 0)
914 cmd
->id
= CMD_SCAN_IO
;
916 cmd
->id
= CMD_SLOW_SCAN_IO
;
917 ret
= ulink_allocate_payload(cmd
, scan_size_bytes
+ 5, PAYLOAD_DIRECTION_OUT
);
920 LOG_ERROR("BUG: ulink_append_scan_cmd() encountered an unknown scan type");
925 if (ret
!= ERROR_OK
) {
930 /* Build payload_out that is common to all scan types */
931 cmd
->payload_out
[0] = scan_size_bytes
& 0xFF;
932 cmd
->payload_out
[1] = bits_last_byte
& 0xFF;
933 cmd
->payload_out
[2] = ((tms_count_start
& 0x0F) << 4) | (tms_count_end
& 0x0F);
934 cmd
->payload_out
[3] = tms_sequence_start
;
935 cmd
->payload_out
[4] = tms_sequence_end
;
937 /* Setup payload_out for types with OUT transfer */
938 if ((scan_type
== SCAN_OUT
) || (scan_type
== SCAN_IO
)) {
939 for (i
= 0; i
< scan_size_bytes
; i
++)
940 cmd
->payload_out
[i
+ 5] = tdi
[i
];
943 /* Setup payload_in pointers for types with IN transfer */
944 if ((scan_type
== SCAN_IN
) || (scan_type
== SCAN_IO
)) {
945 cmd
->payload_in_start
= tdo_start
;
946 cmd
->payload_in
= tdo
;
947 cmd
->payload_in_size
= scan_size_bytes
;
950 cmd
->needs_postprocessing
= postprocess
;
951 cmd
->cmd_origin
= origin
;
953 /* For scan commands, we free payload_in_start only when the command is
954 * the last in a series of split commands or a stand-alone command */
955 cmd
->free_payload_in_start
= postprocess
;
957 return ulink_append_queue(device
, cmd
);
961 * Perform TAP state transitions
963 * @param device pointer to struct ulink identifying ULINK driver instance.
964 * @param count defines the number of TCK clock cycles generated (up to 8).
965 * @param sequence defines the TMS pin levels for each state transition. The
966 * Least-Significant Bit is read first.
967 * @return on success: ERROR_OK
968 * @return on failure: ERROR_FAIL
970 static int ulink_append_clock_tms_cmd(struct ulink
*device
, uint8_t count
,
973 struct ulink_cmd
*cmd
= calloc(1, sizeof(struct ulink_cmd
));
979 if (device
->delay_clock_tms
< 0)
980 cmd
->id
= CMD_CLOCK_TMS
;
982 cmd
->id
= CMD_SLOW_CLOCK_TMS
;
984 /* CMD_CLOCK_TMS has two OUT payload bytes and zero IN payload bytes */
985 ret
= ulink_allocate_payload(cmd
, 2, PAYLOAD_DIRECTION_OUT
);
986 if (ret
!= ERROR_OK
) {
991 cmd
->payload_out
[0] = count
;
992 cmd
->payload_out
[1] = sequence
;
994 return ulink_append_queue(device
, cmd
);
998 * Generate a defined amount of TCK clock cycles
1000 * All other JTAG signals are left unchanged.
1002 * @param device pointer to struct ulink identifying ULINK driver instance.
1003 * @param count the number of TCK clock cycles to generate.
1004 * @return on success: ERROR_OK
1005 * @return on failure: ERROR_FAIL
1007 static int ulink_append_clock_tck_cmd(struct ulink
*device
, uint16_t count
)
1009 struct ulink_cmd
*cmd
= calloc(1, sizeof(struct ulink_cmd
));
1015 if (device
->delay_clock_tck
< 0)
1016 cmd
->id
= CMD_CLOCK_TCK
;
1018 cmd
->id
= CMD_SLOW_CLOCK_TCK
;
1020 /* CMD_CLOCK_TCK has two OUT payload bytes and zero IN payload bytes */
1021 ret
= ulink_allocate_payload(cmd
, 2, PAYLOAD_DIRECTION_OUT
);
1022 if (ret
!= ERROR_OK
) {
1027 cmd
->payload_out
[0] = count
& 0xff;
1028 cmd
->payload_out
[1] = (count
>> 8) & 0xff;
1030 return ulink_append_queue(device
, cmd
);
1034 * Read JTAG signals.
1036 * @param device pointer to struct ulink identifying ULINK driver instance.
1037 * @return on success: ERROR_OK
1038 * @return on failure: ERROR_FAIL
1040 static int ulink_append_get_signals_cmd(struct ulink
*device
)
1042 struct ulink_cmd
*cmd
= calloc(1, sizeof(struct ulink_cmd
));
1048 cmd
->id
= CMD_GET_SIGNALS
;
1049 cmd
->needs_postprocessing
= true;
1051 /* CMD_GET_SIGNALS has two IN payload bytes */
1052 ret
= ulink_allocate_payload(cmd
, 2, PAYLOAD_DIRECTION_IN
);
1054 if (ret
!= ERROR_OK
) {
1059 return ulink_append_queue(device
, cmd
);
1063 * Arbitrarily set JTAG output signals.
1065 * @param device pointer to struct ulink identifying ULINK driver instance.
1066 * @param low defines which signals will be de-asserted. Each bit corresponds
1075 * @param high defines which signals will be asserted.
1076 * @return on success: ERROR_OK
1077 * @return on failure: ERROR_FAIL
1079 static int ulink_append_set_signals_cmd(struct ulink
*device
, uint8_t low
,
1082 struct ulink_cmd
*cmd
= calloc(1, sizeof(struct ulink_cmd
));
1088 cmd
->id
= CMD_SET_SIGNALS
;
1090 /* CMD_SET_SIGNALS has two OUT payload bytes and zero IN payload bytes */
1091 ret
= ulink_allocate_payload(cmd
, 2, PAYLOAD_DIRECTION_OUT
);
1093 if (ret
!= ERROR_OK
) {
1098 cmd
->payload_out
[0] = low
;
1099 cmd
->payload_out
[1] = high
;
1101 return ulink_append_queue(device
, cmd
);
1105 * Sleep for a pre-defined number of microseconds
1107 * @param device pointer to struct ulink identifying ULINK driver instance.
1108 * @param us the number microseconds to sleep.
1109 * @return on success: ERROR_OK
1110 * @return on failure: ERROR_FAIL
1112 static int ulink_append_sleep_cmd(struct ulink
*device
, uint32_t us
)
1114 struct ulink_cmd
*cmd
= calloc(1, sizeof(struct ulink_cmd
));
1120 cmd
->id
= CMD_SLEEP_US
;
1122 /* CMD_SLEEP_US has two OUT payload bytes and zero IN payload bytes */
1123 ret
= ulink_allocate_payload(cmd
, 2, PAYLOAD_DIRECTION_OUT
);
1125 if (ret
!= ERROR_OK
) {
1130 cmd
->payload_out
[0] = us
& 0x00ff;
1131 cmd
->payload_out
[1] = (us
>> 8) & 0x00ff;
1133 return ulink_append_queue(device
, cmd
);
1137 * Set TCK delay counters
1139 * @param device pointer to struct ulink identifying ULINK driver instance.
1140 * @param delay_scan_in delay count top value in jtag_slow_scan_in() function.
1141 * @param delay_scan_out delay count top value in jtag_slow_scan_out() function.
1142 * @param delay_scan_io delay count top value in jtag_slow_scan_io() function.
1143 * @param delay_tck delay count top value in jtag_clock_tck() function.
1144 * @param delay_tms delay count top value in jtag_slow_clock_tms() function.
1145 * @return on success: ERROR_OK
1146 * @return on failure: ERROR_FAIL
1148 static int ulink_append_configure_tck_cmd(struct ulink
*device
, int delay_scan_in
,
1149 int delay_scan_out
, int delay_scan_io
, int delay_tck
, int delay_tms
)
1151 struct ulink_cmd
*cmd
= calloc(1, sizeof(struct ulink_cmd
));
1157 cmd
->id
= CMD_CONFIGURE_TCK_FREQ
;
1159 /* CMD_CONFIGURE_TCK_FREQ has five OUT payload bytes and zero
1160 * IN payload bytes */
1161 ret
= ulink_allocate_payload(cmd
, 5, PAYLOAD_DIRECTION_OUT
);
1162 if (ret
!= ERROR_OK
) {
1167 if (delay_scan_in
< 0)
1168 cmd
->payload_out
[0] = 0;
1170 cmd
->payload_out
[0] = (uint8_t)delay_scan_in
;
1172 if (delay_scan_out
< 0)
1173 cmd
->payload_out
[1] = 0;
1175 cmd
->payload_out
[1] = (uint8_t)delay_scan_out
;
1177 if (delay_scan_io
< 0)
1178 cmd
->payload_out
[2] = 0;
1180 cmd
->payload_out
[2] = (uint8_t)delay_scan_io
;
1183 cmd
->payload_out
[3] = 0;
1185 cmd
->payload_out
[3] = (uint8_t)delay_tck
;
1188 cmd
->payload_out
[4] = 0;
1190 cmd
->payload_out
[4] = (uint8_t)delay_tms
;
1192 return ulink_append_queue(device
, cmd
);
1196 * Turn on/off ULINK LEDs.
1198 * @param device pointer to struct ulink identifying ULINK driver instance.
1199 * @param led_state which LED(s) to turn on or off. The following bits
1200 * influence the LEDS:
1201 * - Bit 0: Turn COM LED on
1202 * - Bit 1: Turn RUN LED on
1203 * - Bit 2: Turn COM LED off
1204 * - Bit 3: Turn RUN LED off
1205 * If both the on-bit and the off-bit for the same LED is set, the LED is
1207 * @return on success: ERROR_OK
1208 * @return on failure: ERROR_FAIL
1210 static int ulink_append_led_cmd(struct ulink
*device
, uint8_t led_state
)
1212 struct ulink_cmd
*cmd
= calloc(1, sizeof(struct ulink_cmd
));
1218 cmd
->id
= CMD_SET_LEDS
;
1220 /* CMD_SET_LEDS has one OUT payload byte and zero IN payload bytes */
1221 ret
= ulink_allocate_payload(cmd
, 1, PAYLOAD_DIRECTION_OUT
);
1222 if (ret
!= ERROR_OK
) {
1227 cmd
->payload_out
[0] = led_state
;
1229 return ulink_append_queue(device
, cmd
);
1233 * Test command. Used to check if the ULINK device is ready to accept new
1236 * @param device pointer to struct ulink identifying ULINK driver instance.
1237 * @return on success: ERROR_OK
1238 * @return on failure: ERROR_FAIL
1240 static int ulink_append_test_cmd(struct ulink
*device
)
1242 struct ulink_cmd
*cmd
= calloc(1, sizeof(struct ulink_cmd
));
1250 /* CMD_TEST has one OUT payload byte and zero IN payload bytes */
1251 ret
= ulink_allocate_payload(cmd
, 1, PAYLOAD_DIRECTION_OUT
);
1252 if (ret
!= ERROR_OK
) {
1257 cmd
->payload_out
[0] = 0xAA;
1259 return ulink_append_queue(device
, cmd
);
1262 /****************** OpenULINK TCK frequency helper functions ******************/
1265 * Calculate delay values for a given TCK frequency.
1267 * The OpenULINK firmware uses five different speed values for different
1268 * commands. These speed values are calculated in these functions.
1270 * The five different commands which support variable TCK frequency are
1271 * implemented twice in the firmware:
1272 * 1. Maximum possible frequency without any artificial delay
1273 * 2. Variable frequency with artificial linear delay loop
1275 * To set the ULINK to maximum frequency, it is only necessary to use the
1276 * corresponding command IDs. To set the ULINK to a lower frequency, the
1277 * delay loop top values have to be calculated first. Then, a
1278 * CMD_CONFIGURE_TCK_FREQ command needs to be sent to the ULINK device.
1280 * The delay values are described by linear equations:
1282 * (t = period, k = constant, x = delay value, d = constant)
1284 * Thus, the delay can be calculated as in the following equation:
1287 * The constants in these equations have been determined and validated by
1288 * measuring the frequency resulting from different delay values.
1290 * @param type for which command to calculate the delay value.
1291 * @param f TCK frequency for which to calculate the delay value in Hz.
1292 * @param delay where to store resulting delay value.
1293 * @return on success: ERROR_OK
1294 * @return on failure: ERROR_FAIL
1296 static int ulink_calculate_delay(enum ulink_delay_type type
, long f
, int *delay
)
1300 /* Calculate period of requested TCK frequency */
1301 t
= 1.0 / (float)(f
);
1304 case DELAY_CLOCK_TCK
:
1305 x
= (t
- (float)(6E-6)) / (float)(4E-6);
1307 case DELAY_CLOCK_TMS
:
1308 x
= (t
- (float)(8.5E-6)) / (float)(4E-6);
1311 x
= (t
- (float)(8.8308E-6)) / (float)(4E-6);
1313 case DELAY_SCAN_OUT
:
1314 x
= (t
- (float)(1.0527E-5)) / (float)(4E-6);
1317 x
= (t
- (float)(1.3132E-5)) / (float)(4E-6);
1324 /* Check if the delay value is negative. This happens when a frequency is
1325 * requested that is too high for the delay loop implementation. In this
1326 * case, set delay value to zero. */
1330 /* We need to convert the exact delay value to an integer. Therefore, we
1331 * round the exact value UP to ensure that the resulting frequency is NOT
1332 * higher than the requested frequency. */
1335 /* Check if the value is within limits */
1339 *delay
= (int)x_ceil
;
1345 * Calculate frequency for a given delay value.
1347 * Similar to the #ulink_calculate_delay function, this function calculates the
1348 * TCK frequency for a given delay value by using linear equations of the form:
1350 * (t = period, k = constant, x = delay value, d = constant)
1352 * @param type for which command to calculate the delay value.
1353 * @param delay delay value for which to calculate the resulting TCK frequency.
1354 * @return the resulting TCK frequency
1356 static long ulink_calculate_frequency(enum ulink_delay_type type
, int delay
)
1364 case DELAY_CLOCK_TCK
:
1366 t
= (float)(2.666E-6);
1368 t
= (float)(4E-6) * (float)(delay
) + (float)(6E-6);
1370 case DELAY_CLOCK_TMS
:
1372 t
= (float)(5.666E-6);
1374 t
= (float)(4E-6) * (float)(delay
) + (float)(8.5E-6);
1378 t
= (float)(5.5E-6);
1380 t
= (float)(4E-6) * (float)(delay
) + (float)(8.8308E-6);
1382 case DELAY_SCAN_OUT
:
1384 t
= (float)(7.0E-6);
1386 t
= (float)(4E-6) * (float)(delay
) + (float)(1.0527E-5);
1390 t
= (float)(9.926E-6);
1392 t
= (float)(4E-6) * (float)(delay
) + (float)(1.3132E-5);
1399 return roundf(f_float
);
1402 /******************* Interface between OpenULINK and OpenOCD ******************/
1405 * Sets the end state follower (see interface.h) if \a endstate is a stable
1408 * @param endstate the state the end state follower should be set to.
1410 static void ulink_set_end_state(tap_state_t endstate
)
1412 if (tap_is_state_stable(endstate
))
1413 tap_set_end_state(endstate
);
1415 LOG_ERROR("BUG: %s is not a valid end state", tap_state_name(endstate
));
1421 * Move from the current TAP state to the current TAP end state.
1423 * @param device pointer to struct ulink identifying ULINK driver instance.
1424 * @return on success: ERROR_OK
1425 * @return on failure: ERROR_FAIL
1427 static int ulink_queue_statemove(struct ulink
*device
)
1429 uint8_t tms_sequence
, tms_count
;
1432 if (tap_get_state() == tap_get_end_state()) {
1433 /* Do nothing if we are already there */
1437 tms_sequence
= tap_get_tms_path(tap_get_state(), tap_get_end_state());
1438 tms_count
= tap_get_tms_path_len(tap_get_state(), tap_get_end_state());
1440 ret
= ulink_append_clock_tms_cmd(device
, tms_count
, tms_sequence
);
1442 if (ret
== ERROR_OK
)
1443 tap_set_state(tap_get_end_state());
1449 * Perform a scan operation on a JTAG register.
1451 * @param device pointer to struct ulink identifying ULINK driver instance.
1452 * @param cmd pointer to the command that shall be executed.
1453 * @return on success: ERROR_OK
1454 * @return on failure: ERROR_FAIL
1456 static int ulink_queue_scan(struct ulink
*device
, struct jtag_command
*cmd
)
1458 uint32_t scan_size_bits
, scan_size_bytes
, bits_last_scan
;
1459 uint32_t scans_max_payload
, bytecount
;
1460 uint8_t *tdi_buffer_start
= NULL
, *tdi_buffer
= NULL
;
1461 uint8_t *tdo_buffer_start
= NULL
, *tdo_buffer
= NULL
;
1463 uint8_t first_tms_count
, first_tms_sequence
;
1464 uint8_t last_tms_count
, last_tms_sequence
;
1466 uint8_t tms_count_pause
, tms_sequence_pause
;
1467 uint8_t tms_count_resume
, tms_sequence_resume
;
1469 uint8_t tms_count_start
, tms_sequence_start
;
1470 uint8_t tms_count_end
, tms_sequence_end
;
1472 enum scan_type type
;
1475 /* Determine scan size */
1476 scan_size_bits
= jtag_scan_size(cmd
->cmd
.scan
);
1477 scan_size_bytes
= DIV_ROUND_UP(scan_size_bits
, 8);
1479 /* Determine scan type (IN/OUT/IO) */
1480 type
= jtag_scan_type(cmd
->cmd
.scan
);
1482 /* Determine number of scan commands with maximum payload */
1483 scans_max_payload
= scan_size_bytes
/ 58;
1485 /* Determine size of last shift command */
1486 bits_last_scan
= scan_size_bits
- (scans_max_payload
* 58 * 8);
1488 /* Allocate TDO buffer if required */
1489 if ((type
== SCAN_IN
) || (type
== SCAN_IO
)) {
1490 tdo_buffer_start
= calloc(sizeof(uint8_t), scan_size_bytes
);
1492 if (tdo_buffer_start
== NULL
)
1495 tdo_buffer
= tdo_buffer_start
;
1498 /* Fill TDI buffer if required */
1499 if ((type
== SCAN_OUT
) || (type
== SCAN_IO
)) {
1500 jtag_build_buffer(cmd
->cmd
.scan
, &tdi_buffer_start
);
1501 tdi_buffer
= tdi_buffer_start
;
1504 /* Get TAP state transitions */
1505 if (cmd
->cmd
.scan
->ir_scan
) {
1506 ulink_set_end_state(TAP_IRSHIFT
);
1507 first_tms_count
= tap_get_tms_path_len(tap_get_state(), tap_get_end_state());
1508 first_tms_sequence
= tap_get_tms_path(tap_get_state(), tap_get_end_state());
1510 tap_set_state(TAP_IRSHIFT
);
1511 tap_set_end_state(cmd
->cmd
.scan
->end_state
);
1512 last_tms_count
= tap_get_tms_path_len(tap_get_state(), tap_get_end_state());
1513 last_tms_sequence
= tap_get_tms_path(tap_get_state(), tap_get_end_state());
1515 /* TAP state transitions for split scans */
1516 tms_count_pause
= tap_get_tms_path_len(TAP_IRSHIFT
, TAP_IRPAUSE
);
1517 tms_sequence_pause
= tap_get_tms_path(TAP_IRSHIFT
, TAP_IRPAUSE
);
1518 tms_count_resume
= tap_get_tms_path_len(TAP_IRPAUSE
, TAP_IRSHIFT
);
1519 tms_sequence_resume
= tap_get_tms_path(TAP_IRPAUSE
, TAP_IRSHIFT
);
1521 ulink_set_end_state(TAP_DRSHIFT
);
1522 first_tms_count
= tap_get_tms_path_len(tap_get_state(), tap_get_end_state());
1523 first_tms_sequence
= tap_get_tms_path(tap_get_state(), tap_get_end_state());
1525 tap_set_state(TAP_DRSHIFT
);
1526 tap_set_end_state(cmd
->cmd
.scan
->end_state
);
1527 last_tms_count
= tap_get_tms_path_len(tap_get_state(), tap_get_end_state());
1528 last_tms_sequence
= tap_get_tms_path(tap_get_state(), tap_get_end_state());
1530 /* TAP state transitions for split scans */
1531 tms_count_pause
= tap_get_tms_path_len(TAP_DRSHIFT
, TAP_DRPAUSE
);
1532 tms_sequence_pause
= tap_get_tms_path(TAP_DRSHIFT
, TAP_DRPAUSE
);
1533 tms_count_resume
= tap_get_tms_path_len(TAP_DRPAUSE
, TAP_DRSHIFT
);
1534 tms_sequence_resume
= tap_get_tms_path(TAP_DRPAUSE
, TAP_DRSHIFT
);
1537 /* Generate scan commands */
1538 bytecount
= scan_size_bytes
;
1539 while (bytecount
> 0) {
1540 if (bytecount
== scan_size_bytes
) {
1541 /* This is the first scan */
1542 tms_count_start
= first_tms_count
;
1543 tms_sequence_start
= first_tms_sequence
;
1545 /* Resume from previous scan */
1546 tms_count_start
= tms_count_resume
;
1547 tms_sequence_start
= tms_sequence_resume
;
1550 if (bytecount
> 58) { /* Full scan, at least one scan will follow */
1551 tms_count_end
= tms_count_pause
;
1552 tms_sequence_end
= tms_sequence_pause
;
1554 ret
= ulink_append_scan_cmd(device
,
1569 /* Update TDI and TDO buffer pointers */
1570 if (tdi_buffer_start
!= NULL
)
1572 if (tdo_buffer_start
!= NULL
)
1574 } else if (bytecount
== 58) { /* Full scan, no further scans */
1575 tms_count_end
= last_tms_count
;
1576 tms_sequence_end
= last_tms_sequence
;
1578 ret
= ulink_append_scan_cmd(device
,
1592 } else {/* Scan with less than maximum payload, no further scans */
1593 tms_count_end
= last_tms_count
;
1594 tms_sequence_end
= last_tms_sequence
;
1596 ret
= ulink_append_scan_cmd(device
,
1612 if (ret
!= ERROR_OK
) {
1613 free(tdi_buffer_start
);
1614 free(tdo_buffer_start
);
1619 free(tdi_buffer_start
);
1621 /* Set current state to the end state requested by the command */
1622 tap_set_state(cmd
->cmd
.scan
->end_state
);
1628 * Move the TAP into the Test Logic Reset state.
1630 * @param device pointer to struct ulink identifying ULINK driver instance.
1631 * @param cmd pointer to the command that shall be executed.
1632 * @return on success: ERROR_OK
1633 * @return on failure: ERROR_FAIL
1635 static int ulink_queue_tlr_reset(struct ulink
*device
, struct jtag_command
*cmd
)
1639 ret
= ulink_append_clock_tms_cmd(device
, 5, 0xff);
1641 if (ret
== ERROR_OK
)
1642 tap_set_state(TAP_RESET
);
1650 * Generate TCK clock cycles while remaining
1651 * in the Run-Test/Idle state.
1653 * @param device pointer to struct ulink identifying ULINK driver instance.
1654 * @param cmd pointer to the command that shall be executed.
1655 * @return on success: ERROR_OK
1656 * @return on failure: ERROR_FAIL
1658 static int ulink_queue_runtest(struct ulink
*device
, struct jtag_command
*cmd
)
1662 /* Only perform statemove if the TAP currently isn't in the TAP_IDLE state */
1663 if (tap_get_state() != TAP_IDLE
) {
1664 ulink_set_end_state(TAP_IDLE
);
1665 ulink_queue_statemove(device
);
1668 /* Generate the clock cycles */
1669 ret
= ulink_append_clock_tck_cmd(device
, cmd
->cmd
.runtest
->num_cycles
);
1670 if (ret
!= ERROR_OK
)
1673 /* Move to end state specified in command */
1674 if (cmd
->cmd
.runtest
->end_state
!= tap_get_state()) {
1675 tap_set_end_state(cmd
->cmd
.runtest
->end_state
);
1676 ulink_queue_statemove(device
);
1683 * Execute a JTAG_RESET command
1685 * @param cmd pointer to the command that shall be executed.
1686 * @return on success: ERROR_OK
1687 * @return on failure: ERROR_FAIL
1689 static int ulink_queue_reset(struct ulink
*device
, struct jtag_command
*cmd
)
1691 uint8_t low
= 0, high
= 0;
1693 if (cmd
->cmd
.reset
->trst
) {
1694 tap_set_state(TAP_RESET
);
1695 high
|= SIGNAL_TRST
;
1699 if (cmd
->cmd
.reset
->srst
)
1700 high
|= SIGNAL_RESET
;
1702 low
|= SIGNAL_RESET
;
1704 return ulink_append_set_signals_cmd(device
, low
, high
);
1708 * Move to one TAP state or several states in succession.
1710 * @param device pointer to struct ulink identifying ULINK driver instance.
1711 * @param cmd pointer to the command that shall be executed.
1712 * @return on success: ERROR_OK
1713 * @return on failure: ERROR_FAIL
1715 static int ulink_queue_pathmove(struct ulink
*device
, struct jtag_command
*cmd
)
1717 int ret
, i
, num_states
, batch_size
, state_count
;
1719 uint8_t tms_sequence
;
1721 num_states
= cmd
->cmd
.pathmove
->num_states
;
1722 path
= cmd
->cmd
.pathmove
->path
;
1725 while (num_states
> 0) {
1728 /* Determine batch size */
1729 if (num_states
>= 8)
1732 batch_size
= num_states
;
1734 for (i
= 0; i
< batch_size
; i
++) {
1735 if (tap_state_transition(tap_get_state(), false) == path
[state_count
]) {
1736 /* Append '0' transition: clear bit 'i' in tms_sequence */
1737 buf_set_u32(&tms_sequence
, i
, 1, 0x0);
1738 } else if (tap_state_transition(tap_get_state(), true)
1739 == path
[state_count
]) {
1740 /* Append '1' transition: set bit 'i' in tms_sequence */
1741 buf_set_u32(&tms_sequence
, i
, 1, 0x1);
1743 /* Invalid state transition */
1744 LOG_ERROR("BUG: %s -> %s isn't a valid TAP state transition",
1745 tap_state_name(tap_get_state()),
1746 tap_state_name(path
[state_count
]));
1750 tap_set_state(path
[state_count
]);
1755 /* Append CLOCK_TMS command to OpenULINK command queue */
1757 "pathmove batch: count = %i, sequence = 0x%x", batch_size
, tms_sequence
);
1758 ret
= ulink_append_clock_tms_cmd(ulink_handle
, batch_size
, tms_sequence
);
1759 if (ret
!= ERROR_OK
)
1767 * Sleep for a specific amount of time.
1769 * @param device pointer to struct ulink identifying ULINK driver instance.
1770 * @param cmd pointer to the command that shall be executed.
1771 * @return on success: ERROR_OK
1772 * @return on failure: ERROR_FAIL
1774 static int ulink_queue_sleep(struct ulink
*device
, struct jtag_command
*cmd
)
1776 /* IMPORTANT! Due to the time offset in command execution introduced by
1777 * command queueing, this needs to be implemented in the ULINK device */
1778 return ulink_append_sleep_cmd(device
, cmd
->cmd
.sleep
->us
);
1782 * Generate TCK cycles while remaining in a stable state.
1784 * @param device pointer to struct ulink identifying ULINK driver instance.
1785 * @param cmd pointer to the command that shall be executed.
1787 static int ulink_queue_stableclocks(struct ulink
*device
, struct jtag_command
*cmd
)
1790 unsigned num_cycles
;
1792 if (!tap_is_state_stable(tap_get_state())) {
1793 LOG_ERROR("JTAG_STABLECLOCKS: state not stable");
1797 num_cycles
= cmd
->cmd
.stableclocks
->num_cycles
;
1799 /* TMS stays either high (Test Logic Reset state) or low (all other states) */
1800 if (tap_get_state() == TAP_RESET
)
1801 ret
= ulink_append_set_signals_cmd(device
, 0, SIGNAL_TMS
);
1803 ret
= ulink_append_set_signals_cmd(device
, SIGNAL_TMS
, 0);
1805 if (ret
!= ERROR_OK
)
1808 while (num_cycles
> 0) {
1809 if (num_cycles
> 0xFFFF) {
1810 /* OpenULINK CMD_CLOCK_TCK can generate up to 0xFFFF (uint16_t) cycles */
1811 ret
= ulink_append_clock_tck_cmd(device
, 0xFFFF);
1812 num_cycles
-= 0xFFFF;
1814 ret
= ulink_append_clock_tck_cmd(device
, num_cycles
);
1818 if (ret
!= ERROR_OK
)
1826 * Post-process JTAG_SCAN command
1828 * @param ulink_cmd pointer to OpenULINK command that shall be processed.
1829 * @return on success: ERROR_OK
1830 * @return on failure: ERROR_FAIL
1832 static int ulink_post_process_scan(struct ulink_cmd
*ulink_cmd
)
1834 struct jtag_command
*cmd
= ulink_cmd
->cmd_origin
;
1837 switch (jtag_scan_type(cmd
->cmd
.scan
)) {
1840 ret
= jtag_read_buffer(ulink_cmd
->payload_in_start
, cmd
->cmd
.scan
);
1843 /* Nothing to do for OUT scans */
1847 LOG_ERROR("BUG: ulink_post_process_scan() encountered an unknown"
1857 * Perform post-processing of commands after OpenULINK queue has been executed.
1859 * @param device pointer to struct ulink identifying ULINK driver instance.
1860 * @return on success: ERROR_OK
1861 * @return on failure: ERROR_FAIL
1863 static int ulink_post_process_queue(struct ulink
*device
)
1865 struct ulink_cmd
*current
;
1866 struct jtag_command
*openocd_cmd
;
1869 current
= device
->queue_start
;
1871 while (current
!= NULL
) {
1872 openocd_cmd
= current
->cmd_origin
;
1874 /* Check if a corresponding OpenOCD command is stored for this
1875 * OpenULINK command */
1876 if ((current
->needs_postprocessing
== true) && (openocd_cmd
!= NULL
)) {
1877 switch (openocd_cmd
->type
) {
1879 ret
= ulink_post_process_scan(current
);
1881 case JTAG_TLR_RESET
:
1886 case JTAG_STABLECLOCKS
:
1887 /* Nothing to do for these commands */
1892 LOG_ERROR("BUG: ulink_post_process_queue() encountered unknown JTAG "
1897 if (ret
!= ERROR_OK
)
1901 current
= current
->next
;
1907 /**************************** JTAG driver functions ***************************/
1910 * Executes the JTAG Command Queue.
1912 * This is done in three stages: First, all OpenOCD commands are processed into
1913 * queued OpenULINK commands. Next, the OpenULINK command queue is sent to the
1914 * ULINK device and data received from the ULINK device is cached. Finally,
1915 * the post-processing function writes back data to the corresponding OpenOCD
1918 * @return on success: ERROR_OK
1919 * @return on failure: ERROR_FAIL
1921 static int ulink_execute_queue(void)
1923 struct jtag_command
*cmd
= jtag_command_queue
;
1927 switch (cmd
->type
) {
1929 ret
= ulink_queue_scan(ulink_handle
, cmd
);
1931 case JTAG_TLR_RESET
:
1932 ret
= ulink_queue_tlr_reset(ulink_handle
, cmd
);
1935 ret
= ulink_queue_runtest(ulink_handle
, cmd
);
1938 ret
= ulink_queue_reset(ulink_handle
, cmd
);
1941 ret
= ulink_queue_pathmove(ulink_handle
, cmd
);
1944 ret
= ulink_queue_sleep(ulink_handle
, cmd
);
1946 case JTAG_STABLECLOCKS
:
1947 ret
= ulink_queue_stableclocks(ulink_handle
, cmd
);
1951 LOG_ERROR("BUG: encountered unknown JTAG command type");
1955 if (ret
!= ERROR_OK
)
1961 if (ulink_handle
->commands_in_queue
> 0) {
1962 ret
= ulink_execute_queued_commands(ulink_handle
, USB_TIMEOUT
);
1963 if (ret
!= ERROR_OK
)
1966 ret
= ulink_post_process_queue(ulink_handle
);
1967 if (ret
!= ERROR_OK
)
1970 ulink_clear_queue(ulink_handle
);
1977 * Set the TCK frequency of the ULINK adapter.
1979 * @param khz desired JTAG TCK frequency.
1980 * @param jtag_speed where to store corresponding adapter-specific speed value.
1981 * @return on success: ERROR_OK
1982 * @return on failure: ERROR_FAIL
1984 static int ulink_khz(int khz
, int *jtag_speed
)
1989 LOG_ERROR("RCLK not supported");
1993 /* CLOCK_TCK commands are decoupled from others. Therefore, the frequency
1994 * setting can be done independently from all other commands. */
1996 ulink_handle
->delay_clock_tck
= -1;
1998 ret
= ulink_calculate_delay(DELAY_CLOCK_TCK
, khz
* 1000,
1999 &ulink_handle
->delay_clock_tck
);
2000 if (ret
!= ERROR_OK
)
2004 /* SCAN_{IN,OUT,IO} commands invoke CLOCK_TMS commands. Therefore, if the
2005 * requested frequency goes below the maximum frequency for SLOW_CLOCK_TMS
2006 * commands, all SCAN commands MUST also use the variable frequency
2007 * implementation! */
2009 ulink_handle
->delay_clock_tms
= -1;
2010 ulink_handle
->delay_scan_in
= -1;
2011 ulink_handle
->delay_scan_out
= -1;
2012 ulink_handle
->delay_scan_io
= -1;
2014 ret
= ulink_calculate_delay(DELAY_CLOCK_TMS
, khz
* 1000,
2015 &ulink_handle
->delay_clock_tms
);
2016 if (ret
!= ERROR_OK
)
2019 ret
= ulink_calculate_delay(DELAY_SCAN_IN
, khz
* 1000,
2020 &ulink_handle
->delay_scan_in
);
2021 if (ret
!= ERROR_OK
)
2024 ret
= ulink_calculate_delay(DELAY_SCAN_OUT
, khz
* 1000,
2025 &ulink_handle
->delay_scan_out
);
2026 if (ret
!= ERROR_OK
)
2029 ret
= ulink_calculate_delay(DELAY_SCAN_IO
, khz
* 1000,
2030 &ulink_handle
->delay_scan_io
);
2031 if (ret
!= ERROR_OK
)
2035 LOG_DEBUG_IO("ULINK TCK setup: delay_tck = %i (%li Hz),",
2036 ulink_handle
->delay_clock_tck
,
2037 ulink_calculate_frequency(DELAY_CLOCK_TCK
, ulink_handle
->delay_clock_tck
));
2038 LOG_DEBUG_IO(" delay_tms = %i (%li Hz),",
2039 ulink_handle
->delay_clock_tms
,
2040 ulink_calculate_frequency(DELAY_CLOCK_TMS
, ulink_handle
->delay_clock_tms
));
2041 LOG_DEBUG_IO(" delay_scan_in = %i (%li Hz),",
2042 ulink_handle
->delay_scan_in
,
2043 ulink_calculate_frequency(DELAY_SCAN_IN
, ulink_handle
->delay_scan_in
));
2044 LOG_DEBUG_IO(" delay_scan_out = %i (%li Hz),",
2045 ulink_handle
->delay_scan_out
,
2046 ulink_calculate_frequency(DELAY_SCAN_OUT
, ulink_handle
->delay_scan_out
));
2047 LOG_DEBUG_IO(" delay_scan_io = %i (%li Hz),",
2048 ulink_handle
->delay_scan_io
,
2049 ulink_calculate_frequency(DELAY_SCAN_IO
, ulink_handle
->delay_scan_io
));
2051 /* Configure the ULINK device with the new delay values */
2052 ret
= ulink_append_configure_tck_cmd(ulink_handle
,
2053 ulink_handle
->delay_scan_in
,
2054 ulink_handle
->delay_scan_out
,
2055 ulink_handle
->delay_scan_io
,
2056 ulink_handle
->delay_clock_tck
,
2057 ulink_handle
->delay_clock_tms
);
2059 if (ret
!= ERROR_OK
)
2068 * Set the TCK frequency of the ULINK adapter.
2070 * Because of the way the TCK frequency is set up in the OpenULINK firmware,
2071 * there are five different speed settings. To simplify things, the
2072 * adapter-specific speed setting value is identical to the TCK frequency in
2075 * @param speed desired adapter-specific speed value.
2076 * @return on success: ERROR_OK
2077 * @return on failure: ERROR_FAIL
2079 static int ulink_speed(int speed
)
2083 return ulink_khz(speed
, &dummy
);
2087 * Convert adapter-specific speed value to corresponding TCK frequency in kHz.
2089 * Because of the way the TCK frequency is set up in the OpenULINK firmware,
2090 * there are five different speed settings. To simplify things, the
2091 * adapter-specific speed setting value is identical to the TCK frequency in
2094 * @param speed adapter-specific speed value.
2095 * @param khz where to store corresponding TCK frequency in kHz.
2096 * @return on success: ERROR_OK
2097 * @return on failure: ERROR_FAIL
2099 static int ulink_speed_div(int speed
, int *khz
)
2107 * Initiates the firmware download to the ULINK adapter and prepares
2110 * @return on success: ERROR_OK
2111 * @return on failure: ERROR_FAIL
2113 static int ulink_init(void)
2115 int ret
, transferred
;
2116 char str_manufacturer
[20];
2117 bool download_firmware
= false;
2118 unsigned char *dummy
;
2119 uint8_t input_signals
, output_signals
;
2121 ulink_handle
= calloc(1, sizeof(struct ulink
));
2122 if (ulink_handle
== NULL
)
2125 libusb_init(&ulink_handle
->libusb_ctx
);
2127 ret
= ulink_usb_open(&ulink_handle
);
2128 if (ret
!= ERROR_OK
) {
2129 LOG_ERROR("Could not open ULINK device");
2131 ulink_handle
= NULL
;
2135 /* Get String Descriptor to determine if firmware needs to be loaded */
2136 ret
= libusb_get_string_descriptor_ascii(ulink_handle
->usb_device_handle
, 1, (unsigned char *)str_manufacturer
, 20);
2138 /* Could not get descriptor -> Unconfigured or original Keil firmware */
2139 download_firmware
= true;
2141 /* We got a String Descriptor, check if it is the correct one */
2142 if (strncmp(str_manufacturer
, "OpenULINK", 9) != 0)
2143 download_firmware
= true;
2146 if (download_firmware
== true) {
2147 LOG_INFO("Loading OpenULINK firmware. This is reversible by power-cycling"
2149 ret
= ulink_load_firmware_and_renumerate(&ulink_handle
,
2150 ULINK_FIRMWARE_FILE
, ULINK_RENUMERATION_DELAY
);
2151 if (ret
!= ERROR_OK
) {
2152 LOG_ERROR("Could not download firmware and re-numerate ULINK");
2154 ulink_handle
= NULL
;
2158 LOG_INFO("ULINK device is already running OpenULINK firmware");
2160 /* Get OpenULINK USB IN/OUT endpoints and claim the interface */
2161 ret
= jtag_libusb_choose_interface(ulink_handle
->usb_device_handle
,
2162 &ulink_handle
->ep_in
, &ulink_handle
->ep_out
, -1, -1, -1, -1);
2163 if (ret
!= ERROR_OK
)
2166 /* Initialize OpenULINK command queue */
2167 ulink_clear_queue(ulink_handle
);
2169 /* Issue one test command with short timeout */
2170 ret
= ulink_append_test_cmd(ulink_handle
);
2171 if (ret
!= ERROR_OK
)
2174 ret
= ulink_execute_queued_commands(ulink_handle
, 200);
2175 if (ret
!= ERROR_OK
) {
2176 /* Sending test command failed. The ULINK device may be forever waiting for
2177 * the host to fetch an USB Bulk IN packet (e. g. OpenOCD crashed or was
2178 * shut down by the user via Ctrl-C. Try to retrieve this Bulk IN packet. */
2179 dummy
= calloc(64, sizeof(uint8_t));
2181 ret
= libusb_bulk_transfer(ulink_handle
->usb_device_handle
, ulink_handle
->ep_in
,
2182 dummy
, 64, &transferred
, 200);
2186 if (ret
!= 0 || transferred
== 0) {
2187 /* Bulk IN transfer failed -> unrecoverable error condition */
2188 LOG_ERROR("Cannot communicate with ULINK device. Disconnect ULINK from "
2189 "the USB port and re-connect, then re-run OpenOCD");
2191 ulink_handle
= NULL
;
2194 #ifdef _DEBUG_USB_COMMS_
2196 /* Successfully received Bulk IN packet -> continue */
2197 LOG_INFO("Recovered from lost Bulk IN packet");
2201 ulink_clear_queue(ulink_handle
);
2203 ret
= ulink_append_get_signals_cmd(ulink_handle
);
2204 if (ret
== ERROR_OK
)
2205 ret
= ulink_execute_queued_commands(ulink_handle
, 200);
2207 if (ret
== ERROR_OK
) {
2208 /* Post-process the single CMD_GET_SIGNALS command */
2209 input_signals
= ulink_handle
->queue_start
->payload_in
[0];
2210 output_signals
= ulink_handle
->queue_start
->payload_in
[1];
2212 ulink_print_signal_states(input_signals
, output_signals
);
2215 ulink_clear_queue(ulink_handle
);
2221 * Closes the USB handle for the ULINK device.
2223 * @return on success: ERROR_OK
2224 * @return on failure: ERROR_FAIL
2226 static int ulink_quit(void)
2230 ret
= ulink_usb_close(&ulink_handle
);
2237 * Set a custom path to ULINK firmware image and force downloading to ULINK.
2239 COMMAND_HANDLER(ulink_download_firmware_handler
)
2244 return ERROR_COMMAND_SYNTAX_ERROR
;
2247 LOG_INFO("Downloading ULINK firmware image %s", CMD_ARGV
[0]);
2249 /* Download firmware image in CMD_ARGV[0] */
2250 ret
= ulink_load_firmware_and_renumerate(&ulink_handle
, CMD_ARGV
[0],
2251 ULINK_RENUMERATION_DELAY
);
2256 /*************************** Command Registration **************************/
2258 static const struct command_registration ulink_command_handlers
[] = {
2260 .name
= "ulink_download_firmware",
2261 .handler
= &ulink_download_firmware_handler
,
2262 .mode
= COMMAND_EXEC
,
2263 .help
= "download firmware image to ULINK device",
2264 .usage
= "path/to/ulink_firmware.hex",
2266 COMMAND_REGISTRATION_DONE
,
2269 static struct jtag_interface ulink_interface
= {
2270 .execute_queue
= ulink_execute_queue
,
2273 struct adapter_driver ulink_adapter_driver
= {
2275 .transports
= jtag_only
,
2276 .commands
= ulink_command_handlers
,
2280 .speed
= ulink_speed
,
2282 .speed_div
= ulink_speed_div
,
2284 .jtag_ops
= &ulink_interface
,
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)