litex_json2renode: fix --bios-binary and add --opensbi-binary

--bios-binary is reverted to loading the bios into _rom_ as per the documentation and litex defaults
--opensbi-binary is added to load the openSBI binary into the opensbi memory region

The examples documented in the wiki now work again
This commit is contained in:
Andrew Dennison 2023-09-25 19:34:09 +10:00
parent 3d956af81d
commit 564f96c6c7
1 changed files with 17 additions and 6 deletions

View File

@ -883,16 +883,23 @@ showAnalyzer sysbus.uart Antmicro.Renode.Analyzers.LoggingUartAnalyzer
""".format(cpu_type, args.repl) """.format(cpu_type, args.repl)
opensbi_base = csr['memories']['opensbi']['base'] if 'opensbi' in csr['memories'] else None opensbi_base = csr['memories']['opensbi']['base'] if 'opensbi' in csr['memories'] else None
if opensbi_base is not None and args.bios_binary: if opensbi_base is not None and args.opensbi_binary:
# load LiteX BIOS to ROM # load OpenSBI to opensbi base
result += """ result += """
sysbus LoadBinary @{} {} sysbus LoadBinary @{} {}
""".format(args.bios_binary, hex(opensbi_base)) """.format(args.opensbi_binary, hex(opensbi_base))
if opensbi_base:
for cpu_id in range(0, number_of_cores): for cpu_id in range(0, number_of_cores):
result += f"cpu{cpu_id} PC {hex(opensbi_base)}\n" result += f"cpu{cpu_id} PC {hex(opensbi_base)}\n"
rom_base = csr['memories']['rom']['base'] if 'rom' in csr['memories'] else None
if rom_base is not None and args.bios_binary:
# load LiteX BIOS to ROM base
result += """
sysbus LoadBinary @{} {}
""".format(args.bios_binary, hex(rom_base))
for cpu_id in range(0, number_of_cores):
result += f"cpu{cpu_id} PC {hex(rom_base)}\n"
if args.tftp_ip: if args.tftp_ip:
result += """ result += """
@ -1047,8 +1054,12 @@ def parse_args():
help='Output platform definition file') help='Output platform definition file')
parser.add_argument('--configure-network', action='store', parser.add_argument('--configure-network', action='store',
help='Generate virtual network and connect it to host') help='Generate virtual network and connect it to host')
parser.add_argument('--bios-binary', action='store', bios_group = parser.add_mutually_exclusive_group()
bios_group.add_argument('--bios-binary', action='store',
help='Path to the BIOS binary') help='Path to the BIOS binary')
bios_group.add_argument('--opensbi-binary', action='store',
help='Path to the OpenSBI binary')
parser.add_argument('--firmware-binary', action='store', parser.add_argument('--firmware-binary', action='store',
help='Path to the binary to load into boot flash') help='Path to the binary to load into boot flash')
parser.add_argument('--flash-binary', action='append', dest='flash_binaries_args', parser.add_argument('--flash-binary', action='append', dest='flash_binaries_args',