utils: litex_server: add usb support
authorSean Cross <sean@xobs.io>
Fri, 19 Apr 2019 14:56:39 +0000 (15:56 +0100)
committerSean Cross <sean@xobs.io>
Fri, 19 Apr 2019 17:02:42 +0000 (18:02 +0100)
Add `--usb` and associated arguments to create a litex bridge over
USB.  This makes use of the new CommUSB module.

Signed-off-by: Sean Cross <sean@xobs.io>
litex/utils/litex_server.py

index f8c6b116ed852f5ec27351bb5dd1bd0629099979..4910122515343ba791001cf9d02edecc2dbea9fb 100755 (executable)
@@ -122,6 +122,16 @@ def main():
                         help="Select PCIe interface")
     parser.add_argument("--pcie-bar", default=None,
                         help="Set PCIe BAR")
+
+    # USB arguments
+    parser.add_argument("--usb", action="store_true",
+                        help="Select USB interface")
+    parser.add_argument("--usb-vid", default=None,
+                        help="Set USB vendor ID")
+    parser.add_argument("--usb-pid", default=None,
+                        help="Set USB product ID")
+    parser.add_argument("--usb-max-retries", default=10,
+                        help="Number of times to try reconnecting to USB")
     args = parser.parse_args()
 
 
@@ -148,6 +158,19 @@ def main():
             exit()
         print("[CommPCIe] bar: {} / ".format(args.pcie_bar), end="")
         comm = CommPCIe(args.pcie_bar)
+    elif args.usb:
+        from litex.soc.tools.remote import CommUSB
+        if args.usb_pid is None and args.usb_vid is None:
+            print("Need to speficy --usb-vid or --usb-pid, exiting.")
+            exit()
+        print("[CommUSB] vid: {} / pid: {} / ".format(args.usb_vid, args.usb_pid), end="")
+        pid = args.usb_pid
+        if pid is not None:
+            pid = int(pid, base=0)
+        vid = args.usb_vid
+        if vid is not None:
+            vid = int(vid, base=0)
+        comm = CommUSB(vid=vid, pid=pid, max_retries=args.usb_max_retries)
     else:
         parser.print_help()
         exit()