Skip to content

Commit 5b9c4c0

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents 9724491 + 538b044 commit 5b9c4c0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+833
-110
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@ os/src/link_app.S
66
os/last-*
77
tools
88
workplace/
9+
os2-ref/src/link_app.S
10+
os3-ref/src/link_app.S
11+
os4-ref/src/link_app.S
12+
os5-ref/src/link_app.S

Dockerfile

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# syntax=docker/dockerfile:1
2+
# This Dockerfile is adapted from https://github.com/LearningOS/rCore-Tutorial-v3/blob/main/Dockerfile
3+
# with the following major updates:
4+
# - ubuntu 18.04 -> 20.04
5+
# - qemu 5.0.0 -> 7.0.0
6+
# - Extensive comments linking to relevant documentation
7+
FROM ubuntu:20.04
8+
9+
ARG QEMU_VERSION=7.0.0
10+
ARG HOME=/root
11+
12+
# 0. Install general tools
13+
ARG DEBIAN_FRONTEND=noninteractive
14+
RUN apt-get update && \
15+
apt-get install -y \
16+
curl \
17+
git \
18+
python3 \
19+
wget
20+
21+
# 1. Set up QEMU RISC-V
22+
# - https://learningos.github.io/rust-based-os-comp2022/0setup-devel-env.html#qemu
23+
# - https://www.qemu.org/download/
24+
# - https://wiki.qemu.org/Documentation/Platforms/RISCV
25+
# - https://risc-v-getting-started-guide.readthedocs.io/en/latest/linux-qemu.html
26+
27+
# 1.1. Download source
28+
WORKDIR ${HOME}
29+
RUN wget https://download.qemu.org/qemu-${QEMU_VERSION}.tar.xz && \
30+
tar xvJf qemu-${QEMU_VERSION}.tar.xz
31+
32+
# 1.2. Install dependencies
33+
# - https://risc-v-getting-started-guide.readthedocs.io/en/latest/linux-qemu.html#prerequisites
34+
RUN apt-get install -y \
35+
autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev \
36+
gawk build-essential bison flex texinfo gperf libtool patchutils bc \
37+
zlib1g-dev libexpat-dev git \
38+
ninja-build pkg-config libglib2.0-dev libpixman-1-dev
39+
40+
# 1.3. Build and install from source
41+
WORKDIR ${HOME}/qemu-${QEMU_VERSION}
42+
RUN ./configure --target-list=riscv64-softmmu,riscv64-linux-user && \
43+
make -j$(nproc) && \
44+
make install
45+
46+
# 1.4. Clean up
47+
WORKDIR ${HOME}
48+
RUN rm -rf qemu-${QEMU_VERSION} qemu-${QEMU_VERSION}.tar.xz
49+
50+
# 1.5. Sanity checking
51+
RUN qemu-system-riscv64 --version && \
52+
qemu-riscv64 --version
53+
54+
# 2. Set up Rust
55+
# - https://learningos.github.io/rust-based-os-comp2022/0setup-devel-env.html#qemu
56+
# - https://www.rust-lang.org/tools/install
57+
# - https://github.com/rust-lang/docker-rust/blob/master/Dockerfile-debian.template
58+
59+
# 2.1. Install
60+
ENV RUSTUP_HOME=/usr/local/rustup \
61+
CARGO_HOME=/usr/local/cargo \
62+
PATH=/usr/local/cargo/bin:$PATH \
63+
RUST_VERSION=nightly
64+
RUN set -eux; \
65+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o rustup-init; \
66+
chmod +x rustup-init; \
67+
./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION; \
68+
rm rustup-init; \
69+
chmod -R a+w $RUSTUP_HOME $CARGO_HOME;
70+
71+
# 2.2. Sanity checking
72+
RUN rustup --version && \
73+
cargo --version && \
74+
rustc --version
75+
76+
# 3. Build env for labs
77+
# See os1/Makefile `env:` for example.
78+
# This avoids having to wait for these steps each time using a new container.
79+
RUN rustup target add riscv64gc-unknown-none-elf && \
80+
cargo install cargo-binutils --vers ~0.2 && \
81+
rustup component add rust-src && \
82+
rustup component add llvm-tools-preview
83+
84+
# Ready to go
85+
WORKDIR ${HOME}

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
DOCKER_NAME ?= dinghao188/rcore-tutorial
1+
DOCKER_NAME ?= rust-os-camp-2022
22
DIR := workplace
33
.PHONY: docker build_docker
44

