skiffos / SkiffOS

Any Linux distribution, anywhere.
https://skiffos.com
MIT License
699 stars 52 forks source link

qemu/riscv64: Add support for new Qemu virt #248

Closed clayauld closed 2 years ago

clayauld commented 2 years ago

I'd like to use Qemu to do some build testing inside SkiffOS. Wondering how much work it would take to add an additional Qemu build for the RISCV64 architecture?

Looks like upstream buildroot already has the kernel defconfig built for two options: one with MMU support and one without

An additional point of reference may be the Ubuntu build for Qemu RISCV64:

I've been able to get this running in Qemu using the following Qemu command:

apt install qemu-system-misc opensbi u-boot-qemu qemu-utils

qemu-system-riscv64 \
  -machine virt \
  -nographic \
  -m 4G -smp 8 \
  -bios /usr/lib/riscv64-linux-gnu/opensbi/generic/fw_jump.elf \
  -kernel /usr/lib/u-boot/qemu-riscv64_smode/uboot.elf \
  -device virtio-net-device,netdev=eth0 \
  -netdev user,id=eth0,hostfwd=tcp::2222-:22 \
  -drive file=ubuntu-22.04.1-preinstalled-server-riscv64+unmatched.img,format=raw,if=virtio
paralin commented 2 years ago

hi @clayauld - running qemu and riscv64 is already supported.

export SKIFF_WORKSPACE=qemu
export SKIFF_CONFIG=virt/qemu,core/gentoo,util/rootlogin
mkdir -p ./overrides/workspaces/qemu/buildroot
echo "BR2_riscv=y" > ./overrides/workspaces/qemu/buildroot/arch
make compile

Then to start qemu:

make cmd/virt/qemu/run

You can override the settings:

export ROOTFS_MAX_SIZE=120G
export QEMU_MEMORY=8G
export QEMU_CPUS=8
make cmd/virt/qemu/run
clayauld commented 2 years ago

Oh! Excellent! Where is this documented? I didn't see it in the configs.

paralin commented 2 years ago

@clayauld https://github.com/skiffos/SkiffOS#qemu

I've added some more info there about selecting alternative architectures too.

Does this solve the issue for your use cases? It's using opensbi built-in to qemu.

clayauld commented 2 years ago

Yes it does!

Thank you for the amazingly fast response, as always.