清华rcore-os实验环境配置中遇到的一点问题(HNU操作系统,不定时更新)

一、前言

最近学校操作系统实验要求学习清华的rcore-os并进行环境配置,和使用gdb进行一些基本的调试,这个过程中遇到了一些可爱的小问题,在此记录一下,方便自己日后回忆,也为后来的学弟学妹栽树。

二、实验准备

1、rCore-Tutorial-v3

2、qemu-7.0.0

3、gdb

三、遇到问题

1、make gdbclient时出现“没有规则制作”错误

(1)错误描述

在make gdbclient时,出现了『make: ***没有规则可制作目标“gdbclient”。停止。』的错误。

产生这种错误的原因是我们的Makefile文件中规定的gdb存放路径与我们的实际路径不相符,导致计算机在执行make命令的时候找不到gdb,自然也打不开gdbcilent。

(2)解决办法

首先我们需要把gdb的二进制可执行文件挪到 rCore-Tutorial-v3/os 目录下;然后打开os目录下的Makefile文件,在其中我们可以看到一行规定gdbclient的字样(我的是在文档的最下边)

gdbclient:
        @riscv64-unknown-elf-gdb -ex 'file $(KERNEL_ELF)' -ex 'set arch riscv:rv64' -ex 'target remote localhost:1234

然后我们只需要再把@riscv64-unknown...这一部分加入./  即

gdbclient:
        @./riscv64-unknown-elf-gdb -ex 'file $(KERNEL_ELF)' -ex 'set arch riscv:rv64' -ex 'target remote localhost:1234

把地址指向我们新复制的gdb的位置即可,再make gdbclient,产生以下效果即为成功:

h34@h34-82SN:~/rCore-Tutorial-v3/os$ make gdbclient
GNU gdb (SiFive GDB 8.3.0-2020.04.1) 8.3
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-linux-gnu --target=riscv64-unknown-elf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://github.com/sifive/freedom-tools/issues>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".
Reading symbols from target/riscv64gc-unknown-none-elf/release/os...
The target architecture is assumed to be riscv:rv64
Remote debugging using localhost:1234
0x0000000000001000 in ?? ()
(gdb) 

2、make gdbserver时出现错误

(1)错误描述

这个错误是我在帮舍友调试的时候发现的错误,所以没有错误截图,在此大概说明一下:舍友在make gdbserver时发现,更新rustc nightly版本不成功,深入探究发现Cargo版本只能支持2015和2018版本的gdb,而这两个版本的gdb并不能支持v3版本的rCore,而欲升级Cargo却又不成功,我戏谑称之为“三角恋错误”。

(2)解决办法

说实话我也不知道怎么解决的这个错误,误打误撞。

首先我更换了Cargo的源为中国科学技术大学的源:

[source.crates-io]
registry = "https://github.com/rust-lang/crates.io-index"
replace-with = 'ustc'
[source.ustc]
registry = "git://mirrors.ustc.edu.cn/crates.io-index"

然后安装一些rust相关的包:

rustup target add riscv64gc-unknown-none-elf
cargo install cargo-binutils
rustup component add llvm-tools-preview
rustup component add rust-src

下载rustc 的nightly版并切换:

rustup install nightly
rustup default nightly

发现切换成功:

rustc --version
rustc 1.78.0-nightly (5119208fd 2024-03-02)

再次make gdbserver,成功。

h34@h34-82SN:~/rCore-Tutorial-v3/os$ make gdbserver
(rustup target list | grep "riscv64gc-unknown-none-elf (installed)") || rustup target add riscv64gc-unknown-none-elf
riscv64gc-unknown-none-elf (installed)
cargo install cargo-binutils
    Updating crates.io index
     Ignored package `cargo-binutils v0.3.6` is already installed, use --force to override
rustup component add rust-src
info: component 'rust-src' is up to date
rustup component add llvm-tools-preview
info: component 'llvm-tools' for target 'x86_64-unknown-linux-gnu' is up to date
Platform: qemu
   Compiling os v0.1.0 (/home/h34/rCore-Tutorial-v3/os)
warning: unused import: `sip`
  --> src/trap/mod.rs:14:10
   |
14 |     sie, sip, sscratch, sstatus, stval, stvec,
   |          ^^^
   |
   = note: `#[warn(unused_imports)]` on by default

warning: `os` (bin "os") generated 1 warning (run `cargo fix --bin "os"` to apply 1 suggestion)
    Finished release [optimized + debuginfo] target(s) in 1.57s
make[1]: 进入目录“/home/h34/rCore-Tutorial-v3/user”
    Finished release [optimized + debuginfo] target(s) in 0.02s
make[1]: 离开目录“/home/h34/rCore-Tutorial-v3/user”
    Finished release [optimized] target(s) in 0.01s
     Running `target/release/easy-fs-fuse -s ../user/src/bin/ -t ../user/target/riscv64gc-unknown-none-elf/release/`
src_path = ../user/src/bin/
target_path = ../user/target/riscv64gc-unknown-none-elf/release/


四、反思

经过这些实验的操作,我觉得我们不应该对于英文输出的error畏而远之,要大胆的去读它们;对于不知道的事情常怀好奇之心,才会有动力去解决它们。正如翁恺老师说的那样:计算机的所有东西都是人做出来的,别人能想出来的,我也一定能想的出来,在计算机里头没有任何黑魔法,所有的东西,只不过是我现在不知道而以,总有一天我会把所有的细节所有的内部的东西全都搞明白的。赠与诸君,与君共勉。


ps.

不定期更新,欢迎和小伙伴们一起讨论!   :)

  • 26
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值