Ejemplo n.º 1
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("string", nargs="*")
    parser.add_argument("-x",
                        default=0,
                        type=int,
                        help="x position, default 0")
    parser.add_argument("-y",
                        default=0,
                        type=int,
                        help="y position, default 0")
    parser.add_argument("-c",
                        "--clear",
                        action="store_true",
                        help="clear the screen")
    args = parser.parse_args()

    client = CommUSB()
    client.open()

    if args.clear:
        clear(client)
    elif args.string:
        string = " ".join(args.string)
        print_string(client, args.x, args.y, string)
    else:
        x = args.x
        y = args.y
        for line in sys.stdin:
            x, y = print_string(client, x, y, line)

    client.close()
Ejemplo n.º 2
0
    def run(self):
        args = self.args
        if args.uart:
            from litex.tools.remote.comm_uart import CommUART
            if args.uart_port is None:
                print("Need to specify --uart-port, exiting.")
                exit()
            uart_port = args.uart_port
            uart_baudrate = int(float(args.uart_baudrate))
            print("[CommUART] port: {} / baudrate: {} / ".format(uart_port, uart_baudrate), end="")
            comm = CommUART(uart_port, uart_baudrate)
        elif args.udp:
            from litex.tools.remote.comm_udp import CommUDP
            udp_ip = args.udp_ip
            udp_port = int(args.udp_port)
            print("[CommUDP] ip: {} / port: {} / ".format(udp_ip, udp_port), end="")
            comm = CommUDP(udp_ip, udp_port)
        elif args.pcie:
            from litex.tools.remote.comm_pcie import CommPCIe
            pcie_bar = args.pcie_bar
            if args.pcie_bar is None:
                print("Need to speficy --pcie-bar, exiting.")
                exit()
            print("[CommPCIe] bar: {} / ".format(args.pcie_bar), end="")
            comm = CommPCIe(args.pcie_bar)
        elif args.usb:
            from litex.tools.remote.comm_usb 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:
            exit()

        self.server = RemoteServer(comm, args.bind_ip, int(args.bind_port))
        self.server.open()
        self.server.start(4)
        self.ready = True
