RISC-V Linux系统rootfs制作

文章目录

buildroot 是一个构建嵌入式Linux系统的框架。整个 buildroot 是由Makefile(*.mk) 脚本和 Kconfig(Config.in) 配置文件构成的,因此可以像配置 Linux 内核一样执行 make menuconfig 进行配置,编译出一个完整的、可以直接烧写到机器上运行的 Linux 系统文件(包含 bootloader、kernel、rootfs 以及 rootfs 中的各种库和应用程序)。

文件系统可以用 busybox、buildroot 等工具制作,busybox 需要自己一步一步的做出来,过程比较麻烦。更便捷的做法是使用 buildroot,它可以自动帮我们完成。

1、下载

官网:https://buildroot.org/download.html

历史版本下载:https://buildroot.org/downloads

shell 复制代码
$ wget https://buildroot.org/downloads/buildroot-2023.02.1.tar.gz
$ tar -zxvf buildroot-2023.02.1.tar.gz
$ cd buildroot-2023.02.1

2、配置与编译

  • 安装依赖
shell 复制代码
$ sudo apt-get -y install build-essential libncurses-dev cpio rsync file unzip bc
  • 配置buildroot
shell 复制代码
$ make menuconfig
  1. 选择RISC-V架构
shell 复制代码
Target options --->
    Target Architecture (i386) --->
        (X) RISCV

Target Architecture Size (64-bit)
  1. 选择ext文件系统类型:
shell 复制代码
Filesystem images --->
    [*] ext2/3/4 root filesystem
        ext2/3/4 variant (ext4)
  • 编译
shell 复制代码
$ make -j10

buildroot 编译过程需要联网,在线下载交叉编译器和各种工具。

编译完后,生成文件在 output/images 目录下,rootfs.ext2 是我们需要用到的。

3、运行

shell 复制代码
#!/bin/sh

qemu-system-riscv64 \
-M virt \
-bios opensbi/build/platform/generic/firmware/fw_jump.elf \
-kernel linux-5.10.181/arch/riscv/boot/Image \
-append "rootwait root=/dev/vda ro" \
-drive file=buildroot-2023.02.1/output/images/rootfs.ext2,format=raw,id=hd0 \
-device virtio-blk-device,drive=hd0 \
-netdev user,id=net0 -device virtio-net-device,netdev=net0 -nographic
相关推荐
虚伪的空想家8 分钟前
k8s集群configmap和secrets备份脚本
linux·容器·kubernetes
the sun3417 分钟前
从 QEMU 直接启动到 U-Boot 引导:嵌入式 Linux 启动流程的本质差异
linux·运维·服务器
草莓熊Lotso27 分钟前
【Linux 线程进阶】进程 vs 线程资源划分 + 线程控制全详解
java·linux·运维·服务器·数据库·c++·mysql
ShineWinsu33 分钟前
对于Linux:文件操作以及文件IO的解析
linux·c++·面试·笔试·io·shell·文件操作
-SGlow-33 分钟前
Linux相关概念和易错知识点(52)(基于System V的信号量和消息队列)
linux·运维·服务器
江畔何人初35 分钟前
TCP的三次握手与四次挥手
linux·服务器·网络·网络协议·tcp/ip
Trouvaille ~1 小时前
【MySQL篇】数据库操作:从创建到管理
linux·数据库·mysql·oracle·xshell·ddl
酸钠鈀1 小时前
AI WB2 SDK Ubuntu 环境搭建
linux·运维·ubuntu
Robot_Nav1 小时前
双系统Linux死机解决方法
linux·运维·服务器
加勒比之杰克1 小时前
从阻塞 IO 到 epoll:把 Linux 网络 IO 一次讲透
linux·网络·windows·select·多路转接·epoll·poll