rust_os_docs
  • rCore OS 开发文档
  • 项目整体介绍
  • Rust语言速成
  • 开发环境配置
  • 整体架构和启动过程
  • Bootloader
  • 内存管理模块
  • 线程管理模块
  • 加载外部程序
  • 文件系统模块
  • Q&A
Powered by GitBook
On this page

开发环境配置

PreviousRust语言速成Next整体架构和启动过程

Last updated 6 years ago

Linux / macOS

需要安装以下软件:

  • nightly编译器

  • Cargo工具: ,

  • QEMU >= 2.12.0

  • (for riscv32)

  • (for aarch64)

安装依赖:

# 安装Rust工具链
curl https://sh.rustup.rs -sSf | sh

# 手动安装QEMU,RV64/AArch64工具链
# macOS:brew install qemu

# 由于天朝特殊的网络环境,建议配置代理服务器
export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static
export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup

# 安装cargo工具
rustup component add rust-src
cargo install cargo-xbuild bootimage
git clone https://github.com/wangrunji0408/RustOS.git --recursive
cd RustOS/kernel
rustup override set nightly
make run arch=riscv32

IDE & Editor

  • 低配版本:Visual Studio Code + Rust插件

Debug

注:不能使用普通gdb,会触发Bug:Remote 'g' packet reply is too long

macOS下使用homebrew安装 altkatz/gcc_cross_compilers/x64-elf-gdb

brew install altkatz/gcc_cross_compilers/x64-elf-gdb

使用make debug运行QEMU,再运行gdb连接

在CLion中可以使用GDB Remote Debug功能,进行GUI debug

Make

辅助命令:

  • make asm:查看kernel的反汇编(objdump -d)

  • make header:查看kernel的各段信息(objdump -h)

  • make sym:查看kernel的符号表(objdump -t)

参数:

  • arch:目标平台,可选:x86_64, riscv32, aarch64

  • mode:编译模式,可选:debug, release

  • LOG:输出调试信息等级,可选:off, error, warn, info, debug, trace,信息量依次递增

  • d:QEMU的调试参数,可输入qemu-system-riscv32 -d help 查看选项

  • smp:CPU核心数

  • board:目标硬件

推荐配置: / +

Rust
cargo-xbuild
bootimage
RISCV64 GNU toolchain
AArch64 GNU toolchain
IDEA
CLion
Rust插件