内核测试-使用 Buildroot 创建根文件系统

📅9/23/2021, 12:00:00 AM

为了让编译好的内核跑起来,我们需要为其构建一个根文件系统。

第三篇,我们要使用 QEMU 模拟 AArch64 架构。

安装 Buildroot

  1. 在其官网下载。
  2. 解压,即可使用。

在 Buildroot 中,我们要关注的是目录 ./output/images,新生成的根文件系统正是保存于此。

使用 Buidroot 的过程类似于编译内核,依旧是这三步

  1. defconfig
  2. menuconfig
  3. make

defconfig

defconfig 的作用可参考编译内核

Buildroot 的 configs/ 目录下存放着诸多的 defconfig,从中挑选适合目标机器架构的即可。

我们要使用 QEMU 来进行 aarch64 架构的模拟,于是使用 qemu_aarch64_virt_defconfig 作为 defconfig。

make qemu_aarch64_virt_defconfig

Target

首先检查,

Target options
|---Target Architecture(**AArch64**)

这时目标架构为 AArch64,说明第一步的 defconfig 成功。

Kernel

因为我们有编译好的内核,所以取消编译内核:

Kernel
|---Linux Kernel[ ]

Build options

更换软件源,只将 GNU 软件的源更换即可:

Build options
|----Mirrors and Download locations
       |----(http://mirrors.nju.edu.cn/gnu/)GNU Software mirror

Filesystem images

选择要制作的根文件系统镜像类型,我在这里额外选了 cpio the root filesystem.

Filesystem images
|----[*]**cpio the root filesystem**
|----[*]ext2/3/4 root filesystem

Save--->Exit 即可。

make

最后一步,执行 make。

制成的根文件系统镜像会存放在 ./output/images 目录下。

总结

Buildroot 制作根文件系统的步骤与编译内核很相似,首先 defconfig,然后 menuconfig,最后 make。

This 

post

 by Yingjie Shang is licensed under 

CC BY 4.0