tools/litex_client: Add --csr-csv support.
Useful to debug multi-FPGA projects.
This commit is contained in:
parent
87d5d7c87c
commit
7ebc7625d5
|
@ -86,15 +86,15 @@ class RemoteClient(EtherboneIPC, CSRBuilder):
|
|||
|
||||
# Utils --------------------------------------------------------------------------------------------
|
||||
|
||||
def reg2addr(reg):
|
||||
bus = RemoteClient()
|
||||
def reg2addr(csr_csv, reg):
|
||||
bus = RemoteClient(csr_csv=csr_csv)
|
||||
if hasattr(bus.regs, reg):
|
||||
return getattr(bus.regs, reg).addr
|
||||
else:
|
||||
raise ValueError(f"Register {reg} not present, exiting.")
|
||||
|
||||
def dump_identifier(port):
|
||||
bus = RemoteClient(port=port)
|
||||
def dump_identifier(csr_csv, port):
|
||||
bus = RemoteClient(csr_csv=csr_csv, port=port)
|
||||
bus.open()
|
||||
|
||||
# On PCIe designs, CSR is remapped to 0 to limit BAR0 size.
|
||||
|
@ -113,8 +113,8 @@ def dump_identifier(port):
|
|||
|
||||
bus.close()
|
||||
|
||||
def dump_registers(port, filter=None):
|
||||
bus = RemoteClient(port=port)
|
||||
def dump_registers(csr_csv, port, filter=None):
|
||||
bus = RemoteClient(csr_csv=csr_csv, port=port)
|
||||
bus.open()
|
||||
|
||||
# On PCIe designs, CSR is remapped to 0 to limit BAR0 size.
|
||||
|
@ -127,8 +127,8 @@ def dump_registers(port, filter=None):
|
|||
|
||||
bus.close()
|
||||
|
||||
def read_memory(port, addr, length):
|
||||
bus = RemoteClient(port=port)
|
||||
def read_memory(csr_csv, port, addr, length):
|
||||
bus = RemoteClient(csr_csv=csr_csv, port=port)
|
||||
bus.open()
|
||||
|
||||
for offset in range(length//4):
|
||||
|
@ -136,8 +136,8 @@ def read_memory(port, addr, length):
|
|||
|
||||
bus.close()
|
||||
|
||||
def write_memory(port, addr, data):
|
||||
bus = RemoteClient(port=port)
|
||||
def write_memory(csr_csv, port, addr, data):
|
||||
bus = RemoteClient(csr_csv=csr_csv, port=port)
|
||||
bus.open()
|
||||
|
||||
bus.write(addr, data)
|
||||
|
@ -148,36 +148,38 @@ def write_memory(port, addr, data):
|
|||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="LiteX Client utility.", formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
||||
parser.add_argument("--port", default="1234", help="Host bind port.")
|
||||
parser.add_argument("--ident", action="store_true", help="Dump SoC identifier.")
|
||||
parser.add_argument("--regs", action="store_true", help="Dump SoC registers.")
|
||||
parser.add_argument("--filter", default=None, help="Registers filter (to be used with --regs).")
|
||||
parser.add_argument("--read", default=None, help="Do a MMAP Read to SoC bus (--read addr/reg).")
|
||||
parser.add_argument("--write", default=None, nargs=2, help="Do a MMAP Write to SoC bus (--write addr/reg data).")
|
||||
parser.add_argument("--length", default="4", help="MMAP access length.")
|
||||
parser.add_argument("--csr-csv", default="csr.csv", help="CSR configuration file")
|
||||
parser.add_argument("--port", default="1234", help="Host bind port.")
|
||||
parser.add_argument("--ident", action="store_true", help="Dump SoC identifier.")
|
||||
parser.add_argument("--regs", action="store_true", help="Dump SoC registers.")
|
||||
parser.add_argument("--filter", default=None, help="Registers filter (to be used with --regs).")
|
||||
parser.add_argument("--read", default=None, help="Do a MMAP Read to SoC bus (--read addr/reg).")
|
||||
parser.add_argument("--write", default=None, nargs=2, help="Do a MMAP Write to SoC bus (--write addr/reg data).")
|
||||
parser.add_argument("--length", default="4", help="MMAP access length.")
|
||||
args = parser.parse_args()
|
||||
|
||||
port = int(args.port, 0)
|
||||
csr_csv = args.csr_csv
|
||||
port = int(args.port, 0)
|
||||
|
||||
if args.ident:
|
||||
dump_identifier(port=port)
|
||||
dump_identifier(csr_csv=csr_csv, port=port)
|
||||
|
||||
if args.regs:
|
||||
dump_registers(port=port, filter=args.filter)
|
||||
dump_registers(csr_csv=csr_csv, port=port, filter=args.filter)
|
||||
|
||||
if args.read:
|
||||
if isinstance(args.read, str):
|
||||
addr = reg2addr(args.read)
|
||||
addr = reg2addr(csr_csv, args.read)
|
||||
else:
|
||||
addr = int(args.read, 0)
|
||||
read_memory(port=port, addr=addr, length=int(args.length, 0))
|
||||
read_memory(csr_csv=csr_csv, port=port, addr=addr, length=int(args.length, 0))
|
||||
|
||||
if args.write:
|
||||
if isinstance(args.write[0], str):
|
||||
addr = reg2addr(args.write[0])
|
||||
addr = reg2addr(csr_csv, args.write[0])
|
||||
else:
|
||||
addr = int(args.write[0], 0)
|
||||
write_memory(port=port, addr=addr, data=int(args.write[1], 0))
|
||||
write_memory(csr_csv=csr_csv, port=port, addr=addr, data=int(args.write[1], 0))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
Loading…
Reference in New Issue