Ejemplo n.º 3
0
def main():
    print("LiteX remote server")
    parser = argparse.ArgumentParser()
    # Common arguments
    parser.add_argument("--bind-ip", default="localhost",
                        help="Host bind address")
    parser.add_argument("--bind-port", default=1234,
                        help="Host bind port")

    # UART arguments
    parser.add_argument("--uart", action="store_true",
                        help="Select UART interface")
    parser.add_argument("--uart-port", default=None,
                        help="Set UART port")
    parser.add_argument("--uart-baudrate", default=115200,
                        help="Set UART baudrate")

    # UDP arguments
    parser.add_argument("--udp", action="store_true",
                        help="Select UDP interface")
    parser.add_argument("--udp-ip", default="192.168.1.50",
                        help="Set UDP remote IP address")
    parser.add_argument("--udp-port", default=1234,
                        help="Set UDP remote port")

    # PCIe arguments
    parser.add_argument("--pcie", action="store_true",
                        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()


    if args.uart:
        from litex.tools.remote.comm_uart import CommUART
        if args.uart_port is None:
            print("Need to specify --uart-port, exiting.")
            exit()
        uart_port = args.uart_port
        uart_baudrate = int(float(args.uart_baudrate))
        print("[CommUART] port: {} / baudrate: {} / ".format(uart_port, uart_baudrate), end="")
        comm = CommUART(uart_port, uart_baudrate)
    elif args.udp:
        from litex.tools.remote.comm_udp import CommUDP
        udp_ip = args.udp_ip
        udp_port = int(args.udp_port)
        print("[CommUDP] ip: {} / port: {} / ".format(udp_ip, udp_port), end="")
        comm = CommUDP(udp_ip, udp_port)
    elif args.pcie:
        from litex.tools.remote.comm_pcie import CommPCIe
        pcie_bar = args.pcie_bar
        if args.pcie_bar is None:
            print("Need to speficy --pcie-bar, exiting.")
            exit()
        print("[CommPCIe] bar: {} / ".format(args.pcie_bar), end="")
        comm = CommPCIe(args.pcie_bar)
    elif args.usb:
        from litex.tools.remote.comm_usb 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()

    server = RemoteServer(comm, args.bind_ip, int(args.bind_port))
    server.open()
    server.start(4)
    try:
        import time
        while True: time.sleep(100)
    except KeyboardInterrupt:
        pass
Ejemplo n.º 4
0
def main():
    parser = argparse.ArgumentParser(
        description="LiteX Server utility",
        formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    # Common arguments
    parser.add_argument("--bind-ip",
                        default="localhost",
                        help="Host bind address.")
    parser.add_argument("--bind-port", default=1234, help="Host bind port.")
    parser.add_argument("--debug", action="store_true", help="Enable debug.")

    # UART arguments
    parser.add_argument("--uart",
                        action="store_true",
                        help="Select UART interface.")
    parser.add_argument("--uart-port", default=None, help="Set UART port.")
    parser.add_argument("--uart-baudrate",
                        default=115200,
                        help="Set UART baudrate.")

    # JTAG arguments
    parser.add_argument("--jtag",
                        action="store_true",
                        help="Select JTAG interface.")
    parser.add_argument("--jtag-config",
                        default="openocd_xc7_ft232.cfg",
                        help="OpenOCD JTAG configuration file.")
    parser.add_argument("--jtag-chain", default=1, help="JTAG chain.")

    # UDP arguments
    parser.add_argument("--udp",
                        action="store_true",
                        help="Select UDP interface.")
    parser.add_argument("--udp-ip",
                        default="192.168.1.50",
                        help="Set UDP remote IP address.")
    parser.add_argument("--udp-port",
                        default=1234,
                        help="Set UDP remote port.")
    parser.add_argument("--udp-scan",
                        action="store_true",
                        help="Scan network for available UDP devices.")

    # PCIe arguments
    parser.add_argument("--pcie",
                        action="store_true",
                        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 USB reconecting retries.")
    args = parser.parse_args()

    # UART mode
    if args.uart:
        from litex.tools.remote.comm_uart import CommUART
        if args.uart_port is None:
            print("Need to specify --uart-port, exiting.")
            exit()
        uart_port = args.uart_port
        uart_baudrate = int(float(args.uart_baudrate))
        print("[CommUART] port: {} / baudrate: {} / ".format(
            uart_port, uart_baudrate),
              end="")
        comm = CommUART(uart_port, uart_baudrate, debug=args.debug)

    # JTAG mode
    elif args.jtag:
        from litex.tools.litex_term import JTAGUART
        from litex.tools.remote.comm_uart import CommUART
        jtag_uart = JTAGUART(config=args.jtag_config,
                             chain=int(args.jtag_chain))
        jtag_uart.open()
        print("[CommUART] port: JTAG / ", end="")
        comm = CommUART(os.ttyname(jtag_uart.name), debug=args.debug)

    # UDP mode
    elif args.udp:
        from litex.tools.remote.comm_udp import CommUDP
        udp_ip = args.udp_ip
        udp_port = int(args.udp_port)
        if args.udp_scan:
            udp_ip = udp_ip.split(".")
            assert len(udp_ip) == 4
            udp_ip[3] = "x"
            udp_ip = ".".join(udp_ip)
            comm = CommUDP(udp_ip, udp_port, debug=args.debug)
            comm.open(probe=False)
            comm.scan(udp_ip)
            comm.close()
            exit()
        else:
            print("[CommUDP] ip: {} / port: {} / ".format(udp_ip, udp_port),
                  end="")
            comm = CommUDP(udp_ip, udp_port, debug=args.debug)

    # PCIe mode
    elif args.pcie:
        from litex.tools.remote.comm_pcie import CommPCIe
        pcie_bar = args.pcie_bar
        if pcie_bar is None:
            print("Need to speficy --pcie-bar, exiting.")
            exit()
        print("[CommPCIe] bar: {} / ".format(pcie_bar), end="")
        comm = CommPCIe(pcie_bar, debug=args.debug)

    # USB mode
    elif args.usb:
        from litex.tools.remote.comm_usb 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,
                       debug=args.debug)

    else:
        parser.print_help()
        exit()

    server = RemoteServer(comm, args.bind_ip, int(args.bind_port))
    server.open()
    server.start(4)
    try:
        import time
        while True:
            time.sleep(100)
    except KeyboardInterrupt:
        pass