Skip to content

Instantly share code, notes, and snippets.

@tingwei628
Last active June 7, 2021 10:55
Show Gist options
  • Save tingwei628/863cc12c6c4ed0487d8892c528ca84b5 to your computer and use it in GitHub Desktop.
Save tingwei628/863cc12c6c4ed0487d8892c528ca84b5 to your computer and use it in GitHub Desktop.
Risc-V toolchain installation on mac

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 directory and ./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

DONE !!

@tingwei628
Copy link
Author

After installing riscv-gnu-toolchain, I chose to building qemu for macOS first and installed qemu.

Step 1: brew install libffi gettext glib pkg-config autoconf automake pixman ninja
Explained

Step2: curl -L https://download.qemu.org/qemu-5.2.0.tar.xz > qemu-5.2.0.tar.xz
(why qemu 5.2.0)

Step3: tar xf qemu-5.2.0.tar.xz

Step4: cd qemu-5.2.0 and mkdir build && cd build

Step5: ../confgiure

Step6: make and make install

DONE!

@tingwei628
Copy link
Author

After installing qemu sucessfully, let's start to build xv6-riscv

Step1: git clone git://github.com/mit-pdos/xv6-riscv-fall19.git
The xv6-riscv-fall19 repository differs slightly from the book's xv6-riscv in order to make the labs easier.

Step2: cd xv6-riscv-fall19 and make

Step3: make qemu

DONE !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment