Skip to content

Commit 20a7330

Browse files
Merge pull request #155 from tenstorrent/asrinivasan/more_lava_changes
More lava related improvements
2 parents a5223b7 + 518f976 commit 20a7330

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

‎Makefile‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ ifeq ($(NO_VIRTIO), 1)
4343
DT_NO_VIRTIO_DEVICES := --dt_no_virtio_devices
4444
endif
4545

46+
ifneq ($(BOOTARGS),)
47+
EXTRA_BOOTARGS := --extra_bootargs "$(BOOTARGS)"
48+
endif
49+
4650
# Uncomment this to make the shell rules verbose
4751
# SHELL_VERBOSE := set -x ;
4852

@@ -99,7 +103,7 @@ boot: _need_linux _need_opensbi _need_dtb _need_rootfs _need_hosttool _need_pyth
99103

100104
# Boot one L2CPU in Blackhole RISC-V CPU into an initramfs specified by $(INITRAMFS)
101105
boot_initramfs: _need_linux _need_opensbi _need_dtb _need_rootfs _need_hosttool _need_python _need_luwen _need_ttkmd _need_pylibfdt
102-
$(PYTHON) boot.py --boot --ttdevice $(TTDEVICE) --l2cpu $(L2CPU) --opensbi_bin fw_jump.bin --opensbi_dst 0x400030000000 --rootfs_dst 0x4000e5000000 --kernel_bin Image --kernel_dst 0x400030200000 --dtb_bin blackhole-card.dtb --dtb_dst 0x400030100000 --boot_device initramfs --rootfs_bin $(INITRAMFS) $(DT_NO_VIRTIO_DEVICES)
106+
$(PYTHON) boot.py --boot --ttdevice $(TTDEVICE) --l2cpu $(L2CPU) --opensbi_bin fw_jump.bin --opensbi_dst 0x400030000000 --rootfs_dst 0x4000e5000000 --kernel_bin Image --kernel_dst 0x400030200000 --dtb_bin blackhole-card.dtb --dtb_dst 0x400030100000 --boot_device initramfs --rootfs_bin $(INITRAMFS) $(DT_NO_VIRTIO_DEVICES) $(EXTRA_BOOTARGS)
103107
./console/tt-bh-linux --ttdevice $(TTDEVICE) --l2cpu $(L2CPU) --disk $(DISK_IMAGE)
104108

105109
# boot_all: _need_linux _need_opensbi _need_dtb _need_dtb_all _need_rootfs _need_hosttool _need_python _need_luwen _need_ttkmd _need_pylibfdt

‎boot.py‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def parse_args():
4040
# If using FW_PAYLOAD, set these args for rootfs and opensbi
4141
parser.add_argument("--boot_device", type=str, required=False, default="vda", help="Options: vda, vdaX or initramfs")
4242
parser.add_argument("--dt_no_virtio_devices", action="store_true", help="Don't patch DT to add virtio device nodes")
43+
parser.add_argument("--extra_bootargs", type=str, default="", help="Extra kernel command line arguments")
4344

4445
# Only used for initramfs
4546
parser.add_argument("--rootfs_bin", type=str, required=False, help="Path to initramfs")
@@ -114,7 +115,7 @@ def main():
114115
opensbi_addr = int(args.opensbi_dst[idx], 16)
115116
opensbi_bytes = read_bin_file(args.opensbi_bin)
116117

117-
if args.rootfs_dst and args.rootfs_bin:
118+
if args.rootfs_dst and args.rootfs_bin and os.path.exists(args.rootfs_bin):
118119
rootfs_addr = int(args.rootfs_dst[idx], 16)
119120
rootfs_bytes = read_bin_file(args.rootfs_bin)
120121

@@ -139,10 +140,13 @@ def main():
139140
if args.boot_device[:len("vda")] == "vda":
140141
bootargs += f" root=/dev/{args.boot_device}"
141142
elif args.boot_device == "initramfs":
142-
bootargs += f" initrd={args.rootfs_dst[idx]},{len(rootfs_bytes)}"
143+
if os.path.exists(args.rootfs_bin):
144+
bootargs += f" initrd={args.rootfs_dst[idx]},{len(rootfs_bytes)}"
143145
else:
144146
print("Unsupported rootfs type")
145147
exit(1)
148+
if args.extra_bootargs:
149+
bootargs += f" {args.extra_bootargs}"
146150
fdt.setprop(chosen_offset, "bootargs", bytes(bootargs, encoding="utf-8") + b'\0')
147151

148152
memory_node = fdt.path_offset("/memory@400030000000", libfdt.QUIET_NOTFOUND)
@@ -205,7 +209,7 @@ def main():
205209
print(f"Writing OpenSBI to 0x{opensbi_addr:x}")
206210
chip.noc_write(0, l2cpu_noc_x, l2cpu_noc_y, opensbi_addr, opensbi_bytes)
207211

208-
if args.rootfs_dst and args.rootfs_bin:
212+
if args.rootfs_dst and args.rootfs_bin and os.path.exists(args.rootfs_bin):
209213
print(f"Writing rootfs to 0x{rootfs_addr:x}")
210214
chip.noc_write(0, l2cpu_noc_x, l2cpu_noc_y, rootfs_addr, rootfs_bytes)
211215

0 commit comments

Comments
 (0)