Skip to content

Commit

Permalink
coresight: adiv5 discovery: increment invalid AP count on exception (#…
Browse files Browse the repository at this point in the history
…1593)

If an exception is raised when probing an AP, increment the invalid
AP count. The scan loop is cleaned up a bit too.
  • Loading branch information
flit committed Jul 28, 2023
1 parent 7e63962 commit 8555b7b
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions pyocd/coresight/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,22 +121,24 @@ def _find_aps(self):
return

ap_list = []
apsel = 0
invalid_count = 0
while apsel < self.MAX_APSEL:
for apsel in range(self.MAX_APSEL):
try:
isValid = AccessPort.probe(self.dp, apsel)
if isValid:
ap_list.append(apsel)
invalid_count = 0
elif not self.session.options.get('scan_all_aps'):
else:
invalid_count += 1
if invalid_count == self.session.options.get('adi.v5.max_invalid_ap_count'):
break
except exceptions.Error as e:
LOG.error("Error probing AP#%d: %s", apsel, e,
exc_info=self.session.log_tracebacks)
apsel += 1
invalid_count += 1

# Stop scanning if we've seen a maximum number of invalid APs, unless `scan_all_aps` is set.
if not self.session.options.get('scan_all_aps') \
and invalid_count >= self.session.options.get('adi.v5.max_invalid_ap_count'):
break

# Update the AP list once we know it's complete.
self.dp.valid_aps = ap_list
Expand Down

0 comments on commit 8555b7b

Please sign in to comment.