1. What is busybox?
Busybox is a single executable implementation of many standard Linux tools. Busybox contains some simple tools, such as CAT and ECHO, and some larger and more complex tools, for example, grep, find, mount, and telnet (but it has fewer options than the traditional version); some refer to busybox as the Swiss army knife in Linux tools.
Principle: Many standard Linux tools can share many common elements. For example, many file-based tools (such as grep and find) need to search for file code in the directory. When these tools are merged into an executable program, they can share these same elements to produce smaller executable programs. In fact, busybox can pack a tool of about 3.5 MB into a size of about KB.
Features:
1. busybox uses the fact that a lot of code is repeated in the Linux utility to re-organize and release the repeated code
To a file, reduce the number of times to include.
2. busybox simplifies unnecessary complex functions to reduce occupied space.
3. The fully customizable busybox provides a flexible and scalable structure.
Ii. Usage:
1. busybox [arguments...] # Or
For example, run the echo command:
$./Busybox echo "This is busybox"
This is busybox
2. [arguments...] # If symlinked
The premise of this usage is to establish a symbolic connection. For example:
$ Ln-s busybox ls
$./Ls/
Bin CDROM etc lib media opt root SELinux sys VaR
Boot Dev home lost + found MNT proc sbin SRV TMP USR
Commands in busybox do not support all available options, but these commands contain common options. If you need to know the options supported by a command, you can use the-help option to call this command.
3. Configure and compile busybox
(1) Default Configuration
1. download the latest source code: http://www.busybox.net/downloads/. the download page is
Busybox-1.13.4.
2. Do not have to decompress the source package: $ tar jxvf busybox-1.13.4.tar.bz2
3. Configure the following in the decompressed source code package:
$ Make defconfig # use the default configuration
$ Make # compile source code
4. At this step, a very large busybox image has been generated. Now you can use the busybox program. The usage has been mentioned above, for example:
$./Busybox echo "This is a busybox"
This is a busybox
(2) manual Configuration:
Configure busybox for Embedded Linux, host ubuntu9.04, target board smartarm3250, target board system linux2.6.27, cross compiler is
/Opt/NXP/gcc-4.3.2-glibc-2.7/bin/ARM-VFP-Linux-GNU-gcc
1. In the source code directory (the premise is that you have downloaded the source code and decompressed it), run the command: $ make menuconfig
-Applets configures different types of commands. You can configure whether to add them to the busybox program.
2. Cross-Compilation:
$ Make cross_compile =
/Opt/NXP/gcc-4.3.2-glibc-2.7/bin/ARM-VFP-Linux-GNU-
Here, cross_compile refers to the path of your cross-compiler GCC. You can also configure
Go to busybox Settings> build Options>
() Select cross compiler prefix,
Then fill in "/opt/NXP/gcc-4.3.2-glibc-2.7/bin/ARM-VFP-Linux-GNU-", and then
Make.
3. The program has been compiled as a program that can be run on the target board.
$ File busybox
Busybox: Elf 32-bit LSB executable, arm, Version 1, dynamically linked
(Uses SHARED libs), stripped
4. The compilation is successful. You only need to download this program to the Board to run it.
4. Extended busybox function: add your own commands
See docs/new_applet-HOWTO.txt documentation
A) Compile the applet code in the appropriate directory. Here, my code is myls. C. Put this code file under the coreutils directory (Because ls. C is in this directory ).
B) add the graphical configuration of the applet In the config. In file in the directory.
Config myls
Bool "myls"
Default y
Help
Myls is used to list the contents of directories.
C) Add the corresponding applet compilation option to the kbuild file in the directory.
Lib-$ (config_myls) + = myls. o
D) add the corresponding usage description in include/usage. h.
# Define myls_trivial_usage "myls truvial help"
# Define myls_full_usage "myls full usage"
E) add the corresponding Applet in inlucde/applets. h.
Use_myls (applet_noexec (myls, myls, _ bb_dir_bin, _ bb_suid_never, myls ))
After completing the preceding steps, make menuconfig to go to coreutils-> and you will find that
[*] Myls
* Indicates that it is configured to busybox by default. The default value is in the config. In file and can be set to none. After compilation, you can use this command like other commands.