Skip to content

Commit

Permalink
litex_json2renode: fix --bios-binary and add --opensbi-binary
Browse files Browse the repository at this point in the history
--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
  • Loading branch information
Andrew Dennison committed Sep 23, 2023
1 parent 3d956af commit 2853942
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions litex/tools/litex_json2renode.py
Original file line number Diff line number Diff line change
Expand Up @@ -883,16 +883,22 @@ def generate_resc(csr, number_of_cores, args, flash_binaries={}, tftp_binaries={
""".format(cpu_type, args.repl)

opensbi_base = csr['memories']['opensbi']['base'] if 'opensbi' in csr['memories'] else None
if opensbi_base is not None and args.bios_binary:
# load LiteX BIOS to ROM
if opensbi_base is not None and args.opensbi_binary:
# load OpenSBI to opensbi base
result += """
sysbus LoadBinary @{} {}
""".format(args.bios_binary, hex(opensbi_base))

if opensbi_base:
""".format(args.opensbi_binary, hex(opensbi_base))
for cpu_id in range(0, number_of_cores):
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))
result += f"cpu0 PC {hex(rom_base)}\n"

if args.tftp_ip:
result += """
Expand Down Expand Up @@ -1049,6 +1055,8 @@ def parse_args():
help='Generate virtual network and connect it to host')
parser.add_argument('--bios-binary', action='store',
help='Path to the BIOS binary')
parser.add_argument('--opensbi-binary', action='store',
help='Path to the OpenSBI binary')
parser.add_argument('--firmware-binary', action='store',
help='Path to the binary to load into boot flash')
parser.add_argument('--flash-binary', action='append', dest='flash_binaries_args',
Expand Down

0 comments on commit 2853942

Please sign in to comment.