从零构建 RISC-V 模拟器与 Linux 系统
RISC-V Emulator and Linux System from Scratch

原始链接: https://github.com/WerWolv/riscv-emulator

此仓库包含跟随博客 https://werwolv.net/posts/linux_bringup/ 所需的所有源代码。 /lib 包含完整的 rv32ima 指令集模拟器代码以及一组最小化的模拟设备。 /main 包含机器配置和为 WebAssembly 使用而暴露的函数。 构建 Linux 所需的所有配置文件均位于 /boot 目录下。主可执行文件也要求所有构建出的二进制文件存放在 boot 文件夹中。 riscv32-unknown-linux-gnu.config 是 crosstool-ng 工具链的配置文件。 riscv_emulator_defconfig 是 Linux 内核的配置文件。 device_tree.dts 是最小化的设备树。可以使用 `dtc -I dts -O dtb device_tree.dts -o device_tree.dtb` 编译为 dtb。 init.c 是初始化程序。可以使用 `riscv32-unknown-linux-gnu-gcc -static init.c -o init` 编译。 initramfs.txt 是用于生成 initramfs 的 gen_init_cpio 配置文件。可以使用 `usr/gen_init_cpio initramfs.txt -o initramfs.cpio` 编译为 cpio。

```Hacker News 新闻 | 往期 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 从零开始构建 RISC-V 模拟器与 Linux 系统 (github.com/werwolv) 8 点,由 Bluestein 发布于 2 小时前 | 隐藏 | 往期 | 收藏 | 2 条评论 帮助 artemonster 0 分钟前 | 下一条 [–] // 将 Linux 内核加载到内存起始位置 ram.write(0x00, LinuxKernel); 回复 kvemkon 21 分钟前 | 上一条 [–] 对应博文的讨论:https://news.ycombinator.com/item?id=49553988 回复 准则 | 常见问题 | 列表 | API | 安全 | 法律 | 加入 YC | 联系 搜索: ```
相关文章

原文

This repo contains all the source code required to follow the blog post at https://werwolv.net/posts/linux_bringup/

  • /lib contains the entire rv32ima instruction set emulator code as well as a minimal set of emulated devices
  • /main contains the configuration for our machine and functions exposed for WebAssembly use

All the config files required to build Linux can be found in /boot. The main executable also expects all the built binaries to be in the boot folder.

  • riscv32-unknown-linux-gnu.config is the crosstool-ng toolchain config file
  • riscv_emulator_defconfig is the Linux Kernel config file
  • device_tree.dts is the minimal device tree
    • Can be compiled to a dtb using dtc -I dts -O dtb device_tree.dts -o device_tree.dtb
  • init.c is the init program
    • Can be compiled using riscv32-unknown-linux-gnu-gcc -static init.c -o init
  • initramfs.txt is the gen_init_cpio config file to generate the initramfs
    • Can be compiled to a cpio using usr/gen_init_cpio initramfs.txt -o initramfs.cpio
联系我们 contact @ memedata.com