Skip to content

Commit 21ff629

Browse files
committed
DAP: clean up and correct access of the session.
- DebugPort uses the target's session for subscribing to reset events, since there might not be a probe in certain cases. - DAPConnector asserts that it has a valid session. - AccessPort consistently gets the session from the DP.
1 parent be325cf commit 21ff629

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

pyocd/coresight/ap.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ def __init__(self, dp, ap_address, idr=None, name="", flags=0, cmpid=None):
522522
self.read_memory_block32 = self._read_memory_block32
523523

524524
# Subscribe to reset events.
525-
self.dp.probe.session.subscribe(self._reset_did_occur, (Target.Event.PRE_RESET, Target.Event.POST_RESET))
525+
self.dp.session.subscribe(self._reset_did_occur, (Target.Event.PRE_RESET, Target.Event.POST_RESET))
526526

527527
@property
528528
def supported_transfer_sizes(self):
@@ -707,7 +707,7 @@ def find_components(self):
707707
self.rom_table.init()
708708
except exceptions.TransferError as error:
709709
LOG.error("Transfer error while reading %s ROM table: %s", self.short_description, error,
710-
exc_info=self.dp.target.session.log_tracebacks)
710+
exc_info=self.dp.session.log_tracebacks)
711711

712712
@property
713713
def implemented_hprot_mask(self):

pyocd/coresight/dap.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ def __init__(self, probe):
116116
self._probe = probe
117117
self._session = probe.session
118118
self._idr = None
119+
120+
# Make sure we have a session, since we get the session from the probe and probes have their session set
121+
# after creation.
122+
assert self._session is not None, "DPConnector requires the probe to have a session"
119123

120124
@property
121125
def idr(self):
@@ -225,7 +229,7 @@ def __init__(self, probe, target):
225229
self._apacc_mem_interface = None
226230

227231
# Subscribe to reset events.
228-
self._probe.session.subscribe(self._reset_did_occur, (Target.Event.PRE_RESET, Target.Event.POST_RESET))
232+
self._session.subscribe(self._reset_did_occur, (Target.Event.PRE_RESET, Target.Event.POST_RESET))
229233

230234
@property
231235
def probe(self):

0 commit comments

Comments
 (0)