Setup xv6-riscv Development Environment

This article introduces how to set up the development environment of xv6-riscv.

Introduction

xv6 is a re-implementation of Dennis Ritchie’s and Ken Thompson’s Unix Version 6 (v6). The main purpose of xv6 is as a teaching operating system for MIT’s 6.1810[1].

Environment

The system environment I use:

  • Ubuntu 24.04.1 LTS

Installation

We need to install related cross-compilation tools, as well as QEMU to simulate the RISC-V chip. The following commands are modified from mmikaitis/xv6-tools-container/xv6-tools-container.def[2]

1
2
sudo apt update
sudo apt install -y build-essential gcc-riscv64-linux-gnu qemu-system-riscv64 gdb-multiarch

Download xv6-riscv

1
2
git clone git@github.com:mit-pdos/xv6-riscv.git
cd xv6-riscv

Compile and Run

1
2
make
make qemu

Now you can see the following output, which means the compilation and running are successful:

1
2
3
4
5
6
xv6 kernel is booting

hart 2 starting
hart 1 starting
init: starting sh
$

To exit QEMU, you can press Ctrl + A, then press X.

QEMU No Response After Startup

I encountered the problem of no response after starting make qemu when setting up the environment. Finally, I found this issue. The solution provided by the related PR works. After my attempt, I can also update the system and QEMU to the latest version. I finally used Ubuntu 24.04.1 LTS and QEMU emulator version 8.2.2 (Debian 1:8.2.2+ds-0ubuntu1.2).

IDE Remote Connection

The project is located on a remote Linux server. If we want to develop using a powerful IDE locally instead of using vim and other text editors on the server, we can use Clion to connect to the server via SSH for development.

Create SSH Connectio in Clion

Select Project Path and IDE Version

After the remote connection is established, you can develop as if you were working on a local project. Run make qemu in the terminal to run xv6-riscv.

IDE Interface

References

  1. xv6-riscv. Archived on 2024-07-23. Retrieved 2024-10-15.
  2. xv6-tools-container.def. Retrieved 2024-10-15.
  3. 【99%环境搭建系列】xv6-riscv内核调试教程. Retrieved 2024-10-15.

Setup xv6-riscv Development Environment
https://blog.zhanganzhi.com/en/2024/10/4ffcfc636790/
Author
Andy Zhang
Posted on
October 15, 2024
Licensed under