Skip to content

Commit d08cb47

Browse files
committed
target_kinetis: ensure AP#0 is MEM_AP to avoid AttributeError
1 parent 2824cce commit d08cb47

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

pyocd/target/builtin/target_MKL28Z512xxx7.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# pyOCD debugger
2+
# Copyright (c) 2020 NXP
23
# Copyright (c) 2006-2013,2018 Arm Limited
34
# SPDX-License-Identifier: Apache-2.0
45
#
@@ -205,8 +206,11 @@ def create_init_sequence(self):
205206
def create_kl28_aps(self):
206207
"""! @brief Set the fixed list of valid AP numbers for KL28."""
207208
self.dp.valid_aps = [0, 1, 2]
208-
209+
209210
def detect_dual_core(self):
211+
if not isinstance(self.aps[0], ap.MEM_AP):
212+
return
213+
210214
# Check if this is the dual core part.
211215
sdid = self.aps[0].read_memory(SIM_SDID)
212216
keyattr = (sdid & SIM_SDID_KEYATTR_MASK) >> SIM_SDID_KEYATTR_SHIFT
@@ -217,6 +221,8 @@ def detect_dual_core(self):
217221
self.memory_map = self.DUAL_MAP
218222

219223
def post_connect_hook(self):
224+
if not isinstance(self.aps[0], ap.MEM_AP):
225+
return
220226
# Disable ROM vector table remapping.
221227
self.aps[0].write32(RCM_MR, RCM_MR_BOOTROM_MASK)
222228

pyocd/target/family/target_kinetis.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# pyOCD debugger
2+
# Copyright (c) 2020 NXP
23
# Copyright (c) 2006-2018 Arm Limited
34
# SPDX-License-Identifier: Apache-2.0
45
#
@@ -117,8 +118,10 @@ def check_flash_security(self):
117118
canAccess = False
118119
else:
119120
try:
120-
for attempt in range(ACCESS_TEST_ATTEMPTS):
121-
self.aps[0].read32(CortexM.DHCSR)
121+
# Ensure to use AP#0 as a MEM_AP
122+
if isinstance(self.aps[0], ap.MEM_AP):
123+
for attempt in range(ACCESS_TEST_ATTEMPTS):
124+
self.aps[0].read32(CortexM.DHCSR)
122125
except exceptions.TransferError:
123126
LOG.debug("Access test failed with fault")
124127
canAccess = False
@@ -157,7 +160,7 @@ def check_flash_security(self):
157160

158161
# Assert that halt on connect was forced above. Reset will stay asserted
159162
# until halt on connect is executed.
160-
# assert self._force_halt_on_connect
163+
# assert self._force_halt_on_connect
161164

162165
isLocked = False
163166
else:

0 commit comments

Comments
 (0)