pyocd / pyOCD

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

Picoprobe: exception raised when UID is specified but no Picoprobe is connected #1116

Closed flit closed 3 years ago

flit commented 3 years ago

The symptom of this bug is the following AttributeError exception raised when a probe UID is specified but there is not a Picoprobe connected to USB.

0000616:CRITICAL:__main__:uncaught exception: 'NoneType' object has no attribute 'serial_number'
Traceback (most recent call last):
  File "/Volumes/projects/pyOCD-flit/pyocd/__main__.py", line 402, in run
    self._COMMANDS[self._args.cmd](self)
  File "/Volumes/projects/pyOCD-flit/pyocd/__main__.py", line 808, in do_commander
    PyOCDCommander(self._args, cmds).run()
  File "/Volumes/projects/pyOCD-flit/pyocd/commands/commander.py", line 65, in run
    if not self.connect():
  File "/Volumes/projects/pyOCD-flit/pyocd/commands/commander.py", line 164, in connect
    probe = ConnectHelper.choose_probe(
  File "/Volumes/projects/pyOCD-flit/pyocd/core/helpers.py", line 138, in choose_probe
    allProbes = ConnectHelper.get_all_connected_probes(blocking=blocking, unique_id=unique_id)
  File "/Volumes/projects/pyOCD-flit/pyocd/core/helpers.py", line 82, in get_all_connected_probes
    allProbes = DebugProbeAggregator.get_all_connected_probes(unique_id=unique_id)
  File "/Volumes/projects/pyOCD-flit/pyocd/probe/aggregator.py", line 58, in get_all_connected_probes
    probe = cls.get_probe_with_id(unique_id, is_explicit)
  File "/Volumes/projects/pyOCD-flit/pyocd/probe/picoprobe.py", line 339, in get_probe_with_id
    probe = PicoLink.enumerate_picoprobes(unique_id)
  File "/Volumes/projects/pyOCD-flit/pyocd/probe/picoprobe.py", line 110, in enumerate_picoprobes
    return PicoLink(core.find(custom_match=FindPicoprobe(uid)))
  File "/Volumes/projects/pyOCD-flit/pyocd/probe/picoprobe.py", line 59, in __init__
    self._probe_id = dev.serial_number
AttributeError: 'NoneType' object has no attribute 'serial_number'
flit commented 3 years ago

cc @newbrain