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

pyocd server crashes when connecting remotely #1067

Closed rickyelopez closed 3 years ago

rickyelopez commented 3 years ago

Using an ST-Link V2 clone, works fine when I use pyocd gdbserver and then connect remotely from gdb with target remote localhost:3333.

But when I run pyocd server on the host and then try to connect with pyocd gdbserver --uid=remote:localhost --target stm32f103cb I see this on the host on startup:

0004869:INFO:tcp_probe_server:Serving debug probe STM32 STLink (51FF6C065075545334211787) on port 5555
0009189:INFO:tcp_probe_server:Remote probe client connected (hostname from port 50010)

and then this when I try to connect:

0009264:ERROR:tcp_probe_server:Error while processing b'{"id": 8, "request": "readprop", "arguments": ["wire_protocol"]}\n' request from client: 'NoneType' object has no attribute 'name'
Traceback (most recent call last):
  File "c:\python39\lib\site-packages\pyocd\probe\tcp_probe_server.py", line 333, in handle
    result = handler(*request_args)
  File "c:\python39\lib\site-packages\pyocd\probe\tcp_probe_server.py", line 386, in _request__read_property
    value = self._PROPERTY_CONVERTERS[name](value)
  File "c:\python39\lib\site-packages\pyocd\probe\tcp_probe_server.py", line 463, in <lambda>
    'wire_protocol':                lambda value: value.name,
AttributeError: 'NoneType' object has no attribute 'name'
0009265:INFO:tcp_probe_server:Remote probe client disconnected (hostname from port 50010)
0009265:ERROR:tcp_probe_server:Error while handling client request (client address ('127.0.0.1', 50010)):
Traceback (most recent call last):
  File "c:\python39\lib\socketserver.py", line 650, in process_request_thread
    self.finish_request(request, client_address)
  File "c:\python39\lib\socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "c:\python39\lib\socketserver.py", line 720, in __init__
    self.handle()
  File "c:\python39\lib\site-packages\pyocd\probe\tcp_probe_server.py", line 333, in handle
    result = handler(*request_args)
  File "c:\python39\lib\site-packages\pyocd\probe\tcp_probe_server.py", line 386, in _request__read_property
    value = self._PROPERTY_CONVERTERS[name](value)
  File "c:\python39\lib\site-packages\pyocd\probe\tcp_probe_server.py", line 463, in <lambda>
    'wire_protocol':                lambda value: value.name,
AttributeError: 'NoneType' object has no attribute 'name'

Host is a Windows 10 machine, client is a WSL1.0 Arch image.

I tried adding print(value) on line 383 of tcp_probe_server.py which resulted in the following being printed before the error shown above:

{<Capability.MANAGED_AP_SELECTION: 4>, <Capability.SWO: 1>, <Capability.MANAGED_DPBANKSEL: 5>}
{<Capability.MANAGED_AP_SELECTION: 4>, <Capability.SWO: 1>, <Capability.MANAGED_DPBANKSEL: 5>}
[<Protocol.DEFAULT: 0>, <Protocol.SWD: 1>, <Protocol.JTAG: 2>]
[<Protocol.DEFAULT: 0>, <Protocol.SWD: 1>, <Protocol.JTAG: 2>]
None

Apologies if this is something silly that I missed. Did some googling and didn't find anything useful.

edit: this appears to work fine on v0.28.3, so looks like this might actually be a bug

flit commented 3 years ago

That was certainly easy to reproduce!