MIT6.828 Fall2018 笔记 - Lab 0: 介绍以及环境配置

预备知识:C语言、汇编语言、计算机组成原理、操作系统

这个学期开始上操作系统课,于是就来试试 MIT 6.828 的实验,建议按照 schedule 安排的顺序学习。

感觉比我学校的实验难很多,需要查找并阅读许多文档资料(我的实验记录里有许多参考资料链接可以看看)才能顺利完成这些实验。

官方提供的资料:

  • Xv6
    • xv6 printout xv6源码打印出的pdf,没啥好看的
    • xv6 book 实验过程中遇到不会的不妨看看这本书,比如这本书的附录B中就对boot loader的代码有详细的解释。
  • 阅读材料

Tools Used in 6.828

Tools Used in 6.828

  • an x86 emulator, QEMU, for running your kernel
  • compiler toolchain, including assembler, linker, C compiler, and debugger, for compiling and testing your kernel.

环境配置 Manjaro WSL2

这里提供三种环境配置:

  1. Manjaro
  2. Debian
  3. Ubuntu

每一种都可以使用虚拟机、WSL(Windows Subsystem for Linux)、WSL2。其中由于Ubuntu提供的qemu版本较低,调试功能不是很成熟,需要自己编译MIT提供的版本,比较麻烦。Debian则需要添加测试版软件源。

我使用的是 Manjaro WSL2。具体安装方法见我写的另一篇文章 Manjaro WSL2 配置记录(也适用于WSL1)。只需要完成1. 安装 WSL 之前的配置2. 基本安装4. 安装 xfce4 桌面并启用 X Server 图形环境这三个部分。

然后再安装我们需要的工具链:

sudo pacman -S --needed binutils gcc gdb make git qemu-arch-extra

如果想要使用 Debian 或 Ubuntu,请看下文:

其他可选环境配置

Debian

设置软件源

sudo nano /etc/apt/sources.list

将原先的内容全部删除,添加以下内容:

# stable
deb http://mirrors.ustc.edu.cn/debian stable main contrib non-free
deb http://mirrors.ustc.edu.cn/debian stable-updates main contrib non-free

# testing
deb http://mirrors.ustc.edu.cn/debian testing main contrib non-free
deb http://mirrors.ustc.edu.cn/debian testing-updates main contrib non-free

将stable软件源设置为默认:

sudo touch /etc/apt/apt.conf.d/my-default-release
sudo nano /etc/apt/apt.conf.d/my-default-release

添加以下内容:

APT::Default-Release "stable";

安装编译工具链等

使用以下命令进行安装:

sudo apt update
sudo apt install git build-essential gdb-multiarch gcc-riscv64-linux-gnu binutils-riscv64-linux-gnu qemu-system-misc/testing

Ubuntu

设置软件源

sudo nano /etc/apt/sources.list

更换为以下内容

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse

然后进行更新

sudo apt update
sudo apt upgrade

安装编译工具链

# 安装编译工具
sudo apt install -y build-essential gdb
# 安装 32-bit 库
sudo apt install gcc-multilib

编译 QEMU

ubuntu提供的qemu版本较低,调试功能不是很成熟,需要自己编译MIT提供的版本
6.828-qemu

sudo apt install libpixman-1-dev pkg-config zlib1g-dev libglib2.0-dev python

# 文件有点大,建议去github下载压缩包,
git clone https://github.com/mit-pdos/6.828-qemu.git qemu
cd qemu
./configure --disable-kvm --target-list="i386-softmmu x86_64-softmmu"

这一步可能会报错。解决办法见MIT-6.828-JOS-环境搭建

若成功会输出一堆东西:

Disabling libtool due to broken toolchain support
Install prefix    /usr/local
BIOS directory    /usr/local/share/qemu
...--省略--...

之后开始编译

sudo make && sudo make install

测试一下是否成功

qemu-system-i386 --version
QEMU emulator version 2.3.0, Copyright (c) 2003-2008 Fabrice Bellard
posted @ 2020-03-04 23:20  hyuuko  阅读(1237)  评论(0编辑  收藏  举报