Skip to content

Commit 7f5ee7c

Browse files
stlink: fix length reported when memory read/write fails
1 parent 5a1ada9 commit 7f5ee7c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pyocd/probe/stlink/stlink.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# pyOCD debugger
2-
# Copyright (c) 2018-2020 Arm Limited
2+
# Copyright (c) 2018-2020,2025 Arm Limited
33
# Copyright (c) 2021-2022 Chris Reed
44
# SPDX-License-Identifier: Apache-2.0
55
#
@@ -419,7 +419,7 @@ def _read_mem(self, addr: int, size: int, memcmd: int, maxrx: int, apsel: int, c
419419

420420
exc = exceptions.TransferFaultError("read")
421421
exc.fault_address = faultAddr
422-
exc.fault_length = thisTransferSize - (faultAddr - addr)
422+
exc.fault_length = addr - faultAddr
423423
raise exc
424424
elif status in self._ERROR_CLASSES:
425425
raise self._ERROR_CLASSES[status](error_message)
@@ -461,7 +461,7 @@ def _write_mem(self, addr: int, data: Sequence[int], memcmd: int, maxtx: int, ap
461461

462462
exc = exceptions.TransferFaultError("write")
463463
exc.fault_address = faultAddr
464-
exc.fault_length = thisTransferSize - (faultAddr - addr)
464+
exc.fault_length = addr - faultAddr
465465
raise exc
466466
elif status in self._ERROR_CLASSES:
467467
raise self._ERROR_CLASSES[status](error_message)

0 commit comments

Comments
 (0)