For this class you'll need the RISC-V versions of a couple different tools: QEMU 5.1+, GDB 8.3+, GCC, and Binutils.
First make sure you have the Windows Subsystem for Linux installed. Then add Ubuntu 20.04 from the Microsoft Store. Afterwards you should be able to launch Ubuntu and interact with the machine. To install all the software you need for this class, run:
$ sudo apt-get update && sudo apt-get upgrade $ sudo apt-get install git build-essential gdb-multiarch qemu-system-misc gcc-riscv64-linux-gnu binutils-riscv64-linux-gnu
From Windows, you can access all of your WSL files under the "\\wsl$\" directory. For instance, the home directory for an Ubuntu 20.04 installation should be at "\\wsl$\Ubuntu-20.04\home\<username>\".
First, install developer tools:
$ xcode-select --install
Next, install Homebrew, a package manager for macOS:
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Next, install the RISC-V compiler toolchain:
$ brew tap riscv/riscv $ brew install riscv-tools
The brew formula may not link into /usr/local. You will need to update your shell's rc file (e.g. ~/.bashrc) to add the appropriate directory to $PATH.
PATH=$PATH:/usr/local/opt/riscv-gnu-toolchain/bin
Finally, install QEMU:
brew install qemu
sudo apt-get install git build-essential gdb-multiarch qemu-system-misc gcc-riscv64-linux-gnu binutils-riscv64-linux-gnu
To test your installation, you should be able to compile and run xv6 (to quit qemu type Ctrl-a x):
# in the xv6 directory $ make qemu # ... lots of output ... init: starting sh $
If that doesn't work, you can double check individual components. Which include QEMU:
$ qemu-system-riscv64 --version QEMU emulator version 5.1.0
And at least one RISC-V version of GCC:
$ riscv64-linux-gnu-gcc --version riscv64-linux-gnu-gcc (Debian 10.3.0-8) 10.3.0 ...
$ riscv64-unknown-elf-gcc --version riscv64-unknown-elf-gcc (GCC) 10.1.0 ...
$ riscv64-unknown-linux-gnu-gcc --version riscv64-unknown-linux-gnu-gcc (GCC) 10.1.0 ...