OpenOCD
angie.c
Go to the documentation of this file.
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /****************************************************************************
3  * File : angie.c
4  * Contents : Driver code for NanoXplore USB-JTAG ANGIE
5  * adapter hardware.
6  * Based on FT232R driver code by: Serge Vakulenko
7  *
8  * Copyright 2024, Ahmed BOUDJELIDA, NanoXplore SAS.
9  * <aboudjelida@nanoxplore.com>
10  ****************************************************************************/
11 
12 #ifdef HAVE_CONFIG_H
13 #include "config.h"
14 #endif
15 
16 #if IS_CYGWIN == 1
17 #include "windows.h"
18 #undef LOG_ERROR
19 #endif
20 
21 // project specific includes
22 #include <jtag/adapter.h>
23 #include <jtag/interface.h>
24 #include <jtag/commands.h>
25 #include <helper/time_support.h>
26 #include "libusb_helper.h"
27 #include <target/image.h>
28 #include <libusb.h>
29 
30 // system includes
31 #include <string.h>
32 #include <stdlib.h>
33 #include <unistd.h>
34 #include <sys/time.h>
35 #include <time.h>
36 
37 /*
38  * Sync bit bang mode is implemented as described in FTDI Application
39  * Note AN232R-01: "Bit Bang Modes for the ANGIE and FT245R".
40  */
41 
45 #define IN_EP 0x84
46 #define OUT_EP 0x02
47 
52 #define CPUCS_REG 0xE600
53 
55 #define REQUEST_FIRMWARE_LOAD 0xA0
56 
58 #define CPU_RESET 0x01
59 
61 #define CPU_START 0x00
62 
64 #define FIRMWARE_ADDR 0x0000
65 
67 #define ANGIE_RENUMERATION_DELAY_US 800000
68 
70 #define ANGIE_FIRMWARE_FILE PKGDATADIR "/angie/angie_firmware.bin"
71 
73 #define ANGIE_BITSTREAM_FILE PKGDATADIR "/angie/angie_bitstream.bit"
74 
79 #define ANGIE_FW_SECTION_SIZE 16384
80 
82 #define VR_CFGOPEN 0xB0
83 #define VR_DATAOUTOPEN 0xB2
84 
85 #define ANGIE_VID 0x584E /* NX Vendor id */
86 #define ANGIE_NPROG_PID 0x424E /* ANGIE non programmed */
87 #define ANGIE_PROG_OOCD_PID 0x414F /* ANGIE programmed OpenOCD */
88 #define ANGIE_PROG_NXB2_PID 0x4a55 /* ANGIE programmed Nxbase2 */
89 
90 #define TCK_GPIO 0
91 #define TDI_GPIO 1
92 #define TDO_GPIO 2
93 #define TMS_GPIO 3
94 #define NTRST_GPIO 4
95 #define NSYSRST_GPIO 6
96 
97 #define ANGIE_XFER_BUFFER_TOTAL_SIZE (16 * 1024)
98 #define ANGIE_USB_BULK_SIZE 512
99 
101 #define ANGIE_USB_TIMEOUT_MS 1000
102 
106 struct read_queue {
107  struct list_head list;
108 };
109 
114  const struct scan_command *cmd;
116  uint8_t *buffer;
117  struct list_head list;
118 };
119 
123 struct angie {
124  struct libusb_device_handle *usbdev;
129  struct read_queue read_queue;
130 };
131 
136 
143 {
144  INIT_LIST_HEAD(&queue->list);
145 }
146 
147 
155  struct read_queue_entry *entry)
156 {
157  list_add_tail(&entry->list, &queue->list);
158 }
159 
167  struct angie *device)
168 {
169  struct read_queue_entry *entry;
170  struct read_queue_entry *tmp;
171 
172  list_for_each_entry_safe(entry, tmp, &queue->list, list) {
173  int scan_size = jtag_scan_size(entry->cmd);
174 
175  // iterate over each bit in scan data
176  for (int bit_cnt = 0; bit_cnt < scan_size; bit_cnt++) {
177  // calculate byte index
178  int bytec = bit_cnt / 8;
179  // calculate bit mask: isolate the specific bit in corresponding byte
180  int bcval = 1 << (bit_cnt % 8);
181  // extract tdo value using index: "bit0_index + bit_cnt*2 + 1"
182  int val = device->reply_buffer[entry->reply_buffer_offset + bit_cnt * 2 + 1];
183  if (val & (1 << TDO_GPIO))
184  entry->buffer[bytec] |= bcval;
185  else
186  entry->buffer[bytec] &= ~bcval;
187  }
188 
189  jtag_read_buffer(entry->buffer, entry->cmd);
190 
191  list_del(&entry->list);
192  free(entry->buffer);
193  free(entry);
194  }
195 }
196 
203 {
204  struct read_queue_entry *entry;
205  struct read_queue_entry *tmp;
206 
207  list_for_each_entry_safe(entry, tmp, &queue->list, list) {
208  list_del(&entry->list);
209  free(entry->buffer);
210  free(entry);
211  }
212 }
213 
231  int xfer_size,
232  int offset,
233  int *bytes_sent)
234 {
235  uint8_t gpifcnt[4];
236  int sent_chunk_size = 0, bytes_received = 0;
237 
238  if (bytes_sent)
239  *bytes_sent = 0;
240 
241  h_u32_to_be(gpifcnt, xfer_size);
242 
243  int ret = jtag_libusb_control_transfer(device->usbdev,
244  LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE,
245  VR_DATAOUTOPEN, 0, 0, (char *)gpifcnt, sizeof(gpifcnt),
247  if (ret != ERROR_OK) {
248  LOG_ERROR("Failed to send GPIF count to target");
249  return ret;
250  }
251 
252  ret = jtag_libusb_bulk_write(device->usbdev, OUT_EP,
253  (char *)device->xfer_buffer + offset,
254  xfer_size, ANGIE_USB_TIMEOUT_MS, &sent_chunk_size);
255  if (ret != ERROR_OK) {
256  LOG_ERROR("USB bulk transfer failed");
257  return ret;
258  }
259 
260  ret = jtag_libusb_bulk_read(device->usbdev, IN_EP,
261  (char *)device->reply_buffer + offset,
262  sent_chunk_size, ANGIE_USB_TIMEOUT_MS, &bytes_received);
263  if (ret != ERROR_OK) {
264  LOG_ERROR("Failed to read USB reply");
265  return ret;
266  }
267 
268  if (sent_chunk_size == xfer_size && bytes_received == xfer_size) {
269  device->reply_buffer_len += xfer_size;
270  device->xfer_buffer_len -= xfer_size;
271  if (bytes_sent)
272  *bytes_sent += sent_chunk_size;
273  } else {
274  return ERROR_FAIL;
275  }
276 
277  return ERROR_OK;
278 }
279 
289 static int angie_buffer_flush(struct angie *device)
290 {
291  if (device->xfer_buffer_len == 0)
292  return ERROR_OK;
293 
294  int total_bytes_sent = 0;
295  device->reply_buffer_len = 0;
296 
297  do {
298  int sent_chunk_size;
299  size_t xfer_size = MIN(device->xfer_buffer_len, ANGIE_USB_BULK_SIZE);
300  int ret = angie_buffer_flush_chunk(device, xfer_size,
301  total_bytes_sent, &sent_chunk_size);
302  if (ret != ERROR_OK)
303  return ret;
304  total_bytes_sent += sent_chunk_size;
305  } while (device->xfer_buffer_len > 0);
306 
307  angie_read_queue_execute(&device->read_queue, device);
308 
309  return ERROR_OK;
310 }
311 
320 static int angie_buffer_flush_check(struct angie *device, size_t size)
321 {
322  if (device->xfer_buffer_len + size >= ANGIE_XFER_BUFFER_TOTAL_SIZE)
323  return angie_buffer_flush(device);
324  return ERROR_OK;
325 }
326 
334 static int angie_buffer_append_simple(struct angie *device, uint8_t value)
335 {
336  if (device->xfer_buffer_len >= ANGIE_XFER_BUFFER_TOTAL_SIZE) {
337  int ret = angie_buffer_flush(device);
338  if (ret != ERROR_OK)
339  return ret;
340  }
341  device->xfer_buffer[device->xfer_buffer_len++] = value;
342  return ERROR_OK;
343 }
344 
354 static int angie_buffer_append(struct angie *device, int tck, int tms, int tdi)
355 {
356  uint8_t val = (1 << NTRST_GPIO) | (1 << NSYSRST_GPIO);
357  if (tck)
358  val |= (1 << TCK_GPIO);
359  if (tms)
360  val |= (1 << TMS_GPIO);
361  if (tdi)
362  val |= (1 << TDI_GPIO);
363 
364  return angie_buffer_append_simple(device, val);
365 }
366 
373 static int angie_usb_open(struct angie *device)
374 {
375  uint16_t avids[] = {
376  ANGIE_VID,
377  ANGIE_VID,
378  ANGIE_VID,
379  0,
380  };
381  uint16_t apids[] = {
385  0,
386  };
387  struct libusb_device_handle *usb_dev;
388 
389  int ret = jtag_libusb_open(avids, apids, NULL, &usb_dev, NULL);
390  if (ret != ERROR_OK) {
391  LOG_ERROR("Failed to open ANGIE USB interface");
392  return ret;
393  }
394 
395  device->usbdev = usb_dev;
396 
397  return ERROR_OK;
398 }
399 
406 static int angie_usb_close(struct angie *device)
407 {
408  int ret = ERROR_OK;
409 
410  if (device->usbdev) {
411  if (libusb_release_interface(device->usbdev, 0) != LIBUSB_SUCCESS) {
412  LOG_ERROR("Could not release interface 0");
413  ret = ERROR_FAIL;
414  }
415 
416  jtag_libusb_close(device->usbdev);
417  device->usbdev = NULL;
418  }
419 
420  return ret;
421 }
422 
431 static int angie_cpu_reset(struct angie *device, char reset_bit)
432 {
433  return jtag_libusb_control_transfer(device->usbdev,
434  LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE,
435  REQUEST_FIRMWARE_LOAD, CPUCS_REG, 0, &reset_bit, 1,
437 }
438 
449 static int angie_write_firmware_section(struct angie *device, uint16_t address,
450  uint8_t *data, size_t size)
451 {
452  int bytes_remaining = size;
453 
454  // Send section data in chunks of up to 64 bytes to ANGIE
455  while (bytes_remaining > 0) {
456  int chunk_size;
457  int transferred;
458 
459  if (bytes_remaining > 64)
460  chunk_size = 64;
461  else
462  chunk_size = bytes_remaining;
463 
464  int ret = jtag_libusb_control_transfer(device->usbdev,
465  LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE,
467  chunk_size, ANGIE_USB_TIMEOUT_MS, &transferred);
468 
469  if (ret != ERROR_OK)
470  return ret;
471 
472  if (transferred != chunk_size) {
473  // Abort if libusb sent less data than requested
474  return ERROR_FAIL;
475  }
476 
477  bytes_remaining -= chunk_size;
478  address += chunk_size;
479  data += chunk_size;
480  }
481 
482  return ERROR_OK;
483 }
484 
494 static int angie_load_firmware(struct angie *device, const char *filename)
495 {
496  struct image angie_firmware_image;
497 
498  int ret = angie_cpu_reset(device, CPU_RESET);
499  if (ret != ERROR_OK) {
500  LOG_ERROR("Could not halt ANGIE CPU");
501  return ret;
502  }
503 
504  angie_firmware_image.base_address = 0;
505  angie_firmware_image.base_address_set = false;
506 
507  ret = image_open(&angie_firmware_image, filename, "bin");
508  if (ret != ERROR_OK) {
509  LOG_ERROR("Could not load firmware image");
510  return ret;
511  }
512 
513  uint8_t *data = malloc(ANGIE_FW_SECTION_SIZE);
514  if (!data) {
515  LOG_ERROR("Out of memory");
516  return ERROR_FAIL;
517  }
518 
519  // Download all sections in the image to ANGIE
520  for (unsigned int i = 0; i < angie_firmware_image.num_sections; i++) {
521  size_t size_read;
522  uint32_t size = angie_firmware_image.sections[i].size;
523  int addr = angie_firmware_image.sections[i].base_address;
524 
525  LOG_DEBUG("section %02i at addr 0x%04x (size 0x%04" PRIx32 ")",
526  i, addr, size);
527 
528  ret = image_read_section(&angie_firmware_image, i, 0,
529  size, data, &size_read);
530  if (ret != ERROR_OK)
531  goto exit;
532  if (size_read != size) {
533  ret = ERROR_FAIL;
534  goto exit;
535  }
536 
538  if (ret != ERROR_OK) {
539  LOG_ERROR("Could not write firmware section");
540  goto exit;
541  }
542  }
543 
544  image_close(&angie_firmware_image);
545 
547  if (ret != ERROR_OK) {
548  LOG_ERROR("Could not restart ANGIE CPU");
549  goto exit;
550  }
551 
552 exit:
553  free(data);
554  return ret;
555 }
556 
569  const char *filename,
570  uint32_t delay_us)
571 {
572  /*
573  * Basic process: After downloading the firmware, the ANGIE will disconnect
574  * itself and re-connect after a short amount of time so we have to close
575  * the handle and re-enumerate USB devices.
576  */
577 
578  int ret = angie_load_firmware(device, filename);
579  if (ret != ERROR_OK)
580  return ret;
581 
582  ret = angie_usb_close(device);
583  if (ret != ERROR_OK)
584  return ret;
585 
586  usleep(delay_us);
587 
588  ret = angie_usb_open(device);
589  if (ret != ERROR_OK)
590  return ret;
591 
592  if (libusb_claim_interface(angie_handle->usbdev, 0) != LIBUSB_SUCCESS)
593  return ERROR_FAIL;
594 
595  return ERROR_OK;
596 }
597 
607 static int angie_load_bitstream(struct angie *device, const char *filename)
608 {
609  int ret = ERROR_OK, transferred;
610  const char *bitstream_file_path = filename;
611  FILE *bitstream_file = NULL;
612  char *bitstream_data = NULL;
613  uint8_t gpifcnt[4];
614 
615  // Open the bitstream file
616  bitstream_file = fopen(bitstream_file_path, "rb");
617  if (!bitstream_file) {
618  LOG_ERROR("Failed to open bitstream file: %s\n", bitstream_file_path);
619  ret = ERROR_FAIL;
620  goto exit;
621  }
622 
623  // Get the size of the bitstream file
624  fseek(bitstream_file, 0, SEEK_END);
625  size_t bitstream_size = ftell(bitstream_file);
626  fseek(bitstream_file, 0, SEEK_SET);
627 
628  // Allocate memory for the bitstream data
629  bitstream_data = malloc(bitstream_size);
630  if (!bitstream_data) {
631  LOG_ERROR("Failed to allocate memory for bitstream data.");
632  ret = ERROR_FAIL;
633  goto exit;
634  }
635 
636  // Read the bitstream data from the file
637  if (fread(bitstream_data, 1, bitstream_size, bitstream_file) != bitstream_size) {
638  LOG_ERROR("Failed to read bitstream data.");
639  ret = ERROR_FAIL;
640  goto exit;
641  }
642 
643  // CFG Open
644  h_u32_to_be(gpifcnt, bitstream_size);
645  ret = jtag_libusb_control_transfer(device->usbdev,
646  LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE,
647  VR_CFGOPEN, 0, 0, (char *)gpifcnt, sizeof(gpifcnt),
648  ANGIE_USB_TIMEOUT_MS, &transferred);
649  if (ret != ERROR_OK) {
650  LOG_ERROR("Failed opencfg");
651  goto exit;
652  }
653 
654  // Send the bitstream data to the microcontroller
655  int actual_length = 0;
656  ret = jtag_libusb_bulk_write(device->usbdev, OUT_EP, bitstream_data,
657  bitstream_size, ANGIE_USB_TIMEOUT_MS, &actual_length);
658  if (ret != ERROR_OK) {
659  LOG_ERROR("Failed to send bitstream data: %s", libusb_strerror(ret));
660  goto exit;
661  }
662 
663  LOG_INFO("Bitstream sent successfully.");
664 
665 exit:
666  free(bitstream_data);
667  if (bitstream_file)
668  fclose(bitstream_file);
669 
670  return ret;
671 }
672 
680 {
681  struct libusb_device_descriptor desc;
682 
683  // Get String Descriptor to determine if firmware needs to be loaded
684  int ret = libusb_get_device_descriptor(libusb_get_device(angie_handle->usbdev),
685  &desc);
686  if (ret != LIBUSB_SUCCESS)
687  // Could not get descriptor -> Unconfigured or original Keil firmware
688  return true;
689  else if (desc.idProduct != ANGIE_PROG_OOCD_PID)
690  return true;
691 
692  return false;
693 }
694 
701 {
702  if (tap_is_state_stable(state)) {
704  } else {
705  LOG_ERROR("BUG: %i is not a valid end state", state);
706  exit(-1);
707  }
708 }
709 
717 static int angie_state_move(struct angie *device, int skip)
718 {
719  int ret;
720  int tms = 0;
721  uint8_t tms_scan = tap_get_tms_path(tap_get_state(), tap_get_end_state());
723 
724  // tms_scan has 8 bits that we bitbang one by one
725  for (int i = skip; i < tms_count; i++) {
726  tms = (tms_scan >> i) & 1;
727  ret = angie_buffer_append(device, 0, tms, 0);
728  if (ret != ERROR_OK)
729  return ret;
730  ret = angie_buffer_append(device, 1, tms, 0);
731  if (ret != ERROR_OK)
732  return ret;
733  }
734  ret = angie_buffer_append(device, 0, tms, 0);
735  if (ret != ERROR_OK)
736  return ret;
737 
739 
740  return ERROR_OK;
741 }
742 
750 static int angie_jtag_scan_size(struct angie *device,
751  const struct scan_command *cmd)
752 {
753  int cmd_size = 0;
754  int count = 0;
755 
756  // move to TAP_IRSHIFT or TAP_DRSHIFT state
757  if (cmd->ir_scan)
759  else
761  cmd_size += count * 2 + 1;
762 
763  // add scan size
764  cmd_size += jtag_scan_size(cmd) * 2;
765 
766  /*
767  * move to cmd specified end state
768  * Also, see below function
769  * we *KNOW* the above loop transitioned out of
770  * the shift state, so we skip the first state
771  * and move directly to the end state.
772  */
773  if (cmd->ir_scan)
774  count = tap_get_tms_path_len(TAP_IRSHIFT, cmd->end_state) - 1;
775  else
776  count = tap_get_tms_path_len(TAP_DRSHIFT, cmd->end_state) - 1;
777  cmd_size += count * 2 + 1;
778 
779  return cmd_size;
780 }
781 
790  const struct scan_command *cmd)
791 {
792  uint8_t *buffer = NULL;
793  LOG_DEBUG_IO("SCAN: size=%d %s scan end in %s", jtag_scan_size(cmd),
794  (cmd->ir_scan) ? "IR" : "DR", tap_state_name(cmd->end_state));
795 
796  if (cmd->ir_scan) {
797  if (tap_get_state() != TAP_IRSHIFT)
799  } else {
800  if (tap_get_state() != TAP_DRSHIFT)
802  }
803  int ret = angie_state_move(device, 0);
804  if (ret != ERROR_OK)
805  return ret;
806  angie_set_end_state(cmd->end_state);
807 
808  // Execute scan
809  int scan_size = jtag_build_buffer(cmd, &buffer);
811 
812  // starting byte index
813  int start_offset = device->xfer_buffer_len;
814 
815  // iterate over each bit in all scan data
816  int tms = 0;
817  int tdi = 0;
818  for (int i = 0; i < scan_size; i++) {
819  // calculate tms
820  // if we finish shifting tdi bits : '1' , else '0'
821  tms = (i == scan_size - 1) ? 1 : 0;
822  // calculate byte index
823  int bytec = i / 8;
824  // calculate bit mask: isolate the specific bit in corresponding byte
825  int bcval = 1 << (i % 8);
826  // if type is not SCAN_IN (not just reading data)
827  // and the bit masked is '1' then tdi = '1'
828  tdi = 0;
829  if (type != SCAN_IN && (buffer[bytec] & bcval))
830  tdi = 1;
831  // write tdi and tms twice in tck=0 and tck=1
832  ret = angie_buffer_append(device, 0, tms, tdi);
833  if (ret != ERROR_OK)
834  return ret;
835  ret = angie_buffer_append(device, 1, tms, tdi);
836  if (ret != ERROR_OK)
837  return ret;
838  }
839 
840  angie_set_end_state(cmd->end_state);
841  if (tap_get_state() != tap_get_end_state()) {
842  /*
843  * We *KNOW* the above loop transitioned out of
844  * the shift state, so we skip the first state
845  * and move directly to the end state.
846  */
847  ret = angie_state_move(device, 1);
848  if (ret != ERROR_OK)
849  return ret;
850  }
851 
852  if (jtag_scan_type(cmd) != SCAN_OUT) {
853  // queue read back buffer for further processing
854  struct read_queue_entry *entry = malloc(sizeof(*entry));
855  if (!entry) {
856  LOG_ERROR("Out of memory");
857  free(buffer);
858  return ERROR_FAIL;
859  }
860 
861  entry->reply_buffer_offset = start_offset;
862  entry->cmd = cmd;
863  entry->buffer = buffer;
864  angie_read_queue_add(&device->read_queue, entry);
865  } else {
866  // built buffer won't be of later use
867  free(buffer);
868  }
869 
870  return ERROR_OK;
871 }
872 
881  const struct runtest_command *cmd)
882 {
883  int cmd_size = 0;
884 
885  if (tap_get_state() != TAP_IDLE)
886  cmd_size += tap_get_tms_path_len(tap_get_state(), TAP_IDLE) * 2 + 1;
887  cmd_size += cmd->num_cycles * 2 + 1;
888  if (tap_get_end_state() != TAP_IDLE)
889  cmd_size += tap_get_tms_path_len(TAP_IDLE, tap_get_end_state()) * 2 + 1;
890 
891  return cmd_size;
892 }
893 
902  const struct runtest_command *cmd)
903 {
904  int ret;
905  enum tap_state saved_end_state = tap_get_end_state();
906 
907  LOG_DEBUG_IO("RUNTEST: %d cycles", cmd->num_cycles);
908 
909  // only do a state_move when we're not already in IDLE
910  if (tap_get_state() != TAP_IDLE) {
912  ret = angie_state_move(device, 0);
913  if (ret != ERROR_OK)
914  return ret;
915  }
916 
917  // execute num_cycles
918  for (unsigned int i = 0; i < cmd->num_cycles; i++) {
919  ret = angie_buffer_append(device, 0, 0, 0);
920  if (ret != ERROR_OK)
921  return ret;
922  ret = angie_buffer_append(device, 1, 0, 0);
923  if (ret != ERROR_OK)
924  return ret;
925  }
926  ret = angie_buffer_append(device, 0, 0, 0);
927  if (ret != ERROR_OK)
928  return ret;
929 
930  // finish in end_state
931  angie_set_end_state(saved_end_state);
932  if (tap_get_state() != tap_get_end_state()) {
933  ret = angie_state_move(device, 0);
934  if (ret != ERROR_OK)
935  return ret;
936  }
937 
938  return ERROR_OK;
939 }
940 
951  const struct tms_command *cmd)
952 {
953  unsigned int num_bits = cmd->num_bits;
954  const uint8_t *bits = cmd->bits;
955 
956  LOG_DEBUG_IO("TMS: %d bits", num_bits);
957 
958  int tms = 0;
959  for (unsigned int i = 0; i < num_bits; i++) {
960  tms = ((bits[i / 8] >> (i % 8)) & 1);
961  int ret = angie_buffer_append(device, 0, tms, 0);
962  if (ret != ERROR_OK)
963  return ret;
964  ret = angie_buffer_append(device, 1, tms, 0);
965  if (ret != ERROR_OK)
966  return ret;
967  }
968 
969  return angie_buffer_append(device, 0, tms, 0);
970 }
971 
982  const struct reset_command *cmd)
983 {
984  LOG_DEBUG_IO("RESET: trst %i srst %i", cmd->trst, cmd->srst);
985 
986  uint8_t out_value = (1 << NTRST_GPIO) | (1 << NSYSRST_GPIO);
987  if (cmd->trst == 1 ||
990 
991  if (cmd->trst == 1)
992  out_value &= ~(1 << NTRST_GPIO); // switch /TRST low
993  else if (cmd->trst == 0)
994  out_value |= (1 << NTRST_GPIO); // switch /TRST high
995 
996  if (cmd->srst == 1)
997  out_value &= ~(1 << NSYSRST_GPIO); // switch /SYSRST low
998  else if (cmd->srst == 0)
999  out_value |= (1 << NSYSRST_GPIO); // switch /SYSRST high
1000 
1001  return angie_buffer_append_simple(device, out_value);
1002 }
1003 
1017  const struct stableclocks_command *cmd)
1018 {
1019  int tms = (tap_get_state() == TAP_RESET ? 1 : 0);
1020 
1021  // send num_cycles clocks onto the cable
1022  for (unsigned int i = 0; i < cmd->num_cycles; i++) {
1023  int ret = angie_buffer_append(device, 1, tms, 0);
1024  if (ret != ERROR_OK)
1025  return ret;
1026  ret = angie_buffer_append(device, 0, tms, 0);
1027  if (ret != ERROR_OK)
1028  return ret;
1029  }
1030 
1031  LOG_DEBUG_IO("clocks %i while in %s", cmd->num_cycles,
1033 
1034  return ERROR_OK;
1035 }
1036 
1045  const struct statemove_command *cmd)
1046 {
1047  LOG_DEBUG_IO("statemove end in %s", tap_state_name(cmd->end_state));
1048  angie_set_end_state(cmd->end_state);
1049  return angie_state_move(device, 0);
1050 }
1051 
1060  const struct pathmove_command *cmd)
1061 {
1062  int ret;
1063  int num_states = cmd->num_states;
1064  int tms = 0;
1065 
1066  LOG_DEBUG_IO("pathmove: %i states, end in %s", cmd->num_states,
1067  tap_state_name(cmd->path[cmd->num_states - 1]));
1068 
1069  int state_count = 0;
1070  while (num_states) {
1071  if (tap_state_transition(tap_get_state(), false) == cmd->path[state_count]) {
1072  tms = 0;
1073  } else if (tap_state_transition(tap_get_state(), true) == cmd->path[state_count]) {
1074  tms = 1;
1075  } else {
1076  LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition",
1078  tap_state_name(cmd->path[state_count]));
1079  return ERROR_JTAG_DEVICE_ERROR;
1080  }
1081 
1082  ret = angie_buffer_append(device, 0, tms, 0);
1083  if (ret != ERROR_OK)
1084  return ret;
1085  ret = angie_buffer_append(device, 1, tms, 0);
1086  if (ret != ERROR_OK)
1087  return ret;
1088 
1089  tap_set_state(cmd->path[state_count]);
1090  state_count++;
1091  num_states--;
1092  }
1093  ret = angie_buffer_append(device, 0, tms, 0);
1094  if (ret != ERROR_OK)
1095  return ret;
1096 
1098 
1099  return ERROR_OK;
1100 }
1101 
1109 static size_t angie_cmd_size(struct angie *device, const struct jtag_command *cmd)
1110 {
1111  switch (cmd->type) {
1112  case JTAG_SCAN:
1113  return angie_jtag_scan_size(device, cmd->cmd.scan);
1114  case JTAG_TMS:
1115  return cmd->cmd.tms->num_bits + 2 + 1;
1116  case JTAG_RESET:
1117  return 1;
1118  case JTAG_RUNTEST:
1119  return angie_jtag_runtest_size(device, cmd->cmd.runtest);
1120  case JTAG_STABLECLOCKS:
1121  return cmd->cmd.stableclocks->num_cycles * 2;
1122  case JTAG_TLR_RESET: // renamed from JTAG_STATEMOVE
1124  cmd->cmd.statemove->end_state) * 2 + 1;
1125  case JTAG_PATHMOVE:
1126  return cmd->cmd.pathmove->num_states * 2 + 1;
1127  case JTAG_SLEEP:
1128  LOG_DEBUG_IO("sleep %" PRIu32, cmd->cmd.sleep->us);
1129  return 0;
1130  default:
1131  LOG_ERROR("BUG: unknown JTAG command type encountered");
1132  return 0;
1133  }
1134 }
1135 
1142 static int angie_jtag_execute_queue(struct jtag_command *cmd_queue)
1143 {
1144  int retval = ERROR_OK;
1145  struct jtag_command *cmd = cmd_queue;
1146  struct angie *device = angie_handle;
1147 
1148  while (cmd) {
1150  if (retval != ERROR_OK)
1151  return retval;
1152 
1153  switch (cmd->type) {
1154  case JTAG_SCAN:
1155  retval = angie_jtag_execute_scan(device, cmd->cmd.scan);
1156  if (retval != ERROR_OK)
1157  return retval;
1158  break;
1159  case JTAG_TMS:
1160  retval = angie_jtag_execute_tms(device, cmd->cmd.tms);
1161  if (retval != ERROR_OK)
1162  return retval;
1163  retval = angie_buffer_flush(device);
1164  if (retval != ERROR_OK)
1165  return retval;
1166  break;
1167  case JTAG_RESET:
1168  angie_jtag_execute_reset(device, cmd->cmd.reset);
1169  retval = angie_buffer_flush(device);
1170  if (retval != ERROR_OK)
1171  return retval;
1172  break;
1173  case JTAG_RUNTEST:
1174  retval = angie_jtag_execute_runtest(device, cmd->cmd.runtest);
1175  if (retval != ERROR_OK)
1176  return retval;
1177  break;
1178  case JTAG_STABLECLOCKS:
1179  /* this is only allowed while in a stable state. A check for a stable
1180  * state was done in jtag_add_clocks()
1181  */
1182  retval = angie_jtag_execute_stableclocks(device, cmd->cmd.stableclocks);
1183  if (retval != ERROR_OK)
1184  return retval;
1185  retval = angie_buffer_flush(device);
1186  if (retval != ERROR_OK)
1187  return retval;
1188  break;
1189  case JTAG_TLR_RESET: // renamed from JTAG_STATEMOVE
1190  retval = angie_jtag_execute_statemove(device, cmd->cmd.statemove);
1191  if (retval != ERROR_OK)
1192  return retval;
1193  retval = angie_buffer_flush(device);
1194  if (retval != ERROR_OK)
1195  return retval;
1196  break;
1197  case JTAG_PATHMOVE:
1198  retval = angie_jtag_execute_pathmove(device, cmd->cmd.pathmove);
1199  if (retval != ERROR_OK)
1200  return retval;
1201  retval = angie_buffer_flush(device);
1202  if (retval != ERROR_OK)
1203  return retval;
1204  break;
1205  case JTAG_SLEEP:
1206  LOG_DEBUG_IO("sleep %" PRIu32, cmd->cmd.sleep->us);
1207  jtag_sleep(cmd->cmd.sleep->us);
1208  break;
1209  default:
1210  LOG_ERROR("BUG: unknown JTAG command type encountered");
1211  break;
1212  }
1213 
1214  cmd = cmd->next;
1215  }
1216 
1217  return angie_buffer_flush(device);
1218 }
1219 
1225 static int angie_quit(void)
1226 {
1227  if (!angie_handle)
1228  return ERROR_OK;
1229 
1230  int ret = angie_usb_close(angie_handle);
1231  if (ret != ERROR_OK)
1232  return ret;
1233 
1235 
1236  free(angie_handle);
1237  angie_handle = NULL;
1238 
1239  return ERROR_OK;
1240 }
1241 
1247 static int angie_init(void)
1248 {
1249  int ret;
1250 
1251  angie_handle = calloc(1, sizeof(*angie_handle));
1252  if (!angie_handle) {
1253  ret = ERROR_FAIL;
1254  goto exit;
1255  }
1256 
1258 
1260  if (ret != ERROR_OK)
1261  goto exit;
1262 
1264  LOG_INFO("Loading ANGIE firmware. This is reversible by power-cycling ANGIE device.");
1265 
1266  ret = libusb_claim_interface(angie_handle->usbdev, 0);
1267  if (ret != LIBUSB_SUCCESS) {
1268  LOG_ERROR("Failed to claim interface 0");
1269  ret = ERROR_FAIL;
1270  goto exit;
1271  }
1272 
1276  if (ret != ERROR_OK) {
1277  LOG_ERROR("Could not download firmware and re-numerate ANGIE");
1278  angie_quit();
1279  return ret;
1280  }
1281 
1283  if (ret != ERROR_OK) {
1284  LOG_ERROR("Could not download bitstream");
1285  angie_quit();
1286  return ret;
1287  }
1288  } else {
1289  LOG_INFO("ANGIE device is already running ANGIE firmware");
1290  }
1291 
1292  return ERROR_OK;
1293 exit:
1294  angie_quit();
1295  return ret;
1296 }
1297 
1303 static int angie_speed(int divisor)
1304 {
1305  int baud = (divisor == 0) ? 3000000 :
1306  (divisor == 1) ? 2000000 :
1307  3000000 / divisor;
1308  LOG_DEBUG("angie speed(%d) rate %d bits/sec", divisor, baud);
1309 
1310  return ERROR_OK;
1311 }
1312 
1320 static int angie_khz(int khz, int *divisor)
1321 {
1322  if (khz == 0) {
1323  LOG_DEBUG("RCLK not supported");
1324  return ERROR_FAIL;
1325  }
1326 
1327  // Calculate frequency divisor.
1328  if (khz > 2500) {
1329  *divisor = 0; // Special case: 3 MHz
1330  } else if (khz > 1700) {
1331  *divisor = 1; // Special case: 2 MHz
1332  } else {
1333  *divisor = (2 * 3000 / khz + 1) / 2;
1334  if (*divisor > 0x3FFF)
1335  *divisor = 0x3FFF;
1336  }
1337  return ERROR_OK;
1338 }
1339 
1347 static int angie_speed_div(int divisor, int *khz)
1348 {
1349  // Maximum 3 Mbaud for bit bang mode
1350  if (divisor == 0)
1351  *khz = 30000;
1352  else if (divisor == 1)
1353  *khz = 20000;
1354  else
1355  *khz = 30000 / divisor;
1356  return ERROR_OK;
1357 }
1358 
1359 static struct jtag_interface angie_interface = {
1361  .execute_queue = angie_jtag_execute_queue,
1362 };
1363 
1365  .name = "angie",
1366  .transport_ids = TRANSPORT_JTAG,
1367  .transport_preferred_id = TRANSPORT_JTAG,
1368 
1369  .init = angie_init,
1370  .quit = angie_quit,
1371  .speed = angie_speed,
1372  .khz = angie_khz,
1373  .speed_div = angie_speed_div,
1374 
1375  .jtag_ops = &angie_interface,
1376 };
static int angie_usb_open(struct angie *device)
Open Angie USB interface.
Definition: angie.c:373
#define ANGIE_XFER_BUFFER_TOTAL_SIZE
Definition: angie.c:97
#define CPUCS_REG
Address of EZ-USB ANGIE CPU Control & Status register.
Definition: angie.c:52
static int angie_init(void)
Angie initialization method.
Definition: angie.c:1247
static bool angie_is_firmware_needed(struct angie *device)
Check if Angie firmware must be updated.
Definition: angie.c:679
#define ANGIE_FIRMWARE_FILE
Default location of ANGIE firmware image.
Definition: angie.c:70
#define ANGIE_NPROG_PID
Definition: angie.c:86
static int angie_jtag_execute_pathmove(struct angie *device, const struct pathmove_command *cmd)
Execute JTAG PATHMOVE command.
Definition: angie.c:1059
static int angie_jtag_scan_size(struct angie *device, const struct scan_command *cmd)
Return JTAG SCAN command size in bytes.
Definition: angie.c:750
static int angie_buffer_flush_check(struct angie *device, size_t size)
Check if transfer buffer has enough remaining space for a given size.
Definition: angie.c:320
#define TMS_GPIO
Definition: angie.c:93
static int angie_jtag_execute_scan(struct angie *device, const struct scan_command *cmd)
Execute JTAG SCAN command.
Definition: angie.c:789
static int angie_state_move(struct angie *device, int skip)
Move TAP to given state.
Definition: angie.c:717
static int angie_load_firmware(struct angie *device, const char *filename)
Downloads a firmware image to the ANGIE's EZ-USB microcontroller over the USB bus.
Definition: angie.c:494
#define CPU_START
Value to write into CPUCS to put EZ-USB ANGIE out of reset.
Definition: angie.c:61
#define TDI_GPIO
Definition: angie.c:91
#define OUT_EP
Definition: angie.c:46
#define ANGIE_USB_TIMEOUT_MS
USB timeout delay in milliseconds.
Definition: angie.c:101
static void angie_read_queue_execute(struct read_queue *queue, struct angie *device)
Execute elements enqueued in the read queue list.
Definition: angie.c:166
struct adapter_driver angie_adapter_driver
Definition: angie.c:1364
#define REQUEST_FIRMWARE_LOAD
USB Control EP0 bRequest: "Firmware Load".
Definition: angie.c:55
static struct jtag_interface angie_interface
Definition: angie.c:1359
#define IN_EP
USB endpoints.
Definition: angie.c:45
#define NTRST_GPIO
Definition: angie.c:94
#define FIRMWARE_ADDR
Base address of firmware in EZ-USB ANGIE code space.
Definition: angie.c:64
static int angie_buffer_flush_chunk(struct angie *device, int xfer_size, int offset, int *bytes_sent)
Flush a chunk of Angie's buffer.
Definition: angie.c:230
static int angie_write_firmware_section(struct angie *device, uint16_t address, uint8_t *data, size_t size)
Send one contiguous firmware section to the ANGIE's EZ-USB microcontroller over the USB bus.
Definition: angie.c:449
#define TCK_GPIO
Definition: angie.c:90
static int angie_jtag_execute_queue(struct jtag_command *cmd_queue)
Execute JTAG commands queue.
Definition: angie.c:1142
static void angie_read_queue_clean(struct read_queue *queue)
Clear the read queue list.
Definition: angie.c:202
static int angie_buffer_flush(struct angie *device)
Flush Angie transfer buffer.
Definition: angie.c:289
#define ANGIE_USB_BULK_SIZE
Definition: angie.c:98
static void angie_read_queue_add(struct read_queue *queue, struct read_queue_entry *entry)
Add a single entry to the read queue.
Definition: angie.c:154
static int angie_jtag_execute_reset(struct angie *device, const struct reset_command *cmd)
Execute JTAG RESET command Control /TRST and /SYSRST pins.
Definition: angie.c:981
#define ANGIE_VID
Definition: angie.c:85
static int angie_jtag_execute_statemove(struct angie *device, const struct statemove_command *cmd)
Execute JTAG STATEMOVE command.
Definition: angie.c:1044
#define ANGIE_FW_SECTION_SIZE
Maximum size of a single firmware section.
Definition: angie.c:79
struct angie * angie_handle
Angie device singleton.
Definition: angie.c:135
static int angie_buffer_append(struct angie *device, int tck, int tms, int tdi)
Append a bit-bang JTAG value to the transfer buffer.
Definition: angie.c:354
static size_t angie_cmd_size(struct angie *device, const struct jtag_command *cmd)
Process command size in bytes.
Definition: angie.c:1109
#define ANGIE_PROG_OOCD_PID
Definition: angie.c:87
#define TDO_GPIO
Definition: angie.c:92
#define ANGIE_RENUMERATION_DELAY_US
Delay (in microseconds) to wait while EZ-USB performs ReNumeration.
Definition: angie.c:67
static int angie_load_firmware_and_renumerate(struct angie *device, const char *filename, uint32_t delay_us)
Puts the ANGIE's EZ-USB microcontroller into reset state, downloads the firmware image,...
Definition: angie.c:568
static int angie_buffer_append_simple(struct angie *device, uint8_t value)
Append a single byte value to the transfer buffer.
Definition: angie.c:334
static int angie_speed(int divisor)
Angie set speed method.
Definition: angie.c:1303
static int angie_khz(int khz, int *divisor)
Angie set khz method.
Definition: angie.c:1320
#define VR_DATAOUTOPEN
Definition: angie.c:83
static int angie_jtag_execute_stableclocks(struct angie *device, const struct stableclocks_command *cmd)
Execute JTAG STABLECLOCKS command Issues a number of clock cycles while staying in a stable state.
Definition: angie.c:1016
static int angie_jtag_execute_runtest(struct angie *device, const struct runtest_command *cmd)
Execute JTAG RUNTEST command.
Definition: angie.c:901
static int angie_quit(void)
Angie quit method.
Definition: angie.c:1225
static int angie_usb_close(struct angie *device)
Releases the ANGIE interface and closes the USB device handle.
Definition: angie.c:406
#define ANGIE_PROG_NXB2_PID
Definition: angie.c:88
#define CPU_RESET
Value to write into CPUCS to put EZ-USB ANGIE into reset.
Definition: angie.c:58
static int angie_cpu_reset(struct angie *device, char reset_bit)
Writes '0' or '1' to the CPUCS register, putting the EZ-USB CPU into reset or out of reset.
Definition: angie.c:431
#define NSYSRST_GPIO
Definition: angie.c:95
#define ANGIE_BITSTREAM_FILE
Default location of ANGIE firmware image.
Definition: angie.c:73
static void angie_read_queue_init(struct read_queue *queue)
Init read queue list.
Definition: angie.c:142
static int angie_jtag_execute_tms(struct angie *device, const struct tms_command *cmd)
Execute JTAG TMS command Clock a bunch of TMS transitions, to change the JTAG state machine.
Definition: angie.c:950
#define VR_CFGOPEN
Vendor Requests.
Definition: angie.c:82
static int angie_speed_div(int divisor, int *khz)
Angie set speed div.
Definition: angie.c:1347
static void angie_set_end_state(enum tap_state state)
Set TAP end state.
Definition: angie.c:700
static int angie_jtag_runtest_size(struct angie *device, const struct runtest_command *cmd)
Return JTAG RUNTEST command size in bytes.
Definition: angie.c:880
static int angie_load_bitstream(struct angie *device, const char *filename)
Downloads a bitstream file to the ANGIE's FPGA through the EZ-USB microcontroller over the USB bus.
Definition: angie.c:607
static const struct device_t * device
Definition: at91rm9200.c:94
unsigned int jtag_scan_size(const struct scan_command *cmd)
Definition: commands.c:181
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
@ JTAG_TLR_RESET
Definition: commands.h:137
@ JTAG_SCAN
Definition: commands.h:129
@ JTAG_PATHMOVE
Definition: commands.h:140
@ JTAG_STABLECLOCKS
Definition: commands.h:142
@ JTAG_RUNTEST
Definition: commands.h:138
@ JTAG_SLEEP
Definition: commands.h:141
@ JTAG_RESET
Definition: commands.h:139
@ JTAG_TMS
Definition: commands.h:143
void delay_us(uint16_t delay)
Definition: delay.c:23
uint64_t buffer
Pointer to data buffer to send over SPI.
Definition: dw-spi-helper.h:0
uint32_t size
Size of dw_spi_transaction::buffer.
Definition: dw-spi-helper.h:4
uint32_t address
Starting address. Sector aligned.
Definition: dw-spi-helper.h:0
uint8_t type
Definition: esp_usb_jtag.c:0
void image_close(struct image *image)
Definition: image.c:1211
int image_read_section(struct image *image, int section, target_addr_t offset, uint32_t size, uint8_t *buffer, size_t *size_read)
Definition: image.c:1079
int image_open(struct image *image, const char *url, const char *type_string)
Definition: image.c:957
enum tap_state tap_get_end_state(void)
For more information,.
Definition: interface.c:56
enum tap_state tap_state_transition(enum tap_state 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(enum tap_state state)
Function tap_state_name Returns a string suitable for display representing the JTAG tap_state.
Definition: interface.c:344
int tap_get_tms_path_len(enum tap_state from, enum tap_state to)
Function int tap_get_tms_path_len returns the total number of bits that represents a TMS path transit...
Definition: interface.c:195
void tap_set_end_state(enum tap_state 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
enum tap_state 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
bool tap_is_state_stable(enum tap_state astate)
Function tap_is_state_stable returns true if the astate is stable.
Definition: interface.c:200
int tap_get_tms_path(enum tap_state from, enum tap_state to)
This function provides a "bit sequence" indicating what has to be done with TMS during a sequence of ...
Definition: interface.c:190
#define DEBUG_CAP_TMS_SEQ
Definition: interface.h:188
#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:50
void jtag_sleep(uint32_t us)
Definition: jtag/core.c:1075
enum reset_types jtag_get_reset_config(void)
Definition: jtag/core.c:1747
#define ERROR_JTAG_DEVICE_ERROR
Definition: jtag.h:558
tap_state
Defines JTAG Test Access Port states.
Definition: jtag.h:37
@ TAP_RESET
Definition: jtag.h:56
@ TAP_IRSHIFT
Definition: jtag.h:51
@ TAP_IDLE
Definition: jtag.h:53
@ TAP_DRSHIFT
Definition: jtag.h:43
@ RESET_SRST_PULLS_TRST
Definition: jtag.h:220
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_control_transfer(struct libusb_device_handle *dev, uint8_t request_type, uint8_t request, uint16_t value, uint16_t index, char *bytes, uint16_t size, unsigned int timeout, int *transferred)
void jtag_libusb_close(struct libusb_device_handle *dev)
int jtag_libusb_bulk_read(struct libusb_device_handle *dev, int ep, char *bytes, int size, int timeout, int *transferred)
static void list_add_tail(struct list_head *new, struct list_head *head)
Definition: list.h:203
#define list_for_each_entry_safe(p, n, h, field)
Definition: list.h:159
static void list_del(struct list_head *entry)
Definition: list.h:88
static void INIT_LIST_HEAD(struct list_head *list)
Definition: list.h:54
#define LOG_DEBUG_IO(expr ...)
Definition: log.h:102
#define ERROR_FAIL
Definition: log.h:174
#define LOG_ERROR(expr ...)
Definition: log.h:133
#define LOG_INFO(expr ...)
Definition: log.h:127
#define LOG_DEBUG(expr ...)
Definition: log.h:110
#define ERROR_OK
Definition: log.h:168
uint8_t bits[QN908X_FLASH_MAX_BLOCKS *QN908X_FLASH_PAGES_PER_BLOCK/8]
Definition: qn908x.c:0
#define MIN(a, b)
Definition: replacements.h:22
target_addr_t addr
Start address to search for the control block.
Definition: rtt/rtt.c:28
Represents a driver for a debugging interface.
Definition: interface.h:208
const char *const name
The name of the interface driver.
Definition: interface.h:210
Angie device main context.
Definition: angie.c:123
size_t xfer_buffer_len
Definition: angie.c:126
struct libusb_device_handle * usbdev
Definition: angie.c:124
uint8_t reply_buffer[ANGIE_XFER_BUFFER_TOTAL_SIZE]
Definition: angie.c:127
size_t reply_buffer_len
Definition: angie.c:128
uint8_t xfer_buffer[ANGIE_XFER_BUFFER_TOTAL_SIZE]
Definition: angie.c:125
struct read_queue read_queue
Definition: angie.c:129
Definition: image.h:48
unsigned int num_sections
Definition: image.h:51
struct imagesection * sections
Definition: image.h:52
long long base_address
Definition: image.h:54
bool base_address_set
Definition: image.h:53
target_addr_t base_address
Definition: image.h:42
uint32_t size
Definition: image.h:43
Represents a driver for a debugging interface.
Definition: interface.h:183
unsigned int supported
Bit vector listing capabilities exposed by this driver.
Definition: interface.h:187
Definition: list.h:41
Definition: osbdm.c:25
Entry element used to forge a reply buffer for openocd JTAG core.
Definition: angie.c:113
const struct scan_command * cmd
Definition: angie.c:114
uint8_t * buffer
Definition: angie.c:116
int reply_buffer_offset
Definition: angie.c:115
struct list_head list
Definition: angie.c:117
List of elements used in a multiple commands reply.
Definition: angie.c:106
struct list_head list
Definition: angie.c:107
The scan_command provide a means of encapsulating a set of scan_field structures that should be scann...
Definition: commands.h:35
Encapsulates a series of bits to be clocked out, affecting state and mode of the interface.
Definition: commands.h:101
#define TRANSPORT_JTAG
Definition: transport.h:19
static void h_u32_to_be(uint8_t *buf, uint32_t val)
Definition: types.h:186
#define NULL
Definition: usb.h:16
uint8_t cmd
Definition: vdebug.c:1
uint8_t offset[4]
Definition: vdebug.c:9
uint8_t state[4]
Definition: vdebug.c:21
uint8_t count[4]
Definition: vdebug.c:22