Add busybox tool for Android

Source: Internet
Author: User

You can enter the android console in two ways:

1. Run the emulator-shell command directly;

2. After starting emulator, run the ADB shell command.

Then we can use some common Linux commands, such as LS and cat. However, the toolbox provided by Android (located in/system/bin) is too simple. Some commands such as find do not support Android or are not well supported. The following describes how to add the busybox tool to Android and compile a busybox tool that can be run in Android. We can use many common Linux commands, such as find and touch.

The procedure is as follows:

1. First download the source code of the latest busybox on the busybox homepage.

2. Download the cross-compilation tool GNU toolchain for ARM processors.

: Http://www.codesourcery.com/gnu_toolchains/arm/download.html

The first option is arm Eabi or arm GNU/Linux, and the second option is ia32 GNU/Linux tar.

The last step is to get an arm-2007q3-51-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2 file.

Decompress the compressed package to a directory in Linux and set the environment variables so that you can find the cross-compilation tool prefixed with "arm-None-Linux-gnueabi.

3. Go to the busybox source code directory.

Run the make menuconfig command to configure the compilation process as follows:

Busybox settings-> build options->

[*] Build busybox as a static binary (no shared libs) should be selected, because the compiled busybox can be run independently.
(/Home/Jo/tool/arm-2008q3/bin/ARM-None-Linux-gnueabi-) Cross Compiler prefex this is the cross compiler's "path + prefix ", you must set it according to the actual situation.
Busybox settings-> Installation Options->
[*] The compiled busybox like don't use/usr won't be installed in the/usr directory of your host. Be sure to select.

4. Execute make to compile the source code. If an error cannot be found during the compilation process, you can specify the path of the header file used by the cross compiler. For example:

$ Make-I./home/Jo/tool/arm-2008q3/ARM-None-Linux-gnueabi/libc/usr/include/

5. After compilation is successful, an executable file named busybox will be obtained.

6. Create a directory/data/busybox on the android console, and copy the file busybox to the directory using the following command:

ADB push busybox/data/busybox

7. Enter the/data/busybox directory from the android console and add the executable attribute chmod + x busybox to the executable file busybox.

8 then we can use the busybox tool. If you want to use bosybox directly in any directory, You need to export the path/data/busybox to the path environment variable:

Export Path = $ path:/data/busybox

9. After setting the environment variable, enter busybox in the command line to see its usage, as shown in:

To search for a file named init. RC in the current directory and Its subdirectories, run the following command:

$ Busybox find.-Name init. RC

10 install busybox.

Run. /busybox -- install-s we will see some errors because the root directory and/sbin directory of the Android system are read-only. therefore, we cannot install some common commands in the/bin directory or modify/init. RC file to set the PATH environment variable.

The default installation path for how to execute the command busybox -- install-S, which may be related to makefile and the settings for compiling busybox.

Although we cannot install Common commands in Android by executing the busybox -- install-s command, we can install Common commands in Android by using another method.

The method is very simple. You can first execute the make install command in the external Linux system to extract the relevant commands. then run the ADB push command. /_ install/bin/data/busybox/bin copy these common commands into the Android system. note: the path of the make install installation command can be set by executing make menuconfig. The default value is. /_ install directory.

In this way, we don't need to add busybox to the front every time we use a Command provided by busybox.

11. Modify the environment variable in the/init. RC file.

Refer to the post for further research on the android startup process.

Note that when you modify the PATH environment variable, put the path "/data/busybox/bin" of Common commands in busybox before the path "/system/bin" of Common commands in Android. Otherwise, the command for finding out will not be the busybox command. You can set it like this:

Export path/data/busybox/bin:/sbin:/system/bin:/system/xbin

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.