OpenOCD
usbprog.c
Go to the documentation of this file.
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 
3 /***************************************************************************
4  * Copyright (C) 2007 by Benedikt Sauter *
5  * sauter@ixbat.de *
6  ***************************************************************************/
7 
8 /*
9  * This file is based on Dominic Rath's amt_jtagaccel.c.
10  *
11  * usbprog is a free programming adapter. You can easily install
12  * different firmware versions from an "online pool" over USB.
13  * The adapter can be used for programming and debugging AVR and ARM
14  * processors, as USB to RS232 converter, as JTAG interface or as
15  * simple I/O interface (5 lines).
16  *
17  * http://www.embedded-projects.net/usbprog
18  */
19 
20 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #endif
23 
24 #include <jtag/interface.h>
25 #include <jtag/commands.h>
26 #include "libusb_helper.h"
27 
28 #define VID 0x1781
29 #define PID 0x0c63
30 
31 /* Pins at usbprog */
32 #define TDO_BIT 0
33 #define TDI_BIT 3
34 #define TCK_BIT 2
35 #define TMS_BIT 1
36 
38 static void usbprog_state_move(void);
39 static void usbprog_path_move(struct pathmove_command *cmd);
40 static void usbprog_runtest(unsigned int num_cycles);
41 static void usbprog_scan(bool ir_scan, enum scan_type type, uint8_t *buffer, int scan_size);
42 
43 #define UNKNOWN_COMMAND 0x00
44 #define PORT_DIRECTION 0x01
45 #define PORT_SET 0x02
46 #define PORT_GET 0x03
47 #define PORT_SETBIT 0x04
48 #define PORT_GETBIT 0x05
49 #define WRITE_TDI 0x06
50 #define READ_TDO 0x07
51 #define WRITE_AND_READ 0x08
52 #define WRITE_TMS 0x09
53 #define WRITE_TMS_CHAIN 0x0A
54 
55 struct usbprog_jtag {
56  struct libusb_device_handle *usb_handle;
57 };
58 
60 
61 static struct usbprog_jtag *usbprog_jtag_open(void);
62 /* static void usbprog_jtag_close(struct usbprog_jtag *usbprog_jtag); */
63 static void usbprog_jtag_init(struct usbprog_jtag *usbprog_jtag);
64 static unsigned char usbprog_jtag_message(struct usbprog_jtag *usbprog_jtag, char *msg, int msglen);
65 
66 static void usbprog_jtag_read_tdo(struct usbprog_jtag *usbprog_jtag, char *buffer, int size);
67 static void usbprog_jtag_write_tdi(struct usbprog_jtag *usbprog_jtag, char *buffer, int size);
68 static void usbprog_jtag_write_and_read(struct usbprog_jtag *usbprog_jtag, char *buffer, int size);
69 static void usbprog_jtag_write_tms(struct usbprog_jtag *usbprog_jtag, char tms_scan);
70 
71 static char tms_chain[64];
72 static int tms_chain_index;
73 
74 static void usbprog_jtag_tms_collect(char tms_scan);
76 
77 static void usbprog_write(int tck, int tms, int tdi);
78 static void usbprog_reset(int trst, int srst);
79 
80 static void usbprog_jtag_set_direction(struct usbprog_jtag *usbprog_jtag, unsigned char direction);
81 static void usbprog_jtag_write_slice(struct usbprog_jtag *usbprog_jtag, unsigned char value);
82 /* static unsigned char usbprog_jtag_get_port(struct usbprog_jtag *usbprog_jtag); */
83 static void usbprog_jtag_set_bit(struct usbprog_jtag *usbprog_jtag, int bit, int value);
84 /* static int usbprog_jtag_get_bit(struct usbprog_jtag *usbprog_jtag, int bit); */
85 
86 static int usbprog_execute_queue(struct jtag_command *cmd_queue)
87 {
88  struct jtag_command *cmd = cmd_queue; /* currently processed command */
89  int scan_size;
90  enum scan_type type;
91  uint8_t *buffer;
92 
93  while (cmd) {
94  switch (cmd->type) {
95  case JTAG_RESET:
96  LOG_DEBUG_IO("reset trst: %i srst %i",
97  cmd->cmd.reset->trst,
98  cmd->cmd.reset->srst);
99  if (cmd->cmd.reset->trst == 1)
101  usbprog_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst);
102  break;
103  case JTAG_RUNTEST:
104  LOG_DEBUG_IO("runtest %u cycles, end in %i",
105  cmd->cmd.runtest->num_cycles,
106  cmd->cmd.runtest->end_state);
107  usbprog_end_state(cmd->cmd.runtest->end_state);
108  usbprog_runtest(cmd->cmd.runtest->num_cycles);
109  break;
110  case JTAG_TLR_RESET:
111  LOG_DEBUG_IO("statemove end in %i", cmd->cmd.statemove->end_state);
112  usbprog_end_state(cmd->cmd.statemove->end_state);
114  break;
115  case JTAG_PATHMOVE:
116  LOG_DEBUG_IO("pathmove: %u states, end in %i",
117  cmd->cmd.pathmove->num_states,
118  cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]);
119  usbprog_path_move(cmd->cmd.pathmove);
120  break;
121  case JTAG_SCAN:
122  LOG_DEBUG_IO("scan end in %i", cmd->cmd.scan->end_state);
123  usbprog_end_state(cmd->cmd.scan->end_state);
124  scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer);
125  type = jtag_scan_type(cmd->cmd.scan);
126  usbprog_scan(cmd->cmd.scan->ir_scan, type, buffer, scan_size);
127  if (jtag_read_buffer(buffer, cmd->cmd.scan) != ERROR_OK)
129  free(buffer);
130  break;
131  case JTAG_SLEEP:
132  LOG_DEBUG_IO("sleep %" PRIu32, cmd->cmd.sleep->us);
133  jtag_sleep(cmd->cmd.sleep->us);
134  break;
135  default:
136  LOG_ERROR("BUG: unknown JTAG command type encountered");
137  exit(-1);
138  }
139 
140  cmd = cmd->next;
141  }
142 
143  return ERROR_OK;
144 }
145 
146 static int usbprog_init(void)
147 {
149 
150  tms_chain_index = 0;
151  if (!usbprog_jtag_handle) {
152  LOG_ERROR("Can't find USB JTAG Interface! Please check connection and permissions.");
153  return ERROR_JTAG_INIT_FAILED;
154  }
155 
156  LOG_INFO("USB JTAG Interface ready!");
157 
159  usbprog_reset(0, 0);
160  usbprog_write(0, 0, 0);
161 
162  return ERROR_OK;
163 }
164 
165 static int usbprog_quit(void)
166 {
167  return ERROR_OK;
168 }
169 
170 /*************** jtag execute commands **********************/
172 {
175  else {
176  LOG_ERROR("BUG: %i is not a valid end state", state);
177  exit(-1);
178  }
179 }
180 
181 static void usbprog_state_move(void)
182 {
183  uint8_t tms_scan = tap_get_tms_path(tap_get_state(), tap_get_end_state());
184 
186 
188 }
189 
191 {
192  unsigned int num_states = cmd->num_states;
193  int state_count;
194 
195  /* There may be queued transitions, and before following a specified
196  path, we must flush those queued transitions */
198 
199  state_count = 0;
200  while (num_states) {
201  if (tap_state_transition(tap_get_state(), false) == cmd->path[state_count]) {
202  /* LOG_INFO("1"); */
203  usbprog_write(0, 0, 0);
204  usbprog_write(1, 0, 0);
205  } else if (tap_state_transition(tap_get_state(),
206  true) == cmd->path[state_count]) {
207  /* LOG_INFO("2"); */
208  usbprog_write(0, 1, 0);
209  usbprog_write(1, 1, 0);
210  } else {
211  LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition",
213  tap_state_name(cmd->path[state_count]));
214  exit(-1);
215  }
216 
217  tap_set_state(cmd->path[state_count]);
218  state_count++;
219  num_states--;
220  }
221 
223 }
224 
225 static void usbprog_runtest(unsigned int num_cycles)
226 {
227  /* only do a state_move when we're not already in IDLE */
228  if (tap_get_state() != TAP_IDLE) {
231  }
232 
233  /* execute num_cycles */
234  if (num_cycles > 0) {
236  usbprog_write(0, 0, 0);
237  } else {
239  /* LOG_INFO("NUM CYCLES %i",num_cycles); */
240  }
241 
242  for (unsigned int i = 0; i < num_cycles; i++) {
243  usbprog_write(1, 0, 0);
244  usbprog_write(0, 0, 0);
245  }
246 
247  LOG_DEBUG_IO("runtest: cur_state %s end_state %s", tap_state_name(
249 
250  /* finish in end_state */
251  /*
252  usbprog_end_state(saved_end_state);
253  if (tap_get_state() != tap_get_end_state())
254  usbprog_state_move();
255  */
256 }
257 
258 static void usbprog_scan(bool ir_scan, enum scan_type type, uint8_t *buffer, int scan_size)
259 {
260  tap_state_t saved_end_state = tap_get_end_state();
261 
262  if (ir_scan)
264  else
266 
267  /* Only move if we're not already there */
268  if (tap_get_state() != tap_get_end_state())
270 
271  usbprog_end_state(saved_end_state);
272 
274 
275  void (*f)(struct usbprog_jtag *usbprog_jtag, char *buffer_local, int size);
276  switch (type) {
277  case SCAN_OUT:
279  break;
280  case SCAN_IN:
282  break;
283  case SCAN_IO:
285  break;
286  default:
287  LOG_ERROR("unknown scan type: %i", type);
288  exit(-1);
289  }
290  f(usbprog_jtag_handle, (char *)buffer, scan_size);
291 
292  /* The adapter does the transition to PAUSE internally */
293  if (ir_scan)
295  else
297 
298  if (tap_get_state() != tap_get_end_state())
300 }
301 
302 /*************** jtag wrapper functions *********************/
303 
304 static void usbprog_write(int tck, int tms, int tdi)
305 {
306  unsigned char output_value = 0x00;
307 
308  if (tms)
309  output_value |= (1 << TMS_BIT);
310  if (tdi)
311  output_value |= (1 << TDI_BIT);
312  if (tck)
313  output_value |= (1 << TCK_BIT);
314 
316 }
317 
318 /* (1) assert or (0) deassert reset lines */
319 static void usbprog_reset(int trst, int srst)
320 {
321  LOG_DEBUG("trst: %i, srst: %i", trst, srst);
322 
323  if (trst)
325  else
327 
328  if (srst)
330  else
332 }
333 
334 /*************** jtag lowlevel functions ********************/
335 
337 {
338  const uint16_t vids[] = { VID, 0 };
339  const uint16_t pids[] = { PID, 0 };
340  struct libusb_device_handle *dev;
341 
342  if (jtag_libusb_open(vids, pids, NULL, &dev, NULL) != ERROR_OK)
343  return NULL;
344 
345  struct usbprog_jtag *tmp = malloc(sizeof(struct usbprog_jtag));
346  tmp->usb_handle = dev;
347 
348  libusb_set_configuration(dev, 1);
349  libusb_claim_interface(dev, 0);
350  libusb_set_interface_alt_setting(dev, 0, 0);
351 
352  return tmp;
353 }
354 
355 #if 0
356 static void usbprog_jtag_close(struct usbprog_jtag *usbprog_jtag)
357 {
358  libusb_close(usbprog_jtag->usb_handle);
359  free(usbprog_jtag);
360 }
361 #endif
362 
363 static unsigned char usbprog_jtag_message(struct usbprog_jtag *usbprog_jtag, char *msg, int msglen)
364 {
365  int transferred;
366 
367  int res = jtag_libusb_bulk_write(usbprog_jtag->usb_handle, 3, msg, msglen, 100, &transferred);
368  if ((msg[0] == 2) || (msg[0] == 1) || (msg[0] == 4) || (msg[0] == 0) ||
369  (msg[0] == 6) || (msg[0] == 0x0A) || (msg[0] == 9))
370  return 1;
371  if (res == ERROR_OK && transferred == msglen) {
372  /* LOG_INFO("HALLLLOOO %i",(int)msg[0]); */
373  res = jtag_libusb_bulk_read(usbprog_jtag->usb_handle, 0x82, msg, 2, 100, &transferred);
374  if (res == ERROR_OK && transferred > 0)
375  return (unsigned char)msg[1];
376  else
377  return -1;
378  } else
379  return -1;
380  return 0;
381 }
382 
384 {
386 }
387 
389 {
390  char tmp[64]; /* fastest packet size for usb controller */
391  int send_bits, bufindex = 0, fillindex = 0, i, loops;
392 
393  char swap;
394  /* 61 byte can be transferred (488 bit) */
395 
396  while (size > 0) {
397  if (size > 488) {
398  send_bits = 488;
399  size = size - 488;
400  loops = 61;
401  } else {
402  send_bits = size;
403  loops = size / 8;
404  loops++;
405  size = 0;
406  }
407  tmp[0] = WRITE_AND_READ;
408  tmp[1] = (char)(send_bits >> 8); /* high */
409  tmp[2] = (char)(send_bits); /* low */
410 
411  for (i = 0; i < loops; i++) {
412  tmp[3 + i] = buffer[bufindex];
413  bufindex++;
414  }
415 
416  int transferred;
417  int res = jtag_libusb_bulk_write(usbprog_jtag->usb_handle, 3, tmp, 64, 1000, &transferred);
418  if (res == ERROR_OK && transferred == 64) {
419  /* LOG_INFO("HALLLLOOO2 %i",(int)tmp[0]); */
420  usleep(1);
421  int timeout = 0;
422  while (jtag_libusb_bulk_read(usbprog_jtag->usb_handle, 0x82, tmp, 64, 1000, &transferred) != ERROR_OK) {
423  timeout++;
424  if (timeout > 10)
425  break;
426  }
427 
428  for (i = 0; i < loops; i++) {
429  swap = tmp[3 + i];
430  buffer[fillindex++] = swap;
431  }
432  }
433  }
434 }
435 
437 {
438  char tmp[64]; /* fastest packet size for usb controller */
439  int send_bits, fillindex = 0, i, loops;
440 
441  char swap;
442  /* 61 byte can be transferred (488 bit) */
443 
444  while (size > 0) {
445  if (size > 488) {
446  send_bits = 488;
447  size = size - 488;
448  loops = 61;
449  } else {
450  send_bits = size;
451  loops = size / 8;
452  loops++;
453  size = 0;
454  }
455  tmp[0] = WRITE_AND_READ;
456  tmp[1] = (char)(send_bits >> 8); /* high */
457  tmp[2] = (char)(send_bits); /* low */
458 
459  int transferred;
460  jtag_libusb_bulk_write(usbprog_jtag->usb_handle, 3, tmp, 3, 1000, &transferred);
461 
462  /* LOG_INFO("HALLLLOOO3 %i",(int)tmp[0]); */
463  int timeout = 0;
464  usleep(1);
465  while (jtag_libusb_bulk_read(usbprog_jtag->usb_handle, 0x82, tmp, 64, 10, &transferred) != ERROR_OK) {
466  timeout++;
467  if (timeout > 10)
468  break;
469  }
470 
471  for (i = 0; i < loops; i++) {
472  swap = tmp[3 + i];
473  buffer[fillindex++] = swap;
474  }
475  }
476 }
477 
479 {
480  char tmp[64]; /* fastest packet size for usb controller */
481  int send_bits, bufindex = 0, i, loops;
482 
483  /* 61 byte can be transferred (488 bit) */
484  while (size > 0) {
485  if (size > 488) {
486  send_bits = 488;
487  size = size - 488;
488  loops = 61;
489  } else {
490  send_bits = size;
491  loops = size/8;
492  /* if (loops == 0) */
493  loops++;
494  size = 0;
495  }
496  tmp[0] = WRITE_TDI;
497  tmp[1] = (char)(send_bits >> 8); /* high */
498  tmp[2] = (char)(send_bits); /* low */
499 
500  for (i = 0; i < loops; i++) {
501  tmp[3 + i] = buffer[bufindex];
502  bufindex++;
503  }
504  int transferred;
505  jtag_libusb_bulk_write(usbprog_jtag->usb_handle, 3, tmp, 64, 1000, &transferred);
506  }
507 }
508 
509 static void usbprog_jtag_write_tms(struct usbprog_jtag *usbprog_jtag, char tms_scan)
510 {
511  usbprog_jtag_tms_collect(tms_scan);
512 }
513 
515 {
516  char tmp[2];
517  tmp[0] = PORT_DIRECTION;
518  tmp[1] = (char)direction;
520 }
521 
522 static void usbprog_jtag_write_slice(struct usbprog_jtag *usbprog_jtag, unsigned char value)
523 {
524  char tmp[2];
525  tmp[0] = PORT_SET;
526  tmp[1] = (char)value;
528 }
529 
530 #if 0
531 static unsigned char usbprog_jtag_get_port(struct usbprog_jtag *usbprog_jtag)
532 {
533  char tmp[2];
534  tmp[0] = PORT_GET;
535  tmp[1] = 0x00;
536  return usbprog_jtag_message(usbprog_jtag, tmp, 2);
537 }
538 #endif
539 
540 static void usbprog_jtag_set_bit(struct usbprog_jtag *usbprog_jtag, int bit, int value)
541 {
542  char tmp[3];
543  tmp[0] = PORT_SETBIT;
544  tmp[1] = (char)bit;
545  if (value == 1)
546  tmp[2] = 0x01;
547  else
548  tmp[2] = 0x00;
550 }
551 
552 #if 0
553 static int usbprog_jtag_get_bit(struct usbprog_jtag *usbprog_jtag, int bit)
554 {
555  char tmp[2];
556  tmp[0] = PORT_GETBIT;
557  tmp[1] = (char)bit;
558 
559  if (usbprog_jtag_message(usbprog_jtag, tmp, 2) > 0)
560  return 1;
561  else
562  return 0;
563 }
564 #endif
565 
566 static void usbprog_jtag_tms_collect(char tms_scan)
567 {
568  tms_chain[tms_chain_index] = tms_scan;
569  tms_chain_index++;
570 }
571 
573 {
574  /* LOG_INFO("TMS SEND"); */
575  if (tms_chain_index > 0) {
576  char tmp[tms_chain_index + 2];
577  tmp[0] = WRITE_TMS_CHAIN;
578  tmp[1] = (char)(tms_chain_index);
579  for (int i = 0; i < tms_chain_index + 1; i++)
580  tmp[2 + i] = tms_chain[i];
581  int transferred;
582  jtag_libusb_bulk_write(usbprog_jtag->usb_handle, 3, tmp, tms_chain_index + 2, 1000, &transferred);
583  tms_chain_index = 0;
584  }
585 }
586 
587 static struct jtag_interface usbprog_interface = {
589 };
590 
592  .name = "usbprog",
593  .transports = jtag_only,
594 
595  .init = usbprog_init,
596  .quit = usbprog_quit,
597 
598  .jtag_ops = &usbprog_interface,
599 };
const char *const jtag_only[]
Definition: adapter.c:27
int jtag_build_buffer(const struct scan_command *cmd, uint8_t **buffer)
Definition: commands.c:192
enum scan_type jtag_scan_type(const struct scan_command *cmd)
Definition: commands.c:167
int jtag_read_buffer(uint8_t *buffer, const struct scan_command *cmd)
Definition: commands.c:230
scan_type
The inferred type of a scan_command structure, indicating whether the command has the host scan in fr...
Definition: commands.h:22
@ SCAN_IN
From device to host,.
Definition: commands.h:24
@ SCAN_OUT
From host to device,.
Definition: commands.h:26
@ SCAN_IO
Full-duplex scan.
Definition: commands.h:28
@ JTAG_TLR_RESET
Definition: commands.h:137
@ JTAG_SCAN
Definition: commands.h:129
@ JTAG_PATHMOVE
Definition: commands.h:140
@ JTAG_RUNTEST
Definition: commands.h:138
@ JTAG_SLEEP
Definition: commands.h:141
@ JTAG_RESET
Definition: commands.h:139
static uint8_t output_value
Definition: ep93xx.c:25
uint8_t type
Definition: esp_usb_jtag.c:0
static uint16_t direction
Definition: ftdi.c:120
bool tap_is_state_stable(tap_state_t astate)
Function tap_is_state_stable returns true if the astate is stable.
Definition: interface.c:200
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...
Definition: interface.c:223
const char * tap_state_name(tap_state_t state)
Function tap_state_name Returns a string suitable for display representing the JTAG tap_state.
Definition: interface.c:344
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 ...
Definition: interface.c:48
tap_state_t tap_get_end_state(void)
For more information,.
Definition: interface.c:56
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 ...
Definition: interface.c:190
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 ...
Definition: interface.c:37
#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...
Definition: interface.h:49
void jtag_sleep(uint32_t us)
Definition: jtag/core.c:1062
@ TAP_RESET
Definition: jtag.h:56
@ TAP_DRPAUSE
Definition: jtag.h:44
@ TAP_IRSHIFT
Definition: jtag.h:51
@ TAP_IDLE
Definition: jtag.h:53
@ TAP_DRSHIFT
Definition: jtag.h:43
@ TAP_IRPAUSE
Definition: jtag.h:52
#define ERROR_JTAG_QUEUE_FAILED
Definition: jtag.h:557
#define ERROR_JTAG_INIT_FAILED
Definition: jtag.h:553
enum tap_state tap_state_t
Defines JTAG Test Access Port states.
int jtag_libusb_open(const uint16_t vids[], const uint16_t pids[], const char *product, struct libusb_device_handle **out, adapter_get_alternate_serial_fn adapter_get_alternate_serial)
int jtag_libusb_bulk_write(struct libusb_device_handle *dev, int ep, char *bytes, int size, int timeout, int *transferred)
int jtag_libusb_bulk_read(struct libusb_device_handle *dev, int ep, char *bytes, int size, int timeout, int *transferred)
#define LOG_DEBUG_IO(expr ...)
Definition: log.h:101
#define LOG_ERROR(expr ...)
Definition: log.h:132
#define LOG_INFO(expr ...)
Definition: log.h:126
#define LOG_DEBUG(expr ...)
Definition: log.h:109
#define ERROR_OK
Definition: log.h:164
static uint32_t bit(uint32_t value, unsigned int b)
Definition: opcodes.h:15
size_t size
Size of the control block search area.
Definition: rtt/rtt.c:30
Represents a driver for a debugging interface.
Definition: interface.h:207
const char *const name
The name of the interface driver.
Definition: interface.h:209
Represents a driver for a debugging interface.
Definition: interface.h:182
int(* execute_queue)(struct jtag_command *cmd_queue)
Execute commands in the supplied queue.
Definition: interface.h:195
Definition: psoc6.c:83
struct libusb_device_handle * usb_handle
Definition: usbprog.c:56
#define NULL
Definition: usb.h:16
static struct jtag_interface usbprog_interface
Definition: usbprog.c:587
#define WRITE_TMS_CHAIN
Definition: usbprog.c:53
#define PID
Definition: usbprog.c:29
static void usbprog_scan(bool ir_scan, enum scan_type type, uint8_t *buffer, int scan_size)
Definition: usbprog.c:258
static void usbprog_jtag_set_bit(struct usbprog_jtag *usbprog_jtag, int bit, int value)
Definition: usbprog.c:540
static void usbprog_jtag_write_tms(struct usbprog_jtag *usbprog_jtag, char tms_scan)
Definition: usbprog.c:509
static struct usbprog_jtag * usbprog_jtag_open(void)
Definition: usbprog.c:336
static int usbprog_execute_queue(struct jtag_command *cmd_queue)
Definition: usbprog.c:86
static struct usbprog_jtag * usbprog_jtag_handle
Definition: usbprog.c:59
static void usbprog_jtag_tms_collect(char tms_scan)
Definition: usbprog.c:566
static void usbprog_jtag_set_direction(struct usbprog_jtag *usbprog_jtag, unsigned char direction)
Definition: usbprog.c:514
#define PORT_SETBIT
Definition: usbprog.c:47
static void usbprog_reset(int trst, int srst)
Definition: usbprog.c:319
static void usbprog_write(int tck, int tms, int tdi)
Definition: usbprog.c:304
static void usbprog_jtag_read_tdo(struct usbprog_jtag *usbprog_jtag, char *buffer, int size)
Definition: usbprog.c:436
static int usbprog_init(void)
Definition: usbprog.c:146
static void usbprog_jtag_write_and_read(struct usbprog_jtag *usbprog_jtag, char *buffer, int size)
Definition: usbprog.c:388
#define PORT_DIRECTION
Definition: usbprog.c:44
static int tms_chain_index
Definition: usbprog.c:72
static void usbprog_runtest(unsigned int num_cycles)
Definition: usbprog.c:225
#define TDI_BIT
Definition: usbprog.c:33
static unsigned char usbprog_jtag_message(struct usbprog_jtag *usbprog_jtag, char *msg, int msglen)
Definition: usbprog.c:363
#define PORT_GET
Definition: usbprog.c:46
static void usbprog_jtag_tms_send(struct usbprog_jtag *usbprog_jtag)
Definition: usbprog.c:572
#define PORT_GETBIT
Definition: usbprog.c:48
static void usbprog_end_state(tap_state_t state)
Definition: usbprog.c:171
static char tms_chain[64]
Definition: usbprog.c:71
static int usbprog_quit(void)
Definition: usbprog.c:165
static void usbprog_state_move(void)
Definition: usbprog.c:181
#define WRITE_TDI
Definition: usbprog.c:49
#define PORT_SET
Definition: usbprog.c:45
static void usbprog_jtag_write_tdi(struct usbprog_jtag *usbprog_jtag, char *buffer, int size)
Definition: usbprog.c:478
static void usbprog_jtag_write_slice(struct usbprog_jtag *usbprog_jtag, unsigned char value)
Definition: usbprog.c:522
#define TMS_BIT
Definition: usbprog.c:35
#define WRITE_AND_READ
Definition: usbprog.c:51
static void usbprog_path_move(struct pathmove_command *cmd)
Definition: usbprog.c:190
#define TCK_BIT
Definition: usbprog.c:34
static void usbprog_jtag_init(struct usbprog_jtag *usbprog_jtag)
Definition: usbprog.c:383
#define VID
Definition: usbprog.c:28
struct adapter_driver usbprog_adapter_driver
Definition: usbprog.c:591
uint8_t cmd
Definition: vdebug.c:1
uint8_t state[4]
Definition: vdebug.c:21