commit b365f34f0f13c4a38a01e9b4753943e354cc870f Author: Imbus <> Date: Mon Apr 29 23:59:31 2024 +0200 Initial diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7fbc588 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +*.pub +*.qcow2 +*.img +*.raw +*.tgz +SHA256* +share diff --git a/makefile b/makefile new file mode 100755 index 0000000..d610838 --- /dev/null +++ b/makefile @@ -0,0 +1,77 @@ +# Inspired by https://www.codemadness.org/openbsd-riscv64-vm.html +# mirror list: https://www.openbsd.org/ftp.html +# mirror := https://mirror.hs-esslingen.de/pub/OpenBSD/ +mirror := https://ftp.lysator.liu.se/pub/OpenBSD/ +release := 7.5 +release_short := $(shell echo ${release} | sed 's/\.//g')# Without dots (7.5 -> 75) + +diskname := openBSD$(release_short).qcow2 +opensbiname := opensbi-1.2.tgz +ubootname := u-boot-riscv64-2021.10p8.tgz + +release_pubkey := openbsd-$(release_short)-base.pub +release_pubkey_url := https://ftp.openbsd.org/pub/OpenBSD/7.5/$(release_pubkey) +CURL := @curl --progress-bar -O + +minirootname := miniroot$(release_short).img + +$(release_pubkey): + $(CURL) ${release_pubkey_url} + +$(minirootname): $(release_pubkey) + $(CURL) ${mirror}/${release}/riscv64/${minirootname} + $(CURL) ${mirror}/${release}/riscv64/SHA256 + $(CURL) ${mirror}/${release}/riscv64/SHA256.sig + signify -C -p ${release_pubkey} -x SHA256.sig $(minirootname) + +$(diskname): + qemu-img create -f qcow2 ${diskname} 10G + +repokeys: $(release_pubkey) + $(CURL) ${mirror}/${release}/packages/amd64/SHA256 + $(CURL) ${mirror}/${release}/packages/amd64/SHA256.sig + +checksums: repokeys + cksum -a sha256 --ignore-missing -c SHA256 + +$(opensbiname): repokeys + $(CURL) ${mirror}/${release}/packages/amd64/${opensbiname} + @# signify -C -p ${release_pubkey} -x SHA256.sig $(opensbiname) + @tar -xzf ${opensbiname} share/opensbi/generic/fw_jump.bin + +$(ubootname): repokeys + $(CURL) ${mirror}/${release}/packages/amd64/${ubootname} + @# signify -C -p ${release_pubkey} -x SHA256.sig $(ubootname) + @tar -xzf ${ubootname} share/u-boot/qemu-riscv64_smode/u-boot.bin + +installer: $(minirootname) $(diskname) $(opensbiname) $(ubootname) + make checksums + @echo "Starting VM with installer..." + @qemu-system-riscv64 \ + -machine virt \ + -nographic \ + -m 2048M \ + -smp 2 \ + -bios share/opensbi/generic/fw_jump.bin \ + -kernel share/u-boot/qemu-riscv64_smode/u-boot.bin \ + -drive file=$(minirootname),format=raw,id=cd0 -device virtio-blk-device,drive=cd0 \ + -drive file=$(diskname),format=qcow2,id=hd0 -device virtio-blk-device,drive=hd0 \ + -netdev user,id=net0,ipv6=off -device virtio-net-device,netdev=net0 + +run: + @echo "Starting VM from disk image..." + @qemu-system-riscv64 \ + -machine virt \ + -nographic \ + -m 2048M \ + -smp 2 \ + -bios share/opensbi/generic/fw_jump.bin \ + -kernel share/u-boot/qemu-riscv64_smode/u-boot.bin \ + -drive file=$(diskname),format=qcow2,id=hd0 -device virtio-blk-device,drive=hd0 \ + -netdev user,id=net0,ipv6=off -device virtio-net-device,netdev=net0 + +clean: + rm -f ${minirootname} ${diskname} ${opensbiname} ${ubootname} ${release_pubkey} SHA256 SHA256.sig + rm -rf share + +.PHONY: installer run clean \ No newline at end of file