Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

openwrt buildroot build_dir and staging_dir

Tags:

openwrt

I am confused about build_dir and staging_dir in openwrt buildroot. What are they used for?

There are feeds in openwrt. I would imagine to build an image. You will select the packages you want in menuconfig and use make to build it.

The packages are fetched from feeds and then compiled into build_dir?

Then what is staging_dir used for?

like image 273
dudeking Avatar asked Sep 25 '14 04:09

dudeking


People also ask

Does OpenWRT use Buildroot?

OpenWRT is based on Buildroot, just as Ubuntu is based on Debian. While the two projects share code, OpenWRT focuses on routers and the like, whereas buildroot is just a general purpose toolchain for embedded linux.

What is Staging_dir?

staging_dir/toolchain... is a mini Linux root with its own bin/ , lib/ , etc that contains the cross C compiler used to build the rest of the firmware. You can actually use that to compile simple C programs outside of OpenWRT that can be loaded onto the firmware.

How long does it take to compile OpenWRT?

Build-time is highly dependable on the number of Cores/Jobs and can be shrunk to less than 30 minutes (from 90 minutes). Build time with single core can take several hours.

What is Linux Buildroot?

Buildroot is a set of Makefiles and patches that simplifies and automates the process of building a complete and bootable Linux environment for an embedded system, while using cross-compilation to allow building for multiple target platforms on a single Linux-based development system.


1 Answers

The directory build_dir is used to unpack all the source archives and to compile them in.

The directory staging_dir is used to "install" all the compiled programs into, ready either for use in building further packages, or for preparing the firmware image.

There are three areas under build_dir:

  • build_dir/host, for compiling all the tools that run on the host computer (OpenWRT builds its own version of sed and many other tools from source). This area will be use for compiling programs that run only on your host.
  • build_dir/toolchain... for compiling the cross-C compiler and C standard library components that will be used to build the packages. This area will be use for compiling programs that run only on your host (the cross C compiler, for example) and also, libraries designed to run on the target that are linked to - e.g. uClibc, libm, pthreads, etc.
  • build_dir/target... for compiling the actual packages, and the Linux kernel, for the target system

Under staging, there are also three areas:

  • staging_dir/host is a mini Linux root with its own bin/, lib/, etc. that the host tools are installed into; the rest of the build system then prefixes its PATH with directories in this area
  • staging_dir/toolchain... is a mini Linux root with its own bin/, lib/, etc that contains the cross C compiler used to build the rest of the firmware. You can actually use that to compile simple C programs outside of OpenWRT that can be loaded onto the firmware. The C compiler might be something like: staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mips-openwrt-linux-uclibc-gcc. You can see the version of the CPU, the C library and gcc encoded into it; this allows multiple targets to be built in the same area concurrently.
  • staging_dir/target.../root-... contains 'installed' versions of each target package again arranged with bin/, lib/, this will become the actual root directory that with some tweaking will get zipped up into the firmware image, something like root-ar71xx. There are some other files in staging_dir/target... primarily used for generating the packages and development packages, etc.

Sorry its a bit verbose, this is hard to describe more succinctly.

like image 143
6EQUJ5 Avatar answered Oct 02 '22 13:10

6EQUJ5