Skip to content

CMSIS Dap USB Bulk SWO Doesn't Work #1754

@jonathanherbstgrapple

Description

@jonathanherbstgrapple

I have a CMSIS Dap device which supports bulk SWO. When I try to use it with pyOCD I get an exception.

Exception in thread SWVReader:
Traceback (most recent call last):
  File "venv/lib/python3.10/site-packages/pyocd/probe/cmsis_dap_probe.py", line 709, in swo_read
    data = self._link.swo_read()
  File "venv/lib/python3.10/site-packages/pyocd/probe/pydapaccess/dap_access_cmsis_dap.py", line 1041, in swo_read
    return self._interface.read_swo()
  File "venv/lib/python3.10/site-packages/pyocd/probe/pydapaccess/interface/pyusb_v2_backend.py", line 254, in read_swo
    raise DAPAccessIntf.DeviceError(f"Probe {self.serial_number} read thread exited unexpectedly") \
pyocd.probe.pydapaccess.dap_access_api.DAPAccessIntf.DeviceError: Probe 0123456789 read thread exited unexpectedly

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/jonathan/.pyenv/versions/3.10.12/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "venv/lib/python3.10/site-packages/pyocd/trace/swv.py", line 200, in run
    data = self._session.probe.swo_read()
  File "venv/lib/python3.10/site-packages/pyocd/probe/cmsis_dap_probe.py", line 713, in swo_read
    raise self._convert_exception(exc) from exc
pyocd.core.exceptions.ProbeError: Probe 0123456789 read thread exited unexpectedly

I did some poking and I found that there doesn't seem to be an exception in the swo thread, but the _swo_thread_did_exit variable from PyUSBv2 is set to True when the thread is still running. I think this could happen if the PyUSBv2 instance is closed then reused. If I set _swo_thread_did_exit to false in start_swo this seems to fix the problem, but I'm not sure how this class is supposed to be treated. Should this class support closing and reusing?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions