fixed issues I47WMN, I477IX,I441IC

This commit is contained in:
Wang Chen
2021-09-06 10:30:57 +08:00
parent 09ea96ffed
commit d9f5e22e99
24 changed files with 256 additions and 247 deletions

View File

@@ -2,13 +2,13 @@
<!-- TOC -->
- [Introduction](#introduction)
- [Operating environment](#operating-environment)
- [Construction and usage](#construction-and-usage)
- [References](#references)
- [1. Introduction](#1-introduction)
- [2. Operating environment](#2-operating-environment)
- [3. Building and usage](#3-building-and-usage)
- [4. References](#4-references)
<!-- /TOC -->
# Introduction
# 1. Introduction
This course is used to teach and demonstrate how to write a simple operating system kernel for the RISC-V platform from scratch. Released under the BSD 2-Clause license (For details, please read the [LICENSE file](./LICENSE) under the root directory of this repository).
@@ -16,68 +16,44 @@ If you have any questions or bug report, please use the issue tracking system on
Note: We also have a mirror repository on gitee (<https://gitee.com/unicornx/riscv-operating-system-mooc>), and we use the issue tracking system on gitee more actively than on github, all issue# filled in git commitment are from the issue tracking system of gitee.
# Operating environment
# 2. Operating environment
All demo codes have been verified under the following equipment environment:
Ubuntu 20.04 is recommended. Ubuntu 20.04 is currently the latest recommended long-term stable release of Ubuntu. It is also the easiest to install and run the environment in this environment.
Some students reported that they hope to still use Ubuntu 18.04. Because the official source of Ubunt 18.04 does not support the RISC-V development kit, so the environment is a little more complicated. I wrote a simple document, and you can refer [here ](./howto-run-with-ubuntu1804.md) to have a try with Ubuntu 18.04.
All demo codes have been verified under the following environment. Please carefully check whether your Ubuntu version and kernel version are consistent with the following information.
```
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.2 LTS
Description: Ubuntu 20.04.3 LTS
Release: 20.04
Codename: focal
$ uname -r
5.8.0-45-generic
5.11.0-27-generic
```
There may be dependent libraries that need to be installed manually. If you are prompted that other libraries and dependencies are missing during the operation, please install them by yourself according to the prompts.
At present, in the Ubuntu 20.04 environment, we can directly use the official GNU toolchain and QEMU emulator, and execute the following command to install online to start the test:
```
$ sudo apt update
$ sudo apt install build-essential git gitk vim libfdt-dev libsdl2-dev
$ sudo apt install build-essential gcc make perl dkms git gcc-riscv64-unknown-elf gdb-multiarch qemu-system-misc
```
The experiment requires some running tools, pre-compiled binary files have been provided, the specific installation steps are described as follows:
# 3. Building and usage
First, create a working directory, and then enter the directory.
```
$ mkdir $HOME/ws
$ cd $HOME/ws
```
Download the development tool package `tools.tar.gz`, the download address are:
- <https://share.weiyun.com/nyTqAGKh>
or
- <https://pan.baidu.com/s/11FAq64YGu3JVkZSTtoVMOg>, password: bjnj
After downloading, copy the file to `$HOME/ws` and unzip it.
```
$ tar xzf tools.tar.gz
```
Add the following path to `$HOME/.bashrc`
```
export PATH="$PATH:$HOME/ws/tools/gcc/bin:$HOME/ws/tools/qemu/bin"
```
Re-import `$HOME/.bashrc` or restart the system to make the configuration effective.
# Construction and usage
- makeCompile and build
- make runStart qemu and run
- make debugStart debugging
- make codeDisassemble to view binary code
- make cleancleanup
- `make`Compile and build
- `make run`Start qemu and run
- `make debug`Start debugging
- `make code`Disassemble to view binary code
- `make clean`cleanup
For specific use, please refer to the Makefile under the specific sub-project.
# References
# 4. References
The design of this course refers to the following network resources, thank you :)

View File

@@ -2,13 +2,13 @@
<!-- TOC -->
- [简介](#简介)
- [运行环境](#运行环境)
- [构建和使用说明](#构建和使用说明)
- [参考文献](#参考文献)
- [1. 简介](#1-简介)
- [2. 运行环境](#2-运行环境)
- [3. 构建和使用说明](#3-构建和使用说明)
- [4. 参考文献](#4-参考文献)
<!-- /TOC -->
# 简介
# 1. 简介
本课程用于教学演示如何从零开始为 RISC-V 平台编写一个简单的操作系统内核。采用 BSD 2-Clause 许可证发布(具体请阅读本仓库根目录下的 [LICENSE 文件](./LICENSE))。
@@ -24,67 +24,44 @@
- **微信学习群**,请添加微信 fangzhang1024 (标注 【汪辰老师】)加入。
# 运行环境
# 2. 运行环境
所有演示代码在以下设备环境下验证通过:
推荐使用 Ubuntu 20.04Ubuntu 20.04 是目前最新的 Ubuntu 长期稳定发行版,在这个环境下安装运行环境也最简单。
有些同学反映希望仍然使用Ubuntu 18.04,因为 Ubunt 18.04 的官方源还不支持 RISC-V 的开发工具包,所以搭建环境稍微复杂一些,我写了一个简单的说明文档,感兴趣的同学可以看 [这里](./howto-run-with-ubuntu1804_zh.md)。
所有演示代码在以下环境下验证通过,请仔细核对你的 Ubuntu 版本和内核版本与以下信息是否一致。
```
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.2 LTS
Description: Ubuntu 20.04.3 LTS
Release: 20.04
Codename: focal
$ uname -r
5.8.0-45-generic
5.11.0-27-generic
```
有可能需要手动安装的依赖库,如果运行过程中提示缺少其他的库和依赖,请按照提示自行安装。
目前在 Ubuntu 20.04 环境下我们可以直接使用官方提供的 GNU工具链和 QEMU 模拟器,执行如下命令在线安装即可开始试验:
```
$ sudo apt update
$ sudo apt install build-essential git gitk vim libfdt-dev libsdl2-dev
$ sudo apt install build-essential gcc make perl dkms git gcc-riscv64-unknown-elf gdb-multiarch qemu-system-misc
```
实验需要一些运行工具,已经提供预先编译好的二进制文件,具体安装步骤描述如下:
# 3. 构建和使用说明
首先,创建一个工作目录,然后进入该目录。
```
$ mkdir $HOME/ws
$ cd $HOME/ws
```
下载开发工具软件包 `tools.tar.gz`,下载地址为:
- 腾讯微云: <https://share.weiyun.com/nyTqAGKh>
或者
- 百度网盘:链接:<https://pan.baidu.com/s/11FAq64YGu3JVkZSTtoVMOg>, 提取码bjnj
下载完毕后将该文件拷贝到 `$HOME/ws` 下并解压。
```
$ tar xzf tools.tar.gz
```
将以下路径加入 `$HOME/.bashrc`
```
export PATH="$PATH:$HOME/ws/tools/gcc/bin:$HOME/ws/tools/qemu/bin"
```
重新导入 `$HOME/.bashrc` 或者重启系统使配置生效即可。
# 构建和使用说明
- make编译构建
- make run启动 qemu 并运行
- make debug启动调试
- make code反汇编查看二进制代码
- make clean清理
- `make`:编译构建
- `make run`:启动 qemu 并运行
- `make debug`:启动调试
- `make code`:反汇编查看二进制代码
- `make clean`:清理
具体使用请参考具体子项目下的 Makefile 文件。
# 参考文献
# 4. 参考文献
本课程的设计参考了如下网络资源,在此表示感谢 :)

View File

@@ -1,6 +1,6 @@
EXEC = test
SRC = $(EXEC).s $(EXEC).c
SRC = ${EXEC}.s ${EXEC}.c
GDBINIT = ./gdbinit

View File

@@ -1,6 +1,6 @@
EXEC = test
SRC = $(EXEC).s
SRC = ${EXEC}.s
GDBINIT = ../gdbinit

View File

@@ -1,6 +1,6 @@
EXEC = test
SRC = $(EXEC).s $(EXEC).c
SRC = ${EXEC}.s ${EXEC}.c
GDBINIT = ./gdbinit

View File

@@ -1,6 +1,6 @@
EXEC = test
SRC = $(EXEC).s
SRC = ${EXEC}.s
GDBINIT = ./gdbinit

View File

@@ -1,6 +1,6 @@
EXEC = test
SRC = $(EXEC).s
SRC = ${EXEC}.s
GDBINIT = ./gdbinit

View File

@@ -1,37 +1,31 @@
CROSS_COMPILE = riscv64-unknown-elf-
CFLAGS = -nostdlib -fno-builtin -march=rv32ima -mabi=ilp32 -g -Wall
QEMU = qemu-system-riscv32
QFLAGS = -nographic -smp 1 -machine virt -bios none
GDB = ${CROSS_COMPILE}gdb
include ../../common.mk
.DEFAULT_GOAL := all
all:
@$(CROSS_COMPILE)gcc $(CFLAGS) ${SRC} -Ttext=0x80000000 -o $(EXEC).elf
@$(CROSS_COMPILE)objcopy -O binary $(EXEC).elf $(EXEC).bin
@${CC} ${CFLAGS} ${SRC} -Ttext=0x80000000 -o ${EXEC}.elf
@${OBJCOPY} -O binary ${EXEC}.elf ${EXEC}.bin
.PHONY : run
run: all
@echo "Press Ctrl-A and then X to exit QEMU"
@echo "------------------------------------"
@echo "No output, please run 'make debug' to see details"
@$(QEMU) $(QFLAGS) -kernel ./$(EXEC).elf
@${QEMU} ${QFLAGS} -kernel ./${EXEC}.elf
.PHONY : debug
debug: all
@echo "Press Ctrl-C and then input 'quit' to exit GDB and QEMU"
@echo "-------------------------------------------------------"
@$(QEMU) $(QFLAGS) -kernel $(EXEC).elf -s -S &
@$(GDB) $(EXEC).elf -q -x ${GDBINIT}
@${QEMU} ${QFLAGS} -kernel ${EXEC}.elf -s -S &
@${GDB} ${EXEC}.elf -q -x ${GDBINIT}
.PHONY : code
code: all
@$(CROSS_COMPILE)objdump -S $(EXEC).elf | less
@${OBJDUMP} -S ${EXEC}.elf | less
.PHONY : hex
hex: all
@hexdump -C $(EXEC).bin
@hexdump -C ${EXEC}.bin
.PHONY : clean
clean:

10
code/common.mk Normal file
View File

@@ -0,0 +1,10 @@
CROSS_COMPILE = riscv64-unknown-elf-
CFLAGS = -nostdlib -fno-builtin -march=rv32ima -mabi=ilp32 -g -Wall
QEMU = qemu-system-riscv32
QFLAGS = -nographic -smp 1 -machine virt -bios none
GDB = gdb-multiarch
CC = ${CROSS_COMPILE}gcc
OBJCOPY = ${CROSS_COMPILE}objcopy
OBJDUMP = ${CROSS_COMPILE}objdump

View File

@@ -1,13 +1,4 @@
CROSS_COMPILE = riscv64-unknown-elf-
CFLAGS = -nostdlib -fno-builtin -march=rv32ima -mabi=ilp32 -g -Wall
QEMU = qemu-system-riscv32
QFLAGS = -nographic -smp 1 -machine virt -bios none
GDB = ${CROSS_COMPILE}gdb
CC = ${CROSS_COMPILE}gcc
OBJCOPY = ${CROSS_COMPILE}objcopy
OBJDUMP = ${CROSS_COMPILE}objdump
include ../../common.mk
SRCS_ASM = \
start.S \
@@ -23,7 +14,7 @@ all: os.elf
# start.o must be the first in dependency!
os.elf: ${OBJS}
${CC} $(CFLAGS) -Ttext=0x80000000 -o os.elf $^
${CC} ${CFLAGS} -Ttext=0x80000000 -o os.elf $^
${OBJCOPY} -O binary os.elf os.bin
%.o : %.c

View File

@@ -1,13 +1,4 @@
CROSS_COMPILE = riscv64-unknown-elf-
CFLAGS = -nostdlib -fno-builtin -march=rv32ima -mabi=ilp32 -g -Wall
QEMU = qemu-system-riscv32
QFLAGS = -nographic -smp 1 -machine virt -bios none
GDB = ${CROSS_COMPILE}gdb
CC = ${CROSS_COMPILE}gcc
OBJCOPY = ${CROSS_COMPILE}objcopy
OBJDUMP = ${CROSS_COMPILE}objdump
include ../../common.mk
SRCS_ASM = \
start.S \
@@ -24,7 +15,7 @@ all: os.elf
# start.o must be the first in dependency!
os.elf: ${OBJS}
${CC} $(CFLAGS) -Ttext=0x80000000 -o os.elf $^
${CC} ${CFLAGS} -Ttext=0x80000000 -o os.elf $^
${OBJCOPY} -O binary os.elf os.bin
%.o : %.c

View File

@@ -1,13 +1,4 @@
CROSS_COMPILE = riscv64-unknown-elf-
CFLAGS = -nostdlib -fno-builtin -march=rv32ima -mabi=ilp32 -g -Wall
QEMU = qemu-system-riscv32
QFLAGS = -nographic -smp 1 -machine virt -bios none
GDB = ${CROSS_COMPILE}gdb
CC = ${CROSS_COMPILE}gcc
OBJCOPY = ${CROSS_COMPILE}objcopy
OBJDUMP = ${CROSS_COMPILE}objdump
include ../../common.mk
SRCS_ASM = \
start.S \
@@ -27,7 +18,7 @@ all: os.elf
# start.o must be the first in dependency!
os.elf: ${OBJS}
${CC} $(CFLAGS) -T os.ld -o os.elf $^
${CC} ${CFLAGS} -T os.ld -o os.elf $^
${OBJCOPY} -O binary os.elf os.bin
%.o : %.c

View File

@@ -1,13 +1,4 @@
CROSS_COMPILE = riscv64-unknown-elf-
CFLAGS = -nostdlib -fno-builtin -march=rv32ima -mabi=ilp32 -g -Wall
QEMU = qemu-system-riscv32
QFLAGS = -nographic -smp 1 -machine virt -bios none
GDB = ${CROSS_COMPILE}gdb
CC = ${CROSS_COMPILE}gcc
OBJCOPY = ${CROSS_COMPILE}objcopy
OBJDUMP = ${CROSS_COMPILE}objdump
include ../../common.mk
SRCS_ASM = \
start.S \
@@ -29,7 +20,7 @@ all: os.elf
# start.o must be the first in dependency!
os.elf: ${OBJS}
${CC} $(CFLAGS) -T os.ld -o os.elf $^
${CC} ${CFLAGS} -T os.ld -o os.elf $^
${OBJCOPY} -O binary os.elf os.bin
%.o : %.c

View File

@@ -1,13 +1,4 @@
CROSS_COMPILE = riscv64-unknown-elf-
CFLAGS = -nostdlib -fno-builtin -march=rv32ima -mabi=ilp32 -g -Wall
QEMU = qemu-system-riscv32
QFLAGS = -nographic -smp 1 -machine virt -bios none
GDB = ${CROSS_COMPILE}gdb
CC = ${CROSS_COMPILE}gcc
OBJCOPY = ${CROSS_COMPILE}objcopy
OBJDUMP = ${CROSS_COMPILE}objdump
include ../../common.mk
SRCS_ASM = \
start.S \
@@ -30,7 +21,7 @@ all: os.elf
# start.o must be the first in dependency!
os.elf: ${OBJS}
${CC} $(CFLAGS) -T os.ld -o os.elf $^
${CC} ${CFLAGS} -T os.ld -o os.elf $^
${OBJCOPY} -O binary os.elf os.bin
%.o : %.c

View File

@@ -1,13 +1,4 @@
CROSS_COMPILE = riscv64-unknown-elf-
CFLAGS = -nostdlib -fno-builtin -march=rv32ima -mabi=ilp32 -g -Wall
QEMU = qemu-system-riscv32
QFLAGS = -nographic -smp 1 -machine virt -bios none
GDB = ${CROSS_COMPILE}gdb
CC = ${CROSS_COMPILE}gcc
OBJCOPY = ${CROSS_COMPILE}objcopy
OBJDUMP = ${CROSS_COMPILE}objdump
include ../../common.mk
SRCS_ASM = \
start.S \
@@ -31,7 +22,7 @@ all: os.elf
# start.o must be the first in dependency!
os.elf: ${OBJS}
${CC} $(CFLAGS) -T os.ld -o os.elf $^
${CC} ${CFLAGS} -T os.ld -o os.elf $^
${OBJCOPY} -O binary os.elf os.bin
%.o : %.c

View File

@@ -1,13 +1,4 @@
CROSS_COMPILE = riscv64-unknown-elf-
CFLAGS = -nostdlib -fno-builtin -march=rv32ima -mabi=ilp32 -g -Wall
QEMU = qemu-system-riscv32
QFLAGS = -nographic -smp 1 -machine virt -bios none
GDB = ${CROSS_COMPILE}gdb
CC = ${CROSS_COMPILE}gcc
OBJCOPY = ${CROSS_COMPILE}objcopy
OBJDUMP = ${CROSS_COMPILE}objdump
include ../../common.mk
SRCS_ASM = \
start.S \
@@ -32,7 +23,7 @@ all: os.elf
# start.o must be the first in dependency!
os.elf: ${OBJS}
${CC} $(CFLAGS) -T os.ld -o os.elf $^
${CC} ${CFLAGS} -T os.ld -o os.elf $^
${OBJCOPY} -O binary os.elf os.bin
%.o : %.c

View File

@@ -1,13 +1,4 @@
CROSS_COMPILE = riscv64-unknown-elf-
CFLAGS = -nostdlib -fno-builtin -march=rv32ima -mabi=ilp32 -g -Wall
QEMU = qemu-system-riscv32
QFLAGS = -nographic -smp 1 -machine virt -bios none
GDB = ${CROSS_COMPILE}gdb
CC = ${CROSS_COMPILE}gcc
OBJCOPY = ${CROSS_COMPILE}objcopy
OBJDUMP = ${CROSS_COMPILE}objdump
include ../../common.mk
SRCS_ASM = \
start.S \
@@ -33,7 +24,7 @@ all: os.elf
# start.o must be the first in dependency!
os.elf: ${OBJS}
${CC} $(CFLAGS) -T os.ld -o os.elf $^
${CC} ${CFLAGS} -T os.ld -o os.elf $^
${OBJCOPY} -O binary os.elf os.bin
%.o : %.c

View File

@@ -1,13 +1,4 @@
CROSS_COMPILE = riscv64-unknown-elf-
CFLAGS = -nostdlib -fno-builtin -march=rv32ima -mabi=ilp32 -g -Wall
QEMU = qemu-system-riscv32
QFLAGS = -nographic -smp 1 -machine virt -bios none
GDB = ${CROSS_COMPILE}gdb
CC = ${CROSS_COMPILE}gcc
OBJCOPY = ${CROSS_COMPILE}objcopy
OBJDUMP = ${CROSS_COMPILE}objdump
include ../../common.mk
SRCS_ASM = \
start.S \
@@ -33,7 +24,7 @@ all: os.elf
# start.o must be the first in dependency!
os.elf: ${OBJS}
${CC} $(CFLAGS) -T os.ld -o os.elf $^
${CC} ${CFLAGS} -T os.ld -o os.elf $^
${OBJCOPY} -O binary os.elf os.bin
%.o : %.c

View File

@@ -1,13 +1,4 @@
CROSS_COMPILE = riscv64-unknown-elf-
CFLAGS = -nostdlib -fno-builtin -march=rv32ima -mabi=ilp32 -g -Wall
QEMU = qemu-system-riscv32
QFLAGS = -nographic -smp 1 -machine virt -bios none
GDB = ${CROSS_COMPILE}gdb
CC = ${CROSS_COMPILE}gcc
OBJCOPY = ${CROSS_COMPILE}objcopy
OBJDUMP = ${CROSS_COMPILE}objdump
include ../../common.mk
SRCS_ASM = \
start.S \
@@ -34,7 +25,7 @@ all: os.elf
# start.o must be the first in dependency!
os.elf: ${OBJS}
${CC} $(CFLAGS) -T os.ld -o os.elf $^
${CC} ${CFLAGS} -T os.ld -o os.elf $^
${OBJCOPY} -O binary os.elf os.bin
%.o : %.c

View File

@@ -1,13 +1,4 @@
CROSS_COMPILE = riscv64-unknown-elf-
CFLAGS = -nostdlib -fno-builtin -march=rv32ima -mabi=ilp32 -g -Wall
QEMU = qemu-system-riscv32
QFLAGS = -nographic -smp 1 -machine virt -bios none
GDB = ${CROSS_COMPILE}gdb
CC = ${CROSS_COMPILE}gcc
OBJCOPY = ${CROSS_COMPILE}objcopy
OBJDUMP = ${CROSS_COMPILE}objdump
include ../../common.mk
SRCS_ASM = \
start.S \
@@ -34,7 +25,7 @@ all: os.elf
# start.o must be the first in dependency!
os.elf: ${OBJS}
${CC} $(CFLAGS) -T os.ld -o os.elf $^
${CC} ${CFLAGS} -T os.ld -o os.elf $^
${OBJCOPY} -O binary os.elf os.bin
%.o : %.c

View File

@@ -1,21 +1,11 @@
include ../../common.mk
SYSCALL = y
CROSS_COMPILE = riscv64-unknown-elf-
CFLAGS = -nostdlib -fno-builtin -march=rv32ima -mabi=ilp32 -g -Wall
ifeq ($(SYSCALL), y)
ifeq (${SYSCALL}, y)
CFLAGS += -D CONFIG_SYSCALL
endif
QEMU = qemu-system-riscv32
QFLAGS = -nographic -smp 1 -machine virt -bios none
GDB = ${CROSS_COMPILE}gdb
CC = ${CROSS_COMPILE}gcc
OBJCOPY = ${CROSS_COMPILE}objcopy
OBJDUMP = ${CROSS_COMPILE}objdump
SRCS_ASM = \
start.S \
mem.S \
@@ -43,7 +33,7 @@ all: os.elf
# start.o must be the first in dependency!
os.elf: ${OBJS}
${CC} $(CFLAGS) -T os.ld -o os.elf $^
${CC} ${CFLAGS} -T os.ld -o os.elf $^
${OBJCOPY} -O binary os.elf os.bin
%.o : %.c

View File

@@ -37,6 +37,22 @@ _start:
# Keep mstatus.MPP as 0, so we will run in User mode after MRET.
# Set mstatus.MPIE to 1, so MRET will enable the interrupt.
li t0, 1 << 7
# https://lore.kernel.org/qemu-devel/20201223192553.332508-1-atish.patra@wdc.com/
# For qemu version >= 6.0, exception would be raised if no PMP enty is
# configured. So just configure one entny, which allows all the whole
# 32-bits physical address range is R/W/X.
# FIXME: I say it is a temporary workaroud due to I think the patch
# above contains bug, and I have raised new issue to qemu but it has not
# been rootcaused till now. Details please refer to
# https://gitlab.com/qemu-project/qemu/-/issues/585 or
# https://gitee.com/unicornx/riscv-operating-system-mooc/issues/I441IC (in chinese)
# So it's just a temporary workaround till now to not block people who
# want to try newer qemu (>= 6.0).
li t0, 0xffffffff
csrw pmpaddr0, t0
li t0, 0xf
csrw pmpcfg0, t0
#else
# Set mstatus.MPP to 3, so we still run in Machine mode after MRET.
# Set mstatus.MPIE to 1, so MRET will enable the interrupt.

View File

@@ -0,0 +1,74 @@
# How to run RVOS on Ubuntu 18.04
All demo codes have been verified under the following environment. Please carefully check whether your Ubuntu version and kernel version are consistent with the following information.
```
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.5 LTS
Release: 18.04
Codename: bionic
$ uname -r
5.4.0-84-generic
```
The installation steps are as follows:
- First, please manually install some basic tools and dependent libraries. Note that if it prompts that other libraries and dependencies are missing during the running process, please follow the prompts and try to install them yourself.
```
$ sudo apt update
$ sudo apt install build-essential gcc make perl dkms git libsnappy1v5 libsdl2-2.0-0 libvdeplug2 librbd1 libaio1
```
- Second, create a working directory, and then enter the directory.
```
$ mkdir $HOME/ws
$ cd $HOME/ws
```
- Then, because the official source of Ubunt 18.04 does not support the RISC-V development kit, I have provided a pre-compiled binary tool file. You can download and install it in the following two ways:
**The first method**: Download the development tool software compressed package `tools.tar.xz` through the network disk. The download address is currently provided for everyones convenience. Two ways are provided for everyone to get what they need. Please pay attention it mau be slower to downloading from the network disk.
- <https://share.weiyun.com/nyTqAGKh>
or
- <https://pan.baidu.com/s/11FAq64YGu3JVkZSTtoVMOg>, password: bjnj
After downloading, copy the file to `$HOME/ws` and unzip it.
```
$ tar xJf tools.tar.xz
```
**Second method**: If you think the download speed through the network disk is too slow, I also store the files in the `tools` package (uncompressed) in the form of a warehouse on **Gitee**, you can execute the following command to clone the tools. The only purpose of this is to allow you to download these files faster:
```
$ cd <YOUR_WORKSPACE>
$ git clone https://gitee.com/unicornx/rvos_tools_ubuntu_18_04.git
```
The uncompressed tools directory in the warehouse is the same as the decompressed content of `tools.tar.xz`.
After the warehouse is cloned, copy the tools directory to `$HOME/ws` as well.
```
$ cp -r rvos_tools_ubuntu_18_04/tools $HOME/ws
```
Note that you also need to modify the value of an environment variable in a Makefile in the `riscv-operating-system-mooc` code repository. Open `code/common.mk` with text editor and change `GDB = gdb-multiarch` to `GDB = ${CROSS_COMPILE}gdb`.
- Finally, add the following path to `$HOME/.bashrc`.
```
export PATH="$HOME/ws/tools/gcc/bin:$HOME/ws/tools/qemu/bin:$PATH"
```
Re-import `$HOME/.bashrc` or restart the system to make the configuration effective.

View File

@@ -0,0 +1,71 @@
# 如何在 Ubuntu 18.04 下开展 RVOS 实验
所有演示代码在以下环境下验证通过,请仔细核对你的 Ubuntu 版本和内核版本与以下信息是否一致。
```
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.5 LTS
Release: 18.04
Codename: bionic
$ uname -r
5.4.0-84-generic
```
因为 Ubunt 18.04 的官方源还不支持 RISC-V 的开发工具包,所以搭建环境稍微复杂一些。安装步骤如下:
- 首先,请手动安装一些基本工具和依赖库。注意如果运行过程中提示缺少其他的库和依赖,请按照提示自行尝试安装。
```
$ sudo apt update
$ sudo apt install build-essential gcc make perl dkms git libsnappy1v5 libsdl2-2.0-0 libvdeplug2 librbd1 libaio1
```
- 其次,创建一个工作目录,然后进入该目录。
```
$ mkdir $HOME/ws
$ cd $HOME/ws
```
- 然后,因为 Ubunt 18.04 的官方源还不支持 RISC-V 的开发工具包,所以我提供了预先编译好的二进制工具文件,大家可以通过以下两种方式下载和安装:
**第一种方式**:通过网盘下载开发工具软件压缩包 `tools.tar.xz`,下载地址目前为了大家方便,提供了两个途径,大家各取所需,注意网盘方式下载可能会比较慢:
- 腾讯微云: <https://share.weiyun.com/nyTqAGKh>
或者
- 百度网盘:链接:<https://pan.baidu.com/s/11FAq64YGu3JVkZSTtoVMOg>, 提取码bjnj
下载完毕后将该文件拷贝到 `$HOME/ws` 下并解压。
```
$ tar xJf tools.tar.xz
```
**第二种方式**:如果你觉得通过网盘下载速度太慢,我还将 `tools` 包中的文件(未压缩)以仓库的形式存放在 **Gitee** 上,你可以执行如下命令将 tools 克隆下来,这么做的唯一目的是为了让你更快地下载这些文件:
```
$ cd <YOUR_WORKSPACE>
$ git clone https://gitee.com/unicornx/rvos_tools_ubuntu_18_04.git
```
仓库里是未压缩的 tools 目录,它和 `tools.tar.xz` 解压缩后的内容是一样的。
仓库克隆完成后将 tools 目录同样拷贝到 `$HOME/ws` 下即可。
```
$ cp -r rvos_tools_ubuntu_18_04/tools $HOME/ws
```
注意最后还需要修改 `riscv-operating-system-mooc` 代码仓库中的一个 Makefile 中的环境变量的值。编辑 `code/common.mk`,将其中的 `GDB = gdb-multiarch` 修改为 `GDB = ${CROSS_COMPILE}gdb`。
- 最后将以下路径加入 `$HOME/.bashrc`
```
export PATH="$HOME/ws/tools/gcc/bin:$HOME/ws/tools/qemu/bin:$PATH"
```
重新导入 `$HOME/.bashrc` 或者重启系统使配置生效即可。