diff --git a/README.md b/README.md index ec36923..d7fbe2a 100644 --- a/README.md +++ b/README.md @@ -222,6 +222,50 @@ Example: $ ./dmctl.py --conn cafe:1312 get-device-info ``` +### SUMP Logic Analyzer mode + +The device can act as a logic analyzer, implementing the SUMP protocol. It +first needs to be put into mode 4, which can be done using the following +command: + +``` +$ ./dmctl.sh set-mode 4 +``` + +As soon as this is done, the SUMP logic analyzer should be available on the +first USB-CDC interface of the device. It can be used with a connection string +such as `ols:conn=/dev/ttyACM0` in sigrok and PulseView. + +### XVC2DAP + +`xvc2dap.py` is a Python script that implements a Xilinx Virtual Cable server +and talks to a CMSIS-DAP device, acting like a bridge between the two. This way, +you can use any CMSIS-DAP device (including this project) as a fake Xilinx +Platform Cable. + +It requires pyOCD as a dependency (for its builtin `pydapaccess` module). + +Usage: + +``` +$ ./xvc2dap.py --help +usage: xvc2dap.py [-h] [--serial SERIAL] address [port] + +positional arguments: + address Host to bind to, for the XVC server, default localhost + port port to bind to, for the XVC server, default 2542 + +optional arguments: + -h, --help show this help message and exit + --serial SERIAL Connection string to the CMSIS-DAP device, as a serial + number, defaults to the first device found. +``` + +### USB Vendor interface protocol + +The USB vendor interface protocol is described +[here](./wiki/USB-config-%26-command-protocol) in the wiki. + ## License TinyUSB is licensed under the [MIT license](https://opensource.org/licenses/MIT). diff --git a/host/xvc2dap.py b/host/xvc2dap.py index 37ed563..54d2603 100755 --- a/host/xvc2dap.py +++ b/host/xvc2dap.py @@ -6,8 +6,6 @@ import struct from typing import * -from pyocd.probe.pydapaccess import * - class EndOfStreamException(Exception): pass @@ -67,14 +65,16 @@ def dap_split_jseq(nbits: int, tms: bytes, tdi: bytes) -> List[JtagSeq]: return res -def get_dap(serial: Optional[str]) -> DAPAccess: +def get_dap(serial: Optional[str]) -> Any: #DAPAccess: + import pyocd.probe.pydapaccess as pydap + if serial is not None: try: - return DAPAccess.get_device(serial) + return pydap.DAPAccess.get_device(serial) except Exception:# as e: raise Exception("Could not find CMSIS-DAP device %s" % serial) else: - devs = DAPAccess.get_connected_devices() + devs = pydap.DAPAccess.get_connected_devices() if len(devs) == 1: return devs[0] elif len(devs) == 0: @@ -97,7 +97,7 @@ def xvc_read_cmd(f) -> bytes: r += bv -def xvc_do_cmd(cmd, f, dap): +def xvc_do_cmd(cmd: bytes, f, dap): if cmd == b"getinfo": # parameter is max vector len (in bits) # we use some value here (2k should be good enough), though in reality @@ -192,13 +192,19 @@ def xvc2dap_do(args: Any) -> int: def main() -> int: + try: + import pyocd.probe.pydapaccess + except ImportError: + print("WARNING: pyocd module not found (not installed?), xvc2dap.py "+\ + "will not work.") + parser = argparse.ArgumentParser() parser.add_argument('--serial', type=str, default=None, help="Connection string to the CMSIS-DAP device, as "+\ "a serial number, defaults to the first device found.") - parser.add_argument('address', type=str, default='localhost', + parser.add_argument('address', type=str, default='localhost', nargs='?', help="Host to bind to, for the XVC server, default "+\ "localhost") parser.add_argument('port', type=int, default=2542, nargs='?',