Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
educg-net-28668-2608132
OSKernel2024-xv6-riscv-k210-3726
Commits
773e5985
Commit
773e5985
authored
6 months ago
by
root
Browse files
Options
Download
Patches
Plain Diff
MFQ提交
parent
6715102f
main
old_HUST
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+46
-121
README.md
README_cn.md
+0
-47
README_cn.md
with
46 additions
and
168 deletions
+46
-168
README.md
+
46
−
121
View file @
773e5985
# XV6-RISCV On K210
Run xv6-riscv on k210 board
[
English
](
./README.md
)
|
[
中文
](
./README_cn.md
)
```
(`-') (`-') <-.(`-')
(OO )_.-> _(OO ) __( OO)
(_| \_)--.,--.(_/,-.\ ,--. (`-') '-'. ,--. .----. .--. .----.
\ `.' / \ \ / (_/ / .' ( OO).-> | .' / \_,-. | /_ | / .. \
\ .') \ / / . / -. (,------. | /) .' .' | | | / \ .
.' \ _ \ /_)' .-. \ `------' | . ' .' /_ | | ' \ / '
/ .'. \ \-'\ / \ `-' / | |\ \ | | | | \ `' /
`--' '--' `-' `----' `--' '--' `------' `--' `---''
```

## Dependencies
+
`k210 board`
or
`qemu-system-riscv64`
+
RISC-V Toolchain:
[
riscv-gnu-toolchain
](
https://github.com/riscv/riscv-gnu-toolchain.git
)
## Installation
```
bash
git clone https://github.com/HUST-OS/xv6-k210
```
## Run on k210 board
First you need to connect your k210 board to your PC.
And check the
`USB serial port`
(In my situation it will be
`ttyUSB0`
):
```
bash
ls
/dev/ |
grep
USB
```
Build the kernel and user program:
```
bash
cd
xv6-k210
make build
```
Instead of the original file system, xv6-k210 runs with FAT32. You might need an SD card with FAT32 format.
Your SD card should NOT keep a partition table. To start
`shell`
and other user programs, you need to copy them into your SD card.
First, connect and mount your SD card (SD card reader required).
```
bash
ls
/dev/
# To check your SD device
mount <your SD device name> <mount point>
make sdcard
dst
=
"SD card mount point"
umount <mount point>
```
Then, insert the SD card to your k210 board and run:
```
bash
make run
```
Sometimes you should change the
`USB serial port`
:
```
bash
make run k210-serialport
=
`
Your-USB-port
`
(
default by ttyUSB0
)
```
Ps: Most of the k210-port in Linux is ttyUSB0, if you use Windows or Mac OS, this doc
may help you:
[
maixpy-doc
](
https://maixpy.sipeed.com/zh/get_started/env_install_driver.html#
)
## Run on qemu-system-riscv64
First, make sure
`qemu-system-riscv64`
is installed on your system.
Second, make a disk image file with FAT32 file system.
```
bash
make fs
```
It will generate a disk image file
`fs.img`
, and compile some user programs like
`shell`
then copy them into the
`fs.img`
.
As long as the
`fs.img`
exists, you don't need to do this every time before running, unless you want to update it.
Finally, start running.
```
bash
make run
platform
=
qemu
```
Ps: Press Ctrl + A then X to quit qemu.
## About shell
The shell commands are user programs, too. Those program should be put in a "/bin" directory in your SD card or the
`fs.img`
.
Now we support a few useful commands, such as
`cd`
,
`ls`
,
`cat`
and so on.
In addition,
`shell`
supports some shortcut keys as below:
-
Ctrl-H -- backspace
-
Ctrl-U -- kill a line
-
Ctrl-D -- end of file (EOF)
-
Ctrl-P -- print process list
## Add my programs on xv6-k210
1.
Make a new C source file in
`xv6-user/`
like
`myprog.c`
, and put your codes;
2.
You can include
`user.h`
to use the functions declared in it, such as
`open`
,
`gets`
and
`printf`
;
3.
Add a line "
`$U/_myprog\`" in `
Makefile
` as below:
`
``
Makefile
UPROGS=
\
$U/_init
\
$U/_sh
\
$U/_cat
\
...
$U/_myprog
\
# Don't ignore the leading '_'
```
4. Then make:
```
bash
make userprogs
```
Now you might see `_myprog` in `xv6-user/` if no error detected. Finally you need to copy it into your SD (see [here](#run-on-k210-board))
or FS image (see [here](#run-on-qemu-system-riscv64)).
## Progress
- [x] Multicore boot
- [x] Bare-metal printf
- [x] Memory alloc
- [x] Page Table
- [x] Timer interrupt
- [x] S mode extern interrupt
- [x] Receive uarths message
- [x] SD card driver
- [x] Process management
- [x] File system
- [x] User program
- [X] Steady keyboard input(k210)
## TODO
Fix the bugs of U-mode exception on k210.
## 基本情况
比赛方向 OS原理赛道-小型内核实现
队伍学校 合肥工业大学(宣城校区)
队伍ID T202419359994371
队伍名称 SOS队
队伍成员 邓梓剑 纪林圣 周文超
指导教师 田卫东 周红鹃
我们保留了原
`xv6-k210`
( https://github.com/HUST-OS/xv6-k210 )中的所有文档,由于我们队伍整体操作系统项目开发经验十分不足,因此打算在前辈的基础上进行一些操作系统内核代码编写的学习,其中文档部分将以2024为前缀进行区分,对于文档描述中冲突的部分,以新文档为准。
### [初赛阶段](doc/2024_初赛文档.md)
*
[
环境配置
](
doc/2024_环境配置.md
)
*
[
系统调用
](
doc/2024_系统调用.md
)
*
[
MFQ实现
](
doc/2024_MFQ实现.md
)
## 各阶段分工
### 初赛阶段
邓梓剑:环境配置、系统调用
纪林圣:多级反馈队列调度算法多级进程调度
周文超:
## 比赛收获
*
通过操作系统大赛,我们学习到了操作系统各功能实现的基本流程,并且真实地运行了一个小型的操作系统内核
*
为我们之后在系统领域深造打下了深厚的基础
**纪林圣:**
通过此次多级反馈队列算法的实现,我理解了操作系统调度的核心原理,并且也掌握了如何通过时间片和优先级动态调整进程的执行顺序。在设计之初,自己对MFQ的原理比较熟悉,但是如何根据xv6-k210代码结构实现基于此架构的MFQ,成为了一大难题,在逐步学习和实践的过程中感受到了操作系统设计的魅力,我也切实提升了自己的理解和能力。
此外,多核环境下的调度也让我印象深刻。在调试过程中,我曾因为未正确处理多核同步而导致队列状态出现错误。通过加锁机制和严格的队列操作规范,我解决了这些问题,并对多核系统中的数据一致性有了更加直观的认识。这是我从理论到实践的一次重要突破。尽管如此,由于时间仓促,代码中一定会存在许多不完善,对于复杂的调度算法,除了功能的完整性,还需要考虑更多的异常处理、边界条件和并发同步问题。
## 致谢
感谢 https://github.com/HUST-OS/xv6-k210
[
README_cn.md
](
README_cn.md
)
以及 rCore ( https://rcore-os.cn/rCore-Tutorial-Book-v3/index.html )
This diff is collapsed.
Click to expand it.
README_cn.md
+
0
−
47
View file @
773e5985
## 基本情况
比赛方向 OS原理赛道-小型内核实现
队伍学校 合肥工业大学(宣城校区)
队伍ID T202419359994371
队伍名称 SOS队
队伍成员 邓梓剑 纪林圣 周文超
指导教师 田卫东 周红鹃
我们保留了原
`xv6-k210`
( https://github.com/HUST-OS/xv6-k210 )中的所有文档,由于我们队伍整体操作系统项目开发经验十分不足,因此打算在前辈的基础上进行一些操作系统内核代码编写的学习,其中文档部分将以2024为前缀进行区分,对于文档描述中冲突的部分,以新文档为准。
### [初赛阶段](doc/2024_初赛文档.md)
*
[
环境配置
](
doc/2024_环境配置.md
)
*
[
系统调用
](
doc/2024_系统调用.md
)
*
[
MFQ实现
](
doc/2024_MFQ实现.md
)
## 各阶段分工
### 初赛阶段
邓梓剑:环境配置、系统调用
纪林圣:多级反馈队列调度算法多级进程调度
周文超:
## 比赛收获
*
通过操作系统大赛,我们学习到了操作系统各功能实现的基本流程,并且真实地运行了一个小型的操作系统内核
*
为我们之后在系统领域深造打下了深厚的基础
**纪林圣:**
通过此次多级反馈队列算法的实现,我理解了操作系统调度的核心原理,并且也掌握了如何通过时间片和优先级动态调整进程的执行顺序。在设计之初,自己对MFQ的原理比较熟悉,但是如何根据xv6-k210代码结构实现基于此架构的MFQ,成为了一大难题,在逐步学习和实践的过程中感受到了操作系统设计的魅力,我也切实提升了自己的理解和能力。
此外,多核环境下的调度也让我印象深刻。在调试过程中,我曾因为未正确处理多核同步而导致队列状态出现错误。通过加锁机制和严格的队列操作规范,我解决了这些问题,并对多核系统中的数据一致性有了更加直观的认识。这是我从理论到实践的一次重要突破。尽管如此,由于时间仓促,代码中一定会存在许多不完善,对于复杂的调度算法,除了功能的完整性,还需要考虑更多的异常处理、边界条件和并发同步问题。
## 致谢
感谢 https://github.com/HUST-OS/xv6-k210
[
README_cn.md
](
README_cn.md
)
以及 rCore ( https://rcore-os.cn/rCore-Tutorial-Book-v3/index.html )
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets