{"id":21826964,"url":"https://github.com/vogtinator/risky-v","last_synced_at":"2025-10-08T04:31:28.597Z","repository":{"id":265064828,"uuid":"895023651","full_name":"Vogtinator/risky-v","owner":"Vogtinator","description":"RISC-V System Emulator running on your GPU","archived":false,"fork":false,"pushed_at":"2024-12-09T09:21:57.000Z","size":429,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-09T10:28:09.513Z","etag":null,"topics":["emulator","glsl-shader","linux-kernel","risc-v"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Vogtinator.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-27T12:26:33.000Z","updated_at":"2024-12-09T09:22:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"5f0a9a50-123d-43b9-b7fb-a0c48eb05c43","html_url":"https://github.com/Vogtinator/risky-v","commit_stats":null,"previous_names":["vogtinator/risky-v"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vogtinator%2Frisky-v","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vogtinator%2Frisky-v/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vogtinator%2Frisky-v/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vogtinator%2Frisky-v/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Vogtinator","download_url":"https://codeload.github.com/Vogtinator/risky-v/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235682050,"owners_count":19028827,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["emulator","glsl-shader","linux-kernel","risc-v"],"created_at":"2024-11-27T18:11:38.927Z","updated_at":"2025-10-08T04:31:23.255Z","avatar_url":"https://github.com/Vogtinator.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"RISKY-V: RISC-V System Emulator running on your GPU\n==\n\nRISKY-V emulates a RISC-V system using OpenGL ES 3.1 the emulator itself is written in GLSL and runs on the GPU as a fragment shader!\n\nWhat it can do\n--\n\nM-mode and U-mode are implemented and by default 32MiB of memory are available to the VM. A 640x480px framebuffer is provided as output and keyboard buttons are passed through as GPIO.\n\nIt can boot Linux and run some programs! You do need some patience.\n\n[Booting and logging in to Linux](https://github.com/user-attachments/assets/97839ddf-15c8-4901-8f37-bd4d68c9addd)\n\nWhat it can't do\n--\n\nS-mode and MMU support are not implemented, so many applications and libraries won't be available.\n\nKeyboard input is currently implemented such that the key codes from the windowing system are passed straight to the emulated system, so the mappings are only accurate when using Wayland. With X11, keys will be mixed up.\n\nBuild and run it\n--\n\nBuild a Linux kernel for riscv32 nommu. Important config options:\n\n```\nCONFIG_32BIT=y\nCONFIG_RISCV_M_MODE=y\nCONFIG_SERIAL_EARLYCON_SEMIHOST=y\nCONFIG_FB_SIMPLE=y\nCONFIG_VT_CONSOLE=y\nCONFIG_RISCV_SLOW_UNALIGNED_ACCESS=y\nCONFIG_GPIO_GENERIC_PLATFORM=y\nCONFIG_KEYBOARD_GPIO_POLLED=y\n```\n\nYou can build an initramfs of your choice and embed it into the kernel build.\n\nIf using buildroot, run `make uclibc-menuconfig` and set `PTHREADS_STACK_DEFAULT_SIZE` to something like 256k instead of the default 2MiB, otherwise some programs run out of memory.\nSeveral programs like nano and prboom don't set the stack size large enough and corrupt memory:\n\n```diff\ndiff --git a/package/Makefile.in b/package/Makefile.in\nindex 82963690..d2783734 100644\n--- a/package/Makefile.in\n+++ b/package/Makefile.in\n@@ -210,7 +210,7 @@ ifeq ($(BR2_riscv),y)\n TARGET_CFLAGS += -fPIC\n endif\n ELF2FLT_FLAGS = $(if $($(PKG)_FLAT_STACKSIZE),\\\n-       -Wl$(comma)-elf2flt=\"-r -s$($(PKG)_FLAT_STACKSIZE)\",\\\n+       -Wl$(comma)-elf2flt=-r$(comma)-elf2flt=-s$($(PKG)_FLAT_STACKSIZE),\\\n         -Wl$(comma)-elf2flt=-r)\n TARGET_CFLAGS += $(ELF2FLT_FLAGS)\n TARGET_CXXFLAGS += $(ELF2FLT_FLAGS)\ndiff --git a/package/nano/nano.mk b/package/nano/nano.mk\nindex a1b94c90..105702a4 100644\n--- a/package/nano/nano.mk\n+++ b/package/nano/nano.mk\n@@ -11,6 +11,7 @@ NANO_SOURCE = nano-$(NANO_VERSION).tar.xz\n NANO_LICENSE = GPL-3.0+\n NANO_LICENSE_FILES = COPYING\n NANO_DEPENDENCIES = ncurses\n+NANO_FLAT_STACKSIZE=0x100000\n \n ifeq ($(BR2_PACKAGE_NCURSES_WCHAR),y)\n NANO_CONF_ENV += ac_cv_prog_NCURSESW_CONFIG=$(STAGING_DIR)/usr/bin/$(NCURSES_CONFIG_SCRIPTS)\ndiff --git a/package/prboom/prboom.mk b/package/prboom/prboom.mk\nindex c1ba05ff..4d074acd 100644\n--- a/package/prboom/prboom.mk\n+++ b/package/prboom/prboom.mk\n@@ -11,6 +11,7 @@ PRBOOM_DEPENDENCIES = sdl sdl_net sdl_mixer\n PRBOOM_LICENSE = GPL-2.0+\n PRBOOM_LICENSE_FILES = COPYING\n PRBOOM_AUTORECONF = YES\n+PRBOOM_FLAT_STACKSIZE=0x100000\n \n PRBOOM_CFLAGS = $(TARGET_CFLAGS)\n \n```\n\nbusybox vi calls openat with filename=NULL and crashes.\n\nThe kernel also requires `CONFIG_PAGE_OFFSET=0x00400000`, but for some reason that's hardcoded in Kconfig and needs a patch:\n\n```diff\ndiff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig\nindex ff1e353b0d6f..7c07151cfed2 100644\n--- a/arch/riscv/Kconfig\n+++ b/arch/riscv/Kconfig\n@@ -285,7 +285,7 @@ config MMU\n \n config PAGE_OFFSET\n        hex\n-       default 0x80000000 if !MMU \u0026\u0026 RISCV_M_MODE\n+       default 0x00400000 if !MMU \u0026\u0026 RISCV_M_MODE\n        default 0x80200000 if !MMU\n        default 0xc0000000 if 32BIT\n        default 0xff60000000000000 if 64BIT\n```\n\nThere is https://lkml.org/lkml/2024/10/26/482 pending which should fix this by making the kernel fully relocatable instead.\n\nFor framebuffer output (e.g. to use SDL), another patch is needed to allow mmap:\n\n```diff\ndiff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig\nindex ff1e353b0d6f..21a98c611605 100644\n--- a/arch/riscv/Kconfig\n+++ b/arch/riscv/Kconfig\n@@ -92,6 +92,7 @@ config RISCV\n        select EDAC_SUPPORT\n        select FRAME_POINTER if PERF_EVENTS || (FUNCTION_TRACER \u0026\u0026 !DYNAMIC_FTRACE)\n        select FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY if DYNAMIC_FTRACE\n+       select FB_PROVIDE_GET_FB_UNMAPPED_AREA if FB \u0026\u0026 !MMU\n        select GENERIC_ARCH_TOPOLOGY\n        select GENERIC_ATOMIC64 if !64BIT\n        select GENERIC_CLOCKEVENTS_BROADCAST if SMP\n```\n\nBuild the kernel:\n\n```\nmake -j8 ARCH=riscv CC=\"clang -target riscv32\" HOSTCC=clang HOSTCXX=clang++ LD=ld\n```\n\nLink or copy the resulting `arch/riscv/boot/Image` into the risky-v directory.\n\nRun `make` to generate resource files and build the main executable, then run `./main`.\n\nPress F11 to switch between framebuffer view (default) and console view. The latter shows the content of registers and the last line of the semihosting console.\n\nHow it works\n--\nTODO.\n\nLicense and External Resources\n--\n\nWhile the RISKY-V code is licensed under the [GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html), some files are from external projects and subject to their individual licenses:\n\nconsolefont.png: https://lucide.github.io/Font-Atlas-Generator/ Using Classic Console, 3072x18px, 256 cells per row, 12x18px cells, font size 14pt.\n\nglad.c/glad.h/khrplatform.h: Generated from https://glad.dav1d.de. gles2 3.1 with all available extensions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvogtinator%2Frisky-v","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvogtinator%2Frisky-v","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvogtinator%2Frisky-v/lists"}