Sped0n/zv6
A complete reimplementation of xv6 (RISC-V) in Zig.
A complete reimplementation of xv6 (RISC-V) in Zig.
The above video is at 10× speed.
build.zig
) for everything (kernel, userland, tools).forktest
, stressfs
, grind
and usertests
).All commands assume you are in the project root.
Build everything (mkfs, all user‐programs, fs.img, initcode, and the kernel):
zig build
To see all of the available build steps:
zig build --help
To rebuild the kernel (or any other single step) you can invoke it by name:
zig build mkfs # compile the mkfs tool
zig build user # compile all user programs
zig build image # regenerate fs.img (depends on mkfs + user)
zig build initcode # generate the initcode binary
zig build kernel # compile the kernel
If you just want to recompile the kernel & skip recreating your disk image:
zig build kernel -Dkeep-fsimg
Start QEMU, boot the kernel, mount fs.img
over virtio:
zig build qemu
You should see the xv6-ish boot output and land in the shell.
Launch QEMU suspended with a GDB stub on TCP port 3333:
zig build qemu-gdb
In another terminal, start your LLDB and connect:
$ lldb zig-out/kernel/kernel --local-lldbinit
(lldb) gdb-remote localhost:3333
(lldb) c
Run QEMU with instruction tracing enabled; output goes to qemu_debug.log
:
zig build qemu-trace
You can then inspect qemu_debug.log
for guest errors, instruction dumps, etc.