Xv6学习(一)Install xv6 (operating system) in linux

xv6简介

Xv6 is a teaching operating system developed in the summer of 2006 for MIT’s operating systems course, 6.828: operating systems Engineering.

下载代码

从官网提供的Git上下载代码

git clone git://pdos.csail.mit.edu/xv6/xv6.git

如果上面的链接下载失败的话可以试试下面的链接

git clone https://github.com/panks/Xv6.git

修改权限

chmod 700 -R Xv6

安装相关库

sudo apt-get install libc6-dev:i386
cd Xv6
make

错误解决

make过程中我遇到如下错误提示

gcc -Werror -Wall -o mkfs mkfs.c

mkfs.c:14:0: error: “static_assert” redefined [-Werror]

#define static_assert(a, b) do { switch (0) case 0: case (a): ; } while (0)

^
In file included from mkfs.c:6:0:

/usr/include/assert.h:120:0: note: this is the location of the previous definition

#define static_assert _Static_assert

^

cc1: all warnings being treated as errors

Makefile:149: recipe for target ‘mkfs’ failed

make: *** [mkfs] Error 1

原因是static_assert这个宏重复定义了,打开mkfs.c文件,将下面这行注销掉就可以了。

#define static_assert(a, b) do { switch (0) case 0: case (a): ; } while (0)

重新make,make通过。

在MakeFile中可以看到有如下编译选项:

qemu: fs.img xv6.img
$(QEMU) -serial mon:stdio $(QEMUOPTS)

qemu-memfs: xv6memfs.img
$(QEMU) xv6memfs.img -smp $(CPUS)

qemu-nox: fs.img xv6.img
$(QEMU) -nographic $(QEMUOPTS)

.gdbinit: .gdbinit.tmpl
sed “s/localhost:1234/localhost:$(GDBPORT)/” < $^ > $@

qemu-gdb: fs.img xv6.img .gdbinit
@echo “*** Now run ‘gdb’.” 1>&2
$(QEMU) -serial mon:stdio $(QEMUOPTS) -S $(QEMUGDB)

qemu-nox-gdb: fs.img xv6.img .gdbinit
@echo “*** Now run ‘gdb’.” 1>&2
$(QEMU) -nographic $(QEMUOPTS) -S $(QEMUGDB)

输入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?

这是因为在make(编译)的时候变量QEMu没有指定

安装qemu

sudo apt-get install qemu

修改MakeFile,手动指定QEMU的位置
找到

# If the makefile can't find QEMU, specify its path here
#QEMU =

修改为

# If the makefile can't find QEMU, specify its path here
QEMU = qemu-system-i386

重新make qemu,程序可成功运行
image

参考链接

Xv6, a simple Unix-like teaching operating system

xv6 install YouTube 视频教程

xv6 + Qemu 在Ubuntu下编译运行教程

Xv6下载 编译 运行

发表评论

电子邮件地址不会被公开。 必填项已用*标注

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax

This site uses Akismet to reduce spam. Learn how your comment data is processed.