Tutorial for rCore OS step by step (2nd edition)

Overview

rCore_tutorial

Actions Status

WARNING

This project is no longer maintained, please try Tutorial v3.5.

Documentations

Please read

Prerequisite

You need: rustup installed, ensure ~/.cargo/bin is added to PATH and run:

make env

Quick Try

$ make run
## If everything is OK, then you will see below info:
......
OpenSBI v0.4 (Jul  2 2019 11:53:53)
   ____                    _____ ____ _____
  / __ \                  / ____|  _ \_   _|
 | |  | |_ __   ___ _ __ | (___ | |_) || |
 | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
 | |__| | |_) |  __/ | | |____) | |_) || |_
  \____/| .__/ \___|_| |_|_____/|____/_____|
        | |
        |_|

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

PMP0: 0x0000000080000000-0x000000008001ffff (A)
PMP1: 0x0000000000000000-0xffffffffffffffff (A,R,W,X)
switch satp from 0x8000000000080256 to 0x800000000008119f
++++ setup memory!    ++++
++++ setup interrupt! ++++
available programs in rust/ are:
  .
  ..
  user_shell
  notebook
  greenthread
  hello_world
  model
++++ setup fs!        ++++
++++ setup process!   ++++
++++ setup timer!     ++++
Rust user shell
>>
Comments
  • page fault after upgrading asm! to llvm_asm!

    page fault after upgrading asm! to llvm_asm!

    make run on master branch, and it panicked with:

    Exception(StorePageFault) va = 0xffffffffffffffe8 instruction = 0x1acfe
    panicked at 'page fault!', src/interrupt.rs:76:5
    
    • rust-toolchain = nightly-2020-06-04
    • riscv = 21e32ee In the meanwhile, multicore branch worked normally 15 days ago, but now it failed with page fault too. Given that the only change of it in the last two weeks was the update of riscv crate, so I think there maybe some bugs in it. Actually, I made it work again by rolling back the riscv version to c62af46.
    bug 
    opened by wyfcyx 4
  • K210 porting logs

    K210 porting logs

    Following the step of @wangrunji0408, I want to port the tutorial from Qemu to K210, a RISC-V board which is cheap and simple, as an important part of the fourth edition of tutorial. K210 is based on RISC-V spec 1.9.1, which was published about 4 years ago. So you can hardly find a toolchain or bootloader that fits it perfectly now. For example, OpenSBI 0.4/0.8 don't work normally on K210... About 1 year and a half ago, rjgg tried to port rCore to K210 and succeed in the end. Here is his log. He modified OpenSBI 0.3 in order to support K210, you can find that version here. How to use it to completing porting? It is at a relative ease. First, download the modified OpenSBI, and change the FW_PAYLOAD_ALIGN to 0x200000 since we want to put our kernel to 0x80200000 on memory. Then, merge the OpenSBI image(fw_payload.bin) and our kernel image into a big one using dd tool and finally burn it into flash. Now, chapter 2 can run on K210 successfully. I will create a new branch about porting later.

    enhancement 
    opened by wyfcyx 2
  • kernel panicked on multicore branch

    kernel panicked on multicore branch

    Sometimes kernel panicked when typing commands in the user shell, the following two errors could be found in the panic infomation:

    panicked at 'called `Option::unwrap()` on a `None` value', src/process/processor.rs:100:40
    panicked at 'thread not exist!', src/process/thread_pool.rs:49:31
    

    Maybe there are some bugs in the scheduling module or the thread management module.

    bug 
    opened by wyfcyx 1
  • refactor: replace asm! with llvm_asm! and fix some clippy issues

    refactor: replace asm! with llvm_asm! and fix some clippy issues

    Replace asm! with llvm_asm!

    And fix some clippy issues, but still have some issues for now. I will fix it after this PR and add fmt and clippy CI check.

    opened by hi-rustin 1
  • Remove output of '\0' in lab-8

    Remove output of '\0' in lab-8

    The println!("message received in child process = {}", string); will print ^@ (ascii 0, '\0') as well. The implement of print a Rust string should print all the bytes but not stop until \0.

    Normally the terminal will not display the ^@, but actually it has been written into stdout. But, What's more, the command less will display it. If we write a simple Rust program like this:

    fn main() {
        let mut string = String::from("");
        string.push('A');
        string.push('\0');
        string.push('\0');
        println!("{}", string);
    }
    

    and run cargo run, it will display A. But if we use cargo run | less, it will display A^@^@.

    So if we use less in the test script to show the result, we should not write '\0' into the stdout (actually alloc::string::String is just a vec<u8> and normally will not contain '\0'). Or it will make a confusing display to the students, students will use meaningless time to debug why there's ^@. (macOS terminal displays ^@, some terminal will display something messy like default terminal of Ubuntu)

    Here, I change the script for not display '\0', but keep the transfer of the '\0' in pipe as the end of transfer.

    opened by LyricZhao 1
  • Fix: 编译新的用户程序,生成的OS镜像没能及时更新

    Fix: 编译新的用户程序,生成的OS镜像没能及时更新

    现在版本的build.rs存在这样的问题:在不改变USER_IMG环境变量的前提下,更新usr/build下的用户程序.img,并不能使得内核镜像中的用户程序一起更新。这是因为build.rs生成的link_user.S本身没有发生改变,按照Rust增量更新机制,打包进可执行文件的数据也不会变。如果在生成代码时加入与编译时间有关的信息,就可以解决这一问题。

    opened by rzswh 1
  • 添加了docker支持,能够自己制作镜像或从远端拉取

    添加了docker支持,能够自己制作镜像或从远端拉取

    参考之前在step_by_step项目中的做法,添加了新的Makefile 运行make docker将会查看本地是否存在镜像panqinglin/tutorial,不存在则从远端拉取,运行docker镜像之后将当前代码目录挂载到镜像内的/mnt目录 同时支持自己修改Dockerfile来修改docker镜像内容,默认情况下make build_docker将在本地生成panqinglin/tutorial镜像,与云端一致。

    opened by PanQL 0
  • Fix commit id mismatch between user and os DIRs.

    Fix commit id mismatch between user and os DIRs.

    The commit id (c611248) of rcore-fs-fuse installed by cargo in usr/Makefile isn't match the commit id (d8d61190) of rcore-fs rcore-fs-sfs in os/Cargo.toml.

    So, got the error running messages:

    available programs in rust/ are: panicked at 'failed to open SFS: WrongFs', src/libcore/result.rs:1189:5

    You need to delete ~/.cargo/bin/rcore-fs-fuse, and rebuild rcore-fs-fuse by 'make rcore-fs-fuse', then 'make user_img'

    opened by chyyuu 0
  •     Fix commit id mismatch between user and os DIRs.

    Fix commit id mismatch between user and os DIRs.

    The commit id (c611248) of rcore-fs-fuse installed by cargo in usr/Makefile  isn't match the commit id (d8d61190) of rcore-fs rcore-fs-sfs in os/Cargo.toml.
    
    So, got the error running messages:
    
    available programs in rust/ are:
    panicked at 'failed to open SFS: WrongFs', src/libcore/result.rs:1189:5
    
    You need to delete ~/.cargo/bin/rcore-fs-fuse, and rebuild rcore-fs-fuse by 'make rcore-fs-fuse', then 'make user_img'
    
    opened by chyyuu 0
