mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
add ability to read out data based on a list of virtual sectors
This adds the `--dump` command, which requires a file that is a copy/paste of a generated virtual to physical table. An example of this log would look like this: ``` INFO:shellchat::cmds::net_cmd: V|P 6000d000 40799000 (services\shellchat\src\cmds\net_cmd.rs:770) INFO:shellchat::cmds::net_cmd: V|P 6000e000 4079a000 (services\shellchat\src\cmds\net_cmd.rs:770) INFO:shellchat::cmds::net_cmd: V|P 6000f000 4079b000 (services\shellchat\src\cmds\net_cmd.rs:770) INFO:shellchat::cmds::net_cmd: V|P 60010000 4079c000 (services\shellchat\src\cmds\net_cmd.rs:770) INFO:shellchat::cmds::net_cmd: V|P 60011000 4079d000 (services\shellchat\src\cmds\net_cmd.rs:770) INFO:shellchat::cmds::net_cmd: V|P 60012000 4079e000 (services\shellchat\src\cmds\net_cmd.rs:770) INFO:shellchat::cmds::net_cmd: V|P 60013000 4079f000 (services\shellchat\src\cmds\net_cmd.rs:770) INFO:shellchat::cmds::net_cmd: V|P 60014000 407a0000 (services\shellchat\src\cmds\net_cmd.rs:770) INFO:shellchat::cmds::net_cmd: V|P 60015000 407a1000 (services\shellchat\src\cmds\net_cmd.rs:770) ``` and so forth. The script can parse this raw log to create the necessary page table mappings to read a large region of virtual memory and save it as a contiguous chunk in a file.
This commit is contained in:
parent
7dbc1f60b0
commit
3e79e3e430
1 changed files with 28 additions and 0 deletions
|
|
@ -9,6 +9,7 @@ import sys
|
|||
import hashlib
|
||||
import csv
|
||||
import urllib.request
|
||||
import re
|
||||
|
||||
from progressbar.bar import ProgressBar
|
||||
|
||||
|
|
@ -482,6 +483,12 @@ def main():
|
|||
parser.add_argument(
|
||||
"--override-csr", required=False, help="CSR file to use instead of CSR values stored with the image. Used to recover in case of partial update of soc_csr.bin", type=str,
|
||||
)
|
||||
parser.add_argument(
|
||||
"--dump", required=False, help="Dump a region of memory. Takes a virtual memory map file as an argument. Looks for lines of format `V|P vaddr paddr`", type=str,
|
||||
)
|
||||
parser.add_argument(
|
||||
"--dump-file", required=False, help="Name out output file for dump. Required if --dump is specified.", type=str,
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
if not len(sys.argv) > 1:
|
||||
|
|
@ -570,6 +577,27 @@ def main():
|
|||
|
||||
vexdbg_addr = int(pc_usb.regions['vexriscv_debug'][0], 0)
|
||||
pc_usb.ping_wdt()
|
||||
|
||||
if args.dump:
|
||||
table = []
|
||||
with open(args.dump, 'r') as map:
|
||||
for line in map.readlines():
|
||||
rgx = re.search('.*V\|P\s([0-9a-fA-F]*)\s([0-9a-fA-F]*).*', line)
|
||||
if rgx is not None:
|
||||
map = rgx.groups()
|
||||
table += [int(map[1], 16)]
|
||||
|
||||
if args.dump_file is None:
|
||||
print("Must specify --dump-file when using --dump")
|
||||
exit(0)
|
||||
with open(args.dump_file, 'wb') as f:
|
||||
for page in table:
|
||||
pc_usb.poke(vexdbg_addr, 0x00020000)
|
||||
data = pc_usb.burst_read(page, 4096)
|
||||
pc_usb.poke(vexdbg_addr, 0x02000000)
|
||||
f.write(data)
|
||||
exit(0)
|
||||
|
||||
print("Halting CPU.")
|
||||
pc_usb.poke(vexdbg_addr, 0x00020000)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue