-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprog.c
More file actions
51 lines (50 loc) · 1.31 KB
/
prog.c
File metadata and controls
51 lines (50 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <getopt.h>
#include <urjtag.h>
int main(int argc, char **argv)
{
int opt;
int params_n = 0;
int device_n = 0;
long frequency = 0;
char *svf, *driver, *bsdl_path;
char *params_bundle = NULL;
char **params = NULL;
svf = driver = NULL;
if (argc < 1)
return ENOENT;
while ((opt = getopt(argc, argv, "i:b:f:d:v")) != -1) {
switch (opt) {
case 'i':
svf = optarg;
break;
case 'f':
frequency = atol(optarg);
break;
case 'd':
driver = optarg;
break;
case 'b':
bsdl_path = optarg;
break;
case 'p':
params_bundle = optarg;
params[params_n++] = strtok(params_bundle, ",");
while(params[params_n++] != NULL)
params[params_n] = strtok(NULL, ",");
break;
default: /* '?' */
fprintf(stderr, "Usage: %s [-i svf] [-d driver] [-f frequency] [-v vendor_id] [-p product_id] [-b bsdl_path]\n",
argv[0]);
return EINVAL;
}
}
if(svf != NULL && driver != NULL) {
return program_jtag(svf, driver, bsdl_path, frequency);
}
return 0;
}