From 4364eb98e26002a463a13ed518fd911c7b210187 Mon Sep 17 00:00:00 2001 From: Christopher Pattenden <82477871+cpattenden-sq@users.noreply.github.com> Date: Fri, 28 Jul 2023 11:53:56 -0400 Subject: [PATCH] JLINKARM_BeginDownload is void, not int. (#181) Reading a return value results in a nonsensical value and frequently an invalid exception. --- pylink/jlink.py | 4 +--- tests/unit/test_jlink.py | 8 -------- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/pylink/jlink.py b/pylink/jlink.py index eb69c67..560cca1 100644 --- a/pylink/jlink.py +++ b/pylink/jlink.py @@ -2194,9 +2194,7 @@ def flash(self, data, addr, on_progress=None, power_on=False, flags=0): pass # Perform read-modify-write operation. - res = self._dll.JLINKARM_BeginDownload(flags=flags) - if res < 0: - raise errors.JLinkEraseException(res) + self._dll.JLINKARM_BeginDownload(flags=flags) if isinstance(data, list): data = bytes(data) diff --git a/tests/unit/test_jlink.py b/tests/unit/test_jlink.py index e6a7e51..b6a910f 100644 --- a/tests/unit/test_jlink.py +++ b/tests/unit/test_jlink.py @@ -2724,14 +2724,7 @@ def test_jlink_flash_fail_to_flash(self): self.jlink.halted = mock.Mock() self.jlink.halted.return_value = True - # BeginDownload failing - self.dll.JLINKARM_BeginDownload.return_value = -1 - self.dll.JLINKARM_EndDownload.return_value = 0 - with self.assertRaises(JLinkException): - self.jlink.flash([0], 0) - # EndDownload failing - self.dll.JLINKARM_BeginDownload.return_value = 0 self.dll.JLINKARM_EndDownload.return_value = -1 with self.assertRaises(JLinkException): self.jlink.flash([0], 0) @@ -2745,7 +2738,6 @@ def test_jlink_flash_success(self): Returns: ``None`` """ - self.dll.JLINKARM_BeginDownload.return_value = 0 self.dll.JLINKARM_WriteMem.return_value = 0 self.dll.JLINKARM_EndDownload.return_value = 0