How to play with a RiscV version of Haiku in TinyEMU or QEMU?

fw_jump.bin and u-boot.bin are available here: Releases · LekKit/RVVM · GitHub. Note: keyboard and mouse will not work with Haiku upstream.

1 Like

Got the RISC-V version of Haiku running in QEMU!

Host OS is Debian testing (trixie)!

4 Likes

It is also should be possible to use VirtIO network with QEMU.

2 Likes

So, networking works in QEMU but not RVVM?.

Networking also works with RVVM, but with small fix:

diff --git a/src/add-ons/kernel/drivers/network/ether/rtl81xx/dev/re/if_re.c b/src/add-ons/kernel/drivers/network/ether/rtl81xx/dev/re/if_re.c
index cf327932cd7..5bd4ee548a7 100644
--- a/src/add-ons/kernel/drivers/network/ether/rtl81xx/dev/re/if_re.c
+++ b/src/add-ons/kernel/drivers/network/ether/rtl81xx/dev/re/if_re.c
@@ -1564,7 +1564,7 @@ re_attach(device_t dev)
 	CSR_WRITE_1(sc, sc->rl_cfg5, cfg);
 	CSR_WRITE_1(sc, RL_EECMD, RL_EEMODE_OFF);
 
-	if ((sc->rl_flags & RL_FLAG_PAR) != 0) {
+	if (true || (sc->rl_flags & RL_FLAG_PAR) != 0) {
 		/*
 		 * XXX Should have a better way to extract station
 		 * address from EEPROM.
4 Likes

Thanks for the patch, i guess this patch is not in master yet?

It is likely RVVM side fault, not Haiku. Patched code originates from FreeBSD.

3 Likes

Anyone gotten Haiku (RiscV) connected to the Internet in QEMU? If so, what do I need to add to my command line, to do so?

  • qemu -netdev (-device virtio-net-pci,netdev=) … (networking)
  • qemu -debugcon file:debug.log … (debugging log to file)
  • qemu -smp 4,sockets=1,cores=4,threads=4,maxcpus=4 -cpu host … (multithread/core setup).
  • qemu -vga … (VESA/VGA-compatibility)

Example (ref: QEMU User Documentation — QEMU documentation)

-netdev user,id=internet
-device virtio-net-pci,mac=50:54:00:00:00:42,netdev=internet,id=internet-dev
-smbios type=41,designation=‘Onboard LAN’,instance=1,kind=ethernet,pcidev=internet-dev

Note: Several things are still a work-in-progress on device driver support for Haiku RISCV…

I ran this command in Haiku (RiscV) in QEMU, as a type of benchmark:

dd if=/dev/zero bs=1MB count=10240 | sha512sum

And I got a result of:
10240000000 bytes (10GB, 9.5GiB) copied, 228.565s, -0.0MB/s

However, that can’t be right… it can’t be ZERO. But I’m a bit puzzled how to calc this out, to know how many MB/s it actually did. It will be interesting to see what people running Haiku (RiscV) on a VisionFive 2 get.

10240MB / 228,565s = 44,8012600354 MB/s

So 49ish MB/s average speed.
That is just calculated though, depending on what actually happened it may be more or less during some time.

Yup… I figured that was how it would be calc’d, but I thought, “Well, maybe it’s a bit more complex than that.” :grin:

dd is currently broken on Haiku riscv64. It sometimes crash, sometimes show wrong speed. Something FPU related.

That’s ok… tinkering is still fun. :grin:

I don’t think that’s specific to riscv64, I started having those problems with dd on x86_64 too. I even had a FPU exception in kernel mode last night from running an autoconf script that uses dd.

What is the best (fastest) way to run Haiku Risc-V in a VM in Haiku 32-bit?
QEMU? RVVM? Something else?

I uploaded test Haiku riscv64 based in my Device manager v2 branch (GitHub - X547/haiku at device_manager2). Following targets are supported:

  1. VisionFive 2 (SD card, NVMe)
  2. TinyEMU (RAW)
  3. QEMU (RAW, UEFI)
  4. RVVM (RAW, UEFI)

Archive includes shell scripts to run various virtual machines. When running on VisionFive 2, flash ROM boot method should be used (both boot mode DIP switches on “LO” position). Firmware version should be not newer than v3.1.5 because of bug #52.

When using TinyEMU, this branch should be used: GitHub - X547/TinyEMU.

RVVM is available here (including Linux and Windows binaries in releases section): GitHub - LekKit/RVVM: The RISC-V Virtual Machine. RVVM is currently fastest software RISC-V emulator, it supports JIT code generation from RISC-V machine code to host machine instructions.

RAW boot loader means that Haiku boot loader is directly used as machine firmware. It boots faster compared to UEFI, but it currently do not support multiple CPU cores and limited to virtual machines only.

Download link: haiku-hrev57311+155-dm2.zip - Google Drive.

11 Likes

Created a package here for RVVM that seems to run fine for booting the image @X512 , nice work! :ok_hand:

10 Likes

Networking in QEMU didn’t seem to quite work for me. The option I quoted above gave an error in QEMU stating it wasn’t an option for the target platform, so I excluded it from my startup script. And although the Network Status shows a connection, the MAC address is ff:ff:ff:ff:ff:ff and no network pings go out; the network is unreachable.

This is my QEMU startup script:

#!/usr/bin/zsh

echo ‘Starting Haiku…’
sleep 1
qemu-system-riscv64
-kernel u-boot.bin
-M virt -m 4096
-device ati-vga
-device virtio-blk-device,drive=x0,bus=virtio-mmio-bus.0
-drive file=haiku-mmc.image,if=none,format=raw,id=x0
-device usb-ehci,id=ehci
-device usb-tablet
-device usb-kbd
-device ramfb
-netdev user,id=internet
-device virtio-net-pci,mac=50:54:00:00:00:42,netdev=internet,id=internet-dev
-serial stdio
-smp 3

Currently on hrev57510 nightly.

1 Like

See: Progress on running Haiku on VisionFive 2 - Development / OS - Haiku Community (haiku-os.org)

Work in progress. Talk to @X512 for further testing.

2 Likes