Merge pull request #1895 from trabucayre/json2dts_linux_fill_network

tools/litex_json2dts_linux.py: adding ip= bootarg when localip and remoteip are provided
This commit is contained in:
enjoy-digital 2024-02-22 10:20:41 +01:00 committed by GitHub
commit dc229f8df9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 2 deletions

View File

@ -68,14 +68,23 @@ def generate_dts(d, initrd_start=None, initrd_size=None, initrd=None, root_devic
initrd_enabled = True initrd_enabled = True
initrd_size = os.path.getsize(initrd) initrd_size = os.path.getsize(initrd)
# if json constants contains localip ethernet has been enabled
if "localip1" in d["constants"]:
localip = '.'.join([str(d["constants"][f"localip{i}"]) for i in range(1,5)])
remoteip = '.'.join([str(d["constants"][f"remoteip{i}"]) for i in range(1,5)])
ip = f" ip={localip}:{remoteip}:{remoteip}:255.255.255.0::eth0:off:::"
else:
ip = ""
if root_device is None: if root_device is None:
root_device = "ram0" root_device = "ram0"
dts += """ dts += """
chosen {{ chosen {{
bootargs = "{console} {rootfs}";""".format( bootargs = "{console} {rootfs}{ip}";""".format(
console = "console=liteuart earlycon=liteuart,0x{:x}".format(d["csr_bases"]["uart"]), console = "console=liteuart earlycon=liteuart,0x{:x}".format(d["csr_bases"]["uart"]),
rootfs = "rootwait root=/dev/{}".format(root_device)) rootfs = "rootwait root=/dev/{}".format(root_device),
ip = ip)
if initrd_enabled is True: if initrd_enabled is True:
dts += """ dts += """