mw_debug: Probe cable if unspecified
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>
Fri, 24 Sep 2021 04:23:06 +0000 (14:23 +1000)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Fri, 24 Sep 2021 04:23:06 +0000 (14:23 +1000)
Instead of defaulting to DigilentHS1

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
scripts/mw_debug/mw_debug.c

index 4179264cc443e166a92f702618e84849c7c2f869..d9fe749a4435fd839bd145ba01dc9a5b5db1cce4 100644 (file)
@@ -220,7 +220,7 @@ static int jtag_init(const char *target)
        int rc, part;
 
        if (!target)
-               target = "DigilentHS1";
+               target = "probe";
        sep = strchr(target, ':');
        cable = strndup(target, sep - target);
        if (sep && *sep) {
@@ -237,6 +237,15 @@ static int jtag_init(const char *target)
        }
        jc->main_part = 0;
 
+       if (strcmp(cable, "probe") == 0) {
+               char *cparams[] = { NULL, NULL,};
+               rc = urj_tap_cable_usb_probe(cparams);
+               if (rc != URJ_STATUS_OK) {
+                       fprintf(stderr, "JTAG cable probe failed\n");
+                       return -1;
+               }
+               cable = strdup(cparams[1]);
+       }
        rc = urj_tap_chain_connect(jc, cable, params);
        if (rc != URJ_STATUS_OK) {
                fprintf(stderr, "JTAG cable detect failed\n");