From 23666d49fa7b26a76f4dff11c1d2cdd31584270d Mon Sep 17 00:00:00 2001 From: Sergey Shchelkanov Date: Mon, 29 May 2023 16:15:28 +0300 Subject: [PATCH] update ocd 0.12 --- tclrpc.py | 40 ++++++++++++---------------------------- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/tclrpc.py b/tclrpc.py index 095e8fd..6b58d82 100644 --- a/tclrpc.py +++ b/tclrpc.py @@ -128,20 +128,8 @@ class OpenOcdTclRpc: return self.run(f"capture \"write_memory {address:#0x} {width} {{{data_string}}}\"") def write_word(self, address:int, word:int): - return self.run(f"capture \"mww {address:#0x} {word}\"") + return self.write_memory(address, 32, [word]) - # def read_memory(self, address:int, width:int, count:int): - # """This function provides an efficient way to read the target memory from a Tcl script. - # A Tcl list containing the requested memory elements is returned by this function. - - # address ... target memory address - - # width ... memory access bit size, can be 8, 16, 32 or 64 - - # count ... number of elements to read """ - # data = self.run(f"capture \"read_memory {address:#0x} {width} {count}\"").split(" ") - # return list(map(lambda word: int(word, base=16), data)) - def read_memory(self, address:int, width:int, count:int): """This function provides an efficient way to read the target memory from a Tcl script. A Tcl list containing the requested memory elements is returned by this function. @@ -151,23 +139,19 @@ class OpenOcdTclRpc: width ... memory access bit size, can be 8, 16, 32 or 64 count ... number of elements to read """ - data = self.run(f"capture \"mem2array {width} {address:#0x} {count}\"").split(" ") + data = self.run(f"capture \"read_memory {address:#0x} {width} {count}\"").split(" ") return list(map(lambda word: int(word, base=16), data)) - # def read_word(self, address:int): - # """This function provides an efficient way to read the target memory from a Tcl script. - # A Tcl list containing the requested memory elements is returned by this function. - - # address ... target memory address - - # width ... memory access bit size, can be 8, 16, 32 or 64 - - # count ... number of elements to read """ - # data = self.run(f"capture \"read_memory {address:#0x} 32 1\"").split(" ") - # return int(data[0], base=16) - def read_word(self, address:int): - data = self.run(f"capture \"mdw {address:#0x}\"").split(" ") - return int(data[1], base=16) + """This function provides an efficient way to read the target memory from a Tcl script. + A Tcl list containing the requested memory elements is returned by this function. + + address ... target memory address + + width ... memory access bit size, can be 8, 16, 32 or 64 + + count ... number of elements to read """ + data = self.run(f"capture \"read_memory {address:#0x} 32 1\"").split(" ") + return int(data[0], base=16)