环境:
Ubuntu 20.04 LTS
一开始没啥好说的,按照官方的文档
https://github.com/mit-pdos/xv6-public
https://pdos.csail.mit.edu/6.828/2020/tools.html
执行
sudo apt-get install git build-essential gdb-multiarch qemu-system-misc gcc-riscv64-linux-gnu binutils-riscv64-linux-gnu
cd 到Xv6的文件夹后
make qemu
报错:
***
*** Error: Couldn't find a working QEMU executable.
*** Is the directory containing the qemu binary in your PATH
*** or have you tried setting the QEMU variable in Makefile?
***
serial mon:stdio -drive file=fs.img,index=1,media=disk,format=raw -drive file=xv6.img,index=0,media=disk,format=raw -smp 2 -m 512
make: serial: Command not found
make: [Makefile:225: qemu] Error 127 (ignored)
定位到qemu
删除line54 的注释
# If the makefile can't find QEMU, specify its path here
QEMU = qemu-system-i386
并且安装qemu-system-i386
sudo apt-get install qemu-system-x86
之后报了新的错误
qemu-system-i386 -serial mon:stdio -drive file=fs.img,index=1,media=disk,format=raw -drive file=xv6.img,index=0,media=disk,format=raw -smp 2 -m 512
Unable to init server: Could not connect: Connection refused
gtk initialization failed
make: *** [Makefile:225: qemu] Error 1
根据报错提示定位到line 225后,新增-nographic
$(QEMU) -nographic -serial mon:stdio $(QEMUOPTS)
再次执行make qemu即可