2 Star 7 Fork 6

rcore-os / zCore

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

zCore

CI Docs Coverage Status issue forks stars license

基于 zircon 并提供 Linux 兼容性的操作系统内核。

原版README

Reimplement Zircon microkernel in safe Rust as a userspace program!

  • zCore设计架构概述
  • 支持bare-metal模式的Zircon & Linux
  • 支持libos模式的Zircon & Linux
  • 支持的图形应用程序等更多指导请查看原版README文档

启动内核

cargo qemu --arch riscv64

这个命令会使用 qemu-system-riscv64 启动 zCore。

默认的文件系统中将包含 busybox 应用程序和 musl-libc 链接器。它们是用自动下载的 musl-libc RISC-V 交叉编译工具链编译的。

目录

项目构建

项目构建采用 xtask 模式,常用操作被封装成 cargo 命令。

另外,还通过 Makefile 提供 make 调用,以兼容一些旧脚本。

目前已测试的开发环境包括 Ubuntu20.04、Ubuntu22.04 和 Debian11,Ubuntu22.04 不能正确编译 x86_64 的 libc 测试。若不需要烧写到物理硬件,使用 WSL2 或其他虚拟机的操作与真机并无不同之处。

构建命令

命令的基本格式为 cargo <command> [--args [value]],这实际上是 cargo run --package xtask --release -- <command> [--args [value]] 的简写。command 被传递给 xtask 应用程序,解析并执行。

许多命令的效果受到仓库环境的影响,也会影响仓库的环境。为了使用方便,如果一个命令依赖于另一个命令的效果,它们被设计为递归的。命令的递归关系图如下,对于它们的详细解释在下一节:


NOTICE 建议使用等宽字体


┌────────────┐ ┌─────────────┐ ┌─────────────┐
| update-all | | check-style | | zircon-init |
└────────────┘ └─────────────┘ └─────────────┘
┌─────┐ ┌──────┐  ┌─────┐  ┌─────────────┐ ┌─────────────────┐
| asm | | qemu |─→| bin |  | linux-libos | | libos-libc-test |
└─────┘ └──────┘  └─────┘  └─────────────┘ └─────────────────┘
                     |            └───┐┌─────┘   ┌───────────┐
                     ↓                ↓↓      ┌──| libc-test |
                 ┌───────┐        ┌────────┐←─┘  └───────────┘
                 | image |───────→| rootfs |←─┐ ┌────────────┐
                 └───────┘        └────────┘  └─| other-test |
                 ┌────────┐           ↑         └────────────┘
                 | opencv |────→┌───────────┐
                 └────────┘  ┌─→| musl-libc |
                 ┌────────┐  |  └───────────┘
                 | ffmpeg |──┘
                 └────────┘
-------------------------------------------------------------------
图例:A 递归执行 B(A 依赖 B 的结果,执行 A 时自动先执行 B)
┌───┐  ┌───┐
| A |─→| B |
└───┘  └───┘

命令参考

如果下面的命令描述与行为不符,或怀疑此文档更新不及时,亦可直接查看内联文档。 如果发现 error: no such subcommand: ...,查看命令简写为哪些命令设置了别名。


NOTICE 内联文档也是中英双语


update-all

更新工具链、依赖和 git 子模块。

如果没有递归克隆子模块,可以使用这个命令克隆。

cargo update-all

check-style

静态检查。设置多种编译选项,检查代码能否编译。

cargo check-style

zircon-init

下载 zircon 模式所需的二进制文件。

cargo zircon-init

asm

反汇并保存编指定架构的内核。默认保存到 target/zcore.asm

cargo asm -m virt-riscv64 -o z.asm

bin

生成内核 raw 镜像到指定位置。默认输出到 target/{arch}/release/zcore.bin

cargo bin -m virt-riscv64 -o z.bin

qemu

在 Qemu 中启动 zCore。这需要 Qemu 已经安装好了。

cargo qemu --arch riscv64 --smp 4

支持将 qemu 连接到 gdb:

cargo qemu --arch riscv64 --smp 4 --gdb 1234

rootfs

重建 Linux rootfs。直接执行这个命令会清空已有的为此架构构造的 rootfs 目录,重建最小的 rootfs。

cargo rootfs --arch riscv64

musl-libs

将 musl 动态库拷贝到 rootfs 目录对应位置。

cargo musl-libs --arch riscv64

ffmpeg

将 ffmpeg 动态库拷贝到 rootfs 目录对应位置。

cargo ffmpeg --arch riscv64

opencv

将 opencv 动态库拷贝到 rootfs 目录对应位置。如果 ffmpeg 已经放好了,opencv 将会编译出包含 ffmepg 支持的版本。

cargo opencv --arch riscv64

libc-test

将 libc 测试集拷贝到 rootfs 目录对应位置。

cargo libc-test --arch riscv64

other-test

将其他测试集拷贝到 rootfs 目录对应位置。

cargo other-test --arch riscv64

image

从 rootfs 目录构建 Linux rootfs 镜像文件。

cargo image --arch riscv64

linux-libos

在 linux libos 模式下启动 zCore 并执行位于指定路径的应用程序。

NOTICE libos 模式只能执行单个应用程序,完成就会退出。

cargo linux-libos --args "/bin/busybox"

可以直接给应用程序传参数:

cargo linux-libos --args "/bin/busybox ls"

平台支持

Qemu/virt

直接使用命令启动,参见启动内核qemu 命令

全志/哪吒

使用以下命令构造系统镜像:

cargo bin -m nezha -o z.bin

然后使用 rustsbi-d1 将镜像部署到 Flash 或 DRAM。

另: 可以查看README for D1 文档获知更多D1开发板有关的操作指导。

赛昉/星光

使用以下命令构造系统镜像:

cargo bin -m visionfive -o z.bin

然后根据此文档的详细说明通过 u-boot 网络启动系统。

晶视/cr1825

使用以下命令构造系统镜像:

cargo bin -m cr1825 -o z.bin

然后通过 u-boot 网络启动系统。

其他

MIT License Copyright (c) 2019-2020 rCore Developers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

Reimplement Zircon microkernel in safe Rust as a userspace program! 展开 收起
Rust 等 5 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/rcore-os/zCore.git
git@gitee.com:rcore-os/zCore.git
rcore-os
zCore
zCore
master

搜索帮助