- Baracco Thomas, s308722
- Masciari Luca, s317624
- Valeriano Carlos Gerardo, s308747
This guide provides step-by-step instructions for installing the Xv6 operating system on Ubuntu and MacOS (Silicon).
Before you begin, make sure you have the following prerequisites installed on your system:
-
First, clone the repository for the RISC-V GNU Compiler Toolchain:
git clone https://github.com/riscv/riscv-gnu-toolchain
-
Next, make sure you have the packages needed to compile the toolchain:
sudo apt-get install autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev python3 python3-pip ninja-build cmake libglib2.0-dev
-
Configure and build the toolchain:
$ cd riscv-gnu-toolchain $ ./configure --prefix=/usr/local $ sudo make $ cd ..
-
Download and install qemu
wget https://download.qemu.org/qemu-8.2.0.tar.xz tar xvJf qemu-8.2.0.tar.xz cd qemu-8.2.0 ./configure --disable-kvm --disable-werror --prefix=/usr/local --target-list="riscv64-softmmu" make sudo make install
-
Open a terminal
-
Install Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
-
Install XCode developer tools:
xcode-select --install
-
Install the RISC-V compiler toolchain with Homebrew (arch -arm64):
brew tap riscv/riscv; brew install riscv-tools
-
Install qemu:
brew install qemu
-
Add the following line in the .zshrc file:
export PATH="$PATH:/usr/local/opt/riscv-gnu-toolchain/bin"
-
Download the qemu-5.1.0 and unzip the downloaded .tar.xz file:
wget https://download.qemu.org/qemu-5.1.0.tar.xz
-
Two patches are needed:
-
PATCH 1 - Create a folder called 'patch' at the same level of the 'qemu-5.1.0' directory and download the .patch file (by clicking the 'mbox' button in the top-right corner of the page at the given link) inside that folder. Then run this from the qemu directory:
patch -p1 < ../patch/v2-tcg-Fix-execution-on-Apple-Silicon.patch
-
PATCH 2 - Find the file util/osdep.c in the 'qemu-5.1.0' directory and add the two lines as shown in the given link.
-
-
Then run configure with the following command from the qemu directory (some packages might be missing so just use brew to install them if that is the case):
./configure --disable-kvm --disable-werror --prefix=/usr/local --target-list="riscv64-softmmu"
-
And complete the installation with:
make; make install
-
Open a terminal.
-
Clone the Xv6 repository using Git:
git clone https://github.com/mit-pdos/xv6-riscv.git cd xv6-riscv
-
Build Xv6:
make
-
Run Xv6 using QEMU:
make qemu
This command will launch QEMU, and you should see the Xv6 shell.
To exit QEMU you can enter ctrl+a
and then x
.
To clean up the Xv6 build files, you can use:
make clean
Tutorial guides used to put together this documentation: