两行命令完成 xv6 环境搭建
xv6环境需要riscv工具链以及qemu等环境,从源码编译不仅慢而且容易遇到各种问题,非常麻烦,在Ubuntu 20.04上可以按如下方式完成
$ apt-get install git build-essential gdb-multiarch
$ apt-get install qemu-system-misc gcc-riscv64-linux-gnu binutils-riscv64-linux-gnu
下载源码
$ git clone https://gitlab.cs.washington.edu/csep551/xv6-19au.git
$ cd xv6-19au
$ make
$ make qemu
...
mkfs/mkfs fs.img README user/xargstest.sh user/_cat user/_echo user/_forktest user/_grep user/_init user/_kill user/_ln user/_ls user/_mkdir user/_rm user/_sh user/_stressfs user/_usertests user/_wc user/_zombie user/_cow user/_uthread user/_call user/_kalloctest user/_bcachetest user/_mounttest user/_crashtest
nmeta 46 (boot, super, log blocks 30 inode blocks 13, bitmap blocks 1) blocks 954 total 1000
balloc: first 675 blocks have been allocated
balloc: write bitmap block at sector 45
qemu-system-riscv64 -machine virt -bios none -kernel kernel/kernel -m 3G -smp 3 -nographic -drive file=fs.img,if=none,format=raw,id=x0 -device virtio-blk-device,drive=x0,bus=virtio-mmio-bus.0
xv6 kernel is booting
virtio disk init 0
hart 2 starting
hart 1 starting
init: starting sh
$
这样直接就跑起来了!
References
[1]https://courses.cs.washington.edu/courses/csep551/19au/labs/util.html