Coder Social home page Coder Social logo

rustsbi-k210's Introduction

RustSBI

RISC-V Supervisor Binary Interface (SBI) library in Rust; runs on M-mode or HS mode.

crates.io Documentation License

Binary downloads

Most users would get RustSBI binary download from the RustSBI Prototyping System. Check out the link here to download binary package for your platform.

Boards, SoC vendors and research groups would provide dedicated RustSBI package for supported platforms. There are packages exists on awesome-rustsbi: it is a curated list of awesome things related to RustSBI, which includes some implementation projects maintained by individuals or the community.

Users on commercial boards may visit implementation specific distribution links depending on the platforms they need, or consult vendors if they provide discrete RustSBI package support.

Minimum supported Rust version

To compile RustSBI library, you need at least stable Rust version of rustc 1.65.0.

Build this project

RustSBI is usually used as a library or dependency. If you wish to, you may build RustSBI library itself using the following command:

cargo build

The build should finish without any errors.

Building under native platform will allow development of hypervisors and emulators. To cross-build for a RISC-V platform environment, you may install the target and build onto it instead:

# If you don't have the cross compile target installed, install it first
rustup target add riscv64imac-unknown-none-elf
# Build this project as library
cargo build --target riscv64imac-unknown-none-elf

The target platform of RISC-V platform firmware is usually a bare metal target. Under normal circumstances these targets in Rust would start with riscv??- and end with -none-elf.

Features

  • Feature rich and extensible operating system runtime
  • Empower support, compatibility for machines, hypervisors and emulators
  • Support to and develop with RISC-V SBI specification v2.0 ratified
  • Written in Rust, builds under stable Rust
  • Capable to develop with other firmware ecosystem projects
  • Adapted for operating system kernel models on your choice

Frequently asked questions

  1. How would I build a RustSBI implementation?

RustSBI have extensive documents on such purposes! No matter what you are building with it, you will find some documents about RustSBI on bare-metal environments, hypervisors and emulators.

Check it out at RustSBI document main page.

  1. Can I use RustSBI on C based kernels?

Yes, you can! RustSBI strictly follows RISC-V SBI standard. All features are prepares for all programming languages, as long as they support RISC-V SBI defined calling convention.

If your kernel language supports other SBI implementations, usually it will support RustSBI in the same way.

Talks and documents

This project is originally a part of rCore Summer of Code 2020 activities, inspired by MeowSBI and other similar projects. Now it is capable of running rCore-Tutorial and other OS kernels on wide supported RISC-V devices.

There are multiple talks related to RustSBI dated back to Aug 2020. These talks discuss from design and abstraction of RustSBI modules, to actual production and research usage scenario related to RustSBI and RISC-V bootloaders. Public slides and blog articles of these talks are available at RustSBI/slides page.

Notes on platform implementation

  1. RustSBI should be used as a library. Under normal circumstances, RustSBI platform can be implemented with embedded Rust's embedded-hal libraries.
  2. Contributions are welcomed! We welcome to implement and test RustSBI for both FPGA cores and real cores. Implementations for emulators are also welcomed. If you are ready, start your own binary project and use RustSBI in it!
  3. If there is a bug in RustSBI project itself, fire an issue or pull request to let us know!

License & Copyright

This project is licensed under either of

Documents from RISC-V SBI Specification are used in this project. These documents are (C) RISC-V Foundation under Creative Commons Attribution 4.0 International License (CC-BY 4.0). The full license text is available at https://creativecommons.org/licenses/by/4.0/.

rustsbi-k210's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

rustsbi-k210's Issues

version 0.0.2终端输出存在异常

以rCore-Tutorial-v3 ch5为例,在sipeed的maix bit开发板上测试:
图片
使用原版本rustsbi在shell中输入不存在的文件时,回显如下:
图片
使用新版本rustsbi:
图片
在shell中输入不存在的文件时,终端回显异常字符,且此后每次回车都会回显:
图片

no serial port found

➜ rustsbi-k210 ls /dev/ttyUSB0
/dev/ttyUSB0
➜ rustsbi-k210 cargo k210
Finished dev [unoptimized + debuginfo] target(s) in 0.01s
Running target/debug/xtask k210
xtask: no serial port found; program exit

非法访问M模式寄存器时,RustSBI不能输出报错信息

非法访问M模式寄存器时,RustSBI不能输出报错信息

背景&预期

处于S/U模式的程序,是不能直接访问M模式寄存器的。SBI应该在非法访问时,提供报错信息。
0.0.1版本的k210支持包已经实现了该功能。但是在0.0.2版本的支持包里,这个功能消失了。

复现步骤

1.使用RustSBI支持包(bin)作为程序的bootloader
2.在程序的入口点直接访问M模式的寄存器 (可以直接在uCoreRV64的代码上改)
csrr a5, mstatus
3.打包k210支持包和自己的程序,烧录到k210
4.如果是 这个支持包(0.1.0),会输出以下报错信息:

ICB3LKU `(KFD5INA369O

5.如果是0.0.1/0.0.2版本的支持包,则没有报错信息,程序也会卡住。

MFQ_@3MX7}T(CP7D_GGPQ

麻烦洛佳大佬有时间看看,感谢

xv6-k210

在运行xv6-k210 os时,出现下面错误

$ make run platform=qemu
[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 2 cores
[rustsbi] Kernel entry: 0x80200000
[rustsbi-panic] hart 0 panicked at 'invalid instruction, mepc: 0000000080200000, instruction: 0000000000000000', src/main.rs:459:17
[rustsbi-panic] system shutdown scheduled due to RustSBI panic

请问一下是哪里的问题呢,谢谢

Handle Load/StoreMisalignment Exception in RustSBI manually on k210 platform

Due to the hardware limit of Kendryte k210 chip(it is okay on qemu), when we want to load a 64-bit value in to a general-purpose register(using ld instruction), we have to guarantee that the address is aligned to 8 bytes. However, it is somehow strict so that many librarys do not consider it, leading to some incompatibility(e.g. xmas-elf crate). The same issue may occurs in other instructions, such as lh/lw/sh/sw/sd, but I have not try them yet.

Should we handle them in RustSBI by performing some aligned memory access manually and then merging the results?

xtask size 没实现

看了源码,发现 xtask size 没实现出来

这个 offset 一定得是 0x2000 吗?

0x2000是怎么计算出来的?

我不会写rust,只会看,不然就直接提PR了hhh

另外,大佬再写一个 指定内核project目录,直接生成需要烧写的bin文件咯。(如果内核编译环境 和 烧录环境不是同一个环境,就还要手动合并一次)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.