rcore-os / rCore-Tutorial-Book-v3

A book about how to write OS kernels in Rust easily.
https://rcore-os.github.io/rCore-Tutorial-Book-v3/
GNU General Public License v3.0
1.23k stars 233 forks source link

rCore-Tutorial-Book-v3/chapter1/0intro #23

Open utterances-bot opened 3 years ago

utterances-bot commented 3 years ago

引言 — rCore-Tutorial-Book-v3 0.1 文档

https://rcore-os.github.io/rCore-Tutorial-Book-v3/chapter1/0intro.html

Joeyscat commented 3 years ago

将 Maix 系列开发连接到 PC

SocialistDalao commented 3 years ago

make run

[rustsbi] RustSBI version 0.1.1 .__ .____. ..__ __ | \ | | | | / | | / || \ | | | |) | | | | | | (-------| |----| (----| |_) || | | / | | | | \ \ | | \ \ | _ < | | | |\ \----.|--' |.----) | | | .----) | | |) || | | | `.| _/ |_/ |__| |___/ |__/ |__|

[rustsbi] Platform: QEMU (Version 0.1.0) [rustsbi] misa: RV64ACDFIMSU [rustsbi] mideleg: 0x222 [rustsbi] medeleg: 0xb1ab [rustsbi-dtb] Hart count: cluster0 with 1 cores [rustsbi] Kernel entry: 0x80200000 [rustsbi-panic] hart 0 panicked at 'invalid instruction, mepc: 000000008000150e, instruction: 0000000030200073', platform/qemu/src/main.rs:458:17 [rustsbi-panic] system shutdown scheduled due to RustSBI panic

why rustsbi-panic?

SocialistDalao commented 3 years ago

Found reason: qemu version not match

rust-sbi don't support qemu 5.2.50, but when I use qemu 5.0.0, it works the same as mentioned in this tutorial in every single word.

Joeyscat commented 3 years ago

QEMU-5.0.0 + WSL2 + RustSBI 0.2.0-alpha.1

➜  os git:(ch1) qemu-system-riscv64 -version
QEMU emulator version 5.0.0
Copyright (c) 2003-2020 Fabrice Bellard and the QEMU Project developers
➜  os git:(ch1) uname -a
Linux DESKTOP-U9V9V76 5.4.72-microsoft-standard-WSL2 #1 SMP Wed Oct 28 23:40:43 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
➜  os git:(ch1) make run
(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 --vers ~0.2
    Updating `git://mirrors.ustc.edu.cn/crates.io-index` index
     Ignored package `cargo-binutils v0.2.0` 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-preview' for target 'x86_64-unknown-linux-gnu' is up to date
Platform: qemu
    Finished release [optimized] target(s) in 0.00s
[rustsbi] RustSBI version 0.2.0-alpha.1
.______       __    __      _______.___________.  _______..______   __
|   _  \     |  |  |  |    /       |           | /       ||   _  \ |  |
|  |_)  |    |  |  |  |   |   (----`---|  |----`|   (----`|  |_)  ||  |
|      /     |  |  |  |    \   \       |  |      \   \    |   _  < |  |
|  |\  \----.|  `--'  |.----)   |      |  |  .----)   |   |  |_)  ||  |
| _| `._____| \______/ |_______/       |__|  |_______/    |______/ |__|

[rustsbi] Platform: QEMU (Version 0.2.0)
[rustsbi] misa: RV64ACDFIMSU
[rustsbi] mideleg: 0x222
[rustsbi] medeleg: 0xb1ab
[rustsbi-dtb] Hart count: cluster0 with 1 cores
[rustsbi] Kernel entry: 0x80200000
Hello, world!
.text [0x80200000, 0x80202000)
.rodata [0x80202000, 0x80203000)
.data [0x80203000, 0x80203000)
boot_stack [0x80203000, 0x80213000)
.bss [0x80213000, 0x80213000)
Panicked at src/main.rs:46 Shutdown machine!
zhaobenx commented 3 years ago

在用docker 运行的时候如果报错 error[E0433]: failed to resolve: could not findaddr_ofinptr``, 可以参考 https://github.com/rcore-os/rCore-Tutorial-v3/issues/14 来修正

fdiskdc commented 3 years ago
引用了过时的API error[E0557]: feature has been removed --> src/main.rs:6:12 6 #![feature(const_in_array_repeat_expressions)] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ feature has been removed

= note: removed due to causing promotable bugs

tanjiaguo commented 3 years ago

make run (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 --vers ~0.2 Updating git://mirrors.ustc.edu.cn/crates.io-index index Ignored package cargo-binutils v0.2.0 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-preview' for target 'x8664-unknown-linux-gnu' is up to date Platform: qemu Finished release [optimized] target(s) in 0.01s [rustsbi] RustSBI version 0.2.0-alpha.1 .__ __.____. ..__ | \ | | | | / | | / || \ | | | |) | | | | | | (-------| |----| (----`| |) || | | / | | | | \ \ | | \ \ | < | | | |\ ----.| `--' |.----) | | | .----) | | |) || | | _| `.___| __/ |___/ |__| |___/ |__/ |__|

[rustsbi] Platform: QEMU (Version 0.2.0) [rustsbi] misa: RV64ACDFIMSU [rustsbi] mideleg: 0x222 [rustsbi] medeleg: 0xb1ab [rustsbi-dtb] Hart count: cluster0 with 1 cores [rustsbi] Kernel entry: 0x80200000 Hello, world! .text [0x80200000, 0x80202000) .rodata [0x80202000, 0x80203000) .data [0x80203000, 0x80203000) boot_stack [0x80203000, 0x80213000) .bss [0x80213000, 0x80213000) Panicked at src/main.rs:46 Shutdown machine!

duny31030 commented 3 years ago

由于操作系统代码无法 ~象~ (像)应用软件那样,可以有方便的调试(Debug)功能。 倒数第二段第一句好像有错别字

chriswuhao commented 2 years ago

请教各路大神,下面的log中这行[qemu-system-riscv64: clint: invalid write: 00000004 ],这个是什么问题,看着也能跑完,多谢。 系统:xubuntu 20.04.1: chris@chris-VirtualBox:~/ucore-os-kernel/rCore-Tutorial-v3/os$ uname -a Linux chris-VirtualBox 5.13.0-35-generic #40~20.04.1-Ubuntu SMP Mon Mar 7 09:18:32 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux chris@chris-VirtualBox:~/ucore-os-kernel/rCore-Tutorial-v3/os$ rustc --version rustc 1.60.0-nightly (9ad5d82f8 2022-01-18) chris@chris-VirtualBox:~/ucore-os-kernel/rCore-Tutorial-v3/os$ cargo --version cargo 1.60.0-nightly (358e79fe5 2022-01-04)

chris@chris-VirtualBox:~/ucore-os-kernel/rCore-Tutorial-v3$ cd os/ chris@chris-VirtualBox:~/ucore-os-kernel/rCore-Tutorial-v3/os$ make run (rustup target list | grep "riscv64gc-unknown-none-elf (installed)") || rustup target add riscv64gc-unknown-none-elf info: syncing channel updates for 'nightly-2022-01-19-x8664-unknown-linux-gnu' info: latest update on 2022-01-19, rust version 1.60.0-nightly (9ad5d82f8 2022-01-18) info: downloading component 'cargo' info: downloading component 'clippy' info: downloading component 'rust-docs' info: downloading component 'rust-std' info: downloading component 'rustc' info: downloading component 'rustfmt' info: installing component 'cargo' info: installing component 'clippy' info: installing component 'rust-docs' info: installing component 'rust-std' info: installing component 'rustc' info: installing component 'rustfmt' info: downloading component 'rust-std' for 'riscv64gc-unknown-none-elf' info: installing component 'rust-std' for 'riscv64gc-unknown-none-elf' 7.7 MiB / 7.7 MiB (100 %) 6.1 MiB/s in 1s ETA: 0s cargo install cargo-binutils --vers =0.3.3 Ignored package cargo-binutils v0.3.3 is already installed, use --force to override rustup component add rust-src info: downloading component 'rust-src' info: installing component 'rust-src' rustup component add llvm-tools-preview info: downloading component 'llvm-tools-preview' info: installing component 'llvm-tools-preview' 22.0 MiB / 22.0 MiB (100 %) 8.0 MiB/s in 2s ETA: 0s (which last-qemu) || (rm -f last-k210 && touch last-qemu && make clean) make[1]: Entering directory '/home/chris/ucore-os-kernel/rCore-Tutorial-v3/os' make[1]: Leaving directory '/home/chris/ucore-os-kernel/rCore-Tutorial-v3/os' Platform: qemu Compiling os v0.1.0 (/home/chris/ucore-os-kernel/rCore-Tutorial-v3/os) Finished release [optimized] target(s) in 2.03s [rustsbi] RustSBI version 0.2.0-alpha.6 .__ __.____. ..__ | \ | | | | / | | / || \ | | | |) | | | | | | (-------| |----| (----`| |) || | | / | | | | \ \ | | \ \ | < | | | |\ ----.| `--' |.----) | | | .----) | | |) || | | _| `.___| __/ |___/ |__| |___/ |__/ |__|

[rustsbi] Implementation: RustSBI-QEMU Version 0.0.2 [rustsbi-dtb] Hart count: cluster0 with 1 cores [rustsbi] misa: RV64ACDFIMSU [rustsbi] mideleg: ssoft, stimer, sext (0x222) [rustsbi] medeleg: ima, ia, bkpt, la, sa, uecall, ipage, lpage, spage (0xb1ab) [rustsbi] pmp0: 0x10000000 ..= 0x10001fff (rwx) [rustsbi] pmp1: 0x80000000 ..= 0x8fffffff (rwx) [rustsbi] pmp2: 0x0 ..= 0xffffffffffffff (---) qemu-system-riscv64: clint: invalid write: 00000004 [rustsbi] enter supervisor 0x80200000 Hello, world! .text [0x80200000, 0x80202000) .rodata [0x80202000, 0x80203000) .data [0x80203000, 0x80203000) boot_stack [0x80203000, 0x80213000) .bss [0x80213000, 0x80213000) Panicked at src/main.rs:46 Shutdown machine!

chriswuhao commented 2 years ago

追加qemu版本信息:

chris@chris-VirtualBox:~/ucore-os-kernel/rCore-Tutorial-v3/os$ qemu-riscv64 --version qemu-riscv64 version 5.0.0 Copyright (c) 2003-2020 Fabrice Bellard and the QEMU Project developers

ZhangTianrong commented 2 years ago

WSL平台。编译后无任何输出,只能从qemu退出。

zhuiYeah commented 2 years ago

quem-5.0.0 编译后卡死,更新为7.0.0后解决[rustsbi] RustSBI version 0.2.2, adapting to RISC-V SBI v1.0.0 .__ .____. ..__ __ | \ | | | | / | | / || \ | | | |) | | | | | | (-------| |----| (----| |_) || | | / | | | | \ \ | | \ \ | _ < | | | |\ \----.|--' |.----) | | | .----) | | |) || | | | `.| _/ |_/ |__| |___/ |__/ |__| [rustsbi] Implementation : RustSBI-QEMU Version 0.1.1 [rustsbi] Platform Name : riscv-virtio,qemu [rustsbi] Platform SMP : 1 [rustsbi] Platform Memory : 0x80000000..0x88000000 [rustsbi] Boot HART : 0 [rustsbi] Device Tree Region : 0x87000000..0x87000ef2 [rustsbi] Firmware Address : 0x80000000 [rustsbi] Supervisor Address : 0x80200000 [rustsbi] pmp01: 0x00000000..0x80000000 (-wr) [rustsbi] pmp02: 0x80000000..0x80200000 (---) [rustsbi] pmp03: 0x80200000..0x88000000 (xwr) Hello, world! .text [0x80200000, 0x80202000) .rodata [0x80202000, 0x80203000) .data [0x80203000, 0x80204000) boot_stack [0x80204000, 0x80214000) .bss [0x80214000, 0x80214000)

pw0rld commented 2 years ago

ch1的例子没跑通,卡住了。 本机环境

   ubuntu20.04,
   kernel 5.11  
   rustc 1.64.0-nightly (9a7b7d5e5 2022-07-19)  
   QEMU emulator version 5.0.0

make run 之后就卡死,没有任何输出

-> % make run
(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-preview' for target 'x86_64-unknown-linux-gnu' is up to date
(which last-qemu) || (rm -f last-k210 && touch last-qemu && make clean)
make[1]: Entering directory '/home/pw0rld/pw/rCore-Tutorial-v3/os'
make[1]: Leaving directory '/home/pw0rld/pw/rCore-Tutorial-v3/os'
Platform: qemu
   Compiling os v0.1.0 (/home/pw0rld/pw/rCore-Tutorial-v3/os)
    Finished release [optimized + debuginfo] target(s) in 0.47s

我自己的解决办法:替换SBI 打开Makefile,修改 BOOTLOADER := ../bootloader/$(SBI)-$(BOARD).bin 改成 BOOTLOADER := default 使用qemu默认的SBI。

(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-preview' for target 'x86_64-unknown-linux-gnu' is up to date
(which last-qemu) || (rm -f last-k210 && touch last-qemu && make clean)
make[1]: Entering directory '/home/pw0rld/pw/rCore-Tutorial-v3/os'
make[1]: Leaving directory '/home/pw0rld/pw/rCore-Tutorial-v3/os'
Platform: qemu
   Compiling os v0.1.0 (/home/pw0rld/pw/rCore-Tutorial-v3/os)
    Finished release [optimized + debuginfo] target(s) in 0.46s
default

OpenSBI v0.6
   ____                    _____ ____ _____
  / __ \                  / ____|  _ \_   _|
 | |  | |_ __   ___ _ __ | (___ | |_) || |
 | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
 | |__| | |_) |  __/ | | |____) | |_) || |_
  \____/| .__/ \___|_| |_|_____/|____/_____|
        | |
        |_|

Platform Name          : QEMU Virt Machine
Platform HART Features : RV64ACDFIMSU
Platform Max HARTs     : 8
Current Hart           : 0
Firmware Base          : 0x80000000
Firmware Size          : 120 KB
Runtime SBI Version    : 0.2

MIDELEG : 0x0000000000000222
MEDELEG : 0x000000000000b109
PMP0    : 0x0000000080000000-0x000000008001ffff (A)
PMP1    : 0x0000000000000000-0xffffffffffffffff (A,R,W,X)
Hello, world!
.text [0x80200000, 0x80202000)
.rodata [0x80202000, 0x80203000)
.data [0x80203000, 0x80204000)
boot_stack [0x80204000, 0x80214000)
.bss [0x80214000, 0x80214000)
wyfcyx commented 2 years ago

@pw0rld 如果使用项目内自带的RustSBI的话,请使用Qemu7.0.0版本。

pw0rld commented 2 years ago

@pw0rld 如果使用项目内自带的RustSBI的话,请使用Qemu7.0.0版本。

不行。我尝试把Qemu升级成7.0

-> % /home/pw0rld/pw/qemu/qemu-7.0.0/build/qemu-system-riscv64 --version
QEMU emulator version 7.0.0
Copyright (c) 2003-2022 Fabrice Bellard and the QEMU Project developers

Makefile

ifeq ($(BOARD),qemu)
    @/home/pw0rld/pw/qemu/qemu-7.0.0/build/qemu-system-riscv64 \
        -machine virt \
        -nographic \
        -bios $(BOOTLOADER) \
        -device loader,file=$(KERNEL_BIN),addr=$(KERNEL_ENTRY_PA)

使用项目的BOOTLOADER := ../bootloader/$(SBI)-$(BOARD).bin 还是进不去 image

如果改成BOOTLOADER :=default, 则是卡在这个界面,也是进不去 image

如果使用qemu 5.0,在ch5,使用getchar就会出现异常字符,不知道是不是因为Qemu版本的原因

-> % qemu-system-riscv64 --version
QEMU emulator version 5.0.0
Copyright (c) 2003-2020 Fabrice Bellard and the QEMU Project developers

输出 image

wyfcyx commented 2 years ago

@pw0rld 首先请检查一下ch1分支是否更新到最新版本。如果不是的话,感觉我也遇到过同样的情况(即使用Qemu7.0.0仍然卡死),猜测可能是我安装了kvm,这个是我能想到的唯一一处不同之处了。请问您是否安装过kvm呢?

wakk3107 commented 1 year ago
wakk@wakk-ubuntu:~/rCore-Tutorial-v3/os$ make run
(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 `ustc` 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-preview' for target 'x86_64-unknown-linux-gnu' is up to date
Platform: qemu
   Compiling cfg-if v1.0.0
error[E0463]: can't find crate for `core`
  |
  = note: the `riscv64gc-unknown-none-elf` target may not be installed
  = help: consider downloading the target with `rustup target add riscv64gc-unknown-none-elf`
  = help: consider building the standard library from source with `cargo build -Zbuild-std`

error[E0463]: can't find crate for `compiler_builtins`

For more information about this error, try `rustc --explain E0463`.
error: could not compile `cfg-if` due to 2 previous errors
make: *** [Makefile:42:kernel] 错误 101

环境配置的步骤都执行过了,这是为啥呀

v1ncente777 commented 1 year ago

[root@openEuler1 rCore-Tutorial-v3]# ls bootloader Dockerfile Makefile README.md dev-env-info.md LICENSE os rust-toolchain.toml [root@openEuler1 rCore-Tutorial-v3]# cd os [root@openEuler1 os]# make run (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 tuna 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-preview' for target 'x8664-unknown-linux-gnu' is up to date Platform: qemu Updating tuna index Compiling log v0.4.17 Compiling cfg-if v1.0.0 Compiling os v0.1.0 (/root/rCore-Tutorial-v3/os) Finished release [optimized + debuginfo] target(s) in 27.26s[rustsbi] RustSBI version 0.3.0-alpha.4, adapting to RISC-V SBI v1.0.0 .__ __.____. ..__ | \ | | | | / | | / || \ | | | |) | | | | | | (-------| |----| (----`| |) || | | / | | | | \ \ | | \ \ | < | | | |\ ----.| `--' |.----) | | | .----) | | |) || | | _| `.___| __/ |___/ |__| |___/ |__/ |__| [rustsbi] Implementation : RustSBI-QEMU Version 0.2.0-alpha.2 [rustsbi] Platform Name : riscv-virtio,qemu [rustsbi] Platform SMP : 1 [rustsbi] Platform Memory : 0x80000000..0x88000000 [rustsbi] Boot HART : 0 [rustsbi] Device Tree Region : 0x87000000..0x87000ef2 [rustsbi] Firmware Address : 0x80000000 [rustsbi] Supervisor Address : 0x80200000 [rustsbi] pmp01: 0x00000000..0x80000000 (-wr) [rustsbi] pmp02: 0x80000000..0x80200000 (---) [rustsbi] pmp03: 0x80200000..0x88000000 (xwr) [rustsbi] pmp04: 0x88000000..0x00000000 (-wr) [kernel] Hello, world! [root@openEuler1 os]#

v1ncente777 commented 1 year ago

[root@openEuler1 os]# make run (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 tuna 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-preview' for target 'x8664-unknown-linux-gnu' is up to date Platform: qemu Finished release [optimized + debuginfo] target(s) in 0.00s [rustsbi] RustSBI version 0.3.0-alpha.4, adapting to RISC-V SBI v1.0.0 .__ __.____. ..__ | \ | | | | / | | / || \ | | | |) | | | | | | (-------| |----| (----`| |) || | | / | | | | \ \ | | \ \ | < | | | |\ ----.| `--' |.----) | | | .----) | | |) || | | _| `.___| __/ |___/ |__| |___/ |__/ |__| [rustsbi] Implementation : RustSBI-QEMU Version 0.2.0-alpha.2 [rustsbi] Platform Name : riscv-virtio,qemu [rustsbi] Platform SMP : 1 [rustsbi] Platform Memory : 0x80000000..0x88000000 [rustsbi] Boot HART : 0 [rustsbi] Device Tree Region : 0x87000000..0x87000ef2 [rustsbi] Firmware Address : 0x80000000 [rustsbi] Supervisor Address : 0x80200000 [rustsbi] pmp01: 0x00000000..0x80000000 (-wr) [rustsbi] pmp02: 0x80000000..0x80200000 (---) [rustsbi] pmp03: 0x80200000..0x88000000 (xwr) [rustsbi] pmp04: 0x88000000..0x00000000 (-wr) [kernel] Hello, world! [root@openEuler1 os]#

readlnh commented 1 year ago

@pw0rld 可以尝试从rustsbi项目下下载最新的release替换掉老的文件

pw0rld commented 1 year ago

@readlnh 感谢提供帮助,这个问题我们已经解决了

coolwx commented 1 year ago

上面的那位wsl看不到输出只能退出的兄弟,虽然过了一年了,不过这里你无法运行大概率是qemu版本不对,检查which qemu-system-riscv64 ,看一下是不是/path/to/qemu7.0.0/build里的那个,大概率是因为你变成了/usr/bin/qemu-system-riscv64这个,调一下path优先级变成export PATH=/path/to/qemu-7.0.0/build:$PATH

ou-bing commented 9 months ago

ch1 分支编译失败:

error: the item `log` is imported redundantly
  --> src/logging.rs:7:11
   |
7  | use log::{self, Level, LevelFilter, Log, Metadata, Record};
   |           ^^^^ the item `log` is already defined here
   |

rustc version is rustc 1.78.0-nightly (c475e2303 2024-02-28)

移除导入的 self 后可以正常运行。

wyfcyx commented 9 months ago

@ou-bing https://github.com/rcore-os/rCore-Tutorial-v3/issues/145 应该近期更新Rust版本吧。

wangfp1145834208 commented 9 months ago

@pw0rld 你好,我最近将ubuntu从18.04升级到20.04后也遇到了这个问题,请问你是如何解决的

wangfp1145834208 commented 9 months ago

@coolwx 感谢提供的思路,用你的方法解决问题了~

Wsgamer7 commented 8 months ago

@coolwx 的方法有效的

zhenzhenChange commented 6 months ago

编译器(Rust 编译器和 C 编译器等)编译出的应用软件在缺省情况下是要链接标准库,而标准库是依赖于操作系统(如 Linux、Windows 等)的,但LibOS操作系统不依赖其他操作系统。

这里的缺省对应的单词应该是 default 吧,但是在如今惯用的翻译语境下,这里用默认会不会更合适点?

Catlordx commented 4 months ago

上面的那位wsl看不到输出只能退出的兄弟,虽然过了一年了,不过这里你无法运行大概率是qemu版本不对,检查which qemu-system-riscv64 ,看一下是不是/path/to/qemu7.0.0/build里的那个,大概率是因为你变成了/usr/bin/qemu-system-riscv64这个,调一下path优先级变成export PATH=/path/to/qemu-7.0.0/build:$PATH

是这样的

medihbt commented 1 month ago

请教一下, ch1 课程的例子跑不起来

系统配置

开发环境:

Rust 编译环境 (ch1 的 rust-toolchain.toml 的工具链被修改成下面的环境):

QEMU System(RISC-V) 运行环境:

报错输出

使用 git checkout ch1 && cd os && make run LOG=TRACE 命令运行此项目. 在不修改源码的情况下会报版本不匹配 & 特定功能被废弃的错误:

error: the feature `panic_info_message` has been stable since 1.81.0 and no longer requires an attribute to enable
  --> src/main.rs:14:12
   |
14 | #![feature(panic_info_message)]
   |            ^^^^^^^^^^^^^^^^^^
   |
note: the lint level is defined here
  --> src/main.rs:11:9
   |
11 | #![deny(warnings)]
   |         ^^^^^^^^
   = note: `#[deny(stable_features)]` implied by `#[deny(warnings)]`

error[E0599]: no method named `unwrap` found for struct `PanicMessage` in the current scope
  --> src/lang_items.rs:14:28
   |
14 |             info.message().unwrap()
   |                            ^^^^^^ method not found in `PanicMessage<'_>`

error[E0599]: no method named `unwrap` found for struct `PanicMessage` in the current scope
  --> src/lang_items.rs:17:58
   |
17 |         println!("[kernel] Panicked: {}", info.message().unwrap());
   |                                                          ^^^^^^ method not found in `PanicMessage<'_>`

注释掉这些被废弃的代码以后可以通过编译,但是没有任何输出:

Platform: qemu
   Compiling os v0.1.0 (/home/medihbt/Devel/rcore/rCore-Tutorial-Code-2024S/os)
    Finished `release` profile [optimized + debuginfo] target(s) in 0.34s

命令行输出在这一行就停下来了, 此后没有任何与 rcore logo / 执行环境相关的命令行输出. QEMU 程序卡死并占满 CPU, 无论如何都无法退出(包括 Ctrl+C 和 Ctrl-A,D 都无法退出), 除非使用 kill 杀死.

wyfcyx commented 1 month ago

@medihbt 请尽量不要用qemu8.x或者升级Rust版本,还没验证过,很可能是跑不起来的。最近会考虑例行升级一下Rust版本。