mw_debug: Add -s frequency argument

Chose -s for speed, vs -f for --force

Signed-off-by: Matt Johnston <matt@codeconstruct.com.au>
pull/346/head
Matt Johnston 3 years ago
parent e05ae0c8cb
commit 04cc4a842c

@ -49,7 +49,7 @@
static bool debug; static bool debug;


struct backend { struct backend {
int (*init)(const char *target); int (*init)(const char *target, int freq);
int (*reset)(void); int (*reset)(void);
int (*command)(uint8_t op, uint8_t addr, uint64_t *data); int (*command)(uint8_t op, uint8_t addr, uint64_t *data);
}; };
@ -67,13 +67,15 @@ static void check(int r, const char *failstr)


static int sim_fd = -1; static int sim_fd = -1;


static int sim_init(const char *target) static int sim_init(const char *target, int freq)
{ {
struct sockaddr_in saddr; struct sockaddr_in saddr;
struct hostent *hp; struct hostent *hp;
const char *p, *host; const char *p, *host;
int port, rc; int port, rc;


(void)freq;

if (!target) if (!target)
target = "localhost:13245"; target = "localhost:13245";
p = strchr(target, ':'); p = strchr(target, ':');
@ -210,7 +212,7 @@ static struct backend sim_backend = {


static urj_chain_t *jc; static urj_chain_t *jc;


static int jtag_init(const char *target) static int jtag_init(const char *target, int freq)
{ {
const char *sep; const char *sep;
const char *cable; const char *cable;
@ -266,6 +268,10 @@ static int jtag_init(const char *target)
return -1; return -1;
} }


if (freq) {
urj_tap_cable_set_frequency(jc->cable, freq);
}

/* XXX Hard wire part 0, that might need to change (use params and detect !) */ /* XXX Hard wire part 0, that might need to change (use params and detect !) */
rc = urj_tap_manual_add(jc, 6); rc = urj_tap_manual_add(jc, 6);
if (rc < 0) { if (rc < 0) {
@ -720,7 +726,7 @@ int main(int argc, char *argv[])
{ {
const char *progname = argv[0]; const char *progname = argv[0];
const char *target = NULL; const char *target = NULL;
int rc, i = 1; int rc, i = 1, freq = 0;


b = NULL; b = NULL;


@ -731,9 +737,10 @@ int main(int argc, char *argv[])
{ "backend", required_argument, 0, 'b' }, { "backend", required_argument, 0, 'b' },
{ "target", required_argument, 0, 't' }, { "target", required_argument, 0, 't' },
{ "debug", no_argument, 0, 'd' }, { "debug", no_argument, 0, 'd' },
{ "frequency", no_argument, 0, 's' },
{ 0, 0, 0, 0 } { 0, 0, 0, 0 }
}; };
c = getopt_long(argc, argv, "dhb:t:", lopts, &oindex); c = getopt_long(argc, argv, "dhb:t:s:", lopts, &oindex);
if (c < 0) if (c < 0)
break; break;
switch(c) { switch(c) {
@ -753,6 +760,13 @@ int main(int argc, char *argv[])
case 't': case 't':
target = optarg; target = optarg;
break; break;
case 's':
freq = atoi(optarg);
if (freq == 0) {
fprintf(stderr, "Bad frequency %s\n", optarg);
exit(1);
}
break;
case 'd': case 'd':
debug = true; debug = true;
} }
@ -761,7 +775,7 @@ int main(int argc, char *argv[])
if (b == NULL) if (b == NULL)
b = &jtag_backend; b = &jtag_backend;


rc = b->init(target); rc = b->init(target, freq);
if (rc < 0) if (rc < 0)
exit(1); exit(1);
for (i = optind; i < argc; i++) { for (i = optind; i < argc; i++) {

Loading…
Cancel
Save