how to rebuild rootfs in buildroot
Asked Answered
P

3

11

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.

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

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.

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

Possibly are there more efficient alternatives than buildroot?

Thanks in advance.

Phew answered 26/7, 2013 at 15:33 Comment(0)
C
13

The make command build all targets

You do not want to do that (until Buildroot is configured).
You first need to configure Buildroot by specifying the target board.
Per the manual you can start from scratch, or create a Buildroot config file for your AT91SAM9X25 board derived from a similar board such as 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

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

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

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.

If you configure Buildroot to use your own or an external tool chain, then make clean would 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.

Of course the Buildroot make is 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.

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

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

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

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

Possibly are there more efficient alternatives than buildroot?

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


ADDENDUM

how to rebuild rootfs in buildroot

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

    .stamp_images_installed
    .stamp_initramfs_rebuilt
    .stamp_target_installed
Countertype answered 26/7, 2013 at 23:12 Comment(5)
Let me rephrase my question regarding building linux kernel within buildroot (could be I explained not clear enough). Buildroot makes: 1.Toolchain -> 2.packages -> 3.Linux kernel -> 4.rootfs images. But, on step 3 (linux kernel) rootfs images are required, because linux configured as use Initial RAM filesystem, but we got it only on step 4. That the problem - I see error message on step 3: there is not rootfs.cpioPhew
"linux configured as use Initial RAM filesystem" -- Is Buildroot also configured for initramfs? The error in step #3 implies you have not configured Buildroot correctly. Your concerns about how Buildroot handles what appears to be a chicken versus egg problem are addressed in the commit description for "add support for initramfs". Essentially Buildroot performs step #3 with an empty initramfs file, and then does an extra step #5 to produce a kernel with the actual initramfs.Countertype
Your answer (i.e. removing the .stamp_xxx files) was very useful for forcing the rebuild of the rootfs. However, I've added extra things to the rootfs with an overlay. When I change to a (slightly) different config without the rootfs overlay, the file from the old overlay is NOT removed from the structure under "target/", or from the final image. I tried deleting the contents of "target" but this caused a build error (it's not a simple build output). Is there a way of cleaning up things which have been removed from the rootfs without doing a full distclean / rebuild?Quanta
@Quanta -- I think there is no alternative to full distclean then rebuild. IIRC it's mentioned in the manual.Countertype
@Countertype Interesting, from this page of the manual: buildroot.org/downloads/manual/manual.html#full-rebuild - Buildroot can't figure out all the possible dependencies, so if a PACKAGE is removed, a clean is needed. BUT, "However, when changes to the root filesystem overlay, a post-build script or a post-image script are made, there is no need for a full rebuild: a simple make invocation will take the changes into account", so changing the rootfs overlay shouldn't require a rebuild... Although I found that it did.Quanta
S
2

Rebuild rootfs in buildroot

  1. View dependencies:
    make show-targets
    
    Example output:
    rootfs-cpio rootfs-tar rootfs-ubi rootfs-ubifs
    
  2. Rebuild the target. Example:
    # Tell buildroot to rebuild `rootfs-ubi`
    make rootfs-ubi rebuild 
    
Selfinterest answered 5/12, 2018 at 2:39 Comment(0)
L
-2

If you only want to regenerate the rootfs partition, do

rm -r output/target && make

This helps, e.g., if you removed files in a rootfs overlay.

Lorollas answered 29/7, 2022 at 8:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.