Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Show HN: Porting xv6 to HiFive Unmatched board (github.com/eyengin)
26 points by eyengin 17 days ago | hide | past | favorite | 4 comments
Hi HN,

I ported the teaching OS xv6-riscv to HiFive Unmatched and got it running on real hardware, including passing usertests.

I've been self-studying OS internals using the MIT 6.1810 materials. After finishing most of the labs, I was eager to see what it's like to run the OS on bare metal, rather than QEMU.

The Unmatched may not have the latest RISC-V features, but it's well-documented, and the Rev B release has made it more affordable, which makes it a good learning platform.

The porting process involved several interesting challenges:

- Hardware Quirks: Handling things like enabling A/D bits in PTEs (the hardware doesn't set them automatically, causing page faults), proper handling of interrupts, and instruction cache synchronization.

- Boot Flow: xv6 expects M-mode on startup, but standard RISC-V boot flows (typically via OpenSBI) jump to S-mode. To bridge this gap, I created a minimal U-Boot FIT image that contains only the xv6 kernel. This way, U-Boot SPL handles the complex CPU/DDR initialization, then hands control to xv6 in M-mode (skipping OpenSBI).

- Drivers: Ported an SPI SD card driver, replacing the virtio disk driver.

I wrote up implementation notes here: https://github.com/eyengin/xv6-riscv-unmatched/blob/unmatche...

Hopefully, this is useful for others who are learning OS internals and want to try running their code on real RISC-V hardware.



Thanks for the nice work.. I plan to do something similar for Vexriscv


Thanks! Working with VexRiscv sounds like fun. Looking forward to seeing how it goes.


I'm more interested in the animated svg. That's cool


Thanks! It's asciinema + svg-term-cli:

    asciinema rec -c "tio /dev/ttyUSB1 -b 115200" uart_output.cast
    cat uart_output.cast | svg-term --window > example.svg




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: