Android Installing Busybox Command Line Tools

From OMAPpedia

(Difference between revisions)
Jump to: navigation, search
(Configure and Build)
(Installing Busybox at run-time: -- add adb root command)
 
(14 intermediate revisions not shown)
Line 1: Line 1:
 +
=== Introduction (Prebuilt binary) ===
 +
This article describes how to install the busybox command line tools in the Android file-system.
This article describes how to install the busybox command line tools in the Android file-system.
Please note that a pre-built version of busybox has been attached to this article if you would prefer not to build busybox yourself. Skip to [http://omappedia.org/wiki/Android_Getting_Started#Installing_Busybox_to_filesystem Installing Busybox to filesystem]  if you select to use the prebuilt version. For the more information on the latest busybox environment visit: [http://www.busybox.net www.busybox.net]
Please note that a pre-built version of busybox has been attached to this article if you would prefer not to build busybox yourself. Skip to [http://omappedia.org/wiki/Android_Getting_Started#Installing_Busybox_to_filesystem Installing Busybox to filesystem]  if you select to use the prebuilt version. For the more information on the latest busybox environment visit: [http://www.busybox.net www.busybox.net]
-
*Prebuilt [http://www.omapzoom.org/gf/download/wikifiles/317/1354/busybox busybox_1.13.3]
+
* [[Media:Busybox.tar.gz|Pre-built Busybox 1.19.3]]
===Configure and Build===
===Configure and Build===
-
Download [http://busybox.net/downloads/busybox-1.13.3.tar.bz2 busybox-1.13.3.tar.bz2] from [http://www.busybox.net www.busybox.net].
+
Download [http://busybox.net/downloads/busybox-1.19.3.tar.bz2 busybox-1.19.3.tar.bz2] from [http://www.busybox.net www.busybox.net].
Extract the busybox source
Extract the busybox source
-
  $ tar jxf busybox-1.13.3.tar.bz2
+
  pc$ tar jxf busybox-1.19.3.tar.bz2
-
  $ cd busybox-1.13.3/
+
  pc$ cd busybox-1.19.3/
Or if you prefer, you can get the latest version of busybox
Or if you prefer, you can get the latest version of busybox
-
  $ git clone git://busybox.net/busybox.git
+
  pc$ git clone git://busybox.net/busybox.git
-
  $ cd busybox/
+
  pc$ cd busybox/
 +
pc$ git checkout -b my_working_branch 1_19_3
Export path to where the cross-compiler is located on the host. For more information on setting up cross-compiler in environment visit: [http://omappedia.org/wiki/Support_Tools#Cross_Compilers Cross Compilers]
Export path to where the cross-compiler is located on the host. For more information on setting up cross-compiler in environment visit: [http://omappedia.org/wiki/Support_Tools#Cross_Compilers Cross Compilers]
-
  $ export PATH=$PATH:/<toolchain_folder>/bin/
+
  pc$ export PATH=$PATH:/<toolchain_folder>/bin/
Configure busybox
Configure busybox
-
  $ make menuconfig
+
  pc$ make menuconfig
In menuconfig set the following options
In menuconfig set the following options
-
  $ Busybox Settings --> Build Options --> Build Busybox as a static binary (no shared libs)  -  Enable this option by pressing "Y"
+
  Busybox Settings --> Build Options --> Build Busybox as a static binary (no shared libs)  -  Enable this option by pressing "Y"
-
  $ Busybox Settings --> Build Options --> Cross compiler prefix  -  Set this option equal to "arm-none-linux-gnueabi-"
+
  Busybox Settings --> Build Options --> Cross compiler prefix  -  Set this option equal to "arm-none-linux-gnueabi-"
-
  $ Busybox Settings --> General Configuration --> Don't use /usr  -  Enable this option by pressing "Y"
+
  Busybox Settings --> General Configuration --> Don't use /usr  -  Enable this option by pressing "Y"
-
  $ Linux Module Utilities --> () Default directory containing modules - Set this option to nothing
+
  Linux Module Utilities --> [ ] Simplified modutils
-
  $ Linux Module Utilities --> () Default name of modules.dep - Set this option to nothing
+
                            [*]  insmod
 +
                            [*]  rmmod
 +
                            [*]  lsmod
 +
                            [*]    Pretty output
 +
                            [ ]  modprobe
 +
                            [ ]  depmod
 +
Linux Module Utilities --> [ ] Support version 2.2/2.4 Linux kernels
 +
Linux Module Utilities --> [ ] Try to load module from a mmap'ed area
 +
Linux Module Utilities --> [*] Support tainted module checking with new kernels
 +
Linux Module Utilities --> () Default directory containing modules - Set this option to nothing
 +
  Linux Module Utilities --> () Default name of modules.dep - Set this option to nothing
You can also enable and disable at that time the tools that are needed/not needed.
You can also enable and disable at that time the tools that are needed/not needed.
Line 33: Line 46:
Build busybox
Build busybox
-
  $ make
+
  pc$ make
-
===Installing Busybox to filesystem===
+
===Copying Busybox to filesystem===
-
Create a /bin directory in the target file-system. For example:
+
Once the busybox executable has been placed in the target file system you will need to "install" busybox, i.e. you will need write permissionTherefore it's recommended to place busybox in the system partition where you can use the "adb remount" command to get write permissions.
-
  $ mkdir /<path-to-android-fs>/bin
+
-
Copy the busybox binary to the /bin directory in the target file-system
+
Create a busybox directory in the target file-system. For example:
-
  $ cp busybox /<path-to-android-fs>/bin
+
  pc$ mkdir -p $MYDROID/out/target/product/blaze/system/busybox
-
Bootup the board with Android filesystem
+
Copy the busybox binary to the /bin directory in the target file-system:
 +
pc$ install -m 777 busybox $MYDROID/out/target/product/blaze/system/busybox/busybox
 +
 
 +
Add the busybox directory to the default path.  Open the init.rc file:
 +
pc> vim $MYDROID/out/target/product/blaze/root/init.rc
 +
Add /system/busybox to PATH in init.rc:
 +
export PATH <font color=red>/system/busybox:</font>/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin
 +
 
 +
===Installing Busybox at run-time===
 +
Bootup the board with Android filesystem, remount system with read-write permissions
 +
pc> ./adb root
 +
pc> ./adb remount
Install the busybox command line tools on the target by executing the following commands on booted filesystem:
Install the busybox command line tools on the target by executing the following commands on booted filesystem:
-
  $ cd /bin
+
  pc> ./adb shell
-
  $ ./busybox --install
+
target$ cd /system/busybox
 +
  target$ ./busybox --install .
 +
target$ ./sh
-
===Make the Busybox shell the default shell===
+
'''NOTE:  Don't forget the DOT at the end of the "install" step above!'''
-
Edit the console service so that it runs the busybox shell and not the default shell by replacing:
+
-
$ vim init.rc
+
-
-service console /system/bin/sh
+
-
+service console /bin/sh
+
-
Add the path of the busybox command line tools to the system path variable by replacing:
+
===Make the Busybox shell the default shell===
-
  $ export PATH /sbin:/system/sbin:/system/bin:/system/xbin
+
Save the original sh executable by renaming it, and then create a soft-link to busybox sh:
-
  #with
+
  target$ cd /system/bin
-
  $ export PATH /bin:/sbin:/system/sbin:/system/bin:/system/xbin
+
  target$ mv sh sh.android
 +
  target$ ln -s /system/busybox/sh sh
 +
Now when you open a shell using "./adb shell" you will have the full busybox capabilities immediately.  The serial port shell will also utilize busybox when you power-up the board.
[[Category:Android]]
[[Category:Android]]

Latest revision as of 18:57, 17 April 2012

Contents

[edit] Introduction (Prebuilt binary)

This article describes how to install the busybox command line tools in the Android file-system. Please note that a pre-built version of busybox has been attached to this article if you would prefer not to build busybox yourself. Skip to Installing Busybox to filesystem if you select to use the prebuilt version. For the more information on the latest busybox environment visit: www.busybox.net

[edit] Configure and Build

Download busybox-1.19.3.tar.bz2 from www.busybox.net.

Extract the busybox source

pc$ tar jxf busybox-1.19.3.tar.bz2
pc$ cd busybox-1.19.3/

Or if you prefer, you can get the latest version of busybox

pc$ git clone git://busybox.net/busybox.git
pc$ cd busybox/
pc$ git checkout -b my_working_branch 1_19_3

Export path to where the cross-compiler is located on the host. For more information on setting up cross-compiler in environment visit: Cross Compilers

pc$ export PATH=$PATH:/<toolchain_folder>/bin/

Configure busybox

pc$ make menuconfig

In menuconfig set the following options

Busybox Settings --> Build Options --> Build Busybox as a static binary (no shared libs)  -  Enable this option by pressing "Y"
Busybox Settings --> Build Options --> Cross compiler prefix  -  Set this option equal to "arm-none-linux-gnueabi-"
Busybox Settings --> General Configuration --> Don't use /usr  -  Enable this option by pressing "Y"
Linux Module Utilities --> [ ] Simplified modutils
                           [*]   insmod
                           [*]   rmmod 
                           [*]   lsmod
                           [*]     Pretty output
                           [ ]   modprobe
                           [ ]   depmod
Linux Module Utilities --> [ ] Support version 2.2/2.4 Linux kernels
Linux Module Utilities --> [ ] Try to load module from a mmap'ed area
Linux Module Utilities --> [*] Support tainted module checking with new kernels
Linux Module Utilities --> () Default directory containing modules - Set this option to nothing
Linux Module Utilities --> () Default name of modules.dep - Set this option to nothing

You can also enable and disable at that time the tools that are needed/not needed. Example of tools that could be disabled: Print Utilities, Mail Utilities

Build busybox

pc$ make

[edit] Copying Busybox to filesystem

Once the busybox executable has been placed in the target file system you will need to "install" busybox, i.e. you will need write permission. Therefore it's recommended to place busybox in the system partition where you can use the "adb remount" command to get write permissions.

Create a busybox directory in the target file-system. For example:

pc$ mkdir -p $MYDROID/out/target/product/blaze/system/busybox

Copy the busybox binary to the /bin directory in the target file-system:

pc$ install -m 777 busybox $MYDROID/out/target/product/blaze/system/busybox/busybox

Add the busybox directory to the default path. Open the init.rc file:

pc> vim $MYDROID/out/target/product/blaze/root/init.rc

Add /system/busybox to PATH in init.rc:

export PATH /system/busybox:/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin

[edit] Installing Busybox at run-time

Bootup the board with Android filesystem, remount system with read-write permissions

pc> ./adb root
pc> ./adb remount

Install the busybox command line tools on the target by executing the following commands on booted filesystem:

pc> ./adb shell
target$ cd /system/busybox
target$ ./busybox --install .
target$ ./sh

NOTE: Don't forget the DOT at the end of the "install" step above!

[edit] Make the Busybox shell the default shell

Save the original sh executable by renaming it, and then create a soft-link to busybox sh:

target$ cd /system/bin
target$ mv sh sh.android
target$ ln -s /system/busybox/sh sh

Now when you open a shell using "./adb shell" you will have the full busybox capabilities immediately. The serial port shell will also utilize busybox when you power-up the board.

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox