Skip to content

Commit e174d3a

Browse files
Merge pull request #156 from tenstorrent/OctopusET-imagedir
Makefile: parameterize KERNEL / OPENSBI / DTB; add IMAGEDIR shortcut
2 parents 20a7330 + 247f42e commit e174d3a

2 files changed

Lines changed: 33 additions & 9 deletions

File tree

‎Makefile‎

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,22 @@ ifeq (,$(findstring /usr/sbin,$(PATH)))
2727
endif
2828
export PATH
2929

30-
# Default riscv64 disk image file. Change this to point at your local image
31-
# if you have one
32-
DISK_IMAGE := rootfs.ext4
30+
# Boot artifacts. Override individually, or set IMAGEDIR=<dir> below to pick
31+
# all four from the same directory (useful when bringing your own distro).
32+
KERNEL ?= Image
33+
OPENSBI ?= fw_jump.bin
34+
DTB ?= blackhole-card.dtb
35+
DISK_IMAGE ?= rootfs.ext4
36+
37+
# IMAGEDIR shortcut: e.g. `make boot IMAGEDIR=gentoo` resolves all four to
38+
# gentoo/{Image,fw_jump.bin,blackhole-card.dtb,rootfs.ext4}. Explicit
39+
# overrides above (KERNEL=, OPENSBI=, DTB=, DISK_IMAGE=) still win.
40+
ifdef IMAGEDIR
41+
KERNEL := $(IMAGEDIR)/Image
42+
OPENSBI := $(IMAGEDIR)/fw_jump.bin
43+
DTB := $(IMAGEDIR)/blackhole-card.dtb
44+
DISK_IMAGE := $(IMAGEDIR)/rootfs.ext4
45+
endif
3346

3447
L2CPU ?= 0
3548
TTDEVICE ?= 0
@@ -98,12 +111,12 @@ help:
98111

99112
# Boot one L2CPU in Blackhole RISC-V CPU
100113
boot: _need_linux _need_opensbi _need_dtb _need_rootfs _need_hosttool _need_python _need_luwen _need_ttkmd _need_pylibfdt
101-
$(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
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
102115
./console/tt-bh-linux --ttdevice $(TTDEVICE) --l2cpu $(L2CPU) --disk $(DISK_IMAGE)
103116

104117
# Boot one L2CPU in Blackhole RISC-V CPU into an initramfs specified by $(INITRAMFS)
105118
boot_initramfs: _need_linux _need_opensbi _need_dtb _need_rootfs _need_hosttool _need_python _need_luwen _need_ttkmd _need_pylibfdt
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)
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)
107120
./console/tt-bh-linux --ttdevice $(TTDEVICE) --l2cpu $(L2CPU) --disk $(DISK_IMAGE)
108121

109122
# boot_all: _need_linux _need_opensbi _need_dtb _need_dtb_all _need_rootfs _need_hosttool _need_python _need_luwen _need_ttkmd _need_pylibfdt
@@ -143,7 +156,7 @@ user-data.img: user-data.yaml _need_cloud_image_utils
143156

144157
# Boot with cloud-init image attached
145158
boot_cloud_init: _need_linux _need_opensbi _need_dtb _need_rootfs _need_hosttool _need_python _need_luwen _need_ttkmd _need_pylibfdt user-data.img
146-
$(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
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
147160
./console/tt-bh-linux --ttdevice $(TTDEVICE) --l2cpu $(L2CPU) --disk $(DISK_IMAGE) --cloud-init user-data.img
148161

149162
#################################
@@ -344,13 +357,13 @@ download_all: download_rootfs download_prebuilt
344357
# Helpers
345358

346359
_need_linux:
347-
$(call _need_file,Image,build,build_linux)
360+
$(call _need_file,$(KERNEL),build,build_linux)
348361

349362
_need_opensbi:
350-
$(call _need_file,fw_jump.bin,build,build_opensbi)
363+
$(call _need_file,$(OPENSBI),build,build_opensbi)
351364

352365
_need_dtb:
353-
$(call _need_file,blackhole-card.dtb,build,build_linux)
366+
$(call _need_file,$(DTB),build,build_linux)
354367

355368
_need_cloud_image_utils:
356369
$(call _need_prog,cloud-localds,install,install_hosttool_pkgs)

‎README.md‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,17 @@ Halt and catch fire!
236236
a particular result. See [this](watch.expect) and
237237
[this](.github/workflows/build.yml#L154) for examples on how to do this
238238

239+
### Bring Your Own Image
240+
241+
`KERNEL`, `OPENSBI`, `DTB`, `DISK_IMAGE` are Make variables; override one
242+
or more on the command line. `IMAGEDIR=<dir>` is a shortcut that resolves
243+
all four to `<dir>/{Image,fw_jump.bin,blackhole-card.dtb,rootfs.ext4}`:
244+
245+
```bash
246+
make boot IMAGEDIR=mydistro
247+
make boot KERNEL=other/Image DISK_IMAGE=other/rootfs.ext4
248+
```
249+
239250
### What is the X280's address map?
240251
| Base | Top | PMA | Description |
241252
|------------------|------------------|--------|-----------------------------|

0 commit comments

Comments
 (0)