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?
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.
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.
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.
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.
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 systemUnder 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 areastaging_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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With