BusyBox 构建 RISC-V Linux 根文件系统 rootfs 示例

BusyBox 构建 RISC-V Linux 根文件系统 rootfs 示例

flyfish

安装工具

sudo apt install libc6-riscv64-cross
sudo apt install binutils-riscv64-linux-gnu
sudo apt install gcc-riscv64-linux-gnu

下载地址

git clone https://git.busybox.net/busybox

配置

CROSS_COMPILE=riscv64-linux-gnu- make menuconfig

在这里插入图片描述
在这里插入图片描述
编译

CROSS_COMPILE=riscv64-linux-gnu- make -j $(nproc)
CROSS_COMPILE=riscv64-linux-gnu- make install

在这里插入图片描述
结果
在这里插入图片描述

在这里插入图片描述

根据下面的桌面Linux 增加些文件夹

在这里插入图片描述

mkdir  dev  etc  home  lib   mnt  proc  root   sys  tmp   var 
mkdir  etc/init.d

在etc/init.d/目录下建立 rcS文件

touch rcS

内容如下

#!/bin/sh
mount -t proc none /proc
mount -t sysfs none /sys
/sbin/mdev -s

在这里插入图片描述建立镜像

qemu-img create rootfs.img  4g
mkfs.ext4 rootfs.img

在这里插入图片描述

开始构建

mkdir rootfs
sudo mount -o loop rootfs.img  rootfs
cd rootfs
sudo cp -r ../busybox/_install/* .
sudo umount rootfs

_install里的文件会全部写入 rootfs.img
在这里插入图片描述

测试
使用这里构建的QEMU
使用这里构建的Linux内核

qemu-system-riscv64 -M virt -m 512M -nographic -kernel riscv64-linux/Linux/arch/riscv/boot/Image -drive file=rootfs.img,format=raw,id=hd0  -device virtio-blk-device,drive=hd0 -append "root=/dev/vda rw console=ttyS0"

运行结果

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

二分掌柜的

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值