| Line 254... |
Line 254... |
| 254 |
f.write(self.emcore.read(addr, size))
|
254 |
f.write(self.emcore.read(addr, size))
|
| 255 |
f.close()
|
255 |
f.close()
|
| 256 |
self.logger.info("done\n")
|
256 |
self.logger.info("done\n")
|
| 257 |
|
257 |
|
| 258 |
@command
|
258 |
@command
|
| - |
|
259 |
def hexdump(self, addr, size, width = 16, wordsize = 1, separate = 4, \
|
| - |
|
260 |
align = False, relative = False, ascii = True, asciisep = 8):
|
| - |
|
261 |
"""
|
| - |
|
262 |
Downloads a region of memory from the device and hexdumps it
|
| - |
|
263 |
<addr>: the address to download the data from
|
| - |
|
264 |
<size>: the number of bytes to be dumped
|
| - |
|
265 |
[width]: the number of words per output line
|
| - |
|
266 |
[wordsize]: the number of bytes per word (little endian)
|
| - |
|
267 |
[separate]: add an additional space character every [separate] words
|
| - |
|
268 |
[align]: if true, output lines are aligned to the line size
|
| - |
|
269 |
[relative]: if true, the addresses displayed are relative to the <addr>, not zero
|
| - |
|
270 |
[ascii]: add ASCII representations of the bytes to the output
|
| - |
|
271 |
[asciisep]: add an additional space character every [asciisep] ASCII characters
|
| - |
|
272 |
"""
|
| - |
|
273 |
addr = to_int(addr)
|
| - |
|
274 |
size = to_int(size)
|
| - |
|
275 |
width = to_int(width)
|
| - |
|
276 |
wordsize = to_int(wordsize)
|
| - |
|
277 |
separate = to_int(separate)
|
| - |
|
278 |
align = to_bool(align)
|
| - |
|
279 |
relative = to_bool(relative)
|
| - |
|
280 |
ascii = to_bool(ascii)
|
| - |
|
281 |
asciisep = to_int(asciisep)
|
| - |
|
282 |
if addr % wordsize != 0: raise ArgumentError("Address is not word aligned!")
|
| - |
|
283 |
if size % wordsize != 0: raise ArgumentError("Size is not word aligned!")
|
| - |
|
284 |
if align: skip = addr % (wordsize * width)
|
| - |
|
285 |
else: skip = 0
|
| - |
|
286 |
if relative: base = 0
|
| - |
|
287 |
else: base = addr
|
| - |
|
288 |
data = self.emcore.read(addr, size)
|
| - |
|
289 |
for r in range(-skip, size, wordsize * width):
|
| - |
|
290 |
sys.stdout.write("%08X:" % (base + r))
|
| - |
|
291 |
for i in range(r, r + wordsize * width, wordsize):
|
| - |
|
292 |
if i - r > 0 and (i - r) % (separate * wordsize) == 0: sys.stdout.write(" ")
|
| - |
|
293 |
if i >= 0 and i < size:
|
| - |
|
294 |
w = 0
|
| - |
|
295 |
for b in range(wordsize):
|
| - |
|
296 |
w = (w << 8) | struct.unpack("B", data[i + b])[0]
|
| - |
|
297 |
sys.stdout.write((" %%%dX" % (wordsize * 2)) % w)
|
| - |
|
298 |
else: sys.stdout.write(" " * (wordsize * 2 + 1))
|
| - |
|
299 |
if ascii:
|
| - |
|
300 |
sys.stdout.write(" |")
|
| - |
|
301 |
for i in range(r, r + wordsize * width):
|
| - |
|
302 |
if i - r > 0 and (i - r) % asciisep == 0: sys.stdout.write(" ")
|
| - |
|
303 |
if i >= 0 and i < size:
|
| - |
|
304 |
if ord(data[i]) > 0x1f: sys.stdout.write(data[i])
|
| - |
|
305 |
else: sys.stdout.write(".")
|
| - |
|
306 |
else: sys.stdout.write(" ")
|
| - |
|
307 |
sys.stdout.write("|")
|
| - |
|
308 |
sys.stdout.write("\n")
|
| - |
|
309 |
|
| - |
|
310 |
@command
|
| 259 |
def uploadint(self, addr, integer):
|
311 |
def uploadint(self, addr, integer):
|
| 260 |
"""
|
312 |
"""
|
| 261 |
Uploads a single integer to the device
|
313 |
Uploads a single integer to the device
|
| 262 |
<addr>: the address to upload the integer to
|
314 |
<addr>: the address to upload the integer to
|
| 263 |
<integer>: the integer to upload
|
315 |
<integer>: the integer to upload
|