Owner
rCore OS
THU Rust operating system workshop. (mirror: https://gitee.com/rcore-os)
rCore OS
RCore-Tutorial-v3 - Let's write an OS which can run on RISC-V in Rust from zero!

rCore-Tutorial-v3 rCore-Tutorial version 3.5. See the Documentation in Chinese. Official QQ group number: 735045051 news 2021.11.20: Now we are updati

rCore OS 786 Jan 2, 2023
Tutorial for rCore OS step by step (3rd edition)

rCore-Tutorial V3(开发中) 本教学仓库是继 rCore_tutorial V2 后重构的 V3 版本。 本文档的目标主要针对「做实验的同学」,我们会对每章结束后提供完成的代码,你的练习题只需要基于我们给出的版本上增量实现即可,不需要重新按照教程写一遍。 而对想完整实现一个 rCor

rCore OS 419 Dec 30, 2022
A comprehensive and FREE Online Rust hacking tutorial utilizing the x64, ARM64 and ARM32 architectures going step-by-step into the world of reverse engineering Rust from scratch.

FREE Reverse Engineering Self-Study Course HERE Hacking Rust A comprehensive and FREE Online Rust hacking tutorial utilizing the x64, ARM64 and ARM32

Kevin Thomas 98 Jun 21, 2023
RCore-Tutorial-v3 - Let's write an OS which can run on RISC-V in Rust from zero!

rCore-Tutorial-v3 rCore-Tutorial version 3.5. See the Documentation in Chinese. Official QQ group number: 735045051 news 2021.11.20: Now we are updati

rCore OS 786 Jan 2, 2023
A Minecraft Java Edition to Bedrock Edition resource pack convertor in Rust

j2be A Minecraft Java Edition to Bedrock Edition resource pack convertor in Rust How to use Note: This project is still in development Run cargo build

Cqdet 11 Sep 15, 2021
Easy c̵̰͠r̵̛̠ö̴̪s̶̩̒s̵̭̀-t̶̲͝h̶̯̚r̵̺͐e̷̖̽ḁ̴̍d̶̖̔ ȓ̵͙ė̶͎ḟ̴͙e̸̖͛r̶̖͗ë̶̱́ṉ̵̒ĉ̷̥e̷͚̍ s̷̹͌h̷̲̉a̵̭͋r̷̫̊ḭ̵̊n̷̬͂g̵̦̃ f̶̻̊ơ̵̜ṟ̸̈́ R̵̞̋ù̵̺s̷̖̅ţ̸͗!̸̼͋

Rust S̵̓i̸̓n̵̉ I̴n̴f̶e̸r̵n̷a̴l mutability! Howdy, friendly Rust developer! Ever had a value get m̵̯̅ð̶͊v̴̮̾ê̴̼͘d away right under your nose just when

null 294 Dec 23, 2022
R1cs-tutorial - Tutorial for writing constraints in the `arkworks` framework

Introduction to SNARK Development with `arkworks` In this tutorial, we will learn how to write applications for use with state-of-the-art zkSNARKs usi

arkworks 113 Dec 29, 2022
As part of the IOP Stack™ Morpheus is a toolset to have gatekeeper-free identity management and verifiable claims as a 2nd layer on top of a blockchain

Internet of People Internet of People (IoP) is a software project creating a decentralized software stack that provides the building blocks and tools

We are building a complete decentralized ecosystem with the IOP Stack™ 9 Nov 4, 2022
Original source code for Practical Rust Projects 2nd ed. by Shing Lyu and Andrew Rzeznik

Apress Source Code This repository accompanies Practical Rust Projects 2nd ed. by Shing Lyu and Andrew Rzeznik (Apress, 2023). Download the files as a

Apress 6 Aug 13, 2023
An easy file system based on eazy-fs of rcore.

fs-rs An easy mixed index file system based on eazy-fs of rcore. Usage if you don't have rust environment, you can download rust by: curl https://sh.r

Clstilmldy 9 Dec 21, 2022
Angolmois BMS player, Rust edition

Angolmois Rust Edition This is a direct, one-to-one translation of Angolmois to Rust programming language. Angolmois is a BM98-like minimalistic music

Kang Seonghoon 95 Oct 20, 2022
Eclipse Corrosion - Rust edition in Eclipse IDE

Eclipse Corrosion Rust edition and debug in Eclipse IDE Corrosion is a Rust development plugin for the Eclipse IDE, providing a rich edition experienc

Eclipse Foundation 194 Dec 23, 2022
Reviving the Research Edition Unix speak command

This repository contains the source code of Unix speak program that appeared in the Third (1973) to Sixth (1975) Research Unix editions, slightly adjusted to run on a modern computer. Details on the code's provenance and the methods employed for reviving it can be found in this blog post.

Diomidis Spinellis 31 Jul 27, 2022
Code and Development environment for adventofcode.com - 2021 edition

aoc-2021 Warning Spoiler Alert! If you want to solve the aoc problems on your own, do not read any further. This repository contains solutions for the

docToolchain 11 Oct 22, 2022
My solutions for the 2021 edition of the Advent of Code, using Rust and SOM (Simple Object Machine)

Advent of Code 2021 These are my solutions for the 2021 edition of the Advent of Code. The solutions are all implemented using both Rust and SOM (Simp

Nicolas Polomack 1 Dec 23, 2021
CosmWasm implementation for limited edition, fixed-price NFTs

CW721 Editions This contract enables the creation of limited edition fixed price NFTs according to the cw721 token standard. Instantiation To instanti

Vernon Johnson 4 Oct 5, 2022
This repository contains the Rust source code for the algorithms in the textbook Algorithms, 4th Edition

Overview This repository contains the Rust source code for the algorithms in the textbook Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.

chuan 549 Dec 26, 2022
Rust crate to implement a counterpart to the PBRT book's (3rd edition) C++ code.

Rust crate to implement a counterpart to the PBRT book's (3rd edition) C++ code.

Jan Walter 763 Dec 27, 2022
Wasmcraft a compiler from WebAssembly to Minecraft Java Edition datapacks

Wasmcraft is a compiler from WebAssembly to Minecraft Java Edition datapacks. Since WebAssembly is a well-supported target for many languages, this means that you can run code written in e.g. C in Minecraft.

null 64 Dec 23, 2022
The Polkadot Hackathon Global Series North America edition is the second in a series of hackathons that brings the cutting edge of blockchain to a global community.

Polkadot Hackathon Project We are translating Uniswap v2 to Ink. Dependencies Install cargo-contract for building Ink contracts: cargo install dylint-

Kristiyan Dilov 3 Jun 28, 2022