23 #define ULINK_VID 0xC251
27 #define ULINK_PID 0x2710
31 #define CPUCS_REG 0x7F92
34 #define REQUEST_FIRMWARE_LOAD 0xA0
37 #define CPU_RESET 0x01
40 #define CPU_START 0x00
43 #define FIRMWARE_ADDR 0x0000
46 #define USB_INTERFACE 0
49 #define ULINK_RENUMERATION_DELAY 1500000
52 #define ULINK_FIRMWARE_FILE PKGDATADIR "/OpenULINK/ulink_firmware.hex"
55 #define SECTION_BUFFERSIZE 8192
58 #define SPLIT_SCAN_THRESHOLD 10
165 struct image *firmware_image,
int section_index);
189 uint8_t tms_count_start,
190 uint8_t tms_sequence_start,
191 uint8_t tms_count_end,
192 uint8_t tms_sequence_end,
231 static int ulink_khz(
int khz,
int *jtag_speed);
239 static struct ulink *ulink_handle;
254 ssize_t num_devices, i;
256 struct libusb_device **usb_devices;
257 struct libusb_device_descriptor usb_desc;
258 struct libusb_device_handle *usb_device_handle;
260 num_devices = libusb_get_device_list((*device)->libusb_ctx, &usb_devices);
262 if (num_devices <= 0)
266 for (i = 0; i < num_devices; i++) {
267 if (libusb_get_device_descriptor(usb_devices[i], &usb_desc) != 0)
278 if (libusb_open(usb_devices[i], &usb_device_handle) != 0)
280 libusb_free_device_list(usb_devices, 1);
282 (*device)->usb_device_handle = usb_device_handle;
297 if (libusb_release_interface((*device)->usb_device_handle, 0) != 0)
300 libusb_close((*device)->usb_device_handle);
302 (*device)->usb_device_handle =
NULL;
322 ret = libusb_control_transfer(
device->usb_device_handle,
323 (LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE),
346 const char *filename, uint32_t delay)
383 struct image ulink_firmware_image;
395 ret =
image_open(&ulink_firmware_image, filename,
"ihex");
397 LOG_ERROR(
"Could not load firmware image");
402 for (
unsigned int i = 0; i < ulink_firmware_image.
num_sections; i++) {
412 LOG_ERROR(
"Could not restart ULINK CPU");
431 struct image *firmware_image,
int section_index)
433 uint16_t
addr,
size, bytes_remaining, chunk_size;
435 uint8_t *data_ptr = data;
442 LOG_DEBUG(
"section %02i at addr 0x%04x (size 0x%04x)", section_index,
addr,
455 bytes_remaining =
size;
458 while (bytes_remaining > 0) {
459 if (bytes_remaining > 64)
462 chunk_size = bytes_remaining;
464 ret = libusb_control_transfer(
device->usb_device_handle,
465 (LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE),
469 if (ret != (
int)chunk_size) {
474 bytes_remaining -= chunk_size;
476 data_ptr += chunk_size;
492 LOG_INFO(
"ULINK signal states: TDI: %i, TDO: %i, TMS: %i, TCK: %i, TRST: %i,"
518 payload = calloc(
size,
sizeof(uint8_t));
521 LOG_ERROR(
"Could not allocate OpenULINK command payload: out of memory");
528 LOG_ERROR(
"BUG: Duplicate payload allocation for OpenULINK command");
538 LOG_ERROR(
"BUG: Duplicate payload allocation for OpenULINK command");
583 current = current->
next;
622 device->commands_in_queue = 0;
638 int newsize_out, newsize_in;
648 if ((newsize_out > 64) || (newsize_in > 64)) {
660 if (!
device->queue_start) {
662 device->commands_in_queue = 1;
668 device->commands_in_queue++;
691 int ret, i, index_out, index_in, count_out, count_in, transferred;
701 for (current =
device->queue_start; current; current = current->
next) {
715 ret = libusb_bulk_transfer(
device->usb_device_handle,
device->ep_out,
719 if (transferred != count_out)
724 ret = libusb_bulk_transfer(
device->usb_device_handle,
device->ep_in,
728 if (transferred != count_in)
733 for (current =
device->queue_start; current; current = current->
next) {
754 return "CMD_SCAN_IN";
756 return "CMD_SLOW_SCAN_IN";
758 return "CMD_SCAN_OUT";
760 return "CMD_SLOW_SCAN_OUT";
762 return "CMD_SCAN_IO";
764 return "CMD_SLOW_SCAN_IO";
766 return "CMD_CLOCK_TMS";
768 return "CMD_SLOW_CLOCK_TMS";
770 return "CMD_CLOCK_TCK";
772 return "CMD_SLOW_CLOCK_TCK";
774 return "CMD_SLEEP_US";
776 return "CMD_SLEEP_MS";
778 return "CMD_GET_SIGNALS";
780 return "CMD_SET_SIGNALS";
782 return "CMD_CONFIGURE_TCK_FREQ";
784 return "CMD_SET_LEDS";
788 return "CMD_UNKNOWN";
801 printf(
" %-22s | OUT size = %i, bytes = 0x",
806 printf(
"\n | IN size = %i\n",
819 printf(
"OpenULINK command queue:\n");
821 for (current =
device->queue_start; current; current = current->
next)
856 int scan_size_bits, uint8_t *tdi, uint8_t *tdo_start, uint8_t *tdo,
857 uint8_t tms_count_start, uint8_t tms_sequence_start, uint8_t tms_count_end,
858 uint8_t tms_sequence_end,
struct jtag_command *origin,
bool postprocess)
861 int ret, i, scan_size_bytes;
862 uint8_t bits_last_byte;
869 if (scan_size_bits > (58 * 8)) {
870 LOG_ERROR(
"BUG: Tried to create CMD_SCAN_IO OpenULINK command with too"
878 bits_last_byte = scan_size_bits % 8;
879 if (bits_last_byte == 0)
885 if (
device->delay_scan_in < 0)
892 if (
device->delay_scan_out < 0)
899 if (
device->delay_scan_io < 0)
906 LOG_ERROR(
"BUG: ulink_append_scan_cmd() encountered an unknown scan type");
917 cmd->payload_out[0] = scan_size_bytes & 0xFF;
918 cmd->payload_out[1] = bits_last_byte & 0xFF;
919 cmd->payload_out[2] = ((tms_count_start & 0x0F) << 4) | (tms_count_end & 0x0F);
920 cmd->payload_out[3] = tms_sequence_start;
921 cmd->payload_out[4] = tms_sequence_end;
925 for (i = 0; i < scan_size_bytes; i++)
926 cmd->payload_out[i + 5] = tdi[i];
931 cmd->payload_in_start = tdo_start;
932 cmd->payload_in = tdo;
933 cmd->payload_in_size = scan_size_bytes;
936 cmd->needs_postprocessing = postprocess;
937 cmd->cmd_origin = origin;
941 cmd->free_payload_in_start = postprocess;
965 if (
device->delay_clock_tms < 0)
1001 if (
device->delay_clock_tck < 0)
1013 cmd->payload_out[0] =
count & 0xff;
1014 cmd->payload_out[1] = (
count >> 8) & 0xff;
1035 cmd->needs_postprocessing =
true;
1084 cmd->payload_out[0] =
low;
1085 cmd->payload_out[1] = high;
1116 cmd->payload_out[0] = us & 0x00ff;
1117 cmd->payload_out[1] = (us >> 8) & 0x00ff;
1154 cmd->payload_out[0] = 0;
1159 cmd->payload_out[1] = 0;
1164 cmd->payload_out[2] = 0;
1169 cmd->payload_out[3] = 0;
1174 cmd->payload_out[4] = 0;
1213 cmd->payload_out[0] = led_state;
1243 cmd->payload_out[0] = 0xAA;
1287 t = 1.0 / (float)(f);
1291 x = (t - (float)(6E-6)) / (
float)(4E-6);
1294 x = (t - (float)(8.5E-6)) / (
float)(4E-6);
1297 x = (t - (float)(8.8308E-6)) / (
float)(4E-6);
1300 x = (t - (float)(1.0527E-5)) / (
float)(4E-6);
1303 x = (t - (float)(1.3132E-5)) / (
float)(4E-6);
1325 *delay = (int)x_ceil;
1352 t = (float)(2.666E-6);
1354 t = (float)(4E-6) * (float)(delay) + (float)(6E-6);
1358 t = (float)(5.666E-6);
1360 t = (float)(4E-6) * (float)(delay) + (float)(8.5E-6);
1364 t = (float)(5.5E-6);
1366 t = (float)(4E-6) * (float)(delay) + (float)(8.8308E-6);
1370 t = (float)(7.0E-6);
1372 t = (float)(4E-6) * (float)(delay) + (float)(1.0527E-5);
1376 t = (float)(9.926E-6);
1378 t = (float)(4E-6) * (float)(delay) + (float)(1.3132E-5);
1385 return roundf(f_float);
1415 uint8_t tms_sequence, tms_count;
1444 uint32_t scan_size_bits, scan_size_bytes, bits_last_scan;
1445 uint32_t scans_max_payload, bytecount;
1449 uint8_t first_tms_count, first_tms_sequence;
1450 uint8_t last_tms_count, last_tms_sequence;
1452 uint8_t tms_count_pause, tms_sequence_pause;
1453 uint8_t tms_count_resume, tms_sequence_resume;
1455 uint8_t tms_count_start, tms_sequence_start;
1456 uint8_t tms_count_end, tms_sequence_end;
1469 scans_max_payload = scan_size_bytes / 58;
1472 bits_last_scan = scan_size_bits - (scans_max_payload * 58 * 8);
1476 tdo_buffer_start = calloc(
sizeof(uint8_t), scan_size_bytes);
1478 if (!tdo_buffer_start)
1491 if (
cmd->cmd.scan->ir_scan) {
1524 bytecount = scan_size_bytes;
1525 while (bytecount > 0) {
1526 if (bytecount == scan_size_bytes) {
1528 tms_count_start = first_tms_count;
1529 tms_sequence_start = first_tms_sequence;
1532 tms_count_start = tms_count_resume;
1533 tms_sequence_start = tms_sequence_resume;
1536 if (bytecount > 58) {
1537 tms_count_end = tms_count_pause;
1538 tms_sequence_end = tms_sequence_pause;
1556 if (tdi_buffer_start)
1558 if (tdo_buffer_start)
1560 }
else if (bytecount == 58) {
1561 tms_count_end = last_tms_count;
1562 tms_sequence_end = last_tms_sequence;
1579 tms_count_end = last_tms_count;
1580 tms_sequence_end = last_tms_sequence;
1599 free(tdi_buffer_start);
1600 free(tdo_buffer_start);
1605 free(tdi_buffer_start);
1678 uint8_t
low = 0, high = 0;
1680 if (
cmd->cmd.reset->trst) {
1686 if (
cmd->cmd.reset->srst)
1704 int ret, i, num_states, batch_size, state_count;
1706 uint8_t tms_sequence;
1708 num_states =
cmd->cmd.pathmove->num_states;
1709 path =
cmd->cmd.pathmove->path;
1712 while (num_states > 0) {
1716 if (num_states >= 8)
1719 batch_size = num_states;
1721 for (i = 0; i < batch_size; i++) {
1726 == path[state_count]) {
1731 LOG_ERROR(
"BUG: %s -> %s isn't a valid TAP state transition",
1744 "pathmove batch: count = %i, sequence = 0x%x", batch_size, tms_sequence);
1777 unsigned num_cycles;
1780 LOG_ERROR(
"JTAG_STABLECLOCKS: state not stable");
1784 num_cycles =
cmd->cmd.stableclocks->num_cycles;
1795 while (num_cycles > 0) {
1796 if (num_cycles > 0xFFFF) {
1799 num_cycles -= 0xFFFF;
1834 LOG_ERROR(
"BUG: ulink_post_process_scan() encountered an unknown"
1856 current =
device->queue_start;
1864 switch (openocd_cmd->
type) {
1879 LOG_ERROR(
"BUG: ulink_post_process_queue() encountered unknown JTAG "
1888 current = current->
next;
1914 switch (
cmd->type) {
1938 LOG_ERROR(
"BUG: encountered unknown JTAG command type");
2022 LOG_DEBUG_IO(
"ULINK TCK setup: delay_tck = %i (%li Hz),",
2102 int ret, transferred;
2103 char str_manufacturer[20];
2104 bool download_firmware =
false;
2105 unsigned char *
dummy;
2106 uint8_t input_signals, output_signals;
2108 ulink_handle = calloc(1,
sizeof(
struct ulink));
2116 LOG_ERROR(
"Could not open ULINK device");
2118 ulink_handle =
NULL;
2123 ret = libusb_get_string_descriptor_ascii(ulink_handle->
usb_device_handle, 1, (
unsigned char *)str_manufacturer, 20);
2126 download_firmware =
true;
2129 if (strncmp(str_manufacturer,
"OpenULINK", 9) != 0)
2130 download_firmware =
true;
2133 if (download_firmware ==
true) {
2134 LOG_INFO(
"Loading OpenULINK firmware. This is reversible by power-cycling"
2139 LOG_ERROR(
"Could not download firmware and re-numerate ULINK");
2141 ulink_handle =
NULL;
2145 LOG_INFO(
"ULINK device is already running OpenULINK firmware");
2149 &ulink_handle->
ep_in, &ulink_handle->
ep_out, -1, -1, -1, -1);
2166 dummy = calloc(64,
sizeof(uint8_t));
2169 dummy, 64, &transferred, 200);
2173 if (ret != 0 || transferred == 0) {
2175 LOG_ERROR(
"Cannot communicate with ULINK device. Disconnect ULINK from "
2176 "the USB port and re-connect, then re-run OpenOCD");
2178 ulink_handle =
NULL;
2181 #ifdef _DEBUG_USB_COMMS_
2184 LOG_INFO(
"Recovered from lost Bulk IN packet");
2247 .
name =
"download_firmware",
2248 .handler = &ulink_download_firmware_handler,
2250 .help =
"download firmware image to ULINK device",
2251 .usage =
"path/to/ulink_firmware.hex",
2260 .help =
"perform ulink management",
const char *const jtag_only[]
static uint8_t tdi_buffer[ARMJTAGEW_TAP_BUFFER_SIZE]
static uint8_t tdo_buffer[ARMJTAGEW_TAP_BUFFER_SIZE]
static const struct device_t * device
static void buf_set_u32(uint8_t *_buffer, unsigned first, unsigned num, uint32_t value)
Sets num bits in _buffer, starting at the first bit, using the bits in value.
#define CMD_ARGV
Use this macro to access the arguments for the command being handled, rather than accessing the varia...
#define ERROR_COMMAND_SYNTAX_ERROR
#define CMD_ARGC
Use this macro to access the number of arguments for the command being handled, rather than accessing...
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
struct jtag_command * jtag_command_queue
The current queue of jtag_command_s structures.
int jtag_build_buffer(const struct scan_command *cmd, uint8_t **buffer)
enum scan_type jtag_scan_type(const struct scan_command *cmd)
int jtag_read_buffer(uint8_t *buffer, const struct scan_command *cmd)
int jtag_scan_size(const struct scan_command *cmd)
scan_type
The inferred type of a scan_command_s structure, indicating whether the command has the host scan in ...
@ SCAN_IN
From device to host,.
@ SCAN_OUT
From host to device,.
@ SCAN_IO
Full-duplex scan.
static uint16_t direction
void image_close(struct image *image)
int image_read_section(struct image *image, int section, target_addr_t offset, uint32_t size, uint8_t *buffer, size_t *size_read)
int image_open(struct image *image, const char *url, const char *type_string)
bool tap_is_state_stable(tap_state_t astate)
Function tap_is_state_stable returns true if the astate is stable.
tap_state_t tap_state_transition(tap_state_t cur_state, bool tms)
Function tap_state_transition takes a current TAP state and returns the next state according to the t...
const char * tap_state_name(tap_state_t state)
Function tap_state_name Returns a string suitable for display representing the JTAG tap_state.
void tap_set_end_state(tap_state_t new_end_state)
This function sets the state of an "end state follower" which tracks the state that any cable driver ...
tap_state_t tap_get_end_state(void)
For more information,.
int tap_get_tms_path(tap_state_t from, tap_state_t to)
This function provides a "bit sequence" indicating what has to be done with TMS during a sequence of ...
int tap_get_tms_path_len(tap_state_t from, tap_state_t to)
Function int tap_get_tms_path_len returns the total number of bits that represents a TMS path transit...
tap_state_t tap_get_state(void)
This function gets the state of the "state follower" which tracks the state of the TAPs connected to ...
#define tap_set_state(new_state)
This function sets the state of a "state follower" which tracks the state of the TAPs connected to th...
uint8_t delay_scan_in
Delay value for SCAN_IN operations with less than maximum TCK frequency.
uint8_t delay_scan_out
Delay value for SCAN_OUT operations with less than maximum TCK frequency.
uint8_t delay_tck
Delay value for CLOCK_TCK operations with less than maximum frequency.
uint8_t delay_scan_io
Delay value for SCAN_IO operations with less than maximum TCK frequency.
uint8_t delay_tms
Delay value for CLOCK_TMS operations with less than maximum frequency.
enum tap_state tap_state_t
Defines JTAG Test Access Port states.
int jtag_libusb_choose_interface(struct libusb_device_handle *devh, unsigned int *usb_read_ep, unsigned int *usb_write_ep, int bclass, int subclass, int protocol, int trans_type)
Find the first interface optionally matching class, subclass and protocol and claim it.
#define LIBUSB_TIMEOUT_MS
#define LOG_DEBUG_IO(expr ...)
#define LOG_ERROR(expr ...)
#define LOG_LEVEL_IS(FOO)
#define LOG_INFO(expr ...)
#define LOG_DEBUG(expr ...)
Definition of the commands supported by the OpenULINK firmware.
#define CMD_CONFIGURE_TCK_FREQ
#define CMD_SLOW_CLOCK_TCK
#define CMD_SLOW_SCAN_OUT
#define CMD_SLOW_CLOCK_TMS
size_t size
Size of the control block search area.
Represents a driver for a debugging interface.
const char *const name
The name of the interface driver.
const char * usage
a string listing the options and arguments, required or optional
unsigned int num_sections
struct imagesection * sections
target_addr_t base_address
enum jtag_command_type type
Represents a driver for a debugging interface.
int(* execute_queue)(void)
Execute queued commands.
OpenULINK command (OpenULINK command queue element).
uint8_t payload_out_size
OUT direction payload size for this command.
uint8_t id
ULINK command ID.
bool needs_postprocessing
Indicates if this command needs post-processing.
uint8_t payload_in_size
IN direction payload size for this command.
uint8_t * payload_in
Pointer where IN payload shall be stored.
bool free_payload_in_start
Indicates if ulink_clear_queue() should free payload_in_start
struct jtag_command * cmd_origin
Pointer to corresponding OpenOCD command for post-processing.
uint8_t * payload_in_start
Pointer to first element of IN payload array.
struct ulink_cmd * next
Pointer to next command (linked list)
uint8_t * payload_out
OUT direction payload data.
Describes one driver instance.
struct libusb_device_handle * usb_device_handle
int delay_scan_out
Delay value for SCAN_OUT commands.
int delay_scan_io
Delay value for SCAN_IO commands.
unsigned int ep_in
IN endpoint number.
int delay_clock_tck
Delay value for CLOCK_TMS commands.
struct ulink_cmd * queue_end
Pointer to last command in queue.
int delay_scan_in
Delay value for SCAN_IN commands.
int delay_clock_tms
Delay value for CLOCK_TCK commands.
unsigned int ep_out
OUT endpoint number.
int commands_in_queue
Number of commands in queue.
struct libusb_context * libusb_ctx
struct ulink_cmd * queue_start
Pointer to first command in queue.
#define DIV_ROUND_UP(m, n)
Rounds m up to the nearest multiple of n using division.
static struct ublast_lowlevel low
#define SECTION_BUFFERSIZE
Maximum size of a single firmware section.
static int ulink_post_process_scan(struct ulink_cmd *ulink_cmd)
Post-process JTAG_SCAN command.
static int ulink_append_configure_tck_cmd(struct ulink *device, int delay_scan_in, int delay_scan_out, int delay_scan_io, int delay_tck, int delay_tms)
Set TCK delay counters.
static int ulink_append_get_signals_cmd(struct ulink *device)
Read JTAG signals.
static int ulink_load_firmware_and_renumerate(struct ulink **device, const char *filename, uint32_t delay)
Puts the ULINK's EZ-USB microcontroller into reset state, downloads the firmware image,...
static const struct command_registration ulink_command_handlers[]
#define CPUCS_REG
Address of EZ-USB CPU Control & Status register.
#define ULINK_FIRMWARE_FILE
Default location of OpenULINK firmware image.
static int ulink_write_firmware_section(struct ulink *device, struct image *firmware_image, int section_index)
Send one contiguous firmware section to the ULINK's EZ-USB microcontroller over the USB bus.
static int ulink_speed_div(int speed, int *khz)
Convert adapter-specific speed value to corresponding TCK frequency in kHz.
static int ulink_load_firmware(struct ulink *device, const char *filename)
Downloads a firmware image to the ULINK's EZ-USB microcontroller over the USB bus.
static int ulink_cpu_reset(struct ulink *device, unsigned char reset_bit)
Writes '0' or '1' to the CPUCS register, putting the EZ-USB CPU into reset or out of reset.
static int ulink_append_sleep_cmd(struct ulink *device, uint32_t us)
Sleep for a pre-defined number of microseconds.
static int ulink_speed(int speed)
Set the TCK frequency of the ULINK adapter.
#define CPU_START
Value to write into CPUCS to put EZ-USB out of reset.
static void ulink_print_queue(struct ulink *device)
Print the OpenULINK command queue to stdout.
static int ulink_append_queue(struct ulink *device, struct ulink_cmd *ulink_cmd)
Add a command to the OpenULINK command queue.
static int __attribute__((unused))
Opens the ULINK device.
static int ulink_queue_tlr_reset(struct ulink *device, struct jtag_command *cmd)
Move the TAP into the Test Logic Reset state.
static int ulink_append_clock_tck_cmd(struct ulink *device, uint16_t count)
Generate a defined amount of TCK clock cycles.
#define REQUEST_FIRMWARE_LOAD
USB Control EP0 bRequest: "Firmware Load".
static int ulink_queue_sleep(struct ulink *device, struct jtag_command *cmd)
Sleep for a specific amount of time.
static int ulink_quit(void)
Closes the USB handle for the ULINK device.
static int ulink_queue_pathmove(struct ulink *device, struct jtag_command *cmd)
Move to one TAP state or several states in succession.
static int ulink_queue_statemove(struct ulink *device)
Move from the current TAP state to the current TAP end state.
#define FIRMWARE_ADDR
Base address of firmware in EZ-USB code space.
#define ULINK_PID
USB Product ID of ULINK device in unconfigured state (no firmware loaded yet) or with OpenULINK firmw...
static void ulink_set_end_state(tap_state_t endstate)
Sets the end state follower (see interface.h) if endstate is a stable state.
static int ulink_execute_queue(void)
Executes the JTAG Command Queue.
static int ulink_append_test_cmd(struct ulink *device)
Test command.
#define ULINK_RENUMERATION_DELAY
Delay (in microseconds) to wait while EZ-USB performs ReNumeration.
static int ulink_allocate_payload(struct ulink_cmd *ulink_cmd, int size, enum ulink_payload_direction direction)
Allocate and initialize space in memory for OpenULINK command payload.
static int ulink_append_set_signals_cmd(struct ulink *device, uint8_t low, uint8_t high)
Arbitrarily set JTAG output signals.
static int ulink_append_led_cmd(struct ulink *device, uint8_t led_state)
Turn on/off ULINK LEDs.
static int ulink_append_clock_tms_cmd(struct ulink *device, uint8_t count, uint8_t sequence)
Perform TAP state transitions.
static int ulink_execute_queued_commands(struct ulink *device, int timeout)
Sends all queued OpenULINK commands to the ULINK for execution.
static const char * ulink_cmd_id_string(uint8_t id)
Convert an OpenULINK command ID (id) to a human-readable string.
static int ulink_queue_scan(struct ulink *device, struct jtag_command *cmd)
Perform a scan operation on a JTAG register.
static int ulink_get_queue_size(struct ulink *device, enum ulink_payload_direction direction)
Get the current number of bytes in the queue, including command IDs.
static int ulink_queue_reset(struct ulink *device, struct jtag_command *cmd)
Execute a JTAG_RESET command.
static int ulink_queue_stableclocks(struct ulink *device, struct jtag_command *cmd)
Generate TCK cycles while remaining in a stable state.
static long ulink_calculate_frequency(enum ulink_delay_type type, int delay)
Calculate frequency for a given delay value.
static const struct command_registration ulink_subcommand_handlers[]
static int ulink_usb_close(struct ulink **device)
Releases the ULINK interface and closes the USB device handle.
static struct jtag_interface ulink_interface
static int ulink_init(void)
Initiates the firmware download to the ULINK adapter and prepares the USB handle.
static int ulink_append_scan_cmd(struct ulink *device, enum scan_type scan_type, int scan_size_bits, uint8_t *tdi, uint8_t *tdo_start, uint8_t *tdo, uint8_t tms_count_start, uint8_t tms_sequence_start, uint8_t tms_count_end, uint8_t tms_sequence_end, struct jtag_command *origin, bool postprocess)
static int ulink_khz(int khz, int *jtag_speed)
Set the TCK frequency of the ULINK adapter.
static void ulink_print_signal_states(uint8_t input_signals, uint8_t output_signals)
Print state of interesting signals via LOG_INFO().
static void ulink_print_command(struct ulink_cmd *ulink_cmd)
Print one OpenULINK command to stdout.
static int ulink_calculate_delay(enum ulink_delay_type type, long f, int *delay)
Calculate delay values for a given TCK frequency.
static void ulink_clear_queue(struct ulink *device)
Clear the OpenULINK command queue.
#define ULINK_VID
USB Vendor ID of ULINK device in unconfigured state (no firmware loaded yet) or with OpenULINK firmwa...
#define CPU_RESET
Value to write into CPUCS to put EZ-USB into reset.
COMMAND_HANDLER(ulink_download_firmware_handler)
Set a custom path to ULINK firmware image and force downloading to ULINK.
struct adapter_driver ulink_adapter_driver
static int ulink_post_process_queue(struct ulink *device)
Perform post-processing of commands after OpenULINK queue has been executed.
ulink_type
ULINK hardware type.
@ ULINK_PRO
Newer ULINK adapter, based on EZ-USB FX2 + FPGA.
@ ULINK_1
Original ULINK adapter, based on Cypress EZ-USB (AN2131): Full JTAG support, no SWD support.
@ ULINK_ME
Newer ULINK adapter, possibly based on ULINK 2.
@ ULINK_2
Newer ULINK adapter, based on NXP LPC2148.
static int ulink_usb_open(struct ulink **device)
static int ulink_queue_runtest(struct ulink *device, struct jtag_command *cmd)
Run Test.