{"id":13667956,"url":"https://github.com/storage-db/nerdos","last_synced_at":"2025-04-26T18:31:04.854Z","repository":{"id":109017315,"uuid":"582937162","full_name":"storage-db/nerdos","owner":"storage-db","description":"一种支持多种架构嵌入式领域的实时操作系统，支持网络通信和grub启动","archived":false,"fork":false,"pushed_at":"2023-06-13T03:56:02.000Z","size":22034,"stargazers_count":65,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-11T03:35:37.333Z","etag":null,"topics":["aarch64","riscv","rtos","x86-64"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/storage-db.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-12-28T09:35:00.000Z","updated_at":"2024-07-26T14:49:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"feb50497-19f8-49b2-a136-1203fef46d38","html_url":"https://github.com/storage-db/nerdos","commit_stats":null,"previous_names":["storage-db/nerdos"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/storage-db%2Fnerdos","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/storage-db%2Fnerdos/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/storage-db%2Fnerdos/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/storage-db%2Fnerdos/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/storage-db","download_url":"https://codeload.github.com/storage-db/nerdos/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251035333,"owners_count":21526348,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aarch64","riscv","rtos","x86-64"],"created_at":"2024-08-02T07:00:55.913Z","updated_at":"2025-04-26T18:30:59.837Z","avatar_url":"https://github.com/storage-db.png","language":"Rust","readme":"# NerdOS\n\n![logo](https://raw.githubusercontent.com/pluveto/0images/master/2023/01/upgit_20230125_1674617889.png)\n\nA hobbyist operating system written in Rust based on [equation314/nimbos](https://github.com/equation314/nimbos).\n\n## TODO\n\n- [x] Net driver\n- [ ] CFS scheduler (I found the rbt implementation but cfs is still a bit difficult and takes time)\n- [ ] message queue\n- [x] k210 support\n- [x] Grub start\n\n## Development Environment\n\n1. Clone the repository\n\n    ```sh\n    git clone https://github.com/cargo-youth/nerdos\n    ```\n\n2. Switch `rust` toolchain to nightly\n\n    ```sh\n    rustup install nightly\n    rustup default nightly\n    ```\n\n3. Install packages\n\n    ```sh\n    sudo apt install autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev \\\n              gawk build-essential bison flex texinfo gperf libtool patchutils bc \\\n              zlib1g-dev libexpat-dev pkg-config  libglib2.0-dev libpixman-1-dev libsdl2-dev \\\n              git tmux python3 python3-pip ninja-build\n    ```\n\n    for arch linux\n\n    ```sh\n    packages=(\n        # ninja\n        ninja autoconf automake libmpc gawk bison flex texinfo \\\n        gperf libtool patchutils bc expat glib2 pixman sdl2 \\\n        python libbpf cmake cargo-binutils\n    )\n    sudo pacman -S --needed \"${packages[@]}\"\n    ```\n\n4. Install `qemu`\n\n    ```sh\n    mkdir kit # Here we create a directory in the project root to store the tools\n    pushd kit\n    wget https://download.qemu.org/qemu-7.2.0.tar.xz\n    tar -xf qemu-7.2.0.tar.xz\n    cd qemu-7.2.0\n    ./configure --target-list=x86_64-softmmu,aarch64-softmmu,riscv64-softmmu,i386-softmmu --enable-debug\n    make -j$(nproc)\n    popd\n    ```\n\n    And then add the following line to your `~/.bashrc`:\n\n    ```sh\n    export PATH=$PATH:/\u003cpath_to_kit\u003e/qemu-7.0.0/build\n    ```\n\n    Here `\u003cpath_to_kit\u003e` is the path to the `kit` directory. For example `/home/pluveto/workspace/playground/nerdos/kit/qemu-7.0.0/build`\n\n5. Install `musl`\n\n    Select your target architecture from [musl.cc](https://musl.cc/).\n\n    ```sh\n    pushd kit\n    wget https://musl.cc/x86_64-linux-musl-cross.tgz\n    tar -xf x86_64-linux-musl-cross.tgz\n    popd\n    ```\n\n    And then add the following line to your `~/.bashrc`:\n\n    ```sh\n    export PATH=$PATH:/path_to_kit/x86_64-linux-musl-cross/bin\n    ```\n\n    Here `path_to_kit` is the path to the `kit` directory. For example `/home/pluveto/workspace/playground/nerdos/kit/x86_64-linux-musl-cross/bin`\n\n6. Test `qemu` and `musl`\n\n    Restart your terminal and run the following commands:\n\n    ```sh\n    qemu-system-x86_64 --version\n    x86_64-linux-musl-gcc --version\n    ```\n\n## Build \u0026 Run (in QEMU)\n\n```sh\ncd kernel\nmake env\nmake run ARCH=x86_64 LOG=warn\n# or \nmake run ARCH=riscv64 LOG=warn\n# or\nmake run ARCH=aarch64 LOG=warn\n```\n\nIf you encounter any problems, try add a `VERBOSE=1` to the `make SOMETHING` command.\n\n```sh\nmake run VERBOSE=1\n```\n\n## Troubleshooting\n\n1. `make run` fails with `error: linker 'x86_64-linux-musl-gcc' not found`\n\n    This is because the `x86_64-linux-musl-gcc` is not in your `PATH`. Or failed to build the musl toolchain.\n\n1. `make run` fails with `Could not access KVM kernel module: No such file or directory`\n\n    This is because you don't have KVM enabled. Try to enable it in your BIOS.\n\n    Or try to run the following command:\n\n    ```sh\n    sudo modprobe kvm-intel\n    ```\n\n    If it shows `modprobe: ERROR: could not insert 'kvm_intel': Operation not supported`, then you don't have KVM enabled. Try to enable it or switch to another architecture.\n\n1. `make run` fails with `riscv64-linux-musl-gcc: No such file or directory`\n\n    This is because you don't have the riscv64 musl toolchain installed. Try to install it with the following command:\n\n    ```sh\n    pushd kit\n    wget https://musl.cc/riscv64-linux-musl-cross.tgz\n    tar -xf riscv64-linux-musl-cross.tgz\n    popd\n    ```\n\n    And then add the following line to your `~/.bashrc`:\n\n    ```sh\n    export PATH=$PATH:/path_to_kit/riscv64-linux-musl-cross/bin\n    ```\n\n    Here `path_to_kit` is the path to the `kit` directory. For example `/home/pluveto/workspace/playground/nerdos/kit/riscv64-linux-musl-cross/bin`\n\n2. ` install qemu ` fails with ` gcc version is too low `(centos) .Try to update it with the following command:\n\n    ```sh\n    yum install centos-release-scl\n    scl enable devtoolset-8 bash\n    ```\n\n    And then you can check its version by  running  the following commands:\n\n    ```sh\n    gcc -v\n    ```\n\n## Code tree guide (Take riscv as an example)\n\n```text\n    |-- arch(arch related)\n|   |-- aarch64\n|   |   |-- config.rs\n|   |   |-- context.rs\n|   |   |-- instructions.rs\n|   |   |-- mod.rs\n|   |   |-- page_table.rs\n|   |   |-- percpu.rs\n|   |   |-- trap.rs\n|   |   `-- trap.S\n|   |-- mod.rs\n|   |-- riscv(riscv architecture related)\n|   |   |-- config.rs(configuration files, kernel and user address space settings, and the sv39 paging mechanism)\n|   |   |-- context.rs(Context related Registers and Processing Logic)\n|   |   |-- instructions.rs\n|   |   |-- macros.rs\n|   |   |-- mod.rs\n|   |   |-- page_table.rs (page mechanism)\n|   |   |-- percpu.rs\n|   |   |-- trap.rs (trap logic processing)\n|   |   `-- trap.S (trap assembly logic)\n|   `-- x86_64\n|       |-- config.rs\n|       |-- context.rs\n|       |-- gdt.rs\n|       |-- idt.rs\n|       |-- instructions.rs\n|       |-- mod.rs\n|       |-- page_table.rs\n|       |-- percpu.rs\n|       |-- syscall.rs\n|       |-- syscall.S\n|       |-- trap.rs\n|       `-- trap.S\n|-- drivers\n|   |-- interrupt\n|   |   |-- apic.rs\n|   |   |-- gicv2.rs\n|   |   |-- i8259_pic.rs\n|   |   |-- mod.rs\n|   |   `-- riscv_intc.rs (riscv interrupt processing related)\n|   |-- misc\n|   |   |-- mod.rs\n|   |   |-- psci.rs\n|   |   |-- qemu_x86_reset.rs\n|   |   `-- sbi.rs (sbi support)\n|   |-- mod.rs\n|   |-- timer (clock)\n|   |   |-- arm_generic_timer.rs\n|   |   |-- mod.rs\n|   |   |-- riscv.rs (riscv clock setting)\n|   |   |-- x86_common.rs\n|   |   |-- x86_hpet.rs\n|   |   `-- x86_tsc.rs\n|   `-- uart\n|       |-- mod.rs\n|       |-- pl011.rs\n|       |-- riscv.rs (Input and output in riscv)\n|       `-- uart16550.rs\n|-- mm (address space)\n|   |-- address.rs (physical/virtual)\n|   |-- frame_allocator.rs (Physical Page Frame Allocator)\n|   |-- heap_allocator.rs (kernel dynamic memory allocation)\n|   |-- memory_set.rs  (introducing address spaces and logical segments, etc.)\n|   |-- mod.rs (mm initialization method)\n|   |-- paging.rs (Page table abstraction and other content such as establishing and dismantling mapping relationship unmap and map)\n|   `-- uaccess.rs\n|-- platform\n|   |-- config.rs\n|   |-- mod.rs\n|   |-- pc\n|   |   |-- mod.rs\n|   |   |-- multiboot.rs\n|   |   `-- multiboot.S\n|   |-- qemu_virt_arm\n|   |   `-- mod.rs\n|   `-- qemu_virt_riscv\n|       `-- mod.rs\n|-- sync (synchronous mutex module)\n|   |-- lazy_init.rs\n|   |-- mod.rs\n|   |-- mutex.rs (todo)\n|   |-- percpu.rs\n|   `-- spin.rs\n|-- syscall\n|   |-- fs.rs (sys_read\u0026sys_write)\n|   |-- mod.rs (syscall dispatch processing)\n|   |-- task.rs (sys_getpid/fork/exec/waitpid/exit/clone)\n|   `-- time.rs (current_time)\n|-- task\n|   |-- manager.rs  (task manager)\n|   |-- mod.rs\n|   |-- schedule (rr scheduling, and then we need to implement cfs scheduling)\n|   |   |-- mod.rs\n|   |   `-- round_robin.rs\n|   |-- structs.rs (task related status)\n|   `-- wait_queue.rs \n`-- utils\n    |-- allocator.rs\n    |-- irq_handler.rs\n    |-- mod.rs\n    |-- ratio.rs\n    `-- timer_list.rs\n|-- config.rs (Configuration related includes memory size, cpu number, scheduling related)\n|-- lang_items.rs (panic processing logic)\n|-- loader.rs (app loads memory and manages it)\n|-- logging.rs (multi-level log and color output)\n|-- main.rs (main function)\n|-- timer.rs\n|-- percpu.rs   (cpu logic)\n```\n","funding_links":[],"categories":["Rust"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstorage-db%2Fnerdos","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstorage-db%2Fnerdos","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstorage-db%2Fnerdos/lists"}