Skip to content

Commit 3739f50

Browse files
committed
console: Add cpp version of boot.py
1 parent a0b63d6 commit 3739f50

4 files changed

Lines changed: 581 additions & 14 deletions

File tree

‎Makefile‎

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,17 +110,17 @@ help:
110110
# Recipes that run things
111111

112112
# Boot one L2CPU in Blackhole RISC-V CPU
113-
boot: _need_linux _need_opensbi _need_dtb _need_rootfs _need_hosttool _need_python _need_luwen _need_ttkmd _need_pylibfdt
114-
$(PYTHON) boot.py --boot --ttdevice $(TTDEVICE) --l2cpu $(L2CPU) --opensbi_bin $(OPENSBI) --opensbi_dst 0x400030000000 --rootfs_dst 0x4000e5000000 --kernel_bin $(KERNEL) --kernel_dst 0x400030200000 --dtb_bin $(DTB) --dtb_dst 0x400030100000
113+
boot: _need_linux _need_opensbi _need_dtb _need_rootfs _need_hosttool _need_ttkmd
114+
./console/boot --boot --ttdevice $(TTDEVICE) --l2cpu $(L2CPU) --opensbi_bin $(OPENSBI) --opensbi_dst 0x400030000000 --rootfs_dst 0x4000e5000000 --kernel_bin $(KERNEL) --kernel_dst 0x400030200000 --dtb_bin $(DTB) --dtb_dst 0x400030100000
115115
./console/tt-bh-linux --ttdevice $(TTDEVICE) --l2cpu $(L2CPU) --disk $(DISK_IMAGE) --network
116116

117117
# Boot one L2CPU in Blackhole RISC-V CPU into an initramfs specified by $(INITRAMFS)
118-
boot_initramfs: _need_linux _need_opensbi _need_dtb _need_rootfs _need_hosttool _need_python _need_luwen _need_ttkmd _need_pylibfdt
119-
$(PYTHON) boot.py --boot --ttdevice $(TTDEVICE) --l2cpu $(L2CPU) --opensbi_bin $(OPENSBI) --opensbi_dst 0x400030000000 --rootfs_dst 0x4000e5000000 --kernel_bin $(KERNEL) --kernel_dst 0x400030200000 --dtb_bin $(DTB) --dtb_dst 0x400030100000 --boot_device initramfs --rootfs_bin $(INITRAMFS) $(DT_NO_VIRTIO_DEVICES) $(EXTRA_BOOTARGS)
118+
boot_initramfs: _need_linux _need_opensbi _need_dtb _need_rootfs _need_hosttool _need_ttkmd
119+
./console/boot --boot --ttdevice $(TTDEVICE) --l2cpu $(L2CPU) --opensbi_bin $(OPENSBI) --opensbi_dst 0x400030000000 --rootfs_dst 0x4000e5000000 --kernel_bin $(KERNEL) --kernel_dst 0x400030200000 --dtb_bin $(DTB) --dtb_dst 0x400030100000 --boot_device initramfs --rootfs_bin $(INITRAMFS) $(DT_NO_VIRTIO_DEVICES) $(EXTRA_BOOTARGS)
120120
./console/tt-bh-linux --ttdevice $(TTDEVICE) --l2cpu $(L2CPU) --disk $(DISK_IMAGE) --network
121121

122-
# boot_all: _need_linux _need_opensbi _need_dtb _need_dtb_all _need_rootfs _need_hosttool _need_python _need_luwen _need_ttkmd _need_pylibfdt
123-
# $(PYTHON) boot.py --boot --ttdevice $(TTDEVICE) --l2cpu 0 1 2 3 --opensbi_bin fw_jump.bin --opensbi_dst 0x400100000000 0x400100000000 0x400100000000 0x400180000000 --rootfs_dst 0x400165000000 0x400165000000 0x400165000000 0x4001e5000000 --kernel_bin Image --kernel_dst 0x400100200000 0x400100200000 0x400100200000 0x400180200000 --dtb_bin blackhole-card.dtb blackhole-card.dtb blackhole-card2.dtb blackhole-card3.dtb --dtb_dst 0x400100100000 0x400100100000 0x400100100000 0x400180100000 --boot_device initramfs --rootfs_bin $(INITRAMFS)
122+
# boot_all: _need_linux _need_opensbi _need_dtb _need_dtb_all _need_rootfs _need_hosttool _need_ttkmd
123+
# ./console/boot --boot --ttdevice $(TTDEVICE) --l2cpu 0 1 2 3 --opensbi_bin fw_jump.bin --opensbi_dst 0x400100000000 0x400100000000 0x400100000000 0x400180000000 --rootfs_dst 0x400165000000 0x400165000000 0x400165000000 0x4001e5000000 --kernel_bin Image --kernel_dst 0x400100200000 0x400100200000 0x400100200000 0x400180200000 --dtb_bin blackhole-card.dtb blackhole-card.dtb blackhole-card2.dtb blackhole-card3.dtb --dtb_dst 0x400100100000 0x400100100000 0x400100100000 0x400180100000 --boot_device initramfs --rootfs_bin $(INITRAMFS)
124124

125125
# Connect to console (requires a booted RISC-V)
126126
connect: _need_hosttool _need_ttkmd
@@ -155,8 +155,8 @@ user-data.img: user-data.yaml _need_cloud_image_utils
155155
cloud-localds -d raw user-data.img user-data.yaml
156156

157157
# Boot with cloud-init image attached
158-
boot_cloud_init: _need_linux _need_opensbi _need_dtb _need_rootfs _need_hosttool _need_python _need_luwen _need_ttkmd _need_pylibfdt user-data.img
159-
$(PYTHON) boot.py --boot --ttdevice $(TTDEVICE) --l2cpu $(L2CPU) --opensbi_bin $(OPENSBI) --opensbi_dst 0x400030000000 --rootfs_dst 0x4000e5000000 --kernel_bin $(KERNEL) --kernel_dst 0x400030200000 --dtb_bin $(DTB) --dtb_dst 0x400030100000
158+
boot_cloud_init: _need_linux _need_opensbi _need_dtb _need_rootfs _need_hosttool _need_ttkmd user-data.img
159+
./console/boot --boot --ttdevice $(TTDEVICE) --l2cpu $(L2CPU) --opensbi_bin $(OPENSBI) --opensbi_dst 0x400030000000 --rootfs_dst 0x4000e5000000 --kernel_bin $(KERNEL) --kernel_dst 0x400030200000 --dtb_bin $(DTB) --dtb_dst 0x400030100000
160160
./console/tt-bh-linux --ttdevice $(TTDEVICE) --l2cpu $(L2CPU) --disk $(DISK_IMAGE) --cloud-init user-data.img --network
161161

162162
#################################
@@ -205,7 +205,7 @@ build_opensbi: _need_riscv64_toolchain _need_gcc _need_python _need_opensbi_tree
205205
ln -f opensbi/build/platform/generic/firmware/fw_jump.bin fw_jump.bin
206206

207207
# Build tt-bh-linux
208-
build_hosttool: _need_gcc _need_libvdeslirp
208+
build_hosttool: _need_gcc _need_libvdeslirp _need_libfdt
209209
$(MAKE) -C console -j $(nproc) $(quiet_make)
210210

211211
# Generate a SSH key and add it to the image
@@ -240,7 +240,7 @@ clean_opensbi:
240240
# Clean host tool tree and remove binary
241241
clean_hosttool:
242242
if [ -d console ]; then $(MAKE) -C console -j $(nproc) $(quiet_make) clean; fi
243-
rm -f console/tt-bh-linux
243+
rm -f console/tt-bh-linux console/boot
244244

245245
# Clean cloned trees
246246
clean_clones:
@@ -286,7 +286,7 @@ install_tool_pkgs:
286286

287287
# Install libraries for compiling the host tool and modifying disk images
288288
install_hosttool_pkgs:
289-
$(call install,libvdeslirp-dev libslirp-dev unzip e2tools tmux cloud-image-utils)
289+
$(call install,libvdeslirp-dev libslirp-dev libfdt-dev unzip e2tools tmux cloud-image-utils)
290290

291291
install_tt_installer: _need_tt_installer
292292
TT_MODE_NON_INTERACTIVE=0 TT_SKIP_INSTALL_HUGEPAGES=0 TT_SKIP_UPDATE_FIRMWARE=0 TT_SKIP_INSTALL_PODMAN=0 TT_SKIP_INSTALL_METALLIUM_CONTAINER=0 TT_REBOOT_OPTION=2 ./tt-installer-v1.1.0.sh
@@ -377,6 +377,7 @@ _need_rootfs:
377377

378378
_need_hosttool:
379379
$(call _need_file,console/tt-bh-linux,build,build_hosttool)
380+
$(call _need_file,console/boot,build,build_hosttool)
380381

381382
_need_ttkmd:
382383
$(call _need_file,/dev/tenstorrent/0,install,install_tt_installer)
@@ -430,6 +431,9 @@ _need_tmux:
430431
_need_libvdeslirp:
431432
$(call _need_file,/usr/include/slirp/libvdeslirp.h,install,install_hosttool_pkgs)
432433

434+
_need_libfdt:
435+
$(call _need_file,/usr/include/libfdt.h,install,install_hosttool_pkgs)
436+
433437
_need_qemu_img:
434438
$(call _need_prog,qemu-img,install,install_tool_pkgs)
435439

‎console/.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
test
22
tt-bh-linux
3+
boot
34
*.d
45
*.o

‎console/Makefile‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
# SPDX-FileCopyrightText: © 2025 Tenstorrent AI ULC
22
# SPDX-License-Identifier: Apache-2.0
33
CXXFLAGS := -Wall -fpermissive -O2 -MMD -MP -g
4-
LDLIBS := -lvdeslirp -lslirp
4+
LDLIBS := -lvdeslirp -lslirp -lfdt
55
LINK.o := $(LINK.cc)
66

77
.PHONY: all clean
88

9-
all: test tt-bh-linux
9+
all: test tt-bh-linux boot
1010

1111
test: test.o l2cpu.o tlb.o
1212

1313
tt-bh-linux: tt-bh-linux.o l2cpu.o tlb.o
1414

15+
boot: boot.o l2cpu.o tlb.o
16+
1517
-include *.d
1618

1719
clean:
18-
$(RM) test tt-bh-linux *.o *.d
20+
$(RM) test tt-bh-linux boot *.o *.d

0 commit comments

Comments
 (0)