educational Unix-like OS. Tools for building and running xv6 under QEMU

educational Unix-like OS. Tools for building and running xv6 under QEMU

This manual is a supplement to the xv6 tutorial book.

Xv6 runs on RISC-V. Compiling xv6 code and running it under QEMU will require RISC-V versions of the tools: QEMU 5.1+, GDB 8.3+, GCC, and Binutils.

Debian and Ubuntu

sudo apt-get install git build-essential gdb-multiarch qemu-system-misc gcc-riscv64-linux-gnu binutils-riscv64-linux-gnu

Arch Linux

sudo pacman -S riscv64-linux-gnu-binutils riscv64-linux-gnu-gcc riscv64-linux-gnu-gdb qemu-emulators-full

Installation under Windows

We recommend get rid of Windows install Linux or use WSL2 – Windows Subsystem for Linux 2.

Use Windows Terminal instead of Powershell/Command Prompt.

Make sure you are using WSL2. WSL1 is arranged differently, which leads to problems when running labs. Command wsl -l -v in the terminal and make sure you have WSL2 running and the appropriate version of Ubuntu.

Install

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

You will find the WSL files in the directory "\\wsl$\". Example: Ubuntu 20.04 user’s home directory is available as "\\wsl$\Ubuntu-20.04\home\<username>\".

Starting a Linux virtual machine

Linux also works under a virtual machine. Choose a platform:

VirtualBox is slower and offers less customization, but it’s free.

Download an OS installation disc, such as Ubuntu Desktop for a 64-bit machine. Create a 64-bit virtual machine, install the OS from disk, and run.

Installation on macOS

Developer toolkit:

xcode-select --install

Homebrew Package Manager:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Tools for assembly under RISC-V:

brew tap riscv/riscv
brew install riscv-tools

Add the path to the compiler $PATH:

PATH=$PATH:/usr/local/opt/riscv-gnu-toolchain/bin

Install QEMU:

brew install qemu

Checking the work

You can now build and run xv6 as described in the first lab:

cd xv6-riscv/
make qemu

Make sure the appropriate version of QEMU is installed:

$ qemu-system-riscv64 --version
QEMU emulator version 5.1.0

and one of the RISC-V versions of the GCC compiler:

$ 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
...

Related posts