Description

There are already numerous ways to run Linux and some programs through emulation in a web browser (e.g. x86 and riscv64 on https://bellard.org/jslinux/), but none use WebGL/WebGPU to run the emulation on the GPU.

I already made a PoC of an AArch64 (64-bit Arm) emulator in OpenCL which is unfortunately hindered by a multitude of OpenCL compiler bugs on all platforms (Intel with beignet or the new compute runtime and AMD with Mesa Clover and rusticl). With more widespread and thus less broken GLSL vs. OpenCL and the less complex implementation requirements for RV32 (especially 32bit integers instead of 64bit), that should not be a major problem anymore.

Goals

Write an RISC-V system emulator in GLSL that is capable of booting Linux and run some userspace programs interactively. Ideally it is small enough to work on online test platforms like Shaderoo with a custom texture that contains bootstrap code, kernel and initrd.

Minimum:

riscv32 without FPU (RV32 IMA) and MMU (µClinux), running Linux in M-mode and userspace in U-mode.

Stretch goals:

FPU support, S-Mode support with MMU, SMP. Custom web frontend with more possibilities for I/O (disk image, network?).

Resources

RISC-V ISA Specifications
Shaderoo
OpenGL 4.5 Quick Reference Card

Result as of Hackweek 2024

WebGL turned out to be insufficient, it only supports OpenGL ES 3.0 but imageLoad/imageStore needs ES 3.1. So we switched directions and had to write a native C++ host for the shaders.

As of Hackweek Friday, the kernel attempts to boot and outputs messages, but panics due to missing memory regions.

Since then, some bugs were fixed and enough hardware emulation implemented, so that now Linux boots with framebuffer support and it's possible to log in and run programs!

The repo with a demo video is available at https://github.com/Vogtinator/risky-v

Looking for hackers with the skills:

risc-v opengl kernel c++

This project is part of:

Hack Week 24

Activity

  • 5 months ago: jlp liked this project.
  • 5 months ago: nkrapp liked this project.
  • 5 months ago: favogt added keyword "risc-v" to this project.
  • 5 months ago: favogt added keyword "opengl" to this project.
  • 5 months ago: favogt added keyword "kernel" to this project.
  • 5 months ago: favogt added keyword "c++" to this project.
  • 5 months ago: llansky3 liked this project.
  • 5 months ago: michals liked this project.
  • 5 months ago: jfkw liked this project.
  • 6 months ago: mwilck liked this project.
  • 6 months ago: horon liked this project.
  • 6 months ago: wfrisch liked this project.
  • 6 months ago: mbrugger liked this project.
  • 6 months ago: vliaskovitis liked this project.
  • 6 months ago: mfriedrich liked this project.
  • 6 months ago: mfriedrich joined this project.
  • 6 months ago: favogt started this project.
  • 6 months ago: favogt originated this project.

  • Comments

    • wfrisch
      6 months ago by wfrisch | Reply

      Impressive! Godspeed with that project.

    • michals
      5 months ago by michals | Reply

      Existing art: https://blog.pimaker.at/texts/rvc1/

    • favogt
      5 months ago by favogt | Reply

      Short update: It's able to boot into buildroot graphically and with keyboard input some applications can be started. Some like vi and nano crash though, which still needs some investigation. Once that's fixed I'll link to a git repo with a writeup!

    Similar Projects

    This project is one of its kind!