Skip to content

Instantly share code, notes, and snippets.

@jdmichaud
Last active April 13, 2025 14:27
Show Gist options
  • Save jdmichaud/a87471709222713d9c6db7da258bc845 to your computer and use it in GitHub Desktop.
Save jdmichaud/a87471709222713d9c6db7da258bc845 to your computer and use it in GitHub Desktop.
Builroot and RISCV

// reference: https://popovicu.com/posts/789-kb-linux-without-mmu-riscv/

How to create a linux kernel that can run on a riscv32ima without an MMU.

  • Download buildroot
  • Untar it and start make menuconfig
  • In Target Options
    • Target Architecture select RISCV
    • In Target Architecture Size select 32
    • In Target ABI select ilp32
    • In Target Instruction Variant select Custom architecture
    • Disable:
      • Integer Multiplication and Division
      • Atomic Instructions
      • Single-precision Floating-point
      • Compressed Instructions (should be already disabled)
      • Vector Instructions (should be already disabled)
  • Target Binary Format should be set to FLAT
  • In Toolchain, in the Thread library implementation section select none (if your processor do not support atomic instruction)
  • In Kernel
    • select Linux Kernel
    • select Kernel configuration to Use the architecture default

Compile to basebone RISCV32:

export fn _start() u8 {
  return 42;
}
zig build-exe foo.zig -target riscv32-freestanding-ilp32 -OReleaseSmall
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment