In this recipe, we'll download BusyBox and configure it using defconfig
, xxx_defconfig
, oldconfig
, allyesconfig/allnoconfig
, menuconfig
, and randconfig
.
BusyBox was designed for Linux in early 1996, originally as a Debian GNU/Linux installer and rescue system. With about 18 years of development, the latest 1.21.0 (at the time of this writing) release has more than 380 applets and about 100 projects claimed using it. The projects embrace Linux, Android, FreeBSD, and others.
It integrates a set of stripped-down Unix tools, including simple ones, such as echo
and ls
, as well as the larger ones, such as grep
, awk
, find
, mount
, and modprobe
and other functional utilities; for example, ifconfig
, route
, dmesg
, tar
, wget
, and even a tiny shell interpreter called ash
.
It is modular, and can be customized to meet different requirements. To discuss and demonstrate its configuration system, first download its source code. It is maintained at http://git.busybox.net/busybox/ and released with .tar
packages at http://busybox.net/downloads/. If you want a stable release, download the .tar
packages or clone the Git repository with the latest (but perhaps not stable) features. At the time of this writing, we used the stable version busybox-1.21.0.tar.bz2
; download it and decompress it.
$ wget http://busybox.net/downloads/busybox-1.20.0.tar.bz2 $ tar jxvf busybox-1.20.0.tar.bz2 $ cd busybox-1.20.0/
To simplify the command-line output, all command-line prompts in the desktop development system is prefixed with the $
symbol; ones that need root permission will follow a sudo
command.
Before configuring, make sure the ncurses
library required by the graphic configurator is installed on the development system.
$ sudo apt-get install libncurses5-dev
Tip
Downloading the example code
You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
The friendliest way to configure BusyBox will be using make menuconfig
. Issue the command to launch a graphic interface, configure the features, and exit to save them.
Issue the following command in a graphic configurator:
$ make menuconfig
It starts the graphic interface.
Configure the features with hotkeys. It allows us to enable, disable, exit, get help, and search with hotkeys. The primary hotkeys include:
<Enter> selects submenus
<Y> includes
<N> excludes
<Space> Switch <Y> and <N>
<Esc><Esc> to exit
<?> for Help
</> for Search
Most configuration options are Boolean type. Use the
ash
shell applet as an example. Press Enter on the shell's submenu. Enable with Y and disable with N.Shells ---> [*] ash
Some configuration options are strings and may require input. Use the cross-compiler
arm-linux-gnueabi-gcc
(see the Compiling Busybox recipe) configuration as an example. Press Enter onBusyBox Settings
and onBuild Options
and then press Enter on(arm-linux-gnueabi-) Cross Compiler prefix
.Busybox Settings ---> Build Options ---> (arm-linux-gnueabi-) Cross Compiler prefix
Save the configuration.
After configuring, Press Esc + Esc to exit, and the configuration will be saved to a file named .config
.
With the previous configuration, we should be able to start the compiling process in the next recipe, but we still need to learn more details about the principle and the other methods of configuration.
BusyBox can be flexibly customized; the main configurable features include Busybox Settings
and Applets
. The former allows us to configure build/compiling and installation features. The latter allows us to configure all of the built-in applets and their features. Both of them will be introduced in the following recipes.
To configure them in fine detail, the Config.src
files (for example, networking/Config.src
) provide configure options for the features, and every option should have a default setting.
Hotkeys are provided to enable, disable, or set the option; the option's value will be converted to symbols prefixed with CONFIG_
and saved into the .config
file, and meanwhile some C headers will be generated.
Besides graphic configuration with make menuconfig
, some other configuration techniques you might want to run with the BusyBox make
tool include:
make config
: Similar tomake menuconfig
, this is a text-based interactive configurator. It does not contain the dependency of thencurses
library, and is not that friendly.make oldconfig
: Resolve any unresolved symbols and regenerate C header files with the old configuration,.config
; it is often executed aftermake clean
.make clean
allows us to delete temporary files created by an old configuration or building. It is often used to get a clean environment for a new configuration or building.make xxx_defconfig
: Some old configurations, such as.config
are renamed and saved to theconfigs/
directory of the BusyBox source code. To re-use them, just runmake
with their names; for example:$ make android2_defconfig
make defconfig
: It uses the option's default setting and generates.config
to the largest generic configuration. This is often used by a newcomer as the base of a new configuration. Based on this default configuration, disable the unnecessary features and reserve only the necessary features and get a minimal configuration eventually.make allyesconfig
/allnoconfig
: They don't use the default settings, but rather enable or disable the features and generate a.config
file accordingly. Some options may still be disabled even withallyesconfig
. If they conflict with the already enabled ones (for example, theCONFIG_NOMMU
configure option is enabled by default), the other features, such asash
, will be disabled.make allyesconfig
will generate the largest BusyBox binary. It should not be used to build a size-critical embedded system, but it may be a good configuration base for a rich-function system.make allnoconfig
provides a clean configuration base. It may be good to get a clean configuration for a size-critical embedded system, but it requires a good understanding of the configuration options.make randconfig
: It generates a configuration with random settings. We don't need it since our real requirement is often deterministic, but BusyBox developers may need it for building tests.