Skip to content

dkaszews/riscv-xmake-samples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RISC-V bare metal assembly with xmake

Small "Hello World" echo program, written in bare metal (no BIOS) RISC-V machine mode assembly for use with the QEMU virt device. Provided as a reference for getting started with RISC-V assembly.

Features

  • UART input and output, works with UTF-8 (backspace and ANSI escapes passthrough)
  • Supports both 32 and 64bit via helper macros and conditional compilation, no C preprocessor required
  • Clean exit from QEMU with return code indicating success or failure (on checked overflow)
  • Instructions for debugging with GDB

Usage

  1. Install xmake, gcc-riscv64-unknown-elf toolchain
  2. xmake build hello
  3. xmake run hello
  4. To debug, run xmake run gdb hello in one terminal and xmake run attach hello in another
    • Optionally, install gdb-multiarch to get register ABI names instead of canonical ones
  5. Switch between configurations with xmake config --arch=rv32g and --arch=rv64g

References

  1. noteed/riscv-hello-asm - toolchain, harts
  2. Benjamin-Davies/spark-minimal-uart - UART I/O with status registers
  3. rust-embedded/qemu-exit - clean exit from QEMU
  4. QEMU GDB usage - attaching debugger

About

Sample code using RISC-V bare-metal assembly and xmake build system

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published