Skip to content

Latest commit

ย 

History

History
73 lines (53 loc) ยท 1.69 KB

File metadata and controls

73 lines (53 loc) ยท 1.69 KB

rust-on-riscv-starter-kit ๐Ÿฆ€๐Ÿš€

A minimal bare-metal Rust "Hello, RISC-V" starter project.

This project runs on the 32-bit RISC-V virt machine in QEMU and prints Hello, RISC-V! to the UART console. No std, no external crates, no magic - just you, Rust, and the hardware.

๐Ÿ›  Requirements

  • Rust toolchain (rustup) with the RISC-V target:
    rustup target add riscv32imac-unknown-none-elf
    
  • QEMU with RISC-V support:
    sudo apt install qemu-system-misc
    

โ–ถ๏ธ Running the Code

  1. Clone the repository:

    git clone https://github.com/ddrcode/rust-on-riscv-starter-kit
    cd rust-on-riscv-starter-kit
    
  2. Build the binary:

    cargo build --release
    
  3. Run it in QEMU:

    qemu-system-riscv32 -machine virt -nographic -bios none -kernel target/riscv32imac-unknown-none-elf/release/hello-riscv
    

You should see:

Hello, RISC-V!

๐Ÿง  Whatโ€™s Inside

  • #![no_std], #![no_main]
  • Direct MMIO write to UART
  • Custom panic handler
  • Manual linker script (linker.ld)
  • No runtime, no external dependencies

๐Ÿ“š Why This Exists

To give you a clean and minimal starting point for:

  • Learning how Rust works without an OS
  • Exploring RISC-V memory-mapped I/O
  • Building your own microkernel or embedded project

๐Ÿ”’ Safety Note

This project uses unsafe โ€” but in a minimal, contained way to talk to hardware. The goal is to show how Rust can own bare-metal safely, step by step.

๐Ÿงฉ Next Ideas

Want to go further? Try:

  • Moving to user mode + ecall
  • Adding interrupt handling
  • Printing from panic info
  • Porting to a real RISC-V board

Made with โค๏ธ and panic() by @ddrcode