OpenOCD
gowin.c
Go to the documentation of this file.
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 
3 /***************************************************************************
4  * Copyright (C) 2022 by Daniel Anselmi *
5  * danselmi@gmx.ch *
6  ***************************************************************************/
7 
8 #ifdef HAVE_CONFIG_H
9 #include "config.h"
10 #endif
11 
12 #include <jtag/jtag.h>
13 #include <jtag/adapter.h>
14 #include <helper/bits.h>
15 #include "pld.h"
16 #include "raw_bit.h"
17 
18 #define NO_OP 0x02
19 #define ERASE_SRAM 0x05
20 #define SRAM_ERASE_DONE 0x09
21 #define IDCODE 0x11
22 #define ADDRESS_INITIALIZATION 0x12
23 #define READ_USERCODE 0x13
24 #define CONFIG_ENABLE 0x15
25 #define TRANSFER_CONFIGURATION_DATA 0x17
26 #define CONFIG_DISABLE 0x3A
27 #define RELOAD 0x3C
28 #define STATUS_REGISTER 0x41
29 #define ERASE_FLASH 0x75
30 #define ENABLE_2ND_FLASH 0x78
31 
32 #define USER1 0x42
33 #define USER2 0x43
34 
35 #define STAUS_MASK_MEMORY_ERASE BIT(5)
36 #define STAUS_MASK_SYSTEM_EDIT_MODE BIT(7)
37 
39  struct jtag_tap *tap;
40 };
41 
43  struct raw_bit_file raw_file;
44  size_t capacity;
45  uint32_t id;
46  uint16_t stored_checksum;
48  int crc_en;
49  uint16_t checksum;
50  uint8_t replace8x;
51  uint8_t replace4x;
52  uint8_t replace2x;
53 };
54 
55 static uint64_t gowin_read_fs_file_bitsequence(const char *bits, int length)
56 {
57  uint64_t res = 0;
58  for (int i = 0; i < length; i++)
59  res = (res << 1) | (*bits++ == '1' ? 1 : 0);
60  return res;
61 }
62 
63 static int gowin_add_byte_to_bit_file(struct gowin_bit_file *bit_file, uint8_t byte)
64 {
65  if (bit_file->raw_file.length + 1 > bit_file->capacity) {
66  uint8_t *buffer;
67  if (bit_file->raw_file.data)
68  buffer = realloc(bit_file->raw_file.data, bit_file->capacity + 8192);
69  else
70  buffer = malloc(8192);
71  if (!buffer) {
72  LOG_ERROR("Out of memory");
73  return ERROR_FAIL;
74  }
75  bit_file->raw_file.data = buffer;
76  bit_file->capacity += 8192;
77  }
78 
79  bit_file->raw_file.data[bit_file->raw_file.length++] = byte;
80 
81  return ERROR_OK;
82 }
83 
84 static int gowin_read_fs_file_header(struct gowin_bit_file *bit_file, FILE *stream)
85 {
86  if (!bit_file)
87  return ERROR_FAIL;
88 
89  int end_of_header = 0;
90  while (!end_of_header) {
91  char buffer[256];
92  char *line = fgets(buffer, 256, stream);
93  if (!line || feof(stream) || ferror(stream))
94  return ERROR_FAIL;
95 
96  if (line[0] == '/')
97  continue;
98 
99  size_t line_length = strlen(line);
100  if (line[line_length - 1] != '\n')
101  return ERROR_FAIL;
102  line_length--;
103 
104  for (unsigned int i = 0; i < line_length; i += 8) {
105  uint8_t byte = gowin_read_fs_file_bitsequence(line + i, 8);
106  int retval = gowin_add_byte_to_bit_file(bit_file, byte);
107  if (retval != ERROR_OK)
108  return retval;
109  }
110 
111  uint8_t key = gowin_read_fs_file_bitsequence(line, 8);
112  line += 8;
113  uint64_t value = gowin_read_fs_file_bitsequence(line, line_length - 8);
114 
115  if (key == 0x06) {
116  bit_file->id = value & 0xffffffff;
117  } else if (key == 0x3B) {
118  end_of_header = 1;
119  bit_file->crc_en = (value & BIT(23)) ? 1 : 0;
120  }
121  }
122 
123  return ERROR_OK;
124 }
125 
126 static int gowin_read_fs_file(struct gowin_bit_file *bit_file, const char *filename)
127 {
128  FILE *input_file = fopen(filename, "r");
129 
130  if (!input_file) {
131  LOG_ERROR("Couldn't open %s: %s", filename, strerror(errno));
133  }
134 
135  int retval = gowin_read_fs_file_header(bit_file, input_file);
136  if (retval != ERROR_OK) {
137  free(bit_file->raw_file.data);
138  fclose(input_file);
139  return retval;
140  }
141 
142  char digits_buffer[9]; /* 8 + 1 trailing zero */
143  do {
144  char *digits = fgets(digits_buffer, 9, input_file);
145  if (feof(input_file))
146  break;
147  if (!digits || ferror(input_file)) {
148  free(bit_file->raw_file.data);
149  fclose(input_file);
150  return ERROR_FAIL;
151  }
152  if (digits[0] == '\n')
153  continue;
154 
155  if (strlen(digits) != 8) {
156  free(bit_file->raw_file.data);
157  fclose(input_file);
158  return ERROR_FAIL;
159  }
160  uint8_t byte = gowin_read_fs_file_bitsequence(digits, 8);
161  retval = gowin_add_byte_to_bit_file(bit_file, byte);
162  if (retval != ERROR_OK) {
163  free(bit_file->raw_file.data);
164  fclose(input_file);
165  return ERROR_FAIL;
166  }
167  } while (1);
168 
169  fclose(input_file);
170  return ERROR_OK;
171 }
172 
173 static int gowin_read_file(struct gowin_bit_file *bit_file, const char *filename, bool *is_fs)
174 {
175  memset(bit_file, 0, sizeof(struct gowin_bit_file));
176 
177  if (!filename || !bit_file)
179 
180  const char *file_suffix_pos = strrchr(filename, '.');
181  if (!file_suffix_pos) {
182  LOG_ERROR("Unable to detect filename suffix");
184  }
185 
186  /* check if binary .bin or ascii .fs */
187  if (strcasecmp(file_suffix_pos, ".bin") == 0) {
188  *is_fs = false;
189  return cpld_read_raw_bit_file(&bit_file->raw_file, filename);
190  } else if (strcasecmp(file_suffix_pos, ".fs") == 0) {
191  *is_fs = true;
192  return gowin_read_fs_file(bit_file, filename);
193  }
194 
195  LOG_ERROR("Filetype not supported, expecting .fs or .bin file");
197 }
198 
199 static int gowin_set_instr(struct jtag_tap *tap, uint8_t new_instr)
200 {
201  struct scan_field field;
202  field.num_bits = tap->ir_length;
203  void *t = calloc(DIV_ROUND_UP(field.num_bits, 8), 1);
204  if (!t) {
205  LOG_ERROR("Out of memory");
206  return ERROR_FAIL;
207  }
208  field.out_value = t;
209  buf_set_u32(t, 0, field.num_bits, new_instr);
210  field.in_value = NULL;
211  jtag_add_ir_scan(tap, &field, TAP_IDLE);
213  free(t);
214  return ERROR_OK;
215 }
216 
217 static int gowin_read_register(struct jtag_tap *tap, uint32_t reg, uint32_t *result)
218 {
219  struct scan_field field;
220 
221  int retval = gowin_set_instr(tap, reg);
222  if (retval != ERROR_OK)
223  return retval;
224  retval = jtag_execute_queue();
225  if (retval != ERROR_OK)
226  return retval;
227 
228  uint8_t buf[4] = {0};
229  field.check_mask = NULL;
230  field.check_value = NULL;
231  field.num_bits = 32;
232  field.out_value = buf;
233  field.in_value = buf;
234 
235  jtag_add_dr_scan(tap, 1, &field, TAP_IDLE);
236  retval = jtag_execute_queue();
237  *result = le_to_h_u32(buf);
238  return retval;
239 }
240 
241 static int gowin_check_status_flag(struct jtag_tap *tap, uint32_t mask, uint32_t flag)
242 {
243  uint32_t status = 0;
244 
245  int retries = 0;
246  do {
247  int retval = gowin_read_register(tap, STATUS_REGISTER, &status);
248  if (retval != ERROR_OK)
249  return retval;
250  if (retries++ == 100000)
251  return ERROR_FAIL;
252  } while ((status & mask) != flag);
253 
254  return ERROR_OK;
255 }
256 
257 static int gowin_enable_config(struct jtag_tap *tap)
258 {
259  int retval = gowin_set_instr(tap, CONFIG_ENABLE);
260  if (retval != ERROR_OK)
261  return retval;
262  retval = jtag_execute_queue();
263  if (retval != ERROR_OK)
264  return retval;
265 
267 }
268 
269 static int gowin_disable_config(struct jtag_tap *tap)
270 {
271  int retval = gowin_set_instr(tap, CONFIG_DISABLE);
272  if (retval != ERROR_OK)
273  return retval;
274  retval = jtag_execute_queue();
275  if (retval != ERROR_OK)
276  return retval;
277 
279 }
280 
281 static int gowin_reload(struct jtag_tap *tap)
282 {
283  int retval = gowin_set_instr(tap, RELOAD);
284  if (retval != ERROR_OK)
285  return retval;
286  retval = gowin_set_instr(tap, NO_OP);
287  if (retval != ERROR_OK)
288  return retval;
289  return jtag_execute_queue();
290 }
291 
292 static int gowin_runtest_idle(struct jtag_tap *tap, unsigned int frac_sec)
293 {
294  int speed = adapter_get_speed_khz() * 1000;
295  int cycles = DIV_ROUND_UP(speed, frac_sec);
296  jtag_add_runtest(cycles, TAP_IDLE);
297  return jtag_execute_queue();
298 }
299 
300 static int gowin_erase_sram(struct jtag_tap *tap, bool tx_erase_done)
301 {
302  /* config is already enabled */
303  int retval = gowin_set_instr(tap, ERASE_SRAM);
304  if (retval != ERROR_OK)
305  return retval;
306  retval = gowin_set_instr(tap, NO_OP);
307  if (retval != ERROR_OK)
308  return retval;
309 
310  /* Delay or Run Test 2~10ms */
311  /* 10 ms is worst case for GW2A-55 */
312  jtag_add_sleep(10000);
313  retval = jtag_execute_queue();
314  if (retval != ERROR_OK)
315  return retval;
316 
319  if (retval != ERROR_OK)
320  return retval;
321 
322  if (tx_erase_done) {
323  retval = gowin_set_instr(tap, SRAM_ERASE_DONE);
324  if (retval != ERROR_OK)
325  return retval;
326  retval = gowin_set_instr(tap, NO_OP);
327  if (retval != ERROR_OK)
328  return retval;
329  retval = jtag_execute_queue();
330  if (retval != ERROR_OK)
331  return retval;
332  /* gen clock cycles in RUN/IDLE for 500us -> 1/500us = 2000/s */
333  retval = gowin_runtest_idle(tap, 2000);
334  if (retval != ERROR_OK)
335  return retval;
336  }
337 
338  retval = gowin_set_instr(tap, NO_OP);
339  if (retval != ERROR_OK)
340  return retval;
341  return jtag_execute_queue();
342 }
343 
344 static int gowin_load_to_sram(struct pld_device *pld_device, const char *filename)
345 {
346  if (!pld_device)
347  return ERROR_FAIL;
348 
349  struct gowin_pld_device *gowin_info = pld_device->driver_priv;
350 
351  if (!gowin_info || !gowin_info->tap)
352  return ERROR_FAIL;
353  struct jtag_tap *tap = gowin_info->tap;
354 
355  bool is_fs = false;
356  struct gowin_bit_file bit_file;
357  int retval = gowin_read_file(&bit_file, filename, &is_fs);
358  if (retval != ERROR_OK)
359  return retval;
360 
361  for (unsigned int i = 0; i < bit_file.raw_file.length; i++)
362  bit_file.raw_file.data[i] = flip_u32(bit_file.raw_file.data[i], 8);
363 
364  uint32_t id;
365  retval = gowin_read_register(tap, IDCODE, &id);
366  if (retval != ERROR_OK) {
367  free(bit_file.raw_file.data);
368  return retval;
369  }
370 
371  if (is_fs && id != bit_file.id) {
372  free(bit_file.raw_file.data);
373  LOG_ERROR("Id on device (0x%8.8" PRIx32 ") and id in bit-stream (0x%8.8" PRIx32 ") don't match.",
374  id, bit_file.id);
375  return ERROR_FAIL;
376  }
377 
378  retval = gowin_enable_config(tap);
379  if (retval != ERROR_OK) {
380  free(bit_file.raw_file.data);
381  return retval;
382  }
383 
384  retval = gowin_erase_sram(tap, false);
385  if (retval != ERROR_OK) {
386  free(bit_file.raw_file.data);
387  return retval;
388  }
389 
391  if (retval != ERROR_OK) {
392  free(bit_file.raw_file.data);
393  return retval;
394  }
396  if (retval != ERROR_OK) {
397  free(bit_file.raw_file.data);
398  return retval;
399  }
400 
401  /* scan out the bitstream */
402  struct scan_field field;
403  field.num_bits = bit_file.raw_file.length * 8;
404  field.out_value = bit_file.raw_file.data;
405  field.in_value = bit_file.raw_file.data;
406  jtag_add_dr_scan(gowin_info->tap, 1, &field, TAP_IDLE);
408 
409  retval = jtag_execute_queue();
410  if (retval != ERROR_OK) {
411  free(bit_file.raw_file.data);
412  return retval;
413  }
414 
415  retval = gowin_disable_config(tap);
416  free(bit_file.raw_file.data);
417  if (retval != ERROR_OK)
418  return retval;
419 
420  retval = gowin_set_instr(gowin_info->tap, NO_OP);
421  if (retval != ERROR_OK)
422  return retval;
423 
424  retval = jtag_execute_queue();
425 
426  return retval;
427 }
428 
429 static int gowin_read_register_command(struct pld_device *pld_device, uint32_t cmd, uint32_t *value)
430 {
431  if (!pld_device)
432  return ERROR_FAIL;
433 
434  struct gowin_pld_device *gowin_info = pld_device->driver_priv;
435 
436  if (!gowin_info || !gowin_info->tap)
437  return ERROR_FAIL;
438 
439  return gowin_read_register(gowin_info->tap, cmd, value);
440 }
441 
443 {
444  if (!pld_device)
445  return ERROR_FAIL;
446 
447  struct gowin_pld_device *gowin_info = pld_device->driver_priv;
448 
449  if (!gowin_info || !gowin_info->tap)
450  return ERROR_FAIL;
451 
452  return gowin_reload(gowin_info->tap);
453 }
454 
455 static int gowin_get_ipdbg_hub(int user_num, struct pld_device *pld_device, struct pld_ipdbg_hub *hub)
456 {
457  if (!pld_device)
458  return ERROR_FAIL;
459 
460  struct gowin_pld_device *pld_device_info = pld_device->driver_priv;
461 
462  if (!pld_device_info || !pld_device_info->tap)
463  return ERROR_FAIL;
464 
465  hub->tap = pld_device_info->tap;
466 
467  if (user_num == 1) {
468  hub->user_ir_code = USER1;
469  } else if (user_num == 2) {
470  hub->user_ir_code = USER2;
471  } else {
472  LOG_ERROR("gowin devices only have user register 1 & 2");
473  return ERROR_FAIL;
474  }
475  return ERROR_OK;
476 }
477 
478 COMMAND_HANDLER(gowin_read_status_command_handler)
479 {
480  if (CMD_ARGC != 1)
482 
484  if (!device) {
485  command_print(CMD, "pld device '#%s' is out of bounds or unknown", CMD_ARGV[0]);
486  return ERROR_FAIL;
487  }
488 
489  uint32_t status = 0;
491 
492  if (retval == ERROR_OK)
493  command_print(CMD, "0x%8.8" PRIx32, status);
494 
495  return retval;
496 }
497 
498 COMMAND_HANDLER(gowin_read_user_register_command_handler)
499 {
500  if (CMD_ARGC != 1)
502 
504  if (!device) {
505  command_print(CMD, "pld device '#%s' is out of bounds or unknown", CMD_ARGV[0]);
506  return ERROR_FAIL;
507  }
508 
509  uint32_t user_reg = 0;
510  int retval = gowin_read_register_command(device, READ_USERCODE, &user_reg);
511 
512  if (retval == ERROR_OK)
513  command_print(CMD, "0x%8.8" PRIx32, user_reg);
514 
515  return retval;
516 }
517 
518 COMMAND_HANDLER(gowin_reload_command_handler)
519 {
520  if (CMD_ARGC != 1)
522 
524  if (!device) {
525  command_print(CMD, "pld device '#%s' is out of bounds or unknown", CMD_ARGV[0]);
526  return ERROR_FAIL;
527  }
528 
530 }
531 
532 static const struct command_registration gowin_exec_command_handlers[] = {
533  {
534  .name = "read_status",
535  .mode = COMMAND_EXEC,
536  .handler = gowin_read_status_command_handler,
537  .help = "reading status register from FPGA",
538  .usage = "pld_name",
539  }, {
540  .name = "read_user",
541  .mode = COMMAND_EXEC,
542  .handler = gowin_read_user_register_command_handler,
543  .help = "reading user register from FPGA",
544  .usage = "pld_name",
545  }, {
546  .name = "refresh",
547  .mode = COMMAND_EXEC,
548  .handler = gowin_reload_command_handler,
549  .help = "reload bitstream from flash to SRAM",
550  .usage = "pld_name",
551  },
553 };
554 
555 static const struct command_registration gowin_command_handler[] = {
556  {
557  .name = "gowin",
558  .mode = COMMAND_ANY,
559  .help = "gowin specific commands",
560  .usage = "",
562  },
564 };
565 
566 PLD_CREATE_COMMAND_HANDLER(gowin_pld_create_command)
567 {
568  if (CMD_ARGC != 4)
570 
571  if (strcmp(CMD_ARGV[2], "-chain-position") != 0)
573 
574  struct jtag_tap *tap = jtag_tap_by_string(CMD_ARGV[3]);
575  if (!tap) {
576  command_print(CMD, "Tap: %s does not exist", CMD_ARGV[3]);
577  return ERROR_FAIL;
578  }
579 
580  struct gowin_pld_device *gowin_info = malloc(sizeof(struct gowin_pld_device));
581  if (!gowin_info) {
582  LOG_ERROR("Out of memory");
583  return ERROR_FAIL;
584  }
585  gowin_info->tap = tap;
586 
587  pld->driver_priv = gowin_info;
588 
589  return ERROR_OK;
590 }
591 
592 struct pld_driver gowin_pld = {
593  .name = "gowin",
594  .commands = gowin_command_handler,
595  .pld_create_command = &gowin_pld_create_command,
596  .load = &gowin_load_to_sram,
597  .get_ipdbg_hub = gowin_get_ipdbg_hub,
598 };
unsigned int adapter_get_speed_khz(void)
Retrieves the clock speed of the adapter in kHz.
Definition: adapter.c:207
static const struct device_t * device
Definition: at91rm9200.c:94
uint32_t flip_u32(uint32_t value, unsigned int num)
Inverts the ordering of bits inside a 32-bit word (e.g.
Definition: binarybuffer.c:165
static void buf_set_u32(uint8_t *_buffer, unsigned int first, unsigned int num, uint32_t value)
Sets num bits in _buffer, starting at the first bit, using the bits in value.
Definition: binarybuffer.h:34
void command_print(struct command_invocation *cmd, const char *format,...)
Definition: command.c:443
#define CMD
Use this macro to access the command being handled, rather than accessing the variable directly.
Definition: command.h:141
#define CMD_ARGV
Use this macro to access the arguments for the command being handled, rather than accessing the varia...
Definition: command.h:156
#define ERROR_COMMAND_SYNTAX_ERROR
Definition: command.h:402
#define CMD_ARGC
Use this macro to access the number of arguments for the command being handled, rather than accessing...
Definition: command.h:151
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
Definition: command.h:253
@ COMMAND_ANY
Definition: command.h:42
@ COMMAND_EXEC
Definition: command.h:40
int mask
Definition: esirisc.c:1741
uint8_t length
Definition: esp_usb_jtag.c:1
#define CONFIG_ENABLE
Definition: gowin.c:24
static int gowin_enable_config(struct jtag_tap *tap)
Definition: gowin.c:257
#define USER1
Definition: gowin.c:32
static const struct command_registration gowin_exec_command_handlers[]
Definition: gowin.c:532
PLD_CREATE_COMMAND_HANDLER(gowin_pld_create_command)
Definition: gowin.c:566
#define SRAM_ERASE_DONE
Definition: gowin.c:20
static uint64_t gowin_read_fs_file_bitsequence(const char *bits, int length)
Definition: gowin.c:55
#define STAUS_MASK_MEMORY_ERASE
Definition: gowin.c:35
static int gowin_check_status_flag(struct jtag_tap *tap, uint32_t mask, uint32_t flag)
Definition: gowin.c:241
COMMAND_HANDLER(gowin_read_status_command_handler)
Definition: gowin.c:478
static int gowin_reload(struct jtag_tap *tap)
Definition: gowin.c:281
static int gowin_reload_command(struct pld_device *pld_device)
Definition: gowin.c:442
static int gowin_erase_sram(struct jtag_tap *tap, bool tx_erase_done)
Definition: gowin.c:300
static int gowin_set_instr(struct jtag_tap *tap, uint8_t new_instr)
Definition: gowin.c:199
#define READ_USERCODE
Definition: gowin.c:23
static int gowin_get_ipdbg_hub(int user_num, struct pld_device *pld_device, struct pld_ipdbg_hub *hub)
Definition: gowin.c:455
#define USER2
Definition: gowin.c:33
#define NO_OP
Definition: gowin.c:18
static int gowin_disable_config(struct jtag_tap *tap)
Definition: gowin.c:269
#define STAUS_MASK_SYSTEM_EDIT_MODE
Definition: gowin.c:36
#define ERASE_SRAM
Definition: gowin.c:19
static int gowin_load_to_sram(struct pld_device *pld_device, const char *filename)
Definition: gowin.c:344
static int gowin_read_register_command(struct pld_device *pld_device, uint32_t cmd, uint32_t *value)
Definition: gowin.c:429
static const struct command_registration gowin_command_handler[]
Definition: gowin.c:555
#define STATUS_REGISTER
Definition: gowin.c:28
static int gowin_read_fs_file(struct gowin_bit_file *bit_file, const char *filename)
Definition: gowin.c:126
static int gowin_read_file(struct gowin_bit_file *bit_file, const char *filename, bool *is_fs)
Definition: gowin.c:173
static int gowin_runtest_idle(struct jtag_tap *tap, unsigned int frac_sec)
Definition: gowin.c:292
#define IDCODE
Definition: gowin.c:21
#define CONFIG_DISABLE
Definition: gowin.c:26
static int gowin_read_fs_file_header(struct gowin_bit_file *bit_file, FILE *stream)
Definition: gowin.c:84
static int gowin_add_byte_to_bit_file(struct gowin_bit_file *bit_file, uint8_t byte)
Definition: gowin.c:63
static int gowin_read_register(struct jtag_tap *tap, uint32_t reg, uint32_t *result)
Definition: gowin.c:217
#define RELOAD
Definition: gowin.c:27
struct pld_driver gowin_pld
Definition: gowin.c:592
#define ADDRESS_INITIALIZATION
Definition: gowin.c:22
#define TRANSFER_CONFIGURATION_DATA
Definition: gowin.c:25
struct jtag_tap * jtag_tap_by_string(const char *s)
Definition: jtag/core.c:237
void jtag_add_runtest(unsigned int num_cycles, tap_state_t state)
Goes to TAP_IDLE (if we're not already there), cycle precisely num_cycles in the TAP_IDLE state,...
Definition: jtag/core.c:592
int jtag_execute_queue(void)
For software FIFO implementations, the queued commands can be executed during this call or earlier.
Definition: jtag/core.c:1037
void jtag_add_sleep(uint32_t us)
Definition: jtag/core.c:870
void jtag_add_ir_scan(struct jtag_tap *active, struct scan_field *in_fields, tap_state_t state)
Generate an IR SCAN with a list of scan fields with one entry for each enabled TAP.
Definition: jtag/core.c:374
void jtag_add_dr_scan(struct jtag_tap *active, int in_num_fields, const struct scan_field *in_fields, tap_state_t state)
Generate a DR SCAN using the fields passed to the function.
Definition: jtag/core.c:451
The JTAG interface can be implemented with a software or hardware fifo.
@ TAP_IDLE
Definition: jtag.h:53
#define ERROR_FAIL
Definition: log.h:170
#define LOG_ERROR(expr ...)
Definition: log.h:132
#define ERROR_OK
Definition: log.h:164
int flag
Definition: mips64.c:29
struct pld_device * get_pld_device_by_name_or_numstr(const char *str)
Definition: pld.c:56
#define ERROR_PLD_FILE_LOAD_FAILED
Definition: pld.h:62
uint8_t bits[QN908X_FLASH_MAX_BLOCKS *QN908X_FLASH_PAGES_PER_BLOCK/8]
Definition: qn908x.c:0
int cpld_read_raw_bit_file(struct raw_bit_file *bit_file, const char *filename)
Definition: raw_bit.c:19
char id[RTT_CB_MAX_ID_LENGTH]
Control block identifier.
Definition: rtt/rtt.c:32
#define BIT(nr)
Definition: stm32l4x.h:18
const char * name
Definition: command.h:235
int compressed
Definition: gowin.c:47
uint32_t id
Definition: gowin.c:45
int crc_en
Definition: gowin.c:48
struct raw_bit_file raw_file
Definition: gowin.c:43
uint8_t replace8x
Definition: gowin.c:50
uint8_t replace2x
Definition: gowin.c:52
size_t capacity
Definition: gowin.c:44
uint16_t stored_checksum
Definition: gowin.c:46
uint16_t checksum
Definition: gowin.c:49
uint8_t replace4x
Definition: gowin.c:51
struct jtag_tap * tap
Definition: gowin.c:39
Definition: jtag.h:101
unsigned int ir_length
size of instruction register
Definition: jtag.h:110
Definition: pld.h:48
void * driver_priv
Definition: pld.h:50
Definition: pld.h:31
const char * name
Definition: pld.h:32
unsigned int user_ir_code
Definition: pld.h:20
struct jtag_tap * tap
Definition: pld.h:19
uint8_t * data
Definition: raw_bit.h:16
size_t length
Definition: raw_bit.h:15
Definition: register.h:111
This structure defines a single scan field in the scan.
Definition: jtag.h:87
uint8_t * in_value
A pointer to a 32-bit memory location for data scanned out.
Definition: jtag.h:93
uint8_t * check_value
The value used to check the data scanned out.
Definition: jtag.h:96
const uint8_t * out_value
A pointer to value to be scanned into the device.
Definition: jtag.h:91
unsigned int num_bits
The number of bits this field specifies.
Definition: jtag.h:89
uint8_t * check_mask
The mask to go with check_value.
Definition: jtag.h:98
#define DIV_ROUND_UP(m, n)
Rounds m up to the nearest multiple of n using division.
Definition: types.h:79
static uint32_t le_to_h_u32(const uint8_t *buf)
Definition: types.h:112
#define NULL
Definition: usb.h:16
uint8_t status[4]
Definition: vdebug.c:17
uint8_t cmd
Definition: vdebug.c:1