pyocd / pyOCD

Open source Python library for programming and debugging Arm Cortex-M microcontrollers
https://pyocd.io
Apache License 2.0
1.13k stars 484 forks source link

Error with CMSIS DAP DIY #945

Closed sabas1080 closed 3 years ago

sabas1080 commented 4 years ago

Hi

I am making a programmer with CH552 and I am testing your great tool but I am have the next error, in openocd work fine, and with pyocd list

Captura de Pantalla 2020-08-29 a la(s) 14 48 10

the error

➜  ~ pyocd erase -t nrf52840 --chip
0001536:CRITICAL:__main__:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyocd/probe/cmsis_dap_probe.py", line 147, in open
    self._link.open()
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyocd/utility/concurrency.py", line 28, in _locking
    return func(self, *args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyocd/probe/pydapaccess/dap_access_cmsis_dap.py", line 592, in open
    self._packet_count = self._protocol.dap_info(self.ID.MAX_PACKET_COUNT)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyocd/probe/pydapaccess/cmsis_dap_core.py", line 138, in dap_info
    raise DAPAccessIntf.DeviceError()
pyocd.probe.pydapaccess.dap_access_api.DAPAccessIntf.DeviceError

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

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyocd/__main__.py", line 362, in run
    self._COMMANDS[self._args.cmd](self)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyocd/__main__.py", line 556, in do_erase
    with session:
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyocd/core/session.py", line 302, in __enter__
    self.open()
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyocd/core/session.py", line 416, in open
    self._probe.open()
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyocd/probe/cmsis_dap_probe.py", line 167, in open
    six.raise_from(self._convert_exception(exc), exc)
  File "<string>", line 3, in raise_from
pyocd.core.exceptions.ProbeError

Thanks

flit commented 4 years ago

(Terribly sorry I missed this issue until now!)

The exception that is being raised here is due to the DAP_Info command not returning a valid packet. Specifically, the first byte of the response packet must be the command ID, and this exception is raised because the first byte does not match the DAP_Info command ID.

Bunch of questions:

It's going to be very hard to diagnose and fix the issue without very detailed information (i.e. code) about the firmware, and, more importantly, USB bus traces. Do you happen to have a USB bus tracer available? 😀 There are also software solutions for Linux (e.g., usbmon) and Windows (several), but software bus trace is in my experience less reliable and quite limited (since it shows the OS view, not the actual bus view).

sabas1080 commented 4 years ago

Hi @flit thanks for answering, answering your questions