Linux 如何在buildroot中重建rootfs

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17885451/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-07 00:23:02  来源:igfitidea点击:

how to rebuild rootfs in buildroot

linuxembeddedarmembedded-linuxbuildroot

提问by Yuri

I am going to setup build environment to make my own linux embedded system for AT91SAM9X25 Board. I am using buildroot to do this. The make command build all targets, the first it build toolchain then packages and then rootfs and images of rootfs (tar, cpio ...). To rebuild rootfs I usually use make clean and then make. The make clean command removes all and including toolchain.

我将设置构建环境,为 AT91SAM9X25 板制作我自己的 linux 嵌入式系统。我正在使用 buildroot 来做到这一点。make 命令构建所有目标,首先构建工具链,然后打包,然后是 rootfs 和 rootfs 的图像(tar、cpio ...)。要重建 rootfs,我通常使用 make clean 然后 make。make clean 命令删除所有工具链,包括工具链。

So the first my question is: Is there some way to remake rootfs without building toolchain? It takes a lot of time.

所以我的第一个问题是:有没有办法在不构建工具链的情况下重新制作 rootfs?这需要很多时间。

Also I am building linux kernel within buildroot. I have turned on BR2_LINUX_KERNEL [=y] in buildroot. The linux configured to use Initial RAM filesystem, so to build kernel it required image of rootfs (which should be created by buildroot). When I run make under root of buildroot the building fails with error Cannot open 'buildroot-2013.05/output/images/rootfs.cpio'. Because (if I understand correctly) the building sequence is toolchain - pakages - rootfs - linux kernel - images of rootfs. When it tries to build linux kernel the rootfs.cpio image is not created.

我也在 buildroot 中构建 linux 内核。我在 buildroot 中打开了 BR2_LINUX_KERNEL [=y]。linux 配置为使用初始 RAM 文件系统,因此要构建内核,它需要 rootfs 映像(应由 buildroot 创建)。当我在 buildroot 的根目录下运行 make 时,构建失败并显示错误无法打开“buildroot-2013.05/output/images/rootfs.cpio”。因为(如果我理解正确的话)构建顺序是工具链 - 包 - rootfs - linux 内核 - rootfs 的图像。当它尝试构建 linux 内核时,不会创建 rootfs.cpio 映像。

So the second question is: How to build linux within buildroot if I want to use Initial RAM filesystem?

所以第二个问题是:如果我想使用初始 RAM 文件系统,如何在 buildroot 中构建 linux?

Possibly are there more efficient alternatives than buildroot?

可能有比 buildroot 更有效的替代方案吗?

Thanks in advance.

提前致谢。

回答by sawdust

The make command build all targets

make 命令构建所有目标

You do not want to do that (until Buildroot is configured).
You first need to configure Buildroot by specifying the target board.
Per the manualyou can start from scratch, or create a Buildroot config file for your AT91SAM9X25 board derived from a similar board such as configs/at91sam9g20dfc_defconfig

您不想这样做(直到配置了 Buildroot)。
您首先需要通过指定目标板来配置 Buildroot。
根据手册,您可以从头开始,或者为您的 AT91SAM9X25 板创建一个 Buildroot 配置文件,该文件源自类似的板,例如configs/at91sam9g20dfc_defconfig

Besides the Buildroot config file, you will also need a Linux kernel config file (unless you want to try configuring the kernel from scratch).
The kernel config file for Atmel's eval board with a AT91SAM9x5 is at91sam9x5ek_defconfig

除了 Buildroot 配置文件,您还需要一个 Linux 内核配置文件(除非您想尝试从头开始配置内核)。
带有 AT91SAM9x5 的 Atmel 评估板的内核配置文件是at91sam9x5ek_defconfig

You should also read section 3.4.2. Creating your own board support

您还应该阅读第 3.4.2 节。创建您自己的董事会支持

So the first my question is: Is there some way to remake rootfs without building toolchain? It takes a lot of time.

所以我的第一个问题是:有没有办法在不构建工具链的情况下重新制作 rootfs?这需要很多时间。

The answer depends on how you define "remake rootfs". If you delete the directory output/images/, then the files of the rootfs are rewritten.
If you delete directories in output/build/, then those packages or subsystems are recompiled from source.

答案取决于您如何定义“ remake rootfs”。如果删除目录output/images/,则 rootfs 的文件将被重写。
如果删除 中的目录output/build/,那么这些包或子系统将从源代码重新编译。

If you configure Buildroot to use your own or an external tool chain, then make cleanwould not remove them. If you configure Buildroot to install the toolchain it builds outside of its directory, then it may leave it alone during a make clean.

如果您将 Buildroot 配置为使用您自己的或外部工具链,则make clean不会删除它们。如果您将 Buildroot 配置为在其目录之外安装它构建的工具链,那么它可能会在make clean.

Of course the Buildroot makeis smart enough to know what has changed since the last build and what has to be recompiled.
It should be the rare case that you need to delete directories in output/build/to force recompilation.

当然,Buildrootmake足够聪明,可以知道自上次构建以来发生了什么变化以及必须重新编译什么。
您需要删除目录output/build/以强制重新编译的情况应该很少见。

So the second question is: How to build linux within buildroot if I want to use Initial RAM filesystem?

所以第二个问题是:如果我想使用初始 RAM 文件系统,如何在 buildroot 中构建 linux?

You need to properly configure both Buildroot and the Linux kernel.

您需要正确配置 Buildroot 和 Linux 内核。

make menuconfig
    Filesystem images --->
make linux-menuconfig
    General setup --->
make

More concise information on using Buildroot for AT91SAM9x5 is this Linx4SAM page

关于为 AT91SAM9x5 使用Buildroot 的更简洁信息是这个 Linx4SAM 页面

Possibly are there more efficient alternatives than buildroot?

可能有比 buildroot 更有效的替代方案吗?

There are other tools such as Open Embedded, but describing them as "more efficient" is subjective.

还有其他工具,例如Open Embedded,但将它们描述为“更高效”是主观的。



ADDENDUM

附录

how to rebuild rootfs in buildroot

如何在buildroot中重建rootfs

To force the rootfs to be rebuilt (in this case an initramfs) delete three hidden files in the output/build/linux-x.xx.xxdirectory

要强制重建 rootfs(在本例中为 initramfs),请删除output/build/linux-x.xx.xx目录中的三个隐藏文件

    .stamp_images_installed
    .stamp_initramfs_rebuilt
    .stamp_target_installed

回答by Mike

Rebuild rootfs in buildroot

在 buildroot 中重建 rootfs

  1. View dependencies : make show-targets eg : rootfs-cpio rootfs-tar rootfs-ubi rootfs-ubifs
  2. make rootfs-ubi rebuild // Buildroot will rebuild rootfs-ubi
  1. 查看依赖项:make show-targets 例如:rootfs-cpio rootfs-tar rootfs-ubi rootfs-ubifs
  2. make rootfs-ubi rebuild // Buildroot 将重建 rootfs-ubi