diff options
author | Marc Schink <dev@zapb.de> | 2022-02-25 15:44:58 +0100 |
---|---|---|
committer | Antonio Borneo <borneo.antonio@gmail.com> | 2022-03-12 09:48:19 +0000 |
commit | be0d68eb66b513ef406ffa83102f89a8f4602914 (patch) | |
tree | 08dd44dbe610f2c39251098a11d06d5fdd6a403d /contrib/rpc_examples | |
parent | e370e06b724f6e3a0fdd8611a3d461c2cc15735c (diff) | |
download | riscv-openocd-be0d68eb66b513ef406ffa83102f89a8f4602914.zip riscv-openocd-be0d68eb66b513ef406ffa83102f89a8f4602914.tar.gz riscv-openocd-be0d68eb66b513ef406ffa83102f89a8f4602914.tar.bz2 |
Remove all occurrences of 'mem2array' and 'array2mem'
Replace deprecated commands 'mem2array' and 'array2mem' with
new Tcl commands 'read_memory' and 'write_memory'.
Change-Id: I116d995995396133ca782b14cce02bd1ab917a4e
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/6859
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Diffstat (limited to 'contrib/rpc_examples')
-rwxr-xr-x | contrib/rpc_examples/ocd_rpc_example.py | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/contrib/rpc_examples/ocd_rpc_example.py b/contrib/rpc_examples/ocd_rpc_example.py index 3470d84..e6146f6 100755 --- a/contrib/rpc_examples/ocd_rpc_example.py +++ b/contrib/rpc_examples/ocd_rpc_example.py @@ -95,24 +95,16 @@ class OpenOcd: return None if (len(raw) < 2) else strToHex(raw[1]) def readMemory(self, wordLen, address, n): - self.send("array unset output") # better to clear the array before - self.send("mem2array output %d 0x%x %d" % (wordLen, address, n)) - - output = [*map(int, self.send("return $output").split(" "))] - d = dict([tuple(output[i:i + 2]) for i in range(0, len(output), 2)]) - - return [d[k] for k in sorted(d.keys())] + output = self.send("read_memory 0x%x %d %d" % (address, wordLen, n)) + return [*map(lambda x: int(x, 16), output.split(" "))] def writeVariable(self, address, value): assert value is not None self.send("mww 0x%x 0x%x" % (address, value)) - def writeMemory(self, wordLen, address, n, data): - array = " ".join(["%d 0x%x" % (a, b) for a, b in enumerate(data)]) - - self.send("array unset 1986ве1т") # better to clear the array before - self.send("array set 1986ве1т { %s }" % array) - self.send("array2mem 1986ве1т 0x%x %s %d" % (wordLen, address, n)) + def writeMemory(self, wordLen, address, data): + data = "{" + ' '.join(['0x%x' % x for x in data]) + "}" + self.send("write_memory 0x%x %d %s" % (address, wordLen, data)) if __name__ == "__main__": |