mirror of
https://github.com/enjoy-digital/litex.git
synced 2025-01-04 09:52:26 -05:00
json2dts_linux: Add configuration for root device
This allows setting a root device other than ram0, this is useful when using a rootfs from the SD card. Doing this makes boot time faster and saves on memory footprint used by an in ram initrd.
This commit is contained in:
parent
ec2f2a6af5
commit
ea06948c62
1 changed files with 7 additions and 2 deletions
|
@ -12,7 +12,7 @@ import json
|
|||
import argparse
|
||||
import os
|
||||
|
||||
def generate_dts(d, initrd_start=None, initrd_size=None, initrd=None, polling=False):
|
||||
def generate_dts(d, initrd_start=None, initrd_size=None, initrd=None, root_device=None, polling=False):
|
||||
|
||||
kB = 1024
|
||||
mB = kB*1024
|
||||
|
@ -52,13 +52,16 @@ def generate_dts(d, initrd_start=None, initrd_size=None, initrd=None, polling=Fa
|
|||
initrd_enabled = True
|
||||
initrd_size = os.path.getsize(initrd)
|
||||
|
||||
if root_device is None:
|
||||
root_device = "ram0"
|
||||
|
||||
dts += """
|
||||
chosen {{
|
||||
bootargs = "mem={main_ram_size_mb}M@0x{main_ram_base:x} {console} {rootfs} init=/sbin/init swiotlb=32";""".format(
|
||||
main_ram_base = d["memories"]["main_ram"]["base"],
|
||||
main_ram_size_mb = d["memories"]["main_ram"]["size"] // mB,
|
||||
console = "console=liteuart earlycon=liteuart,0x{:x}".format(d["csr_bases"]["uart"]),
|
||||
rootfs = "rootwait root=/dev/ram0")
|
||||
rootfs = "rootwait root=/dev/{}".format(root_device))
|
||||
|
||||
if initrd_enabled is True:
|
||||
dts += """
|
||||
|
@ -644,6 +647,7 @@ def main():
|
|||
parser.add_argument("--initrd-start", type=int, help="Location of initrd in RAM (relative, default depends on CPU)")
|
||||
parser.add_argument("--initrd-size", type=int, help="Size of initrd (default=8MB)")
|
||||
parser.add_argument("--initrd", type=str, help="Supports arguments 'enabled', 'disabled' or a file name. Set to 'disabled' if you use a kernel built in rootfs or have your rootfs on an SD card partition. If a file name is provied the size of the file will be used instead of --initrd-size. (default=enabled)")
|
||||
parser.add_argument("--root-device", type=str, help="Device that has our rootfs, if using initrd use the default. For SD card's use something like mmcblk0p3. (default=ram0)")
|
||||
parser.add_argument("--polling", action="store_true", help="Force polling mode on peripherals")
|
||||
args = parser.parse_args()
|
||||
|
||||
|
@ -652,6 +656,7 @@ def main():
|
|||
initrd_start = args.initrd_start,
|
||||
initrd_size = args.initrd_size,
|
||||
initrd = args.initrd,
|
||||
root_device = args.root_device,
|
||||
polling = args.polling,
|
||||
)
|
||||
print(r)
|
||||
|
|
Loading…
Reference in a new issue