Tools

对于这个课程,你需要一些Risc-V版本的工具:QEMU 5.1, GDB 8.3, GCC, Binutils.

通过APT安装(Debian/Ubuntu)

确保你运行的debian版本是bullseyesidubuntu能够通过运行cat /etc/debian_version来检查),然后执行:

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

修复qemu-system-misc

qemu-system-misc似乎更新后,破坏我们的内核的兼容性。如果我们运行make qemu后,系统hand了,你需要去卸载它,然后安装旧版本。

$ sudo apt-get remove qemu-system-misc
$ sudo apt-get install qemu-system-misc=1:4.2-3ubuntu6

其它Linux发行版(如:编译工具链)

我们是假设安装工具链到/usr/local,你编译工具链时需要有一些磁盘空间(大概9GiB)

首先,克隆RISC-V GNU Compiler工具链仓库

$ git clone --recursive https://github.com/riscv/riscv-gnu-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

配置和编译工具链

$ cd riscv-gnu-toolchain
$ ./configure --prefix=/usr/local
$ sudo make
$ cd ..

接着,解压缩QEMU 5.1.0源码

编译riscv64-softmmuQEMU

测试

进行测试你的安装是否成功,你运行如下命令并检查

你也能够编译与运行xv6

Ctrl-a x执行退出操作

Last updated