There're three parts:
- riscv-gnu-toolchain installation
- qemu installation
- build xv6-riscv
Part1: riscv-gnu-toolchain installation
Env: macOS Catalina
10.15.7
Step1:
git clone --recursive https://github.com/riscv/riscv-gnu-toolchain
Although it doesn't need
--recursive
in README, this issue still happened on mac.
Step2:
brew install python3 gawk gnu-sed gmp mpfr libmpc isl zlib expat
Step3:
cd riscv-gnu-toolchain
./configure --prefix=/opt/riscv --enable-multilib
To build either cross-compiler with support for both 32-bit and 64-bit
Step4: find your .zshrc
, append this line
export PATH="$PATH:/opt/riscv/bin"
and then
source .zshrc
Part2: qemu installation
After installing riscv-gnu-toolchain, I chose to building qemu for macOS first and installed qemu.
Step 1: install prerequisites
brew install libffi gettext glib pkg-config autoconf automake pixman ninja
Step2: pull the source of qemu
curl -L https://download.qemu.org/qemu-5.2.0.tar.xz > qemu-5.2.0.tar.xz
Step3: unzip
tar xf qemu-5.2.0.tar.xz
Step4: build and install qemu
cd qemu-5.2.0
and
mkdir build && cd build
../confgiure`
make
make install
Part3: build xv6-riscv
After installing
qemu
sucessfully, let's start to build xv6-riscv
Step1: Pull the source of xv6-riscv
git clone git://github.com/mit-pdos/xv6-riscv-fall19.git
Step2:
cd xv6-riscv-fall19
and
make
make qemu
That's it!
Thanks for your reading~
Top comments (2)
Here is a RISC-V "Hello World" example
Step 1: write
rv-hello.s
Step2: assemble rv-hello.s and link
Step3: run the program
// Hello World!
Exit qemu :
Ctrl + a
thenx