@@ -63,7 +63,7 @@ clean:
6363
rm -rf ${DIR}
6464

6565
docker:
66-
docker run --rm -it --mount type=bind,source=$(shell pwd),destination=/mnt ${DOCKER_NAME}
66+
docker run --rm -it -v ${PWD}:/mnt -w /mnt ${DOCKER_NAME} bash
6767

6868
build_docker:
6969
docker build -t ${DOCKER_NAME} .

QA.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# 常见问题解答
2+
3+
## Q0:GitHub classroom是啥?如何使用?
4+
5+
### A:
6+
7+
- [B站的GitHub Classroom 视频介绍](https://www.bilibili.com/video/BV12L41147r7?spm_id_from=333.337.search-card.all.click&vd_source=8e19ee6e49f598fda8c17e306d8b3726)
8+
- [Youtube的GitHub Classroom视频介绍](https://www.youtube.com/playlist?list=PLIRjfNq867bewk3ZGV6Z7a16YDNRCpK3u)
9+
- [github文档:使用 GitHub Classroom 教学](https://docs.github.com/cn/education/manage-coursework-with-github-classroom/get-started-with-github-classroom)
10+
11+
## Q1:已经在classroom中建立了自己的仓库(例如 “LearningOS/lab0-0-setup-env-run-os1-chyyuu2022"),但是源仓库“LearningOS/rust-based-os-comp2022“更新了,如何处理?
12+
13+
### A:
14+
15+
**方法一:**
16+
17+
重新点击加入课程的链接,在页面下方会有一行字“We've configured the repository associated with this assignment (update)”,“update”是一个链接,点击update就可以把自己的仓库更新到与最新状态的repository template一致。
18+
19+
20+
**方法二:**
21+
22+
​ 在自己构建的仓库根目录下执行以下命令:
23+
24+
```makefile
25+
git remote add upstream "https://github.com/LearningOS/rust-based-os-comp2022.git"
26+
git fetch upstream
27+
git checkout -b foo
28+
git branch -D main
29+
git checkout -t upstream/main
30+
git reset --hard origin/main
31+
git push -f
32+
```
33+
34+
**方法三:**
35+
36+
向管理员“助教许善朴”申请删除已生成仓库,再点击 链接重新创建仓库。
37+
38+
## Q2:在classroom中建立了自己的仓库中,进行提交 `git push` 后,触发 CI后,出现 Annotations 错误“The job was not stared because recent account payments have failed or your spending limit needs to be increased. Please check the 'Billing & plans' section in your settings”,无法完成自动CI功能,比如 `Autograding` 等。
39+
40+
### A:
41+
42+
**方法一:**
43+
44+
这是由于对用户的私有仓库进行CI 相关的github action是需要付费的。用户可通过给自己的github账户充值来解决。https://docs.github.com/cn/billing/managing-billing-for-github-actions/about-billing-for-github-actions 给出了具体信息。
45+
46+
**方法二:**
47+
48+
对用户的公开仓库进行CI github action是不需要付费的。在项目的 `Settings` -> `Change visibility` 将项目改成Public, 重新触发Action。
49+
目前设置了让用户具有修改自己的项目从private --> public的能力。
50+
如果用户还是发现自己的权限不够,或看不到 `Settings` 这个选项,可以通过联系助教帮助来解决。
51+
52+
## Q3:我刚开始准备学习Rust,是Rust新手,我应该如何入门?
53+
54+
### A:
55+
56+
- [Rust 大佬给初学者的学习建议](https://github.com/rustlang-cn/Rustt/blob/main/Articles/%5B2022-04-02%5D%20Rust%20%E5%A4%A7%E4%BD%AC%E7%BB%99%E5%88%9D%E5%AD%A6%E8%80%85%E7%9A%84%E5%AD%A6%E4%B9%A0%E5%BB%BA%E8%AE%AE.md)
57+
- [张汉东:学习 Rust 你需要一个认知框架](https://zhuanlan.zhihu.com/p/494001676)
58+
- [Rust语言圣经(Rust Course)](https://course.rs/)
59+
- [Rust速查表(cheatsheet)](https://cheats.rs/) 该项目不仅提供了基础的语法速查,还有执行顺序详解和编写时需要关注的注意事项。项目还包含了示例代码(EX)、书籍(BK)、标准(STD)等相关资料的扩展。
60+
61+
## Q4:我不熟悉GitHub和Git,有啥快速入门的资源吗?
62+
63+
### A:
64+
65+
- [包括:从 0 开始学习 GitHub 系列1-7](https://jtxiao.com/main/categories/%E5%B7%A5%E5%85%B7/)
66+
- [超级简单的Git入门](https://backlog.com/git-tutorial/cn/)
67+
- [git - 简明指南](https://rogerdudler.github.io/git-guide/index.zh.html)
68+
- [中文git-tips](https://github.com/521xueweihan/git-tips)
69+
- [GitHub 官方制作的 Git 速查表](https://education.github.com/git-cheat-sheet-education.pdf)
70+
71+
## Q5:我不熟悉Linux的各种命令,有啥快速入门的资源吗?
72+
73+
### A:
74+
75+
- [中文Linux命令(linux-command)搜索引擎](https://wangchujiang.com/linux-command/):随用随搜Linux命令,而且还支持中文搜索
76+
- [新版 Linux 命令百科全书》(英文)](https://github.com/tldr-pages/tldr)
77+
78+
## Q6:我碰到一些命令/应用(比如vim, curl)、操作(比如vscode)或语言用法(比如Makefile)等不知到哪里能快速查找,怎么办?
79+
80+
### A:
81+
82+
- [Rico's cheatsheets](https://devhints.io/) 开源、全面的速查表网站,涵盖了前端、后端、运维、IDE 多个方面,而且界面友好简洁支持在线查看
83+
- [所有与命令行相关的cheatsheet](http://cheat.sh/):号称「你唯一需要的命令行相关速查表」

README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
1-
![Open in Codespaces](https://classroom.github.com/assets/open-in-codespaces-abfff4d4e15f9e1bd8274d9a39a0befe03a0632bb0f153d0ec72ff541cedbe34.svg)
21
# Open-Source OS Training Comp 2022
32

43
Welcome to Open-Source OS Training Comp 2022(2022年开源操作系统训练营).
54
## Scheduling
65
- NOTICE current [**SCHEDULING**](./scheduling.md)(2022年开源操作系统训练营的计划安排)!
6+
- [News](./news.md)(2022年开源操作系统训练营的新闻和纪要)
77
## History
88
- [open-source os training comp 2021](https://github.com/rcore-os/rCore/wiki/os-tutorial-summer-of-code-2021)
99
- [open-source os training comp 2020](https://github.com/rcore-os/rCore/wiki/os-tutorial-summer-of-code-2020)
10-
## Guide
10+
11+
## Guide & Lab Test for Rust
12+
- [learning rust guide](https://course.rs/)(Rust语言圣经)
13+
- [Rust-lang Lab Test based on Rustlings](https://classroom.github.com/a/YTNg1dEH)(采用Github Classroom模式的Rustling小练习)
14+
## Guide for OS
1115
- Guide deployed version can be found [here](https://learningos.github.io/rust-based-os-comp2022/)(精简OS实验指导)
1216
- [rCore Tutorial v3 Guide](https://rcore-os.github.io/rCore-Tutorial-Book-v3/) (2022春季OS课程讲义)
1317
- [OS Course Slides in 2022 spring](https://learningos.github.io/os-lectures/)(2022春季OS课程Slides)
1418
- [OS Course Videos in 2022 spring](./relatedinfo.md)(2022春季OS课程Videos)
15-
19+
- [OS API Docs in 2022 spring](./relatedinfo.md)(2022春季OS课程实验中 ``cargo doc`` 生成的各章参考OS的API文档)
20+
1621
First, you can read [Guide](https://learningos.github.io/rust-based-os-comp2022/) to:
1722
- (Important) `git clone` this repo.
1823
- (Important) setup development environment.
@@ -46,5 +51,8 @@ According to the [Guide](https://learningos.github.io/rust-based-os-comp2022/),
4651
- lab4: `make test6` && `make test7` for lab4
4752
- lab5: `make test8` for lab5
4853

49-
## Send issues
50-
If you meet any problems or some difficulties, please send issues to [Issues in rust-based-os-comp2022](https://github.com/LearningOS/rust-based-os-comp2022/issues)
54+
## QA &Send issues
55+
56+
There are some methods for common questions & problems, please read [QA](./QA.md).
57+
58+
If you meet any other new problems or some difficulties, please send issues to [Issues in rust-based-os-comp2022](https://github.com/LearningOS/rust-based-os-comp2022/issues)

ci-user/Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ else ifeq ($(CHAPTER), 8)
2020
endif
2121

2222
randomize:
23-
find user/src/bin -name "*.rs" | xargs sed -i 's/OK/OK$(RAND)/g'
24-
find user/src/bin -name "*.rs" | xargs sed -i 's/passed/passed$(RAND)/g'
25-
find check -name "*.py" | xargs sed -i 's/OK/OK$(RAND)/g'
26-
find check -name "*.py" | xargs sed -i 's/passed/passed$(RAND)/g'
23+
find user/src/bin -name "*.rs" | xargs perl -pi -e s,OK,OK$(RAND),g
24+
find user/src/bin -name "*.rs" | xargs perl -pi -e s,passed,passed$(RAND),g
25+
find check -name "*.py" | xargs perl -pi -e s,OK,OK$(RAND),g
26+
find check -name "*.py" | xargs perl -pi -e s,passed,passed$(RAND),g
2727

2828
test: randomize
2929
python3 overwrite.py $(CHAPTER)

guide/source/0setup-devel-env.rst

Lines changed: 69 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919

2020
目前,实验主要支持 Ubuntu18.04/20.04 操作系统。使用 Windows10 和 macOS 的读者,可以安装一台 Ubuntu18.04 虚拟机或 Docker
21-
进行实验。也可基于 **gihub classroom with codespaces** 进行开发。
21+
进行实验。也可基于 **github classroom with codespaces** 进行开发。
2222

2323

2424
Github Classroom方式进行在线OS 环境配置
@@ -49,16 +49,52 @@ Docker方式进行本地OS开发环境配置
4949

5050
**Docker 开发环境**
5151

52-
感谢 dinghao188 和张汉东老师帮忙配置好的 Docker 开发环境,进入 Docker 开发环境之后不需要任何软件工具链的安装和配置,可以直接将 tutorial 运行起来,目前应该仅支持将 tutorial 运行在 Qemu 模拟器上。
53-
54-
使用方法如下(以 Ubuntu18.04 为例):
55-
56-
1. 通过 ``su`` 切换到管理员账户 ``root`` ;
57-
2. 在 ``rCore-Tutorial`` 根目录下 ``make docker`` 进入到 Docker 环境;
58-
3. 进入 Docker 之后,会发现当前处于根目录 ``/`` ,我们通过 ``cd mnt`` 将当前工作路径切换到 ``/mnt`` 目录;
59-
4. 通过 ``ls`` 可以发现 ``/mnt`` 目录下的内容和 ``rCore-Tutorial-v3`` 目录下的内容完全相同,接下来就可以在这个环境下运行 tutorial 了。例如 ``cd os && make run`` 。
60-
61-
注:目前的Docker开发环境没有配置 Qemu-7.0.0 和下载 https://github.com/LearningOS/rust-based-os-comp2022.git 。所以还需要按照下面的步骤进行手动配置。
52+
53+
54+
使用方法如下(以 Ubuntu20.04 为例):
55+
56+
1. 以 ``lab0-0`` 为例,下载克隆本次的实验repo 或 https://github.com/LearningOS/rust-based-os-comp2022.git ; 在 ``lab0-0`` repo的根目录下,执行 ``make build_docker`` 来建立基于docker的开发环境;
57+
2. 在 ``lab0-0`` repo的根目录下执行 ``make docker`` 进入到 Docker 开发环境;
58+
3. 进入 Docker 之后,会发现当前处于根目录 ``/`` ,我们通过 ``cd os1`` 将当前工作路径切换到 ``lab0-0`` repo的根目录下;
59+
4. 接下来就可以在这个环境下进行实验了。例如 ``LOG=DEBUG make run`` 。
60+
61+
大致操作和输出如下:
62+
63+
.. code-block:: bash
64+
65+
$ make build_docker
66+
$ make docker
67+
docker$ cd os1
68+
docker$ LOG=DEBUG make run
69+
...
70+
[rustsbi] RustSBI version 0.2.2, adapting to RISC-V SBI v1.0.0
71+
.______ __ __ _______.___________. _______..______ __
72+
| _ \ | | | | / | | / || _ \ | |
73+
| |_) | | | | | | (----`---| |----`| (----`| |_) || |
74+
| / | | | | \ \ | | \ \ | _ < | |
75+
| |\ \----.| `--' |.----) | | | .----) | | |_) || |
76+
| _| `._____| \______/ |_______/ |__| |_______/ |______/ |__|
77+
[rustsbi] Implementation : RustSBI-QEMU Version 0.1.1
78+
[rustsbi] Platform Name : riscv-virtio,qemu
79+
[rustsbi] Platform SMP : 1
80+
[rustsbi] Platform Memory : 0x80000000..0x88000000
81+
[rustsbi] Boot HART : 0
82+
[rustsbi] Device Tree Region : 0x87000000..0x87000ef2
83+
[rustsbi] Firmware Address : 0x80000000
84+
[rustsbi] Supervisor Address : 0x80200000
85+
[rustsbi] pmp01: 0x00000000..0x80000000 (-wr)
86+
[rustsbi] pmp02: 0x80000000..0x80200000 (---)
87+
[rustsbi] pmp03: 0x80200000..0x88000000 (xwr)
88+
Hello, world!
89+
[DEBUG] .rodata [0x80203000, 0x80205000)
90+
[ INFO] .data [0x80205000, 0x80206000)
91+
[ WARN] boot_stack [0x80206000, 0x80216000)
92+
[ERROR] .bss [0x80216000, 0x80217000)
93+
94+
注:
95+
96+
- 感谢 qobilidop, dinghao188 和张汉东老师帮忙配置好的 Docker 开发环境,进入 Docker 开发环境之后不需要任何软件工具链的安装和配置,可以直接将 tutorial 运行起来,目前应该仅支持将 本次实验 运行在 Qemu-7.0.0 模拟器上。
97+
- 目前的Docker开发环境主要是建立好了实验用的开发环境,还没有设置国内crates源(可选) 、配置基于github classroom的自动测试环境等 。所以还需要参考上面或下面的步骤进行部分配置和部分安装。
6298
6399
64100
手动方式进行本地OS开发环境配置
@@ -104,8 +140,8 @@ Rust 开发环境配置
104140
105141
.. code-block:: bash
106142
107-
export RUSTUP_DIST_SERVER=https://mirrors.tuna.edu.cn/rustup
108-
export RUSTUP_UPDATE_ROOT=https://mirrors.tuna.edu.cn/rustup/rustup
143+
export RUSTUP_UPDATE_ROOT=https://mirrors.tuna.tsinghua.edu.cn/rustup/rustup
144+
export RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup
109145
curl https://sh.rustup.rs -sSf | sh
110146
111147
也可以设置科学上网代理:
@@ -222,12 +258,29 @@ Qemu 模拟器安装
222258
试运行 rCore-Tutorial
223259
------------------------------------------------------------
224260
261+
基于Github Classroom 模式
262+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
263+
225264
.. code-block:: bash
226265
227-
$ git clone https://github.com/LearningOS/rust-based-os-comp2022.git
228-
$ cd rust-based-os-comp2022
229-
$ make setupclassroom //注意:这一步很重要,是用于github classroom自动评测你的工作。这一步只需在首次克隆项目仓库时执行一次,以后一般就不用执行了,除非 .github/workflows/classroom.yml发生了变化。
266+
$ git clone ``Github-Classroom帮你生成的某个OS实验的仓库``
267+
$ cd ``刚克隆的本地某个OS实验的仓库``
268+
$ make setupclassroom_``实验编号`` //注意:这一步很重要,是用于github classroom自动评测你的工作。这一步只需在首次克隆项目仓库时执行一次,以后一般就不用执行了,除非 .github/workflows/classroom.yml发生了变化。实验编号是与某个实验匹配的编号
230269
270+
271+
.. note::
272+
273+
实验名称 :实验编号
274+
275+
- lab0-0 : test1
276+
- lab0-1:test2
277+
- lab1:test3
278+
- lab2:test4
279+
- lab3:test5
280+
- lab4:test6
281+
- lab5:test8
282+
283+
231284
我们先运行不需要处理用户代码的裸机操作系统 ``os1`` :
232285
233286
.. code-block:: bash

guide/source/chapter1/0intro.rst

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,21 @@
6161

6262
.. code-block:: console
6363
64-
$ git clone https://github.com/LearningOS/rust-based-os-comp2022.git
65-
$ cd rust-based-os-comp2022/
64+
$ git clone ``gitaddr of github-classroom-build-lab0-0``
65+
$ cd ``github-classroom-build-lab0-0``
6666
$ make setupclassroom_test1 //注意:这一步很重要,是用于github classroom自动评测你的工作。这一步只需在首次克隆项目仓库时执行一次,以后一般就不用执行了,除非 .github/workflows/classroom.yml发生了变化。
6767
68+
.. note::
6869

70+
实验名称 :实验编号
71+
72+
- lab0-0 : test1
73+
- lab0-1:test2
74+
- lab1:test3
75+
- lab2:test4
76+
- lab3:test5
77+
- lab4:test6
78+
- lab5:test8
6979

7080
运行本章代码,并设置日志级别为 ``TRACE``:
7181

0 commit comments

Comments
 (0)