Before starting, ensure you have:
- Git installed
- A Unix-like environment (Linux, macOS, or WSL for Windows)
- At least 1GB of free disk space
- Internet connection
sudo apt-get update
sudo apt-get install git build-essential gdb-multiarch qemu-system-misc gcc-riscv64-linux-gnu binutils-riscv64-linux-gnu
brew tap riscv/riscv
brew install riscv-tools
brew install qemu
-
Clone the Repository
git clone git://g.csail.mit.edu/xv6-labs-2020 cd xv6-labs-2020
-
Switch to the Initial Lab Branch (util)
git checkout util
-
Test the Installation
make qemu
This command will:
- Compile the xv6 operating system
- Start QEMU emulator
- Boot xv6
If successful, you should see the xv6 boot sequence and a prompt that looks like this:
xv6 kernel is booting hart 1 starting hart 2 starting init: starting sh $
-
Exit QEMU
- Press
Ctrl-a
thenx
to exit QEMU
- Press
console 3 21 0
$ QEMU: Terminated
(base) ➜ xv6-labs-2020 git:(util) ✗
-
Using GDB for Debugging In one terminal:
make qemu-gdb
In another terminal:
gdb kernel/kernel
-
Useful Make Commands
make clean # Clean build files make # Build xv6 make qemu # Run xv6 in QEMU make grade # Test your implementation (when working on labs)
-
File Organization
kernel/
: Kernel source filesuser/
: User programsMakefile
: Build configuration
-
Each lab has its own branch. To switch to a different lab:
git fetch git checkout [lab-name]
-
Common lab branches:
- util
- syscall
- pgtbl
- traps
- lazy
- cow
- thread
- lock
- fs
- mmap
-
Before starting each lab, make sure to:
git checkout [lab-name] make clean
- Make your changes in the appropriate files
- Test your implementation:
make grade
- Commit your changes:
git add [modified-files] git commit -m "Descriptive message about changes"